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, alpha, 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
from proveit.linear_algebra import ScalarMult, TensorProd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [U_1_to_i, V, W_1_to_k]
expr = ExprTuple(Lambda(K, Forall(instance_param_or_params = [alpha], instance_expr = Forall(instance_param_or_params = [i, k], instance_expr = Forall(instance_param_or_params = sub_expr1, instance_expr = Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, ScalarMult(alpha, b), c_1_to_k), ScalarMult(alpha, TensorProd(a_1_to_i, b, c_1_to_k))).with_wrapping_at(1), domains = sub_expr1).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), domain = Natural), domain = K)))
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_{\alpha \in K}~\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), b \in V,\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} \left(\alpha \cdot b\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(\alpha \cdot \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)\right) \end{array} \end{array}\right)\end{array}\right]\end{array}\right]\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: 72
body: 2
2Operationoperator: 32
operand: 4
3ExprTuple4
4Lambdaparameter: 80
body: 6
5ExprTuple80
6Conditionalvalue: 7
condition: 8
7Operationoperator: 32
operand: 11
8Operationoperator: 78
operands: 10
9ExprTuple11
10ExprTuple80, 72
11Lambdaparameters: 12
body: 13
12ExprTuple87, 90
13Conditionalvalue: 14
condition: 15
14Operationoperator: 32
operand: 18
15Operationoperator: 49
operands: 17
16ExprTuple18
17ExprTuple19, 20
18Lambdaparameters: 21
body: 22
19Operationoperator: 78
operands: 23
20Operationoperator: 78
operands: 24
21ExprTuple25, 70, 26
22Conditionalvalue: 27
condition: 28
23ExprTuple87, 29
24ExprTuple90, 29
25ExprRangelambda_map: 30
start_index: 89
end_index: 87
26ExprRangelambda_map: 31
start_index: 89
end_index: 90
27Operationoperator: 32
operand: 35
28Operationoperator: 49
operands: 34
29Literal
30Lambdaparameter: 98
body: 84
31Lambdaparameter: 98
body: 85
32Literal
33ExprTuple35
34ExprTuple36, 37, 38
35Lambdaparameters: 76
body: 39
36ExprRangelambda_map: 40
start_index: 89
end_index: 87
37Operationoperator: 52
operands: 41
38ExprRangelambda_map: 42
start_index: 89
end_index: 90
39Conditionalvalue: 43
condition: 44
40Lambdaparameter: 98
body: 45
41ExprTuple70, 59
42Lambdaparameter: 98
body: 46
43Operationoperator: 47
operands: 48
44Operationoperator: 49
operands: 50
45Operationoperator: 52
operands: 51
46Operationoperator: 52
operands: 53
47Literal
48ExprTuple54, 55
49Literal
50ExprTuple56, 57, 58
51ExprTuple84, 59
52Literal
53ExprTuple85, 59
54Operationoperator: 75
operands: 60
55Operationoperator: 73
operands: 61
56ExprRangelambda_map: 62
start_index: 89
end_index: 87
57Operationoperator: 78
operands: 63
58ExprRangelambda_map: 64
start_index: 89
end_index: 90
59Operationoperator: 65
operand: 72
60ExprTuple81, 67, 83
61ExprTuple80, 68
62Lambdaparameter: 98
body: 69
63ExprTuple82, 70
64Lambdaparameter: 98
body: 71
65Literal
66ExprTuple72
67Operationoperator: 73
operands: 74
68Operationoperator: 75
operands: 76
69Operationoperator: 78
operands: 77
70Variable
71Operationoperator: 78
operands: 79
72Variable
73Literal
74ExprTuple80, 82
75Literal
76ExprTuple81, 82, 83
77ExprTuple93, 84
78Literal
79ExprTuple94, 85
80Variable
81ExprRangelambda_map: 86
start_index: 89
end_index: 87
82Variable
83ExprRangelambda_map: 88
start_index: 89
end_index: 90
84IndexedVarvariable: 91
index: 98
85IndexedVarvariable: 92
index: 98
86Lambdaparameter: 98
body: 93
87Variable
88Lambdaparameter: 98
body: 94
89Literal
90Variable
91Variable
92Variable
93IndexedVarvariable: 95
index: 98
94IndexedVarvariable: 96
index: 98
95Variable
96Variable
97ExprTuple98
98Variable