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 A, ExprRange, ExprTuple, Function, IndexedVar, K, Lambda, V, Variable, W, n, v
from proveit.core_expr_types import A_1_to_n, V_1_to_n, W_1_to_n, v_1_to_n
from proveit.linear_algebra import LinMap, TensorProd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import NaturalPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda(K, Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [V_1_to_n, W_1_to_n], instance_expr = Forall(instance_param_or_params = [A_1_to_n], instance_expr = Forall(instance_param_or_params = [v_1_to_n], instance_expr = Equals(Function(TensorProd(A_1_to_n), [TensorProd(v_1_to_n)]), TensorProd(ExprRange(sub_expr1, Function(IndexedVar(A, sub_expr1), [IndexedVar(v, sub_expr1)]), one, n))), domains = [V_1_to_n]).with_wrapping(), domains = [ExprRange(sub_expr1, LinMap(IndexedVar(V, sub_expr1), IndexedVar(W, sub_expr1)), one, n)]).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), domain = NaturalPos)))
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_{n \in \mathbb{N}^+}~\left[\begin{array}{l}\forall_{V_{1}, V_{2}, \ldots, V_{n}, W_{1}, W_{2}, \ldots, W_{n} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{\left(A_{1} \in \mathcal{L}\left(V_{1}, W_{1}\right)\right), \left(A_{2} \in \mathcal{L}\left(V_{2}, W_{2}\right)\right), \ldots, \left(A_{n} \in \mathcal{L}\left(V_{n}, W_{n}\right)\right)}~\\
\left[\begin{array}{l}\forall_{\left(v_{1} \in V_{1}\right), \left(v_{2} \in V_{2}\right), \ldots, \left(v_{n} \in V_{n}\right)}~\\
\left(\left(A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{n}\right)\left(v_{1} {\otimes}  v_{2} {\otimes}  \ldots {\otimes}  v_{n}\right) = \left(A_{1}\left(v_{1}\right) {\otimes}  A_{2}\left(v_{2}\right) {\otimes}  \ldots {\otimes}  A_{n}\left(v_{n}\right)\right)\right)\end{array}\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: 49
body: 2
2Operationoperator: 33
operand: 4
3ExprTuple4
4Lambdaparameter: 83
body: 6
5ExprTuple83
6Conditionalvalue: 7
condition: 8
7Operationoperator: 33
operand: 11
8Operationoperator: 74
operands: 10
9ExprTuple11
10ExprTuple83, 12
11Lambdaparameters: 13
body: 14
12Literal
13ExprTuple15, 16
14Conditionalvalue: 17
condition: 18
15ExprRangelambda_map: 19
start_index: 82
end_index: 83
16ExprRangelambda_map: 20
start_index: 82
end_index: 83
17Operationoperator: 33
operand: 23
18Operationoperator: 52
operands: 22
19Lambdaparameter: 91
body: 80
20Lambdaparameter: 91
body: 69
21ExprTuple23
22ExprTuple24, 25
23Lambdaparameters: 65
body: 26
24ExprRangelambda_map: 27
start_index: 82
end_index: 83
25ExprRangelambda_map: 28
start_index: 82
end_index: 83
26Conditionalvalue: 29
condition: 30
27Lambdaparameter: 91
body: 31
28Lambdaparameter: 91
body: 32
29Operationoperator: 33
operand: 39
30Operationoperator: 52
operands: 35
31Operationoperator: 37
operands: 36
32Operationoperator: 37
operands: 38
33Literal
34ExprTuple39
35ExprTuple40
36ExprTuple80, 41
37Literal
38ExprTuple69, 41
39Lambdaparameters: 72
body: 42
40ExprRangelambda_map: 43
start_index: 82
end_index: 83
41Operationoperator: 44
operand: 49
42Conditionalvalue: 46
condition: 47
43Lambdaparameter: 91
body: 48
44Literal
45ExprTuple49
46Operationoperator: 50
operands: 51
47Operationoperator: 52
operands: 53
48Operationoperator: 74
operands: 54
49Variable
50Literal
51ExprTuple55, 56
52Literal
53ExprTuple57
54ExprTuple84, 58
55Operationoperator: 59
operand: 66
56Operationoperator: 71
operands: 61
57ExprRangelambda_map: 62
start_index: 82
end_index: 83
58Operationoperator: 63
operands: 64
59Operationoperator: 71
operands: 65
60ExprTuple66
61ExprTuple67
62Lambdaparameter: 91
body: 68
63Literal
64ExprTuple80, 69
65ExprTuple70
66Operationoperator: 71
operands: 72
67ExprRangelambda_map: 73
start_index: 82
end_index: 83
68Operationoperator: 74
operands: 75
69IndexedVarvariable: 76
index: 91
70ExprRangelambda_map: 77
start_index: 82
end_index: 83
71Literal
72ExprTuple78
73Lambdaparameter: 91
body: 79
74Literal
75ExprTuple88, 80
76Variable
77Lambdaparameter: 91
body: 84
78ExprRangelambda_map: 81
start_index: 82
end_index: 83
79Operationoperator: 84
operand: 88
80IndexedVarvariable: 86
index: 91
81Lambdaparameter: 91
body: 88
82Literal
83Variable
84IndexedVarvariable: 87
index: 91
85ExprTuple88
86Variable
87Variable
88IndexedVarvariable: 89
index: 91
89Variable
90ExprTuple91
91Variable