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, i, j, k
from proveit.core_expr_types import U_1_to_i, V_1_to_j, W_1_to_k, a_1_to_i, b_1_to_j, c_1_to_k
from proveit.linear_algebra import TensorProd, VecSpaces
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [U_1_to_i, V_1_to_j, W_1_to_k]
expr = ExprTuple(Lambda([i, j, k], Conditional(Forall(instance_param_or_params = sub_expr1, instance_expr = Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, b_1_to_j, c_1_to_k), TensorProd(a_1_to_i, TensorProd(b_1_to_j), c_1_to_k)).with_wrapping_at(2), domains = sub_expr1).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), And(InSet(i, Natural), InSet(j, 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, j, k\right) \mapsto \left\{\begin{array}{l}\forall_{U_{1}, U_{2}, \ldots, U_{i}, V_{1}, V_{2}, \ldots, V_{j}, 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(b_{1} \in V_{1}\right), \left(b_{2} \in V_{2}\right), \ldots, \left(b_{j} \in V_{j}\right),\left(c_{1} \in W_{1}\right), \left(c_{2} \in W_{2}\right), \ldots, \left(c_{k} \in W_{k}\right)}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}{\otimes} b_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) =  \\ \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(b_{1} {\otimes}  b_{2} {\otimes}  \ldots {\otimes}  b_{j}\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \end{array} \end{array}\right)\end{array}\right]\end{array} \textrm{ if } i \in \mathbb{N} ,  j \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
2ExprTuple71, 88, 75
3Conditionalvalue: 4
condition: 5
4Operationoperator: 26
operand: 8
5Operationoperator: 44
operands: 7
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameters: 12
body: 13
9Operationoperator: 78
operands: 14
10Operationoperator: 78
operands: 15
11Operationoperator: 78
operands: 16
12ExprTuple17, 18, 19
13Conditionalvalue: 20
condition: 21
14ExprTuple71, 22
15ExprTuple88, 22
16ExprTuple75, 22
17ExprRangelambda_map: 23
start_index: 87
end_index: 71
18ExprRangelambda_map: 24
start_index: 87
end_index: 88
19ExprRangelambda_map: 25
start_index: 87
end_index: 75
20Operationoperator: 26
operand: 29
21Operationoperator: 44
operands: 28
22Literal
23Lambdaparameter: 97
body: 82
24Lambdaparameter: 97
body: 83
25Lambdaparameter: 97
body: 85
26Literal
27ExprTuple29
28ExprTuple30, 31, 32
29Lambdaparameters: 56
body: 33
30ExprRangelambda_map: 34
start_index: 87
end_index: 71
31ExprRangelambda_map: 35
start_index: 87
end_index: 88
32ExprRangelambda_map: 36
start_index: 87
end_index: 75
33Conditionalvalue: 37
condition: 38
34Lambdaparameter: 97
body: 39
35Lambdaparameter: 97
body: 40
36Lambdaparameter: 97
body: 41
37Operationoperator: 42
operands: 43
38Operationoperator: 44
operands: 45
39Operationoperator: 48
operands: 46
40Operationoperator: 48
operands: 47
41Operationoperator: 48
operands: 49
42Literal
43ExprTuple50, 51
44Literal
45ExprTuple52, 53, 54
46ExprTuple82, 55
47ExprTuple83, 55
48Literal
49ExprTuple85, 55
50Operationoperator: 72
operands: 56
51Operationoperator: 72
operands: 57
52ExprRangelambda_map: 58
start_index: 87
end_index: 71
53ExprRangelambda_map: 59
start_index: 87
end_index: 88
54ExprRangelambda_map: 60
start_index: 87
end_index: 75
55Operationoperator: 61
operand: 69
56ExprTuple63, 80, 65
57ExprTuple63, 64, 65
58Lambdaparameter: 97
body: 66
59Lambdaparameter: 97
body: 67
60Lambdaparameter: 97
body: 68
61Literal
62ExprTuple69
63ExprRangelambda_map: 70
start_index: 87
end_index: 71
64Operationoperator: 72
operands: 73
65ExprRangelambda_map: 74
start_index: 87
end_index: 75
66Operationoperator: 78
operands: 76
67Operationoperator: 78
operands: 77
68Operationoperator: 78
operands: 79
69Variable
70Lambdaparameter: 97
body: 81
71Variable
72Literal
73ExprTuple80
74Lambdaparameter: 97
body: 84
75Variable
76ExprTuple81, 82
77ExprTuple94, 83
78Literal
79ExprTuple84, 85
80ExprRangelambda_map: 86
start_index: 87
end_index: 88
81IndexedVarvariable: 89
index: 97
82IndexedVarvariable: 90
index: 97
83IndexedVarvariable: 91
index: 97
84IndexedVarvariable: 92
index: 97
85IndexedVarvariable: 93
index: 97
86Lambdaparameter: 97
body: 94
87Literal
88Variable
89Variable
90Variable
91Variable
92Variable
93Variable
94IndexedVarvariable: 95
index: 97
95Variable
96ExprTuple97
97Variable