logo

Expression of type Lambda

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 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 = 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(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)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple18, 17, 22
2Operationoperator: 14
operands: 3
3ExprTuple4, 5
4Operationoperator: 23
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple18, 9
7Literal
8ExprTuple10, 11
9Operationoperator: 12
operands: 13
10Operationoperator: 14
operands: 15
11ExprRangelambda_map: 16
start_index: 26
end_index: 27
12Literal
13ExprTuple17
14Literal
15ExprTuple18, 19
16Lambdaparameter: 33
body: 20
17ExprRangelambda_map: 21
start_index: 26
end_index: 27
18Variable
19ExprTuple22
20Operationoperator: 23
operands: 24
21Lambdaparameter: 33
body: 28
22ExprRangelambda_map: 25
start_index: 26
end_index: 27
23Literal
24ExprTuple29, 28
25Lambdaparameter: 33
body: 29
26Literal
27Variable
28IndexedVarvariable: 30
index: 33
29IndexedVarvariable: 31
index: 33
30Variable
31Variable
32ExprTuple33
33Variable