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, Conditional, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, m
from proveit.core_expr_types import A_1_to_m
from proveit.logic import And, Boolean, Forall, InSet, Or
from proveit.numbers import Add, NaturalPos, one, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(A, sub_expr1)
sub_expr3 = Add(m, one)
expr = ExprTuple(Lambda(m, Conditional(Forall(instance_param_or_params = [ExprRange(sub_expr1, sub_expr2, one, Add(m, two))], instance_expr = InSet(Or(ExprRange(sub_expr1, sub_expr2, one, sub_expr3)), Boolean), condition = ExprRange(sub_expr1, InSet(sub_expr2, Boolean), one, sub_expr3)), And(InSet(m, NaturalPos), Forall(instance_param_or_params = [A_1_to_m], instance_expr = InSet(Or(A_1_to_m), Boolean), domain = Boolean)))))
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 + 2}~|~\left(A_{1} \in \mathbb{B}\right), \left(A_{2} \in \mathbb{B}\right), \ldots, \left(A_{m + 1} \in \mathbb{B}\right)}~\left(\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m + 1}\right) \in \mathbb{B}\right) \textrm{ if } m \in \mathbb{N}^+ ,  \forall_{A_{1}, A_{2}, \ldots, A_{m} \in \mathbb{B}}~\left(\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m}\right) \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
1Lambdaparameter: 48
body: 3
2ExprTuple48
3Conditionalvalue: 4
condition: 5
4Operationoperator: 14
operand: 8
5Operationoperator: 33
operands: 7
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 49
operands: 13
10Operationoperator: 14
operand: 20
11ExprTuple16
12Conditionalvalue: 17
condition: 18
13ExprTuple48, 19
14Literal
15ExprTuple20
16ExprRangelambda_map: 46
start_index: 47
end_index: 21
17Operationoperator: 49
operands: 22
18Operationoperator: 33
operands: 23
19Literal
20Lambdaparameters: 40
body: 24
21Operationoperator: 42
operands: 25
22ExprTuple26, 52
23ExprTuple27
24Conditionalvalue: 28
condition: 29
25ExprTuple48, 30
26Operationoperator: 39
operands: 31
27ExprRangelambda_map: 41
start_index: 47
end_index: 38
28Operationoperator: 49
operands: 32
29Operationoperator: 33
operands: 34
30Literal
31ExprTuple35
32ExprTuple36, 52
33Literal
34ExprTuple37
35ExprRangelambda_map: 46
start_index: 47
end_index: 38
36Operationoperator: 39
operands: 40
37ExprRangelambda_map: 41
start_index: 47
end_index: 48
38Operationoperator: 42
operands: 43
39Literal
40ExprTuple44
41Lambdaparameter: 55
body: 45
42Literal
43ExprTuple48, 47
44ExprRangelambda_map: 46
start_index: 47
end_index: 48
45Operationoperator: 49
operands: 50
46Lambdaparameter: 55
body: 51
47Literal
48Variable
49Literal
50ExprTuple51, 52
51IndexedVarvariable: 53
index: 55
52Literal
53Variable
54ExprTuple55
55Variable