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.logic import And, Boolean, InSet, Or
from proveit.numbers import Add, 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([ExprRange(sub_expr1, sub_expr2, one, Add(m, two))], Conditional(InSet(Or(ExprRange(sub_expr1, sub_expr2, one, sub_expr3)), Boolean), And(ExprRange(sub_expr1, InSet(sub_expr2, Boolean), one, sub_expr3)))))
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 + 2}\right) \mapsto \left\{\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m + 1}\right) \in \mathbb{B} \textrm{ if } \left(A_{1} \in \mathbb{B}\right) \land  \left(A_{2} \in \mathbb{B}\right) \land  \ldots \land  \left(A_{m + 1} \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: 2
body: 3
2ExprTuple4
3Conditionalvalue: 5
condition: 6
4ExprRangelambda_map: 20
start_index: 29
end_index: 7
5Operationoperator: 22
operands: 8
6Operationoperator: 9
operands: 10
7Operationoperator: 24
operands: 11
8ExprTuple12, 27
9Literal
10ExprTuple13
11ExprTuple28, 14
12Operationoperator: 15
operands: 16
13ExprRangelambda_map: 17
start_index: 29
end_index: 21
14Literal
15Literal
16ExprTuple18
17Lambdaparameter: 32
body: 19
18ExprRangelambda_map: 20
start_index: 29
end_index: 21
19Operationoperator: 22
operands: 23
20Lambdaparameter: 32
body: 26
21Operationoperator: 24
operands: 25
22Literal
23ExprTuple26, 27
24Literal
25ExprTuple28, 29
26IndexedVarvariable: 30
index: 32
27Literal
28Variable
29Literal
30Variable
31ExprTuple32
32Variable