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, 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 And, Equals, Forall, Implies, InSet, NotEquals
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, 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(), 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(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} \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
1ExprTuple111, 114
2Conditionalvalue: 3
condition: 4
3Operationoperator: 36
operand: 7
4Operationoperator: 64
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 10
body: 11
8Operationoperator: 81
operands: 12
9Operationoperator: 81
operands: 13
10ExprTuple14, 107, 15
11Conditionalvalue: 16
condition: 17
12ExprTuple111, 18
13ExprTuple114, 18
14ExprRangelambda_map: 19
start_index: 113
end_index: 111
15ExprRangelambda_map: 20
start_index: 113
end_index: 114
16Operationoperator: 36
operand: 23
17Operationoperator: 64
operands: 22
18Literal
19Lambdaparameter: 124
body: 76
20Lambdaparameter: 124
body: 77
21ExprTuple23
22ExprTuple24, 25, 26
23Lambdaparameters: 27
body: 28
24ExprRangelambda_map: 29
start_index: 113
end_index: 111
25Operationoperator: 40
operands: 30
26ExprRangelambda_map: 31
start_index: 113
end_index: 114
27ExprTuple103, 104, 105, 106
28Conditionalvalue: 32
condition: 33
29Lambdaparameter: 124
body: 34
30ExprTuple107, 47
31Lambdaparameter: 124
body: 35
32Operationoperator: 36
operand: 42
33Operationoperator: 64
operands: 38
34Operationoperator: 40
operands: 39
35Operationoperator: 40
operands: 41
36Literal
37ExprTuple42
38ExprTuple43, 44, 45, 46
39ExprTuple76, 47
40Literal
41ExprTuple77, 47
42Lambdaparameters: 84
body: 48
43ExprRangelambda_map: 49
start_index: 113
end_index: 111
44ExprRangelambda_map: 50
start_index: 113
end_index: 114
45ExprRangelambda_map: 51
start_index: 113
end_index: 111
46ExprRangelambda_map: 52
start_index: 113
end_index: 114
47Operationoperator: 53
operand: 61
48Conditionalvalue: 55
condition: 56
49Lambdaparameter: 124
body: 57
50Lambdaparameter: 124
body: 58
51Lambdaparameter: 124
body: 59
52Lambdaparameter: 124
body: 60
53Literal
54ExprTuple61
55Operationoperator: 62
operands: 63
56Operationoperator: 64
operands: 65
57Operationoperator: 81
operands: 66
58Operationoperator: 81
operands: 67
59Operationoperator: 81
operands: 68
60Operationoperator: 81
operands: 69
61Variable
62Literal
63ExprTuple70, 71
64Literal
65ExprTuple72, 73, 74, 75
66ExprTuple115, 76
67ExprTuple116, 77
68ExprTuple117, 76
69ExprTuple118, 77
70Operationoperator: 83
operands: 78
71Operationoperator: 83
operands: 79
72Operationoperator: 81
operands: 80
73Operationoperator: 81
operands: 82
74Operationoperator: 83
operands: 84
75Operationoperator: 85
operands: 86
76IndexedVarvariable: 87
index: 124
77IndexedVarvariable: 88
index: 124
78ExprTuple89, 90
79ExprTuple91, 92
80ExprTuple101, 107
81Literal
82ExprTuple102, 107
83Literal
84ExprTuple101, 102
85Literal
86ExprTuple101, 93
87Variable
88Variable
89Operationoperator: 97
operands: 94
90Operationoperator: 97
operands: 95
91Operationoperator: 97
operands: 96
92Operationoperator: 97
operands: 98
93Operationoperator: 99
operand: 107
94ExprTuple103, 101, 104
95ExprTuple105, 102, 106
96ExprTuple103, 104
97Literal
98ExprTuple105, 106
99Literal
100ExprTuple107
101Variable
102Variable
103ExprRangelambda_map: 108
start_index: 113
end_index: 111
104ExprRangelambda_map: 109
start_index: 113
end_index: 114
105ExprRangelambda_map: 110
start_index: 113
end_index: 111
106ExprRangelambda_map: 112
start_index: 113
end_index: 114
107Variable
108Lambdaparameter: 124
body: 115
109Lambdaparameter: 124
body: 116
110Lambdaparameter: 124
body: 117
111Variable
112Lambdaparameter: 124
body: 118
113Literal
114Variable
115IndexedVarvariable: 119
index: 124
116IndexedVarvariable: 120
index: 124
117IndexedVarvariable: 121
index: 124
118IndexedVarvariable: 122
index: 124
119Variable
120Variable
121Variable
122Variable
123ExprTuple124
124Variable