logo

Expression of type ExprTuple

from the theory of proveit.logic.booleans.disjunction

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import A, B, C, Conditional, D, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, l, m, n
from proveit.core_expr_types import A_1_to_l, C_1_to_m, D_1_to_n
from proveit.logic import And, Boolean, Equals, InSet, Or
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda([A_1_to_l, B, C_1_to_m, D_1_to_n], Conditional(Equals(Or(A_1_to_l, B, C_1_to_m, D_1_to_n), Or(A_1_to_l, C_1_to_m, B, D_1_to_n)).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(A, sub_expr1), Boolean), one, l), InSet(B, Boolean), ExprRange(sub_expr1, InSet(IndexedVar(C, sub_expr1), Boolean), one, m), ExprRange(sub_expr1, InSet(IndexedVar(D, sub_expr1), Boolean), one, n)))))
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left(\left(A_{1}, A_{2}, \ldots, A_{l}, B, C_{1}, C_{2}, \ldots, C_{m}, D_{1}, D_{2}, \ldots, D_{n}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{l} \lor B\lor C_{1} \lor  C_{2} \lor  \ldots \lor  C_{m}\lor D_{1} \lor  D_{2} \lor  \ldots \lor  D_{n}\right) =  \\ \left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{l}\lor C_{1} \lor  C_{2} \lor  \ldots \lor  C_{m} \lor B\lor D_{1} \lor  D_{2} \lor  \ldots \lor  D_{n}\right) \end{array} \end{array} \textrm{ if } \left(A_{1} \in \mathbb{B}\right) ,  \left(A_{2} \in \mathbb{B}\right) ,  \ldots ,  \left(A_{l} \in \mathbb{B}\right) ,  B \in \mathbb{B}, \left(C_{1} \in \mathbb{B}\right) ,  \left(C_{2} \in \mathbb{B}\right) ,  \ldots ,  \left(C_{m} \in \mathbb{B}\right), \left(D_{1} \in \mathbb{B}\right) ,  \left(D_{2} \in \mathbb{B}\right) ,  \ldots ,  \left(D_{n} \in \mathbb{B}\right)\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 15
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14
9Operationoperator: 16
operands: 15
10Operationoperator: 16
operands: 17
11ExprRangelambda_map: 18
start_index: 34
end_index: 30
12Operationoperator: 38
operands: 19
13ExprRangelambda_map: 20
start_index: 34
end_index: 32
14ExprRangelambda_map: 21
start_index: 34
end_index: 35
15ExprTuple22, 26, 23, 24
16Literal
17ExprTuple22, 23, 26, 24
18Lambdaparameter: 48
body: 25
19ExprTuple26, 43
20Lambdaparameter: 48
body: 27
21Lambdaparameter: 48
body: 28
22ExprRangelambda_map: 29
start_index: 34
end_index: 30
23ExprRangelambda_map: 31
start_index: 34
end_index: 32
24ExprRangelambda_map: 33
start_index: 34
end_index: 35
25Operationoperator: 38
operands: 36
26Variable
27Operationoperator: 38
operands: 37
28Operationoperator: 38
operands: 39
29Lambdaparameter: 48
body: 40
30Variable
31Lambdaparameter: 48
body: 41
32Variable
33Lambdaparameter: 48
body: 42
34Literal
35Variable
36ExprTuple40, 43
37ExprTuple41, 43
38Literal
39ExprTuple42, 43
40IndexedVarvariable: 44
index: 48
41IndexedVarvariable: 45
index: 48
42IndexedVarvariable: 46
index: 48
43Literal
44Variable
45Variable
46Variable
47ExprTuple48
48Variable