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 Conditional, ExprTuple, Lambda, m, x
from proveit.core_expr_types import A_1_to_m, a_1_to_m
from proveit.logic import And, CartProd, Equals, Forall, InSet
from proveit.logic.sets.cartesian_products import a_in_A__1_to_m
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(m, Conditional(Forall(instance_param_or_params = [x, A_1_to_m, a_1_to_m], instance_expr = 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)), InSet(m, NaturalPos))))
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_{x, A_{1}, A_{2}, \ldots, A_{m}, a_{1}, a_{2}, \ldots, a_{m}}~\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) \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: 37
body: 3
2ExprTuple37
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 33
operands: 8
6Literal
7ExprTuple9
8ExprTuple37, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple28, 27, 32
12Operationoperator: 24
operands: 13
13ExprTuple14, 15
14Operationoperator: 33
operands: 16
15Operationoperator: 17
operands: 18
16ExprTuple28, 19
17Literal
18ExprTuple20, 21
19Operationoperator: 22
operands: 23
20Operationoperator: 24
operands: 25
21ExprRangelambda_map: 26
start_index: 36
end_index: 37
22Literal
23ExprTuple27
24Literal
25ExprTuple28, 29
26Lambdaparameter: 43
body: 30
27ExprRangelambda_map: 31
start_index: 36
end_index: 37
28Variable
29ExprTuple32
30Operationoperator: 33
operands: 34
31Lambdaparameter: 43
body: 38
32ExprRangelambda_map: 35
start_index: 36
end_index: 37
33Literal
34ExprTuple39, 38
35Lambdaparameter: 43
body: 39
36Literal
37Variable
38IndexedVarvariable: 40
index: 43
39IndexedVarvariable: 41
index: 43
40Variable
41Variable
42ExprTuple43
43Variable