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, i, k
from proveit.core_expr_types import a_1_to_i, c_1_to_k, d_1_to_i, e_1_to_k
from proveit.linear_algebra import TensorProd
from proveit.logic import And, Equals, Forall, Implies, InSet
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, e_1_to_k], Conditional(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), 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(e, 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}, e_{1}, e_{2}, \ldots, e_{k}\right) \mapsto \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) \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(e_{1} \in W_{1}\right) ,  \left(e_{2} \in W_{2}\right) ,  \ldots ,  \left(e_{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
2ExprTuple54, 55, 56, 58
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12, 13, 14
10Lambdaparameter: 57
body: 16
11ExprRangelambda_map: 17
start_index: 64
end_index: 62
12ExprRangelambda_map: 18
start_index: 64
end_index: 65
13ExprRangelambda_map: 19
start_index: 64
end_index: 62
14ExprRangelambda_map: 20
start_index: 64
end_index: 65
15ExprTuple57
16Conditionalvalue: 21
condition: 22
17Lambdaparameter: 75
body: 23
18Lambdaparameter: 75
body: 24
19Lambdaparameter: 75
body: 25
20Lambdaparameter: 75
body: 26
21Operationoperator: 27
operands: 28
22Operationoperator: 33
operands: 29
23Operationoperator: 33
operands: 30
24Operationoperator: 33
operands: 31
25Operationoperator: 33
operands: 32
26Operationoperator: 33
operands: 34
27Literal
28ExprTuple35, 36
29ExprTuple57, 37
30ExprTuple66, 38
31ExprTuple67, 39
32ExprTuple68, 38
33Literal
34ExprTuple69, 39
35Operationoperator: 41
operands: 40
36Operationoperator: 41
operands: 42
37Variable
38IndexedVarvariable: 43
index: 75
39IndexedVarvariable: 44
index: 75
40ExprTuple45, 46
41Literal
42ExprTuple47, 48
43Variable
44Variable
45Operationoperator: 52
operands: 49
46Operationoperator: 52
operands: 50
47Operationoperator: 52
operands: 51
48Operationoperator: 52
operands: 53
49ExprTuple54, 55
50ExprTuple56, 58
51ExprTuple54, 57, 55
52Literal
53ExprTuple56, 57, 58
54ExprRangelambda_map: 59
start_index: 64
end_index: 62
55ExprRangelambda_map: 60
start_index: 64
end_index: 65
56ExprRangelambda_map: 61
start_index: 64
end_index: 62
57Variable
58ExprRangelambda_map: 63
start_index: 64
end_index: 65
59Lambdaparameter: 75
body: 66
60Lambdaparameter: 75
body: 67
61Lambdaparameter: 75
body: 68
62Variable
63Lambdaparameter: 75
body: 69
64Literal
65Variable
66IndexedVarvariable: 70
index: 75
67IndexedVarvariable: 71
index: 75
68IndexedVarvariable: 72
index: 75
69IndexedVarvariable: 73
index: 75
70Variable
71Variable
72Variable
73Variable
74ExprTuple75
75Variable