logo

Expression of type Lambda

from the theory of proveit.linear_algebra.tensors

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, b, i, k
from proveit.core_expr_types import U_1_to_i, W_1_to_k, a_1_to_i, c_1_to_k, d_1_to_i, e_1_to_k
from proveit.linear_algebra import TensorProd, VecSpaces
from proveit.logic import Equals, Forall, Implies
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda(K, Forall(instance_param_or_params = [i, k], instance_expr = Forall(instance_param_or_params = [U_1_to_i, V, W_1_to_k], instance_expr = Forall(instance_param_or_params = [a_1_to_i, c_1_to_k, d_1_to_i, e_1_to_k], instance_expr = Forall(instance_param_or_params = [b], instance_expr = Implies(Equals(TensorProd(a_1_to_i, c_1_to_k), TensorProd(d_1_to_i, e_1_to_k)).with_wrapping_at(2), Equals(TensorProd(a_1_to_i, b, c_1_to_k), TensorProd(d_1_to_i, b, e_1_to_k)).with_wrapping_at(2)).with_wrapping_at(2), domain = V), domains = [U_1_to_i, W_1_to_k, U_1_to_i, W_1_to_k]).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), domain = 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())
K \mapsto \left[\forall_{i, k \in \mathbb{N}}~\left[\begin{array}{l}\forall_{U_{1}, U_{2}, \ldots, U_{i}, V, W_{1}, W_{2}, \ldots, W_{k} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{\left(a_{1} \in U_{1}\right), \left(a_{2} \in U_{2}\right), \ldots, \left(a_{i} \in U_{i}\right),\left(c_{1} \in W_{1}\right), \left(c_{2} \in W_{2}\right), \ldots, \left(c_{k} \in W_{k}\right),\left(d_{1} \in U_{1}\right), \left(d_{2} \in U_{2}\right), \ldots, \left(d_{i} \in U_{i}\right),\left(e_{1} \in W_{1}\right), \left(e_{2} \in W_{2}\right), \ldots, \left(e_{k} \in W_{k}\right)}~\\
\left[\forall_{b \in V}~\left(\begin{array}{c} \begin{array}{l} \left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i}{\otimes} e_{1} {\otimes}  e_{2} {\otimes}  \ldots {\otimes}  e_{k}\right) \end{array} \end{array}\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i} {\otimes} b{\otimes} e_{1} {\otimes}  e_{2} {\otimes}  \ldots {\otimes}  e_{k}\right) \end{array} \end{array}\right) \end{array} \end{array}\right)\right]\end{array}\right]\end{array}\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: 66
body: 1
1Operationoperator: 39
operand: 3
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple102, 105
5Conditionalvalue: 6
condition: 7
6Operationoperator: 39
operand: 10
7Operationoperator: 41
operands: 9
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 13
body: 14
11Operationoperator: 73
operands: 15
12Operationoperator: 73
operands: 16
13ExprTuple17, 77, 18
14Conditionalvalue: 19
condition: 20
15ExprTuple102, 21
16ExprTuple105, 21
17ExprRangelambda_map: 22
start_index: 104
end_index: 102
18ExprRangelambda_map: 23
start_index: 104
end_index: 105
19Operationoperator: 39
operand: 26
20Operationoperator: 41
operands: 25
21Literal
22Lambdaparameter: 115
body: 78
23Lambdaparameter: 115
body: 79
24ExprTuple26
25ExprTuple27, 28, 29
26Lambdaparameters: 30
body: 31
27ExprRangelambda_map: 32
start_index: 104
end_index: 102
28Operationoperator: 44
operands: 33
29ExprRangelambda_map: 34
start_index: 104
end_index: 105
30ExprTuple94, 95, 96, 98
31Conditionalvalue: 35
condition: 36
32Lambdaparameter: 115
body: 37
33ExprTuple77, 51
34Lambdaparameter: 115
body: 38
35Operationoperator: 39
operand: 46
36Operationoperator: 41
operands: 42
37Operationoperator: 44
operands: 43
38Operationoperator: 44
operands: 45
39Literal
40ExprTuple46
41Literal
42ExprTuple47, 48, 49, 50
43ExprTuple78, 51
44Literal
45ExprTuple79, 51
46Lambdaparameter: 97
body: 53
47ExprRangelambda_map: 54
start_index: 104
end_index: 102
48ExprRangelambda_map: 55
start_index: 104
end_index: 105
49ExprRangelambda_map: 56
start_index: 104
end_index: 102
50ExprRangelambda_map: 57
start_index: 104
end_index: 105
51Operationoperator: 58
operand: 66
52ExprTuple97
53Conditionalvalue: 60
condition: 61
54Lambdaparameter: 115
body: 62
55Lambdaparameter: 115
body: 63
56Lambdaparameter: 115
body: 64
57Lambdaparameter: 115
body: 65
58Literal
59ExprTuple66
60Operationoperator: 67
operands: 68
61Operationoperator: 73
operands: 69
62Operationoperator: 73
operands: 70
63Operationoperator: 73
operands: 71
64Operationoperator: 73
operands: 72
65Operationoperator: 73
operands: 74
66Variable
67Literal
68ExprTuple75, 76
69ExprTuple97, 77
70ExprTuple106, 78
71ExprTuple107, 79
72ExprTuple108, 78
73Literal
74ExprTuple109, 79
75Operationoperator: 81
operands: 80
76Operationoperator: 81
operands: 82
77Variable
78IndexedVarvariable: 83
index: 115
79IndexedVarvariable: 84
index: 115
80ExprTuple85, 86
81Literal
82ExprTuple87, 88
83Variable
84Variable
85Operationoperator: 92
operands: 89
86Operationoperator: 92
operands: 90
87Operationoperator: 92
operands: 91
88Operationoperator: 92
operands: 93
89ExprTuple94, 95
90ExprTuple96, 98
91ExprTuple94, 97, 95
92Literal
93ExprTuple96, 97, 98
94ExprRangelambda_map: 99
start_index: 104
end_index: 102
95ExprRangelambda_map: 100
start_index: 104
end_index: 105
96ExprRangelambda_map: 101
start_index: 104
end_index: 102
97Variable
98ExprRangelambda_map: 103
start_index: 104
end_index: 105
99Lambdaparameter: 115
body: 106
100Lambdaparameter: 115
body: 107
101Lambdaparameter: 115
body: 108
102Variable
103Lambdaparameter: 115
body: 109
104Literal
105Variable
106IndexedVarvariable: 110
index: 115
107IndexedVarvariable: 111
index: 115
108IndexedVarvariable: 112
index: 115
109IndexedVarvariable: 113
index: 115
110Variable
111Variable
112Variable
113Variable
114ExprTuple115
115Variable