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 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 Equals, Forall, Implies, NotEquals
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(K, Forall(instance_param_or_params = [i, k], instance_expr = 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(), domain = 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(K \mapsto \left[\forall_{i, k \in \mathbb{N}}~\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}\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
1Lambdaparameter: 65
body: 2
2Operationoperator: 40
operand: 4
3ExprTuple4
4Lambdaparameters: 5
body: 6
5ExprTuple115, 118
6Conditionalvalue: 7
condition: 8
7Operationoperator: 40
operand: 11
8Operationoperator: 68
operands: 10
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameters: 14
body: 15
12Operationoperator: 85
operands: 16
13Operationoperator: 85
operands: 17
14ExprTuple18, 111, 19
15Conditionalvalue: 20
condition: 21
16ExprTuple115, 22
17ExprTuple118, 22
18ExprRangelambda_map: 23
start_index: 117
end_index: 115
19ExprRangelambda_map: 24
start_index: 117
end_index: 118
20Operationoperator: 40
operand: 27
21Operationoperator: 68
operands: 26
22Literal
23Lambdaparameter: 128
body: 80
24Lambdaparameter: 128
body: 81
25ExprTuple27
26ExprTuple28, 29, 30
27Lambdaparameters: 31
body: 32
28ExprRangelambda_map: 33
start_index: 117
end_index: 115
29Operationoperator: 44
operands: 34
30ExprRangelambda_map: 35
start_index: 117
end_index: 118
31ExprTuple107, 108, 109, 110
32Conditionalvalue: 36
condition: 37
33Lambdaparameter: 128
body: 38
34ExprTuple111, 51
35Lambdaparameter: 128
body: 39
36Operationoperator: 40
operand: 46
37Operationoperator: 68
operands: 42
38Operationoperator: 44
operands: 43
39Operationoperator: 44
operands: 45
40Literal
41ExprTuple46
42ExprTuple47, 48, 49, 50
43ExprTuple80, 51
44Literal
45ExprTuple81, 51
46Lambdaparameters: 88
body: 52
47ExprRangelambda_map: 53
start_index: 117
end_index: 115
48ExprRangelambda_map: 54
start_index: 117
end_index: 118
49ExprRangelambda_map: 55
start_index: 117
end_index: 115
50ExprRangelambda_map: 56
start_index: 117
end_index: 118
51Operationoperator: 57
operand: 65
52Conditionalvalue: 59
condition: 60
53Lambdaparameter: 128
body: 61
54Lambdaparameter: 128
body: 62
55Lambdaparameter: 128
body: 63
56Lambdaparameter: 128
body: 64
57Literal
58ExprTuple65
59Operationoperator: 66
operands: 67
60Operationoperator: 68
operands: 69
61Operationoperator: 85
operands: 70
62Operationoperator: 85
operands: 71
63Operationoperator: 85
operands: 72
64Operationoperator: 85
operands: 73
65Variable
66Literal
67ExprTuple74, 75
68Literal
69ExprTuple76, 77, 78, 79
70ExprTuple119, 80
71ExprTuple120, 81
72ExprTuple121, 80
73ExprTuple122, 81
74Operationoperator: 87
operands: 82
75Operationoperator: 87
operands: 83
76Operationoperator: 85
operands: 84
77Operationoperator: 85
operands: 86
78Operationoperator: 87
operands: 88
79Operationoperator: 89
operands: 90
80IndexedVarvariable: 91
index: 128
81IndexedVarvariable: 92
index: 128
82ExprTuple93, 94
83ExprTuple95, 96
84ExprTuple105, 111
85Literal
86ExprTuple106, 111
87Literal
88ExprTuple105, 106
89Literal
90ExprTuple105, 97
91Variable
92Variable
93Operationoperator: 101
operands: 98
94Operationoperator: 101
operands: 99
95Operationoperator: 101
operands: 100
96Operationoperator: 101
operands: 102
97Operationoperator: 103
operand: 111
98ExprTuple107, 105, 108
99ExprTuple109, 106, 110
100ExprTuple107, 108
101Literal
102ExprTuple109, 110
103Literal
104ExprTuple111
105Variable
106Variable
107ExprRangelambda_map: 112
start_index: 117
end_index: 115
108ExprRangelambda_map: 113
start_index: 117
end_index: 118
109ExprRangelambda_map: 114
start_index: 117
end_index: 115
110ExprRangelambda_map: 116
start_index: 117
end_index: 118
111Variable
112Lambdaparameter: 128
body: 119
113Lambdaparameter: 128
body: 120
114Lambdaparameter: 128
body: 121
115Variable
116Lambdaparameter: 128
body: 122
117Literal
118Variable
119IndexedVarvariable: 123
index: 128
120IndexedVarvariable: 124
index: 128
121IndexedVarvariable: 125
index: 128
122IndexedVarvariable: 126
index: 128
123Variable
124Variable
125Variable
126Variable
127ExprTuple128
128Variable