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, Conditional, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, m
from proveit.core_expr_types import A_1_to_m, B_1_to_m
from proveit.logic import And, Boolean, Implies, InSet, Not, Or
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(B, sub_expr1)
sub_expr3 = IndexedVar(A, sub_expr1)
expr = ExprTuple(Lambda([A_1_to_m, B_1_to_m], Conditional(Or(ExprRange(sub_expr1, Not(sub_expr2), one, m)), And(ExprRange(sub_expr1, InSet(sub_expr3, Boolean), one, m), ExprRange(sub_expr1, InSet(sub_expr2, Boolean), one, m), Or(ExprRange(sub_expr1, Not(sub_expr3), one, m)), ExprRange(sub_expr1, Implies(sub_expr3, sub_expr2), one, m)))))
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_{m}, B_{1}, B_{2}, \ldots, B_{m}\right) \mapsto \left\{(\lnot B_{1}) \lor  (\lnot B_{2}) \lor  \ldots \lor  (\lnot B_{m}) \textrm{ if } \left(A_{1} \in \mathbb{B}\right) ,  \left(A_{2} \in \mathbb{B}\right) ,  \ldots ,  \left(A_{m} \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) ,  (\lnot A_{1}) \lor  (\lnot A_{2}) \lor  \ldots \lor  (\lnot A_{m}), \left(A_{1} \Rightarrow B_{1}\right) ,  \left(A_{2} \Rightarrow B_{2}\right) ,  \ldots ,  \left(A_{m} \Rightarrow B_{m}\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: 2
body: 3
2ExprTuple4, 5
3Conditionalvalue: 6
condition: 7
4ExprRangelambda_map: 8
start_index: 34
end_index: 35
5ExprRangelambda_map: 9
start_index: 34
end_index: 35
6Operationoperator: 21
operands: 10
7Operationoperator: 11
operands: 12
8Lambdaparameter: 47
body: 44
9Lambdaparameter: 47
body: 40
10ExprTuple13
11Literal
12ExprTuple14, 15, 16, 17
13ExprRangelambda_map: 18
start_index: 34
end_index: 35
14ExprRangelambda_map: 19
start_index: 34
end_index: 35
15ExprRangelambda_map: 20
start_index: 34
end_index: 35
16Operationoperator: 21
operands: 22
17ExprRangelambda_map: 23
start_index: 34
end_index: 35
18Lambdaparameter: 47
body: 24
19Lambdaparameter: 47
body: 25
20Lambdaparameter: 47
body: 26
21Literal
22ExprTuple27
23Lambdaparameter: 47
body: 28
24Operationoperator: 41
operand: 40
25Operationoperator: 31
operands: 30
26Operationoperator: 31
operands: 32
27ExprRangelambda_map: 33
start_index: 34
end_index: 35
28Operationoperator: 36
operands: 37
29ExprTuple40
30ExprTuple44, 38
31Literal
32ExprTuple40, 38
33Lambdaparameter: 47
body: 39
34Literal
35Variable
36Literal
37ExprTuple44, 40
38Literal
39Operationoperator: 41
operand: 44
40IndexedVarvariable: 43
index: 47
41Literal
42ExprTuple44
43Variable
44IndexedVarvariable: 45
index: 47
45Variable
46ExprTuple47
47Variable