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, e, 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, f_1_to_k
from proveit.linear_algebra import TensorProd, VecSpaces, VecZero
from proveit.logic import Equals, Forall, Implies, NotEquals
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, f_1_to_k], instance_expr = Forall(instance_param_or_params = [b, e], instance_expr = Implies(Equals(TensorProd(a_1_to_i, b, c_1_to_k), TensorProd(d_1_to_i, e, f_1_to_k)).with_wrapping_at(2), Equals(TensorProd(a_1_to_i, c_1_to_k), TensorProd(d_1_to_i, f_1_to_k)).with_wrapping_at(2)).with_wrapping_at(2), domain = V, conditions = [Equals(b, e), NotEquals(b, VecZero(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(f_{1} \in W_{1}\right), \left(f_{2} \in W_{2}\right), \ldots, \left(f_{k} \in W_{k}\right)}~\\
\left[\forall_{b, e \in V~|~b = e, b \neq \vec{0}\left(V\right)}~\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} 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} e{\otimes} f_{1} {\otimes}  f_{2} {\otimes}  \ldots {\otimes}  f_{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} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(d_{1} {\otimes}  d_{2} {\otimes}  \ldots {\otimes}  d_{i}{\otimes} f_{1} {\otimes}  f_{2} {\otimes}  \ldots {\otimes}  f_{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: 64
body: 1
1Operationoperator: 39
operand: 3
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple114, 117
5Conditionalvalue: 6
condition: 7
6Operationoperator: 39
operand: 10
7Operationoperator: 67
operands: 9
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 13
body: 14
11Operationoperator: 84
operands: 15
12Operationoperator: 84
operands: 16
13ExprTuple17, 110, 18
14Conditionalvalue: 19
condition: 20
15ExprTuple114, 21
16ExprTuple117, 21
17ExprRangelambda_map: 22
start_index: 116
end_index: 114
18ExprRangelambda_map: 23
start_index: 116
end_index: 117
19Operationoperator: 39
operand: 26
20Operationoperator: 67
operands: 25
21Literal
22Lambdaparameter: 127
body: 79
23Lambdaparameter: 127
body: 80
24ExprTuple26
25ExprTuple27, 28, 29
26Lambdaparameters: 30
body: 31
27ExprRangelambda_map: 32
start_index: 116
end_index: 114
28Operationoperator: 43
operands: 33
29ExprRangelambda_map: 34
start_index: 116
end_index: 117
30ExprTuple106, 107, 108, 109
31Conditionalvalue: 35
condition: 36
32Lambdaparameter: 127
body: 37
33ExprTuple110, 50
34Lambdaparameter: 127
body: 38
35Operationoperator: 39
operand: 45
36Operationoperator: 67
operands: 41
37Operationoperator: 43
operands: 42
38Operationoperator: 43
operands: 44
39Literal
40ExprTuple45
41ExprTuple46, 47, 48, 49
42ExprTuple79, 50
43Literal
44ExprTuple80, 50
45Lambdaparameters: 87
body: 51
46ExprRangelambda_map: 52
start_index: 116
end_index: 114
47ExprRangelambda_map: 53
start_index: 116
end_index: 117
48ExprRangelambda_map: 54
start_index: 116
end_index: 114
49ExprRangelambda_map: 55
start_index: 116
end_index: 117
50Operationoperator: 56
operand: 64
51Conditionalvalue: 58
condition: 59
52Lambdaparameter: 127
body: 60
53Lambdaparameter: 127
body: 61
54Lambdaparameter: 127
body: 62
55Lambdaparameter: 127
body: 63
56Literal
57ExprTuple64
58Operationoperator: 65
operands: 66
59Operationoperator: 67
operands: 68
60Operationoperator: 84
operands: 69
61Operationoperator: 84
operands: 70
62Operationoperator: 84
operands: 71
63Operationoperator: 84
operands: 72
64Variable
65Literal
66ExprTuple73, 74
67Literal
68ExprTuple75, 76, 77, 78
69ExprTuple118, 79
70ExprTuple119, 80
71ExprTuple120, 79
72ExprTuple121, 80
73Operationoperator: 86
operands: 81
74Operationoperator: 86
operands: 82
75Operationoperator: 84
operands: 83
76Operationoperator: 84
operands: 85
77Operationoperator: 86
operands: 87
78Operationoperator: 88
operands: 89
79IndexedVarvariable: 90
index: 127
80IndexedVarvariable: 91
index: 127
81ExprTuple92, 93
82ExprTuple94, 95
83ExprTuple104, 110
84Literal
85ExprTuple105, 110
86Literal
87ExprTuple104, 105
88Literal
89ExprTuple104, 96
90Variable
91Variable
92Operationoperator: 100
operands: 97
93Operationoperator: 100
operands: 98
94Operationoperator: 100
operands: 99
95Operationoperator: 100
operands: 101
96Operationoperator: 102
operand: 110
97ExprTuple106, 104, 107
98ExprTuple108, 105, 109
99ExprTuple106, 107
100Literal
101ExprTuple108, 109
102Literal
103ExprTuple110
104Variable
105Variable
106ExprRangelambda_map: 111
start_index: 116
end_index: 114
107ExprRangelambda_map: 112
start_index: 116
end_index: 117
108ExprRangelambda_map: 113
start_index: 116
end_index: 114
109ExprRangelambda_map: 115
start_index: 116
end_index: 117
110Variable
111Lambdaparameter: 127
body: 118
112Lambdaparameter: 127
body: 119
113Lambdaparameter: 127
body: 120
114Variable
115Lambdaparameter: 127
body: 121
116Literal
117Variable
118IndexedVarvariable: 122
index: 127
119IndexedVarvariable: 123
index: 127
120IndexedVarvariable: 124
index: 127
121IndexedVarvariable: 125
index: 127
122Variable
123Variable
124Variable
125Variable
126ExprTuple127
127Variable