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, 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, InSet
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(alpha, Conditional(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), InSet(alpha, 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(\alpha \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), 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] \textrm{ if } \alpha \in K\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: 77
body: 3
2ExprTuple77
3Conditionalvalue: 4
condition: 5
4Operationoperator: 29
operand: 8
5Operationoperator: 75
operands: 7
6ExprTuple8
7ExprTuple77, 69
8Lambdaparameters: 9
body: 10
9ExprTuple84, 87
10Conditionalvalue: 11
condition: 12
11Operationoperator: 29
operand: 15
12Operationoperator: 46
operands: 14
13ExprTuple15
14ExprTuple16, 17
15Lambdaparameters: 18
body: 19
16Operationoperator: 75
operands: 20
17Operationoperator: 75
operands: 21
18ExprTuple22, 67, 23
19Conditionalvalue: 24
condition: 25
20ExprTuple84, 26
21ExprTuple87, 26
22ExprRangelambda_map: 27
start_index: 86
end_index: 84
23ExprRangelambda_map: 28
start_index: 86
end_index: 87
24Operationoperator: 29
operand: 32
25Operationoperator: 46
operands: 31
26Literal
27Lambdaparameter: 95
body: 81
28Lambdaparameter: 95
body: 82
29Literal
30ExprTuple32
31ExprTuple33, 34, 35
32Lambdaparameters: 73
body: 36
33ExprRangelambda_map: 37
start_index: 86
end_index: 84
34Operationoperator: 49
operands: 38
35ExprRangelambda_map: 39
start_index: 86
end_index: 87
36Conditionalvalue: 40
condition: 41
37Lambdaparameter: 95
body: 42
38ExprTuple67, 56
39Lambdaparameter: 95
body: 43
40Operationoperator: 44
operands: 45
41Operationoperator: 46
operands: 47
42Operationoperator: 49
operands: 48
43Operationoperator: 49
operands: 50
44Literal
45ExprTuple51, 52
46Literal
47ExprTuple53, 54, 55
48ExprTuple81, 56
49Literal
50ExprTuple82, 56
51Operationoperator: 72
operands: 57
52Operationoperator: 70
operands: 58
53ExprRangelambda_map: 59
start_index: 86
end_index: 84
54Operationoperator: 75
operands: 60
55ExprRangelambda_map: 61
start_index: 86
end_index: 87
56Operationoperator: 62
operand: 69
57ExprTuple78, 64, 80
58ExprTuple77, 65
59Lambdaparameter: 95
body: 66
60ExprTuple79, 67
61Lambdaparameter: 95
body: 68
62Literal
63ExprTuple69
64Operationoperator: 70
operands: 71
65Operationoperator: 72
operands: 73
66Operationoperator: 75
operands: 74
67Variable
68Operationoperator: 75
operands: 76
69Variable
70Literal
71ExprTuple77, 79
72Literal
73ExprTuple78, 79, 80
74ExprTuple90, 81
75Literal
76ExprTuple91, 82
77Variable
78ExprRangelambda_map: 83
start_index: 86
end_index: 84
79Variable
80ExprRangelambda_map: 85
start_index: 86
end_index: 87
81IndexedVarvariable: 88
index: 95
82IndexedVarvariable: 89
index: 95
83Lambdaparameter: 95
body: 90
84Variable
85Lambdaparameter: 95
body: 91
86Literal
87Variable
88Variable
89Variable
90IndexedVarvariable: 92
index: 95
91IndexedVarvariable: 93
index: 95
92Variable
93Variable
94ExprTuple95
95Variable