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, ExprTuple, K, Lambda, V, 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, InSet, NotEquals
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([i, k], Conditional(Forall(instance_param_or_params = [U_1_to_i, V, W_1_to_k], instance_expr = 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(), domain = VecSpaces(K)).with_wrapping(), And(InSet(i, Natural), InSet(k, Natural)))))
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(i, k\right) \mapsto \left\{\begin{array}{l}\forall_{U_{1}, U_{2}, \ldots, U_{i}, V, W_{1}, W_{2}, \ldots, W_{k} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\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}\right]\end{array} \textrm{ if } i \in \mathbb{N} ,  k \in \mathbb{N}\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
2ExprTuple112, 115
3Conditionalvalue: 4
condition: 5
4Operationoperator: 37
operand: 8
5Operationoperator: 65
operands: 7
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 82
operands: 13
10Operationoperator: 82
operands: 14
11ExprTuple15, 108, 16
12Conditionalvalue: 17
condition: 18
13ExprTuple112, 19
14ExprTuple115, 19
15ExprRangelambda_map: 20
start_index: 114
end_index: 112
16ExprRangelambda_map: 21
start_index: 114
end_index: 115
17Operationoperator: 37
operand: 24
18Operationoperator: 65
operands: 23
19Literal
20Lambdaparameter: 125
body: 77
21Lambdaparameter: 125
body: 78
22ExprTuple24
23ExprTuple25, 26, 27
24Lambdaparameters: 28
body: 29
25ExprRangelambda_map: 30
start_index: 114
end_index: 112
26Operationoperator: 41
operands: 31
27ExprRangelambda_map: 32
start_index: 114
end_index: 115
28ExprTuple104, 105, 106, 107
29Conditionalvalue: 33
condition: 34
30Lambdaparameter: 125
body: 35
31ExprTuple108, 48
32Lambdaparameter: 125
body: 36
33Operationoperator: 37
operand: 43
34Operationoperator: 65
operands: 39
35Operationoperator: 41
operands: 40
36Operationoperator: 41
operands: 42
37Literal
38ExprTuple43
39ExprTuple44, 45, 46, 47
40ExprTuple77, 48
41Literal
42ExprTuple78, 48
43Lambdaparameters: 85
body: 49
44ExprRangelambda_map: 50
start_index: 114
end_index: 112
45ExprRangelambda_map: 51
start_index: 114
end_index: 115
46ExprRangelambda_map: 52
start_index: 114
end_index: 112
47ExprRangelambda_map: 53
start_index: 114
end_index: 115
48Operationoperator: 54
operand: 62
49Conditionalvalue: 56
condition: 57
50Lambdaparameter: 125
body: 58
51Lambdaparameter: 125
body: 59
52Lambdaparameter: 125
body: 60
53Lambdaparameter: 125
body: 61
54Literal
55ExprTuple62
56Operationoperator: 63
operands: 64
57Operationoperator: 65
operands: 66
58Operationoperator: 82
operands: 67
59Operationoperator: 82
operands: 68
60Operationoperator: 82
operands: 69
61Operationoperator: 82
operands: 70
62Variable
63Literal
64ExprTuple71, 72
65Literal
66ExprTuple73, 74, 75, 76
67ExprTuple116, 77
68ExprTuple117, 78
69ExprTuple118, 77
70ExprTuple119, 78
71Operationoperator: 84
operands: 79
72Operationoperator: 84
operands: 80
73Operationoperator: 82
operands: 81
74Operationoperator: 82
operands: 83
75Operationoperator: 84
operands: 85
76Operationoperator: 86
operands: 87
77IndexedVarvariable: 88
index: 125
78IndexedVarvariable: 89
index: 125
79ExprTuple90, 91
80ExprTuple92, 93
81ExprTuple102, 108
82Literal
83ExprTuple103, 108
84Literal
85ExprTuple102, 103
86Literal
87ExprTuple102, 94
88Variable
89Variable
90Operationoperator: 98
operands: 95
91Operationoperator: 98
operands: 96
92Operationoperator: 98
operands: 97
93Operationoperator: 98
operands: 99
94Operationoperator: 100
operand: 108
95ExprTuple104, 102, 105
96ExprTuple106, 103, 107
97ExprTuple104, 105
98Literal
99ExprTuple106, 107
100Literal
101ExprTuple108
102Variable
103Variable
104ExprRangelambda_map: 109
start_index: 114
end_index: 112
105ExprRangelambda_map: 110
start_index: 114
end_index: 115
106ExprRangelambda_map: 111
start_index: 114
end_index: 112
107ExprRangelambda_map: 113
start_index: 114
end_index: 115
108Variable
109Lambdaparameter: 125
body: 116
110Lambdaparameter: 125
body: 117
111Lambdaparameter: 125
body: 118
112Variable
113Lambdaparameter: 125
body: 119
114Literal
115Variable
116IndexedVarvariable: 120
index: 125
117IndexedVarvariable: 121
index: 125
118IndexedVarvariable: 122
index: 125
119IndexedVarvariable: 123
index: 125
120Variable
121Variable
122Variable
123Variable
124ExprTuple125
125Variable