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 Conditional, 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, InClass
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda(V, Conditional(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), InClass(V, 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())
V \mapsto \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] \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\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: 69
body: 2
1ExprTuple69
2Conditionalvalue: 3
condition: 4
3Operationoperator: 17
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple69, 9
8Lambdaparameters: 10
body: 11
9Operationoperator: 12
operand: 16
10ExprTuple56, 58, 61
11Conditionalvalue: 14
condition: 15
12Literal
13ExprTuple16
14Operationoperator: 17
operand: 20
15Operationoperator: 33
operands: 19
16Variable
17Literal
18ExprTuple20
19ExprTuple21, 22, 23
20Lambdaparameters: 41
body: 24
21Operationoperator: 64
operands: 25
22Operationoperator: 64
operands: 26
23Operationoperator: 64
operands: 27
24Conditionalvalue: 28
condition: 29
25ExprTuple56, 30
26ExprTuple58, 30
27ExprTuple61, 30
28Operationoperator: 31
operands: 32
29Operationoperator: 33
operands: 34
30Literal
31Literal
32ExprTuple35, 36
33Literal
34ExprTuple37, 38, 39, 40
35Operationoperator: 42
operands: 41
36Operationoperator: 42
operands: 43
37ExprRangelambda_map: 44
start_index: 60
end_index: 56
38ExprRangelambda_map: 45
start_index: 60
end_index: 58
39Operationoperator: 64
operands: 46
40ExprRangelambda_map: 47
start_index: 60
end_index: 61
41ExprTuple48, 49, 53, 50
42Literal
43ExprTuple48, 53, 49, 50
44Lambdaparameter: 74
body: 51
45Lambdaparameter: 74
body: 52
46ExprTuple53, 69
47Lambdaparameter: 74
body: 54
48ExprRangelambda_map: 55
start_index: 60
end_index: 56
49ExprRangelambda_map: 57
start_index: 60
end_index: 58
50ExprRangelambda_map: 59
start_index: 60
end_index: 61
51Operationoperator: 64
operands: 62
52Operationoperator: 64
operands: 63
53Variable
54Operationoperator: 64
operands: 65
55Lambdaparameter: 74
body: 66
56Variable
57Lambdaparameter: 74
body: 67
58Variable
59Lambdaparameter: 74
body: 68
60Literal
61Variable
62ExprTuple66, 69
63ExprTuple67, 69
64Literal
65ExprTuple68, 69
66IndexedVarvariable: 70
index: 74
67IndexedVarvariable: 71
index: 74
68IndexedVarvariable: 72
index: 74
69Variable
70Variable
71Variable
72Variable
73ExprTuple74
74Variable