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, 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, InClass, NotEquals
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, 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(), 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(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} \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, 96, 5
3Conditionalvalue: 6
condition: 7
4ExprRangelambda_map: 8
start_index: 102
end_index: 100
5ExprRangelambda_map: 9
start_index: 102
end_index: 103
6Operationoperator: 25
operand: 12
7Operationoperator: 53
operands: 11
8Lambdaparameter: 113
body: 65
9Lambdaparameter: 113
body: 66
10ExprTuple12
11ExprTuple13, 14, 15
12Lambdaparameters: 16
body: 17
13ExprRangelambda_map: 18
start_index: 102
end_index: 100
14Operationoperator: 29
operands: 19
15ExprRangelambda_map: 20
start_index: 102
end_index: 103
16ExprTuple92, 93, 94, 95
17Conditionalvalue: 21
condition: 22
18Lambdaparameter: 113
body: 23
19ExprTuple96, 36
20Lambdaparameter: 113
body: 24
21Operationoperator: 25
operand: 31
22Operationoperator: 53
operands: 27
23Operationoperator: 29
operands: 28
24Operationoperator: 29
operands: 30
25Literal
26ExprTuple31
27ExprTuple32, 33, 34, 35
28ExprTuple65, 36
29Literal
30ExprTuple66, 36
31Lambdaparameters: 73
body: 37
32ExprRangelambda_map: 38
start_index: 102
end_index: 100
33ExprRangelambda_map: 39
start_index: 102
end_index: 103
34ExprRangelambda_map: 40
start_index: 102
end_index: 100
35ExprRangelambda_map: 41
start_index: 102
end_index: 103
36Operationoperator: 42
operand: 50
37Conditionalvalue: 44
condition: 45
38Lambdaparameter: 113
body: 46
39Lambdaparameter: 113
body: 47
40Lambdaparameter: 113
body: 48
41Lambdaparameter: 113
body: 49
42Literal
43ExprTuple50
44Operationoperator: 51
operands: 52
45Operationoperator: 53
operands: 54
46Operationoperator: 70
operands: 55
47Operationoperator: 70
operands: 56
48Operationoperator: 70
operands: 57
49Operationoperator: 70
operands: 58
50Variable
51Literal
52ExprTuple59, 60
53Literal
54ExprTuple61, 62, 63, 64
55ExprTuple104, 65
56ExprTuple105, 66
57ExprTuple106, 65
58ExprTuple107, 66
59Operationoperator: 72
operands: 67
60Operationoperator: 72
operands: 68
61Operationoperator: 70
operands: 69
62Operationoperator: 70
operands: 71
63Operationoperator: 72
operands: 73
64Operationoperator: 74
operands: 75
65IndexedVarvariable: 76
index: 113
66IndexedVarvariable: 77
index: 113
67ExprTuple78, 79
68ExprTuple80, 81
69ExprTuple90, 96
70Literal
71ExprTuple91, 96
72Literal
73ExprTuple90, 91
74Literal
75ExprTuple90, 82
76Variable
77Variable
78Operationoperator: 86
operands: 83
79Operationoperator: 86
operands: 84
80Operationoperator: 86
operands: 85
81Operationoperator: 86
operands: 87
82Operationoperator: 88
operand: 96
83ExprTuple92, 90, 93
84ExprTuple94, 91, 95
85ExprTuple92, 93
86Literal
87ExprTuple94, 95
88Literal
89ExprTuple96
90Variable
91Variable
92ExprRangelambda_map: 97
start_index: 102
end_index: 100
93ExprRangelambda_map: 98
start_index: 102
end_index: 103
94ExprRangelambda_map: 99
start_index: 102
end_index: 100
95ExprRangelambda_map: 101
start_index: 102
end_index: 103
96Variable
97Lambdaparameter: 113
body: 104
98Lambdaparameter: 113
body: 105
99Lambdaparameter: 113
body: 106
100Variable
101Lambdaparameter: 113
body: 107
102Literal
103Variable
104IndexedVarvariable: 108
index: 113
105IndexedVarvariable: 109
index: 113
106IndexedVarvariable: 110
index: 113
107IndexedVarvariable: 111
index: 113
108Variable
109Variable
110Variable
111Variable
112ExprTuple113
113Variable