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, Conditional, 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 And, Equals, Forall, InClass
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(V, sub_expr1)
sub_expr3 = IndexedVar(W, sub_expr1)
sub_expr4 = VecSpaces(K)
expr = ExprTuple(Lambda([V_1_to_n, W_1_to_n], Conditional(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(sub_expr2, sub_expr3), one, n)]).with_wrapping(), And(ExprRange(sub_expr1, InClass(sub_expr2, sub_expr4), one, n), ExprRange(sub_expr1, InClass(sub_expr3, sub_expr4), one, n)))))
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(V_{1}, V_{2}, \ldots, V_{n}, W_{1}, W_{2}, \ldots, W_{n}\right) \mapsto \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} \textrm{ if } \left(V_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(V_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(V_{n} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right), \left(W_{1} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \left(W_{2} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right) ,  \ldots ,  \left(W_{n} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\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
1Lambdaparameters: 2
body: 3
2ExprTuple4, 5
3Conditionalvalue: 6
condition: 7
4ExprRangelambda_map: 8
start_index: 71
end_index: 72
5ExprRangelambda_map: 9
start_index: 71
end_index: 72
6Operationoperator: 22
operand: 12
7Operationoperator: 41
operands: 11
8Lambdaparameter: 80
body: 69
9Lambdaparameter: 80
body: 58
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameters: 54
body: 15
13ExprRangelambda_map: 16
start_index: 71
end_index: 72
14ExprRangelambda_map: 17
start_index: 71
end_index: 72
15Conditionalvalue: 18
condition: 19
16Lambdaparameter: 80
body: 20
17Lambdaparameter: 80
body: 21
18Operationoperator: 22
operand: 28
19Operationoperator: 41
operands: 24
20Operationoperator: 26
operands: 25
21Operationoperator: 26
operands: 27
22Literal
23ExprTuple28
24ExprTuple29
25ExprTuple69, 30
26Literal
27ExprTuple58, 30
28Lambdaparameters: 61
body: 31
29ExprRangelambda_map: 32
start_index: 71
end_index: 72
30Operationoperator: 33
operand: 38
31Conditionalvalue: 35
condition: 36
32Lambdaparameter: 80
body: 37
33Literal
34ExprTuple38
35Operationoperator: 39
operands: 40
36Operationoperator: 41
operands: 42
37Operationoperator: 63
operands: 43
38Variable
39Literal
40ExprTuple44, 45
41Literal
42ExprTuple46
43ExprTuple73, 47
44Operationoperator: 48
operand: 55
45Operationoperator: 60
operands: 50
46ExprRangelambda_map: 51
start_index: 71
end_index: 72
47Operationoperator: 52
operands: 53
48Operationoperator: 60
operands: 54
49ExprTuple55
50ExprTuple56
51Lambdaparameter: 80
body: 57
52Literal
53ExprTuple69, 58
54ExprTuple59
55Operationoperator: 60
operands: 61
56ExprRangelambda_map: 62
start_index: 71
end_index: 72
57Operationoperator: 63
operands: 64
58IndexedVarvariable: 65
index: 80
59ExprRangelambda_map: 66
start_index: 71
end_index: 72
60Literal
61ExprTuple67
62Lambdaparameter: 80
body: 68
63Literal
64ExprTuple77, 69
65Variable
66Lambdaparameter: 80
body: 73
67ExprRangelambda_map: 70
start_index: 71
end_index: 72
68Operationoperator: 73
operand: 77
69IndexedVarvariable: 75
index: 80
70Lambdaparameter: 80
body: 77
71Literal
72Variable
73IndexedVarvariable: 76
index: 80
74ExprTuple77
75Variable
76Variable
77IndexedVarvariable: 78
index: 80
78Variable
79ExprTuple80
80Variable