logo

Expression of type ExprTuple

from the theory of proveit.logic.booleans.conjunction

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, B_1_to_m, D_1_to_n
from proveit.logic import And, Boolean, Equals, InSet
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_1_to_m, C, D_1_to_n], Conditional(Equals(And(A_1_to_l, B_1_to_m, C, D_1_to_n), And(A_1_to_l, C, B_1_to_m, D_1_to_n)).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(A, sub_expr1), Boolean), one, l), ExprRange(sub_expr1, InSet(IndexedVar(B, sub_expr1), Boolean), one, m), InSet(C, Boolean), 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_{1}, B_{2}, \ldots, B_{m}, C, D_{1}, D_{2}, \ldots, D_{n}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(A_{1} \land  A_{2} \land  \ldots \land  A_{l}\land B_{1} \land  B_{2} \land  \ldots \land  B_{m} \land C\land D_{1} \land  D_{2} \land  \ldots \land  D_{n}\right) =  \\ \left(A_{1} \land  A_{2} \land  \ldots \land  A_{l} \land C\land B_{1} \land  B_{2} \land  \ldots \land  B_{m}\land D_{1} \land  D_{2} \land  \ldots \land  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), \left(B_{1} \in \mathbb{B}\right) ,  \left(B_{2} \in \mathbb{B}\right) ,  \ldots ,  \left(B_{m} \in \mathbb{B}\right) ,  C \in \mathbb{B}, \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: 14
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 15
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple10, 11, 12, 13
8Operationoperator: 15
operands: 14
9Operationoperator: 15
operands: 16
10ExprRangelambda_map: 17
start_index: 33
end_index: 29
11ExprRangelambda_map: 18
start_index: 33
end_index: 31
12Operationoperator: 37
operands: 19
13ExprRangelambda_map: 20
start_index: 33
end_index: 34
14ExprTuple21, 22, 26, 23
15Literal
16ExprTuple21, 26, 22, 23
17Lambdaparameter: 47
body: 24
18Lambdaparameter: 47
body: 25
19ExprTuple26, 42
20Lambdaparameter: 47
body: 27
21ExprRangelambda_map: 28
start_index: 33
end_index: 29
22ExprRangelambda_map: 30
start_index: 33
end_index: 31
23ExprRangelambda_map: 32
start_index: 33
end_index: 34
24Operationoperator: 37
operands: 35
25Operationoperator: 37
operands: 36
26Variable
27Operationoperator: 37
operands: 38
28Lambdaparameter: 47
body: 39
29Variable
30Lambdaparameter: 47
body: 40
31Variable
32Lambdaparameter: 47
body: 41
33Literal
34Variable
35ExprTuple39, 42
36ExprTuple40, 42
37Literal
38ExprTuple41, 42
39IndexedVarvariable: 43
index: 47
40IndexedVarvariable: 44
index: 47
41IndexedVarvariable: 45
index: 47
42Literal
43Variable
44Variable
45Variable
46ExprTuple47
47Variable