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, 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 And, Equals, Forall, Implies, InSet
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, 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(), 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(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} \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
2ExprTuple100, 103
3Conditionalvalue: 4
condition: 5
4Operationoperator: 37
operand: 8
5Operationoperator: 39
operands: 7
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 71
operands: 13
10Operationoperator: 71
operands: 14
11ExprTuple15, 75, 16
12Conditionalvalue: 17
condition: 18
13ExprTuple100, 19
14ExprTuple103, 19
15ExprRangelambda_map: 20
start_index: 102
end_index: 100
16ExprRangelambda_map: 21
start_index: 102
end_index: 103
17Operationoperator: 37
operand: 24
18Operationoperator: 39
operands: 23
19Literal
20Lambdaparameter: 113
body: 76
21Lambdaparameter: 113
body: 77
22ExprTuple24
23ExprTuple25, 26, 27
24Lambdaparameters: 28
body: 29
25ExprRangelambda_map: 30
start_index: 102
end_index: 100
26Operationoperator: 42
operands: 31
27ExprRangelambda_map: 32
start_index: 102
end_index: 103
28ExprTuple92, 93, 94, 96
29Conditionalvalue: 33
condition: 34
30Lambdaparameter: 113
body: 35
31ExprTuple75, 49
32Lambdaparameter: 113
body: 36
33Operationoperator: 37
operand: 44
34Operationoperator: 39
operands: 40
35Operationoperator: 42
operands: 41
36Operationoperator: 42
operands: 43
37Literal
38ExprTuple44
39Literal
40ExprTuple45, 46, 47, 48
41ExprTuple76, 49
42Literal
43ExprTuple77, 49
44Lambdaparameter: 95
body: 51
45ExprRangelambda_map: 52
start_index: 102
end_index: 100
46ExprRangelambda_map: 53
start_index: 102
end_index: 103
47ExprRangelambda_map: 54
start_index: 102
end_index: 100
48ExprRangelambda_map: 55
start_index: 102
end_index: 103
49Operationoperator: 56
operand: 64
50ExprTuple95
51Conditionalvalue: 58
condition: 59
52Lambdaparameter: 113
body: 60
53Lambdaparameter: 113
body: 61
54Lambdaparameter: 113
body: 62
55Lambdaparameter: 113
body: 63
56Literal
57ExprTuple64
58Operationoperator: 65
operands: 66
59Operationoperator: 71
operands: 67
60Operationoperator: 71
operands: 68
61Operationoperator: 71
operands: 69
62Operationoperator: 71
operands: 70
63Operationoperator: 71
operands: 72
64Variable
65Literal
66ExprTuple73, 74
67ExprTuple95, 75
68ExprTuple104, 76
69ExprTuple105, 77
70ExprTuple106, 76
71Literal
72ExprTuple107, 77
73Operationoperator: 79
operands: 78
74Operationoperator: 79
operands: 80
75Variable
76IndexedVarvariable: 81
index: 113
77IndexedVarvariable: 82
index: 113
78ExprTuple83, 84
79Literal
80ExprTuple85, 86
81Variable
82Variable
83Operationoperator: 90
operands: 87
84Operationoperator: 90
operands: 88
85Operationoperator: 90
operands: 89
86Operationoperator: 90
operands: 91
87ExprTuple92, 93
88ExprTuple94, 96
89ExprTuple92, 95, 93
90Literal
91ExprTuple94, 95, 96
92ExprRangelambda_map: 97
start_index: 102
end_index: 100
93ExprRangelambda_map: 98
start_index: 102
end_index: 103
94ExprRangelambda_map: 99
start_index: 102
end_index: 100
95Variable
96ExprRangelambda_map: 101
start_index: 102
end_index: 103
97Lambdaparameter: 113
body: 104
98Lambdaparameter: 113
body: 105
99Lambdaparameter: 113
body: 106
100Variable
101Lambdaparameter: 113
body: 107
102Literal
103Variable
104IndexedVarvariable: 108
index: 113
105IndexedVarvariable: 109
index: 113
106IndexedVarvariable: 110
index: 113
107IndexedVarvariable: 111
index: 113
108Variable
109Variable
110Variable
111Variable
112ExprTuple113
113Variable