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, ExprRange, IndexedVar, K, Lambda, U, V, Variable, W, i, j, k
from proveit.core_expr_types import U_1_to_i, V_1_to_j, W_1_to_k, a_1_to_i, b_1_to_j, c_1_to_k
from proveit.linear_algebra import TensorProd, VecSpaces
from proveit.logic import And, Equals, Forall, InClass
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = VecSpaces(K)
sub_expr3 = [U_1_to_i, V_1_to_j, W_1_to_k]
expr = Lambda(sub_expr3, Conditional(Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, TensorProd(b_1_to_j), c_1_to_k), TensorProd(a_1_to_i, b_1_to_j, c_1_to_k)).with_wrapping_at(1), domains = sub_expr3).with_wrapping(), And(ExprRange(sub_expr1, InClass(IndexedVar(U, sub_expr1), sub_expr2), one, i), ExprRange(sub_expr1, InClass(IndexedVar(V, sub_expr1), sub_expr2), one, j), ExprRange(sub_expr1, InClass(IndexedVar(W, sub_expr1), sub_expr2), one, 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())
\left(U_{1}, U_{2}, \ldots, U_{i}, V_{1}, V_{2}, \ldots, V_{j}, W_{1}, W_{2}, \ldots, W_{k}\right) \mapsto \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(b_{1} \in V_{1}\right), \left(b_{2} \in V_{2}\right), \ldots, \left(b_{j} \in V_{j}\right),\left(c_{1} \in W_{1}\right), \left(c_{2} \in W_{2}\right), \ldots, \left(c_{k} \in W_{k}\right)}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(b_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}{\otimes} b_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \end{array} \end{array}\right)\end{array} \textrm{ if } \left(U_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(U_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(U_{i} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right), \left(V_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(V_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(V_{j} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right), \left(W_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(W_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(W_{k} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right)\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
1ExprTuple3, 4, 5
2Conditionalvalue: 6
condition: 7
3ExprRangelambda_map: 8
start_index: 72
end_index: 58
4ExprRangelambda_map: 9
start_index: 72
end_index: 73
5ExprRangelambda_map: 10
start_index: 72
end_index: 60
6Operationoperator: 11
operand: 14
7Operationoperator: 29
operands: 13
8Lambdaparameter: 82
body: 67
9Lambdaparameter: 82
body: 68
10Lambdaparameter: 82
body: 70
11Literal
12ExprTuple14
13ExprTuple15, 16, 17
14Lambdaparameters: 42
body: 18
15ExprRangelambda_map: 19
start_index: 72
end_index: 58
16ExprRangelambda_map: 20
start_index: 72
end_index: 73
17ExprRangelambda_map: 21
start_index: 72
end_index: 60
18Conditionalvalue: 22
condition: 23
19Lambdaparameter: 82
body: 24
20Lambdaparameter: 82
body: 25
21Lambdaparameter: 82
body: 26
22Operationoperator: 27
operands: 28
23Operationoperator: 29
operands: 30
24Operationoperator: 33
operands: 31
25Operationoperator: 33
operands: 32
26Operationoperator: 33
operands: 34
27Literal
28ExprTuple35, 36
29Literal
30ExprTuple37, 38, 39
31ExprTuple67, 40
32ExprTuple68, 40
33Literal
34ExprTuple70, 40
35Operationoperator: 55
operands: 41
36Operationoperator: 55
operands: 42
37ExprRangelambda_map: 43
start_index: 72
end_index: 58
38ExprRangelambda_map: 44
start_index: 72
end_index: 73
39ExprRangelambda_map: 45
start_index: 72
end_index: 60
40Operationoperator: 46
operand: 54
41ExprTuple49, 48, 50
42ExprTuple49, 65, 50
43Lambdaparameter: 82
body: 51
44Lambdaparameter: 82
body: 52
45Lambdaparameter: 82
body: 53
46Literal
47ExprTuple54
48Operationoperator: 55
operands: 56
49ExprRangelambda_map: 57
start_index: 72
end_index: 58
50ExprRangelambda_map: 59
start_index: 72
end_index: 60
51Operationoperator: 63
operands: 61
52Operationoperator: 63
operands: 62
53Operationoperator: 63
operands: 64
54Variable
55Literal
56ExprTuple65
57Lambdaparameter: 82
body: 66
58Variable
59Lambdaparameter: 82
body: 69
60Variable
61ExprTuple66, 67
62ExprTuple79, 68
63Literal
64ExprTuple69, 70
65ExprRangelambda_map: 71
start_index: 72
end_index: 73
66IndexedVarvariable: 74
index: 82
67IndexedVarvariable: 75
index: 82
68IndexedVarvariable: 76
index: 82
69IndexedVarvariable: 77
index: 82
70IndexedVarvariable: 78
index: 82
71Lambdaparameter: 82
body: 79
72Literal
73Variable
74Variable
75Variable
76Variable
77Variable
78Variable
79IndexedVarvariable: 80
index: 82
80Variable
81ExprTuple82
82Variable