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, 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 Equals, Forall
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [U_1_to_i, V_1_to_j, W_1_to_k]
expr = Lambda(K, Forall(instance_param_or_params = [i, j, k], instance_expr = Forall(instance_param_or_params = sub_expr1, instance_expr = 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_expr1).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, j, k \in \mathbb{N}}~\left[\begin{array}{l}\forall_{U_{1}, U_{2}, \ldots, U_{i}, V_{1}, V_{2}, \ldots, V_{j}, 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(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}\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: 71
body: 1
1Operationoperator: 28
operand: 3
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple75, 90, 77
5Conditionalvalue: 6
condition: 7
6Operationoperator: 28
operand: 10
7Operationoperator: 46
operands: 9
8ExprTuple10
9ExprTuple11, 12, 13
10Lambdaparameters: 14
body: 15
11Operationoperator: 80
operands: 16
12Operationoperator: 80
operands: 17
13Operationoperator: 80
operands: 18
14ExprTuple19, 20, 21
15Conditionalvalue: 22
condition: 23
16ExprTuple75, 24
17ExprTuple90, 24
18ExprTuple77, 24
19ExprRangelambda_map: 25
start_index: 89
end_index: 75
20ExprRangelambda_map: 26
start_index: 89
end_index: 90
21ExprRangelambda_map: 27
start_index: 89
end_index: 77
22Operationoperator: 28
operand: 31
23Operationoperator: 46
operands: 30
24Literal
25Lambdaparameter: 99
body: 84
26Lambdaparameter: 99
body: 85
27Lambdaparameter: 99
body: 87
28Literal
29ExprTuple31
30ExprTuple32, 33, 34
31Lambdaparameters: 59
body: 35
32ExprRangelambda_map: 36
start_index: 89
end_index: 75
33ExprRangelambda_map: 37
start_index: 89
end_index: 90
34ExprRangelambda_map: 38
start_index: 89
end_index: 77
35Conditionalvalue: 39
condition: 40
36Lambdaparameter: 99
body: 41
37Lambdaparameter: 99
body: 42
38Lambdaparameter: 99
body: 43
39Operationoperator: 44
operands: 45
40Operationoperator: 46
operands: 47
41Operationoperator: 50
operands: 48
42Operationoperator: 50
operands: 49
43Operationoperator: 50
operands: 51
44Literal
45ExprTuple52, 53
46Literal
47ExprTuple54, 55, 56
48ExprTuple84, 57
49ExprTuple85, 57
50Literal
51ExprTuple87, 57
52Operationoperator: 72
operands: 58
53Operationoperator: 72
operands: 59
54ExprRangelambda_map: 60
start_index: 89
end_index: 75
55ExprRangelambda_map: 61
start_index: 89
end_index: 90
56ExprRangelambda_map: 62
start_index: 89
end_index: 77
57Operationoperator: 63
operand: 71
58ExprTuple66, 65, 67
59ExprTuple66, 82, 67
60Lambdaparameter: 99
body: 68
61Lambdaparameter: 99
body: 69
62Lambdaparameter: 99
body: 70
63Literal
64ExprTuple71
65Operationoperator: 72
operands: 73
66ExprRangelambda_map: 74
start_index: 89
end_index: 75
67ExprRangelambda_map: 76
start_index: 89
end_index: 77
68Operationoperator: 80
operands: 78
69Operationoperator: 80
operands: 79
70Operationoperator: 80
operands: 81
71Variable
72Literal
73ExprTuple82
74Lambdaparameter: 99
body: 83
75Variable
76Lambdaparameter: 99
body: 86
77Variable
78ExprTuple83, 84
79ExprTuple96, 85
80Literal
81ExprTuple86, 87
82ExprRangelambda_map: 88
start_index: 89
end_index: 90
83IndexedVarvariable: 91
index: 99
84IndexedVarvariable: 92
index: 99
85IndexedVarvariable: 93
index: 99
86IndexedVarvariable: 94
index: 99
87IndexedVarvariable: 95
index: 99
88Lambdaparameter: 99
body: 96
89Literal
90Variable
91Variable
92Variable
93Variable
94Variable
95Variable
96IndexedVarvariable: 97
index: 99
97Variable
98ExprTuple99
99Variable