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, alpha, 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
from proveit.linear_algebra import ScalarMult, 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, W_1_to_k]
expr = ExprTuple(Lambda(sub_expr3, Conditional(Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, ScalarMult(alpha, b), c_1_to_k), ScalarMult(alpha, TensorProd(a_1_to_i, b, 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), 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), b \in V,\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(\alpha \cdot b\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(\alpha \cdot \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)\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) ,  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, 48, 5
3Conditionalvalue: 6
condition: 7
4ExprRangelambda_map: 8
start_index: 67
end_index: 65
5ExprRangelambda_map: 9
start_index: 67
end_index: 68
6Operationoperator: 10
operand: 13
7Operationoperator: 27
operands: 12
8Lambdaparameter: 76
body: 62
9Lambdaparameter: 76
body: 63
10Literal
11ExprTuple13
12ExprTuple14, 15, 16
13Lambdaparameters: 54
body: 17
14ExprRangelambda_map: 18
start_index: 67
end_index: 65
15Operationoperator: 30
operands: 19
16ExprRangelambda_map: 20
start_index: 67
end_index: 68
17Conditionalvalue: 21
condition: 22
18Lambdaparameter: 76
body: 23
19ExprTuple48, 37
20Lambdaparameter: 76
body: 24
21Operationoperator: 25
operands: 26
22Operationoperator: 27
operands: 28
23Operationoperator: 30
operands: 29
24Operationoperator: 30
operands: 31
25Literal
26ExprTuple32, 33
27Literal
28ExprTuple34, 35, 36
29ExprTuple62, 37
30Literal
31ExprTuple63, 37
32Operationoperator: 53
operands: 38
33Operationoperator: 51
operands: 39
34ExprRangelambda_map: 40
start_index: 67
end_index: 65
35Operationoperator: 56
operands: 41
36ExprRangelambda_map: 42
start_index: 67
end_index: 68
37Operationoperator: 43
operand: 50
38ExprTuple59, 45, 61
39ExprTuple58, 46
40Lambdaparameter: 76
body: 47
41ExprTuple60, 48
42Lambdaparameter: 76
body: 49
43Literal
44ExprTuple50
45Operationoperator: 51
operands: 52
46Operationoperator: 53
operands: 54
47Operationoperator: 56
operands: 55
48Variable
49Operationoperator: 56
operands: 57
50Variable
51Literal
52ExprTuple58, 60
53Literal
54ExprTuple59, 60, 61
55ExprTuple71, 62
56Literal
57ExprTuple72, 63
58Variable
59ExprRangelambda_map: 64
start_index: 67
end_index: 65
60Variable
61ExprRangelambda_map: 66
start_index: 67
end_index: 68
62IndexedVarvariable: 69
index: 76
63IndexedVarvariable: 70
index: 76
64Lambdaparameter: 76
body: 71
65Variable
66Lambdaparameter: 76
body: 72
67Literal
68Variable
69Variable
70Variable
71IndexedVarvariable: 73
index: 76
72IndexedVarvariable: 74
index: 76
73Variable
74Variable
75ExprTuple76
76Variable