logo

Expression of type ExprTuple

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, ExprTuple, IndexedVar, K, Lambda, U, V, Variable, W, 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, 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)
expr = ExprTuple(Lambda([U_1_to_i, V, W_1_to_k], Conditional(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(), And(ExprRange(sub_expr1, InClass(IndexedVar(U, sub_expr1), sub_expr2), one, i), InClass(V, sub_expr2), 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(\left(U_{1}, U_{2}, \ldots, U_{i}, V, 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(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} \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) ,  V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple4, 63, 5
3Conditionalvalue: 6
condition: 7
4ExprRangelambda_map: 8
start_index: 90
end_index: 88
5ExprRangelambda_map: 9
start_index: 90
end_index: 91
6Operationoperator: 25
operand: 12
7Operationoperator: 27
operands: 11
8Lambdaparameter: 101
body: 64
9Lambdaparameter: 101
body: 65
10ExprTuple12
11ExprTuple13, 14, 15
12Lambdaparameters: 16
body: 17
13ExprRangelambda_map: 18
start_index: 90
end_index: 88
14Operationoperator: 30
operands: 19
15ExprRangelambda_map: 20
start_index: 90
end_index: 91
16ExprTuple80, 81, 82, 84
17Conditionalvalue: 21
condition: 22
18Lambdaparameter: 101
body: 23
19ExprTuple63, 37
20Lambdaparameter: 101
body: 24
21Operationoperator: 25
operand: 32
22Operationoperator: 27
operands: 28
23Operationoperator: 30
operands: 29
24Operationoperator: 30
operands: 31
25Literal
26ExprTuple32
27Literal
28ExprTuple33, 34, 35, 36
29ExprTuple64, 37
30Literal
31ExprTuple65, 37
32Lambdaparameter: 83
body: 39
33ExprRangelambda_map: 40
start_index: 90
end_index: 88
34ExprRangelambda_map: 41
start_index: 90
end_index: 91
35ExprRangelambda_map: 42
start_index: 90
end_index: 88
36ExprRangelambda_map: 43
start_index: 90
end_index: 91
37Operationoperator: 44
operand: 52
38ExprTuple83
39Conditionalvalue: 46
condition: 47
40Lambdaparameter: 101
body: 48
41Lambdaparameter: 101
body: 49
42Lambdaparameter: 101
body: 50
43Lambdaparameter: 101
body: 51
44Literal
45ExprTuple52
46Operationoperator: 53
operands: 54
47Operationoperator: 59
operands: 55
48Operationoperator: 59
operands: 56
49Operationoperator: 59
operands: 57
50Operationoperator: 59
operands: 58
51Operationoperator: 59
operands: 60
52Variable
53Literal
54ExprTuple61, 62
55ExprTuple83, 63
56ExprTuple92, 64
57ExprTuple93, 65
58ExprTuple94, 64
59Literal
60ExprTuple95, 65
61Operationoperator: 67
operands: 66
62Operationoperator: 67
operands: 68
63Variable
64IndexedVarvariable: 69
index: 101
65IndexedVarvariable: 70
index: 101
66ExprTuple71, 72
67Literal
68ExprTuple73, 74
69Variable
70Variable
71Operationoperator: 78
operands: 75
72Operationoperator: 78
operands: 76
73Operationoperator: 78
operands: 77
74Operationoperator: 78
operands: 79
75ExprTuple80, 81
76ExprTuple82, 84
77ExprTuple80, 83, 81
78Literal
79ExprTuple82, 83, 84
80ExprRangelambda_map: 85
start_index: 90
end_index: 88
81ExprRangelambda_map: 86
start_index: 90
end_index: 91
82ExprRangelambda_map: 87
start_index: 90
end_index: 88
83Variable
84ExprRangelambda_map: 89
start_index: 90
end_index: 91
85Lambdaparameter: 101
body: 92
86Lambdaparameter: 101
body: 93
87Lambdaparameter: 101
body: 94
88Variable
89Lambdaparameter: 101
body: 95
90Literal
91Variable
92IndexedVarvariable: 96
index: 101
93IndexedVarvariable: 97
index: 101
94IndexedVarvariable: 98
index: 101
95IndexedVarvariable: 99
index: 101
96Variable
97Variable
98Variable
99Variable
100ExprTuple101
101Variable