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 Conditional, 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 And, Equals, Forall, Implies, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, k], Conditional(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(), And(InSet(i, 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, k\right) \mapsto \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} \textrm{ if } i \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
1ExprTuple99, 102
2Conditionalvalue: 3
condition: 4
3Operationoperator: 36
operand: 7
4Operationoperator: 38
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 10
body: 11
8Operationoperator: 70
operands: 12
9Operationoperator: 70
operands: 13
10ExprTuple14, 74, 15
11Conditionalvalue: 16
condition: 17
12ExprTuple99, 18
13ExprTuple102, 18
14ExprRangelambda_map: 19
start_index: 101
end_index: 99
15ExprRangelambda_map: 20
start_index: 101
end_index: 102
16Operationoperator: 36
operand: 23
17Operationoperator: 38
operands: 22
18Literal
19Lambdaparameter: 112
body: 75
20Lambdaparameter: 112
body: 76
21ExprTuple23
22ExprTuple24, 25, 26
23Lambdaparameters: 27
body: 28
24ExprRangelambda_map: 29
start_index: 101
end_index: 99
25Operationoperator: 41
operands: 30
26ExprRangelambda_map: 31
start_index: 101
end_index: 102
27ExprTuple91, 92, 93, 95
28Conditionalvalue: 32
condition: 33
29Lambdaparameter: 112
body: 34
30ExprTuple74, 48
31Lambdaparameter: 112
body: 35
32Operationoperator: 36
operand: 43
33Operationoperator: 38
operands: 39
34Operationoperator: 41
operands: 40
35Operationoperator: 41
operands: 42
36Literal
37ExprTuple43
38Literal
39ExprTuple44, 45, 46, 47
40ExprTuple75, 48
41Literal
42ExprTuple76, 48
43Lambdaparameter: 94
body: 50
44ExprRangelambda_map: 51
start_index: 101
end_index: 99
45ExprRangelambda_map: 52
start_index: 101
end_index: 102
46ExprRangelambda_map: 53
start_index: 101
end_index: 99
47ExprRangelambda_map: 54
start_index: 101
end_index: 102
48Operationoperator: 55
operand: 63
49ExprTuple94
50Conditionalvalue: 57
condition: 58
51Lambdaparameter: 112
body: 59
52Lambdaparameter: 112
body: 60
53Lambdaparameter: 112
body: 61
54Lambdaparameter: 112
body: 62
55Literal
56ExprTuple63
57Operationoperator: 64
operands: 65
58Operationoperator: 70
operands: 66
59Operationoperator: 70
operands: 67
60Operationoperator: 70
operands: 68
61Operationoperator: 70
operands: 69
62Operationoperator: 70
operands: 71
63Variable
64Literal
65ExprTuple72, 73
66ExprTuple94, 74
67ExprTuple103, 75
68ExprTuple104, 76
69ExprTuple105, 75
70Literal
71ExprTuple106, 76
72Operationoperator: 78
operands: 77
73Operationoperator: 78
operands: 79
74Variable
75IndexedVarvariable: 80
index: 112
76IndexedVarvariable: 81
index: 112
77ExprTuple82, 83
78Literal
79ExprTuple84, 85
80Variable
81Variable
82Operationoperator: 89
operands: 86
83Operationoperator: 89
operands: 87
84Operationoperator: 89
operands: 88
85Operationoperator: 89
operands: 90
86ExprTuple91, 92
87ExprTuple93, 95
88ExprTuple91, 94, 92
89Literal
90ExprTuple93, 94, 95
91ExprRangelambda_map: 96
start_index: 101
end_index: 99
92ExprRangelambda_map: 97
start_index: 101
end_index: 102
93ExprRangelambda_map: 98
start_index: 101
end_index: 99
94Variable
95ExprRangelambda_map: 100
start_index: 101
end_index: 102
96Lambdaparameter: 112
body: 103
97Lambdaparameter: 112
body: 104
98Lambdaparameter: 112
body: 105
99Variable
100Lambdaparameter: 112
body: 106
101Literal
102Variable
103IndexedVarvariable: 107
index: 112
104IndexedVarvariable: 108
index: 112
105IndexedVarvariable: 109
index: 112
106IndexedVarvariable: 110
index: 112
107Variable
108Variable
109Variable
110Variable
111ExprTuple112
112Variable