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 Boolean, Forall, Implies, InSet, Not, Or
from proveit.numbers import Natural, 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(m, Conditional(Forall(instance_param_or_params = [A_1_to_m, B_1_to_m], instance_expr = Or(ExprRange(sub_expr1, Not(sub_expr2), one, m)), domain = Boolean, conditions = [Or(ExprRange(sub_expr1, Not(sub_expr3), one, m)), ExprRange(sub_expr1, Implies(sub_expr3, sub_expr2), one, m)]), InSet(m, Natural))))
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(m \mapsto \left\{\forall_{A_{1}, A_{2}, \ldots, A_{m}, B_{1}, B_{2}, \ldots, B_{m} \in \mathbb{B}~|~(\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)}~\left((\lnot B_{1}) \lor  (\lnot B_{2}) \lor  \ldots \lor  (\lnot B_{m})\right) \textrm{ if } m \in \mathbb{N}\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
1Lambdaparameter: 44
body: 3
2ExprTuple44
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 40
operands: 8
6Literal
7ExprTuple9
8ExprTuple44, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple13, 14
12Conditionalvalue: 15
condition: 16
13ExprRangelambda_map: 17
start_index: 43
end_index: 44
14ExprRangelambda_map: 18
start_index: 43
end_index: 44
15Operationoperator: 30
operands: 19
16Operationoperator: 20
operands: 21
17Lambdaparameter: 56
body: 53
18Lambdaparameter: 56
body: 49
19ExprTuple22
20Literal
21ExprTuple23, 24, 25, 26
22ExprRangelambda_map: 27
start_index: 43
end_index: 44
23ExprRangelambda_map: 28
start_index: 43
end_index: 44
24ExprRangelambda_map: 29
start_index: 43
end_index: 44
25Operationoperator: 30
operands: 31
26ExprRangelambda_map: 32
start_index: 43
end_index: 44
27Lambdaparameter: 56
body: 33
28Lambdaparameter: 56
body: 34
29Lambdaparameter: 56
body: 35
30Literal
31ExprTuple36
32Lambdaparameter: 56
body: 37
33Operationoperator: 50
operand: 49
34Operationoperator: 40
operands: 39
35Operationoperator: 40
operands: 41
36ExprRangelambda_map: 42
start_index: 43
end_index: 44
37Operationoperator: 45
operands: 46
38ExprTuple49
39ExprTuple53, 47
40Literal
41ExprTuple49, 47
42Lambdaparameter: 56
body: 48
43Literal
44Variable
45Literal
46ExprTuple53, 49
47Literal
48Operationoperator: 50
operand: 53
49IndexedVarvariable: 52
index: 56
50Literal
51ExprTuple53
52Variable
53IndexedVarvariable: 54
index: 56
54Variable
55ExprTuple56
56Variable