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, Lambda, U, V, Variable, W, a, b, c, d, e, f, i, k
from proveit.core_expr_types import a_1_to_i, c_1_to_k, d_1_to_i, f_1_to_k
from proveit.linear_algebra import TensorProd, VecZero
from proveit.logic import And, Equals, Forall, Implies, InSet, 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 = IndexedVar(U, sub_expr1)
sub_expr3 = IndexedVar(W, sub_expr1)
expr = ExprTuple(Lambda([a_1_to_i, c_1_to_k, d_1_to_i, f_1_to_k], Conditional(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))]), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), sub_expr2), one, i), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), sub_expr3), one, k), ExprRange(sub_expr1, InSet(IndexedVar(d, sub_expr1), sub_expr2), one, i), ExprRange(sub_expr1, InSet(IndexedVar(f, sub_expr1), sub_expr3), 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(a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{k}, d_{1}, d_{2}, \ldots, d_{i}, f_{1}, f_{2}, \ldots, f_{k}\right) \mapsto \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) \textrm{ if } \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)\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
2ExprTuple66, 67, 68, 69
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 27
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11, 12, 13
9Lambdaparameters: 47
body: 14
10ExprRangelambda_map: 15
start_index: 76
end_index: 74
11ExprRangelambda_map: 16
start_index: 76
end_index: 77
12ExprRangelambda_map: 17
start_index: 76
end_index: 74
13ExprRangelambda_map: 18
start_index: 76
end_index: 77
14Conditionalvalue: 19
condition: 20
15Lambdaparameter: 87
body: 21
16Lambdaparameter: 87
body: 22
17Lambdaparameter: 87
body: 23
18Lambdaparameter: 87
body: 24
19Operationoperator: 25
operands: 26
20Operationoperator: 27
operands: 28
21Operationoperator: 44
operands: 29
22Operationoperator: 44
operands: 30
23Operationoperator: 44
operands: 31
24Operationoperator: 44
operands: 32
25Literal
26ExprTuple33, 34
27Literal
28ExprTuple35, 36, 37, 38
29ExprTuple78, 39
30ExprTuple79, 40
31ExprTuple80, 39
32ExprTuple81, 40
33Operationoperator: 46
operands: 41
34Operationoperator: 46
operands: 42
35Operationoperator: 44
operands: 43
36Operationoperator: 44
operands: 45
37Operationoperator: 46
operands: 47
38Operationoperator: 48
operands: 49
39IndexedVarvariable: 50
index: 87
40IndexedVarvariable: 51
index: 87
41ExprTuple52, 53
42ExprTuple54, 55
43ExprTuple64, 70
44Literal
45ExprTuple65, 70
46Literal
47ExprTuple64, 65
48Literal
49ExprTuple64, 56
50Variable
51Variable
52Operationoperator: 60
operands: 57
53Operationoperator: 60
operands: 58
54Operationoperator: 60
operands: 59
55Operationoperator: 60
operands: 61
56Operationoperator: 62
operand: 70
57ExprTuple66, 64, 67
58ExprTuple68, 65, 69
59ExprTuple66, 67
60Literal
61ExprTuple68, 69
62Literal
63ExprTuple70
64Variable
65Variable
66ExprRangelambda_map: 71
start_index: 76
end_index: 74
67ExprRangelambda_map: 72
start_index: 76
end_index: 77
68ExprRangelambda_map: 73
start_index: 76
end_index: 74
69ExprRangelambda_map: 75
start_index: 76
end_index: 77
70Variable
71Lambdaparameter: 87
body: 78
72Lambdaparameter: 87
body: 79
73Lambdaparameter: 87
body: 80
74Variable
75Lambdaparameter: 87
body: 81
76Literal
77Variable
78IndexedVarvariable: 82
index: 87
79IndexedVarvariable: 83
index: 87
80IndexedVarvariable: 84
index: 87
81IndexedVarvariable: 85
index: 87
82Variable
83Variable
84Variable
85Variable
86ExprTuple87
87Variable