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 Equals, Forall, InSet
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(n, Conditional(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(), InSet(n, 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(n \mapsto \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} \textrm{ if } n \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
1Lambdaparameter: 80
body: 3
2ExprTuple80
3Conditionalvalue: 4
condition: 5
4Operationoperator: 30
operand: 8
5Operationoperator: 71
operands: 7
6ExprTuple8
7ExprTuple80, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple12, 13
11Conditionalvalue: 14
condition: 15
12ExprRangelambda_map: 16
start_index: 79
end_index: 80
13ExprRangelambda_map: 17
start_index: 79
end_index: 80
14Operationoperator: 30
operand: 20
15Operationoperator: 49
operands: 19
16Lambdaparameter: 88
body: 77
17Lambdaparameter: 88
body: 66
18ExprTuple20
19ExprTuple21, 22
20Lambdaparameters: 62
body: 23
21ExprRangelambda_map: 24
start_index: 79
end_index: 80
22ExprRangelambda_map: 25
start_index: 79
end_index: 80
23Conditionalvalue: 26
condition: 27
24Lambdaparameter: 88
body: 28
25Lambdaparameter: 88
body: 29
26Operationoperator: 30
operand: 36
27Operationoperator: 49
operands: 32
28Operationoperator: 34
operands: 33
29Operationoperator: 34
operands: 35
30Literal
31ExprTuple36
32ExprTuple37
33ExprTuple77, 38
34Literal
35ExprTuple66, 38
36Lambdaparameters: 69
body: 39
37ExprRangelambda_map: 40
start_index: 79
end_index: 80
38Operationoperator: 41
operand: 46
39Conditionalvalue: 43
condition: 44
40Lambdaparameter: 88
body: 45
41Literal
42ExprTuple46
43Operationoperator: 47
operands: 48
44Operationoperator: 49
operands: 50
45Operationoperator: 71
operands: 51
46Variable
47Literal
48ExprTuple52, 53
49Literal
50ExprTuple54
51ExprTuple81, 55
52Operationoperator: 56
operand: 63
53Operationoperator: 68
operands: 58
54ExprRangelambda_map: 59
start_index: 79
end_index: 80
55Operationoperator: 60
operands: 61
56Operationoperator: 68
operands: 62
57ExprTuple63
58ExprTuple64
59Lambdaparameter: 88
body: 65
60Literal
61ExprTuple77, 66
62ExprTuple67
63Operationoperator: 68
operands: 69
64ExprRangelambda_map: 70
start_index: 79
end_index: 80
65Operationoperator: 71
operands: 72
66IndexedVarvariable: 73
index: 88
67ExprRangelambda_map: 74
start_index: 79
end_index: 80
68Literal
69ExprTuple75
70Lambdaparameter: 88
body: 76
71Literal
72ExprTuple85, 77
73Variable
74Lambdaparameter: 88
body: 81
75ExprRangelambda_map: 78
start_index: 79
end_index: 80
76Operationoperator: 81
operand: 85
77IndexedVarvariable: 83
index: 88
78Lambdaparameter: 88
body: 85
79Literal
80Variable
81IndexedVarvariable: 84
index: 88
82ExprTuple85
83Variable
84Variable
85IndexedVarvariable: 86
index: 88
86Variable
87ExprTuple88
88Variable