logo

Expression of type Lambda

from the theory of proveit.core_expr_types.tuples

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, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k, d_1_to_j
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, j, k], Conditional(Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k, d_1_to_j], instance_expr = Equals([a_1_to_i, b_1_to_j, c_1_to_k], [a_1_to_i, d_1_to_j, c_1_to_k]).with_wrapping_at(2), condition = Equals([b_1_to_j], [d_1_to_j])), And(InSet(i, Natural), InSet(j, Natural), InSet(k, Natural))))
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(i, j, k\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k}, d_{1}, d_{2}, \ldots, d_{j}~|~\left(b_{1}, b_{2}, \ldots, b_{j}\right) = \left(d_{1}, d_{2}, \ldots, d_{j}\right)}~\left(\begin{array}{c} \begin{array}{l} \left(a_{1}, a_{2}, \ldots, a_{i},b_{1}, b_{2}, \ldots, b_{j},c_{1}, c_{2}, \ldots, c_{k}\right) =  \\ \left(a_{1}, a_{2}, \ldots, a_{i},d_{1}, d_{2}, \ldots, d_{j},c_{1}, c_{2}, \ldots, c_{k}\right) \end{array} \end{array}\right) \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  k \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
0Lambdaparameters: 1
body: 2
1ExprTuple34, 40, 36
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameters: 13
body: 14
10Operationoperator: 17
operands: 15
11Operationoperator: 17
operands: 16
12Operationoperator: 17
operands: 18
13ExprTuple29, 31, 30, 32
14Conditionalvalue: 19
condition: 20
15ExprTuple34, 21
16ExprTuple40, 21
17Literal
18ExprTuple36, 21
19Operationoperator: 23
operands: 22
20Operationoperator: 23
operands: 24
21Literal
22ExprTuple25, 26
23Literal
24ExprTuple27, 28
25ExprTuple29, 31, 30
26ExprTuple29, 32, 30
27ExprTuple31
28ExprTuple32
29ExprRangelambda_map: 33
start_index: 39
end_index: 34
30ExprRangelambda_map: 35
start_index: 39
end_index: 36
31ExprRangelambda_map: 37
start_index: 39
end_index: 40
32ExprRangelambda_map: 38
start_index: 39
end_index: 40
33Lambdaparameter: 50
body: 41
34Variable
35Lambdaparameter: 50
body: 42
36Variable
37Lambdaparameter: 50
body: 43
38Lambdaparameter: 50
body: 44
39Literal
40Variable
41IndexedVarvariable: 45
index: 50
42IndexedVarvariable: 46
index: 50
43IndexedVarvariable: 47
index: 50
44IndexedVarvariable: 48
index: 50
45Variable
46Variable
47Variable
48Variable
49ExprTuple50
50Variable