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, 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 = ExprTuple(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(\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..\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, 5, 6
3Conditionalvalue: 7
condition: 8
4ExprRangelambda_map: 9
start_index: 73
end_index: 59
5ExprRangelambda_map: 10
start_index: 73
end_index: 74
6ExprRangelambda_map: 11
start_index: 73
end_index: 61
7Operationoperator: 12
operand: 15
8Operationoperator: 30
operands: 14
9Lambdaparameter: 83
body: 68
10Lambdaparameter: 83
body: 69
11Lambdaparameter: 83
body: 71
12Literal
13ExprTuple15
14ExprTuple16, 17, 18
15Lambdaparameters: 43
body: 19
16ExprRangelambda_map: 20
start_index: 73
end_index: 59
17ExprRangelambda_map: 21
start_index: 73
end_index: 74
18ExprRangelambda_map: 22
start_index: 73
end_index: 61
19Conditionalvalue: 23
condition: 24
20Lambdaparameter: 83
body: 25
21Lambdaparameter: 83
body: 26
22Lambdaparameter: 83
body: 27
23Operationoperator: 28
operands: 29
24Operationoperator: 30
operands: 31
25Operationoperator: 34
operands: 32
26Operationoperator: 34
operands: 33
27Operationoperator: 34
operands: 35
28Literal
29ExprTuple36, 37
30Literal
31ExprTuple38, 39, 40
32ExprTuple68, 41
33ExprTuple69, 41
34Literal
35ExprTuple71, 41
36Operationoperator: 56
operands: 42
37Operationoperator: 56
operands: 43
38ExprRangelambda_map: 44
start_index: 73
end_index: 59
39ExprRangelambda_map: 45
start_index: 73
end_index: 74
40ExprRangelambda_map: 46
start_index: 73
end_index: 61
41Operationoperator: 47
operand: 55
42ExprTuple50, 49, 51
43ExprTuple50, 66, 51
44Lambdaparameter: 83
body: 52
45Lambdaparameter: 83
body: 53
46Lambdaparameter: 83
body: 54
47Literal
48ExprTuple55
49Operationoperator: 56
operands: 57
50ExprRangelambda_map: 58
start_index: 73
end_index: 59
51ExprRangelambda_map: 60
start_index: 73
end_index: 61
52Operationoperator: 64
operands: 62
53Operationoperator: 64
operands: 63
54Operationoperator: 64
operands: 65
55Variable
56Literal
57ExprTuple66
58Lambdaparameter: 83
body: 67
59Variable
60Lambdaparameter: 83
body: 70
61Variable
62ExprTuple67, 68
63ExprTuple80, 69
64Literal
65ExprTuple70, 71
66ExprRangelambda_map: 72
start_index: 73
end_index: 74
67IndexedVarvariable: 75
index: 83
68IndexedVarvariable: 76
index: 83
69IndexedVarvariable: 77
index: 83
70IndexedVarvariable: 78
index: 83
71IndexedVarvariable: 79
index: 83
72Lambdaparameter: 83
body: 80
73Literal
74Variable
75Variable
76Variable
77Variable
78Variable
79Variable
80IndexedVarvariable: 81
index: 83
81Variable
82ExprTuple83
83Variable