logo

Expression of type ExprTuple

from the theory of proveit.logic.sets.cartesian_products

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 ExprTuple, Lambda, x
from proveit.core_expr_types import A_1_to_m, a_1_to_m
from proveit.logic import And, CartProd, Equals, InSet
from proveit.logic.sets.cartesian_products import a_in_A__1_to_m
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([x, A_1_to_m, a_1_to_m], Equals(InSet(x, CartProd(A_1_to_m)), And(Equals(x, [a_1_to_m]), a_in_A__1_to_m)).with_wrapping_at(2)))
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(x, A_{1}, A_{2}, \ldots, A_{m}, a_{1}, a_{2}, \ldots, a_{m}\right) \mapsto \left(\begin{array}{c} \begin{array}{l} \left(x \in \left(A_{1} \times  A_{2} \times  \ldots \times  A_{m}\right)\right) =  \\ \left(\left(x = \left(a_{1}, a_{2}, \ldots, a_{m}\right)\right)\land \left(a_{1} \in A_{1}\right) \land  \left(a_{2} \in A_{2}\right) \land  \ldots \land  \left(a_{m} \in A_{m}\right)\right) \end{array} \end{array}\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
2ExprTuple19, 18, 23
3Operationoperator: 15
operands: 4
4ExprTuple5, 6
5Operationoperator: 24
operands: 7
6Operationoperator: 8
operands: 9
7ExprTuple19, 10
8Literal
9ExprTuple11, 12
10Operationoperator: 13
operands: 14
11Operationoperator: 15
operands: 16
12ExprRangelambda_map: 17
start_index: 27
end_index: 28
13Literal
14ExprTuple18
15Literal
16ExprTuple19, 20
17Lambdaparameter: 34
body: 21
18ExprRangelambda_map: 22
start_index: 27
end_index: 28
19Variable
20ExprTuple23
21Operationoperator: 24
operands: 25
22Lambdaparameter: 34
body: 29
23ExprRangelambda_map: 26
start_index: 27
end_index: 28
24Literal
25ExprTuple30, 29
26Lambdaparameter: 34
body: 30
27Literal
28Variable
29IndexedVarvariable: 31
index: 34
30IndexedVarvariable: 32
index: 34
31Variable
32Variable
33ExprTuple34
34Variable