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 Conditional, 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 = 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())
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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 36
body: 2
1ExprTuple36
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 32
operands: 7
5Literal
6ExprTuple8
7ExprTuple36, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple27, 26, 31
11Operationoperator: 23
operands: 12
12ExprTuple13, 14
13Operationoperator: 32
operands: 15
14Operationoperator: 16
operands: 17
15ExprTuple27, 18
16Literal
17ExprTuple19, 20
18Operationoperator: 21
operands: 22
19Operationoperator: 23
operands: 24
20ExprRangelambda_map: 25
start_index: 35
end_index: 36
21Literal
22ExprTuple26
23Literal
24ExprTuple27, 28
25Lambdaparameter: 42
body: 29
26ExprRangelambda_map: 30
start_index: 35
end_index: 36
27Variable
28ExprTuple31
29Operationoperator: 32
operands: 33
30Lambdaparameter: 42
body: 37
31ExprRangelambda_map: 34
start_index: 35
end_index: 36
32Literal
33ExprTuple38, 37
34Lambdaparameter: 42
body: 38
35Literal
36Variable
37IndexedVarvariable: 39
index: 42
38IndexedVarvariable: 40
index: 42
39Variable
40Variable
41ExprTuple42
42Variable