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, 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, InSet
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([i, j, k], Conditional(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(), And(InSet(i, Natural), InSet(j, 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, j, k\right) \mapsto \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} \textrm{ if } i \in \mathbb{N} ,  j \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
1ExprTuple72, 87, 74
2Conditionalvalue: 3
condition: 4
3Operationoperator: 25
operand: 7
4Operationoperator: 43
operands: 6
5ExprTuple7
6ExprTuple8, 9, 10
7Lambdaparameters: 11
body: 12
8Operationoperator: 77
operands: 13
9Operationoperator: 77
operands: 14
10Operationoperator: 77
operands: 15
11ExprTuple16, 17, 18
12Conditionalvalue: 19
condition: 20
13ExprTuple72, 21
14ExprTuple87, 21
15ExprTuple74, 21
16ExprRangelambda_map: 22
start_index: 86
end_index: 72
17ExprRangelambda_map: 23
start_index: 86
end_index: 87
18ExprRangelambda_map: 24
start_index: 86
end_index: 74
19Operationoperator: 25
operand: 28
20Operationoperator: 43
operands: 27
21Literal
22Lambdaparameter: 96
body: 81
23Lambdaparameter: 96
body: 82
24Lambdaparameter: 96
body: 84
25Literal
26ExprTuple28
27ExprTuple29, 30, 31
28Lambdaparameters: 56
body: 32
29ExprRangelambda_map: 33
start_index: 86
end_index: 72
30ExprRangelambda_map: 34
start_index: 86
end_index: 87
31ExprRangelambda_map: 35
start_index: 86
end_index: 74
32Conditionalvalue: 36
condition: 37
33Lambdaparameter: 96
body: 38
34Lambdaparameter: 96
body: 39
35Lambdaparameter: 96
body: 40
36Operationoperator: 41
operands: 42
37Operationoperator: 43
operands: 44
38Operationoperator: 47
operands: 45
39Operationoperator: 47
operands: 46
40Operationoperator: 47
operands: 48
41Literal
42ExprTuple49, 50
43Literal
44ExprTuple51, 52, 53
45ExprTuple81, 54
46ExprTuple82, 54
47Literal
48ExprTuple84, 54
49Operationoperator: 69
operands: 55
50Operationoperator: 69
operands: 56
51ExprRangelambda_map: 57
start_index: 86
end_index: 72
52ExprRangelambda_map: 58
start_index: 86
end_index: 87
53ExprRangelambda_map: 59
start_index: 86
end_index: 74
54Operationoperator: 60
operand: 68
55ExprTuple63, 62, 64
56ExprTuple63, 79, 64
57Lambdaparameter: 96
body: 65
58Lambdaparameter: 96
body: 66
59Lambdaparameter: 96
body: 67
60Literal
61ExprTuple68
62Operationoperator: 69
operands: 70
63ExprRangelambda_map: 71
start_index: 86
end_index: 72
64ExprRangelambda_map: 73
start_index: 86
end_index: 74
65Operationoperator: 77
operands: 75
66Operationoperator: 77
operands: 76
67Operationoperator: 77
operands: 78
68Variable
69Literal
70ExprTuple79
71Lambdaparameter: 96
body: 80
72Variable
73Lambdaparameter: 96
body: 83
74Variable
75ExprTuple80, 81
76ExprTuple93, 82
77Literal
78ExprTuple83, 84
79ExprRangelambda_map: 85
start_index: 86
end_index: 87
80IndexedVarvariable: 88
index: 96
81IndexedVarvariable: 89
index: 96
82IndexedVarvariable: 90
index: 96
83IndexedVarvariable: 91
index: 96
84IndexedVarvariable: 92
index: 96
85Lambdaparameter: 96
body: 93
86Literal
87Variable
88Variable
89Variable
90Variable
91Variable
92Variable
93IndexedVarvariable: 94
index: 96
94Variable
95ExprTuple96
96Variable