logo

Expression of type Lambda

from the theory of proveit.linear_algebra.addition

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 K, Lambda, V, c, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, d_1_to_k
from proveit.linear_algebra import VecAdd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda(K, Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [i, j, k], instance_expr = Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c, d_1_to_k], instance_expr = Equals(VecAdd(a_1_to_i, b_1_to_j, c, d_1_to_k), VecAdd(a_1_to_i, c, b_1_to_j, d_1_to_k)).with_wrapping_at(2), domain = V), domain = Natural), domain = VecSpaces(K)))
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())
K \mapsto \left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{i, j, k \in \mathbb{N}}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}, c, d_{1}, d_{2}, \ldots, d_{k} \in V}~\left(\begin{array}{c} \begin{array}{l} \left(a_{1} +  a_{2} +  \ldots +  a_{i}+ b_{1} +  b_{2} +  \ldots +  b_{j} + c+ d_{1} +  d_{2} +  \ldots +  d_{k}\right) =  \\ \left(a_{1} +  a_{2} +  \ldots +  a_{i} + c+ b_{1} +  b_{2} +  \ldots +  b_{j}+ d_{1} +  d_{2} +  \ldots +  d_{k}\right) \end{array} \end{array}\right)\right]\right]\right]
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 19
body: 1
1Operationoperator: 20
operand: 3
2ExprTuple3
3Lambdaparameter: 72
body: 5
4ExprTuple72
5Conditionalvalue: 6
condition: 7
6Operationoperator: 20
operand: 11
7Operationoperator: 9
operands: 10
8ExprTuple11
9Literal
10ExprTuple72, 12
11Lambdaparameters: 13
body: 14
12Operationoperator: 15
operand: 19
13ExprTuple59, 61, 64
14Conditionalvalue: 17
condition: 18
15Literal
16ExprTuple19
17Operationoperator: 20
operand: 23
18Operationoperator: 36
operands: 22
19Variable
20Literal
21ExprTuple23
22ExprTuple24, 25, 26
23Lambdaparameters: 44
body: 27
24Operationoperator: 67
operands: 28
25Operationoperator: 67
operands: 29
26Operationoperator: 67
operands: 30
27Conditionalvalue: 31
condition: 32
28ExprTuple59, 33
29ExprTuple61, 33
30ExprTuple64, 33
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operands: 37
33Literal
34Literal
35ExprTuple38, 39
36Literal
37ExprTuple40, 41, 42, 43
38Operationoperator: 45
operands: 44
39Operationoperator: 45
operands: 46
40ExprRangelambda_map: 47
start_index: 63
end_index: 59
41ExprRangelambda_map: 48
start_index: 63
end_index: 61
42Operationoperator: 67
operands: 49
43ExprRangelambda_map: 50
start_index: 63
end_index: 64
44ExprTuple51, 52, 56, 53
45Literal
46ExprTuple51, 56, 52, 53
47Lambdaparameter: 77
body: 54
48Lambdaparameter: 77
body: 55
49ExprTuple56, 72
50Lambdaparameter: 77
body: 57
51ExprRangelambda_map: 58
start_index: 63
end_index: 59
52ExprRangelambda_map: 60
start_index: 63
end_index: 61
53ExprRangelambda_map: 62
start_index: 63
end_index: 64
54Operationoperator: 67
operands: 65
55Operationoperator: 67
operands: 66
56Variable
57Operationoperator: 67
operands: 68
58Lambdaparameter: 77
body: 69
59Variable
60Lambdaparameter: 77
body: 70
61Variable
62Lambdaparameter: 77
body: 71
63Literal
64Variable
65ExprTuple69, 72
66ExprTuple70, 72
67Literal
68ExprTuple71, 72
69IndexedVarvariable: 73
index: 77
70IndexedVarvariable: 74
index: 77
71IndexedVarvariable: 75
index: 77
72Variable
73Variable
74Variable
75Variable
76ExprTuple77
77Variable