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, 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, e_1_to_k
from proveit.linear_algebra import TensorProd, VecSpaces
from proveit.logic import Equals, Forall, Implies
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, e_1_to_k], instance_expr = 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), 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(e_{1} \in W_{1}\right), \left(e_{2} \in W_{2}\right), \ldots, \left(e_{k} \in W_{k}\right)}~\\
\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)\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: 67
body: 2
2Operationoperator: 40
operand: 4
3ExprTuple4
4Lambdaparameters: 5
body: 6
5ExprTuple103, 106
6Conditionalvalue: 7
condition: 8
7Operationoperator: 40
operand: 11
8Operationoperator: 42
operands: 10
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameters: 14
body: 15
12Operationoperator: 74
operands: 16
13Operationoperator: 74
operands: 17
14ExprTuple18, 78, 19
15Conditionalvalue: 20
condition: 21
16ExprTuple103, 22
17ExprTuple106, 22
18ExprRangelambda_map: 23
start_index: 105
end_index: 103
19ExprRangelambda_map: 24
start_index: 105
end_index: 106
20Operationoperator: 40
operand: 27
21Operationoperator: 42
operands: 26
22Literal
23Lambdaparameter: 116
body: 79
24Lambdaparameter: 116
body: 80
25ExprTuple27
26ExprTuple28, 29, 30
27Lambdaparameters: 31
body: 32
28ExprRangelambda_map: 33
start_index: 105
end_index: 103
29Operationoperator: 45
operands: 34
30ExprRangelambda_map: 35
start_index: 105
end_index: 106
31ExprTuple95, 96, 97, 99
32Conditionalvalue: 36
condition: 37
33Lambdaparameter: 116
body: 38
34ExprTuple78, 52
35Lambdaparameter: 116
body: 39
36Operationoperator: 40
operand: 47
37Operationoperator: 42
operands: 43
38Operationoperator: 45
operands: 44
39Operationoperator: 45
operands: 46
40Literal
41ExprTuple47
42Literal
43ExprTuple48, 49, 50, 51
44ExprTuple79, 52
45Literal
46ExprTuple80, 52
47Lambdaparameter: 98
body: 54
48ExprRangelambda_map: 55
start_index: 105
end_index: 103
49ExprRangelambda_map: 56
start_index: 105
end_index: 106
50ExprRangelambda_map: 57
start_index: 105
end_index: 103
51ExprRangelambda_map: 58
start_index: 105
end_index: 106
52Operationoperator: 59
operand: 67
53ExprTuple98
54Conditionalvalue: 61
condition: 62
55Lambdaparameter: 116
body: 63
56Lambdaparameter: 116
body: 64
57Lambdaparameter: 116
body: 65
58Lambdaparameter: 116
body: 66
59Literal
60ExprTuple67
61Operationoperator: 68
operands: 69
62Operationoperator: 74
operands: 70
63Operationoperator: 74
operands: 71
64Operationoperator: 74
operands: 72
65Operationoperator: 74
operands: 73
66Operationoperator: 74
operands: 75
67Variable
68Literal
69ExprTuple76, 77
70ExprTuple98, 78
71ExprTuple107, 79
72ExprTuple108, 80
73ExprTuple109, 79
74Literal
75ExprTuple110, 80
76Operationoperator: 82
operands: 81
77Operationoperator: 82
operands: 83
78Variable
79IndexedVarvariable: 84
index: 116
80IndexedVarvariable: 85
index: 116
81ExprTuple86, 87
82Literal
83ExprTuple88, 89
84Variable
85Variable
86Operationoperator: 93
operands: 90
87Operationoperator: 93
operands: 91
88Operationoperator: 93
operands: 92
89Operationoperator: 93
operands: 94
90ExprTuple95, 96
91ExprTuple97, 99
92ExprTuple95, 98, 96
93Literal
94ExprTuple97, 98, 99
95ExprRangelambda_map: 100
start_index: 105
end_index: 103
96ExprRangelambda_map: 101
start_index: 105
end_index: 106
97ExprRangelambda_map: 102
start_index: 105
end_index: 103
98Variable
99ExprRangelambda_map: 104
start_index: 105
end_index: 106
100Lambdaparameter: 116
body: 107
101Lambdaparameter: 116
body: 108
102Lambdaparameter: 116
body: 109
103Variable
104Lambdaparameter: 116
body: 110
105Literal
106Variable
107IndexedVarvariable: 111
index: 116
108IndexedVarvariable: 112
index: 116
109IndexedVarvariable: 113
index: 116
110IndexedVarvariable: 114
index: 116
111Variable
112Variable
113Variable
114Variable
115ExprTuple116
116Variable