logo

Expression of type ExprTuple

from the theory of proveit.linear_algebra.inner_products

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, B, Conditional, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, i, lambda_, m, n, v
from proveit.core_expr_types import a_1_to_m, a_i, b_1_to_n, b_i, lambda_i
from proveit.linear_algebra import Dim, HilbertSpaces, OrthoNormBases, ScalarMult, TensorProd, VecSum
from proveit.logic import And, Equals, Exists, Forall, InClass, InSet, Set
from proveit.numbers import Interval, Min, RealNonNeg, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Min(m, n)
expr = ExprTuple(Lambda([A, B], Conditional(Forall(instance_param_or_params = [v], instance_expr = Exists(instance_param_or_params = [a_1_to_m], instance_expr = Exists(instance_param_or_params = [b_1_to_n], instance_expr = Exists(instance_param_or_params = [ExprRange(sub_expr1, IndexedVar(lambda_, sub_expr1), one, sub_expr2)], instance_expr = Equals(v, VecSum(index_or_indices = [i], summand = ScalarMult(lambda_i, TensorProd(a_i, b_i)), domain = Interval(one, sub_expr2))), domain = RealNonNeg).with_wrapping(), condition = InSet(Set(b_1_to_n), OrthoNormBases(B))).with_wrapping(), condition = InSet(Set(a_1_to_m), OrthoNormBases(A))).with_wrapping(), domain = TensorProd(A, B)), And(InClass(A, HilbertSpaces), InClass(B, HilbertSpaces), Equals(Dim(A), m), Equals(Dim(B), 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(A, B\right) \mapsto \left\{\forall_{v \in A {\otimes} B}~\left[\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{m}~|~\left\{a_{1}, a_{2}, \ldots, a_{m}\right\} \in \textrm{O.N.Bases}\left(A\right)}~\\
\left[\begin{array}{l}\exists_{b_{1}, b_{2}, \ldots, b_{n}~|~\left\{b_{1}, b_{2}, \ldots, b_{n}\right\} \in \textrm{O.N.Bases}\left(B\right)}~\\
\left[\begin{array}{l}\exists_{\lambda_{1}, \lambda_{2}, \ldots, \lambda_{{\rm Min}\left(m, n\right)} \in \mathbb{R}^{\ge 0}}~\\
\left(v = \left(\sum_{i=1}^{{\rm Min}\left(m, n\right)} \left(\lambda_{i} \cdot \left(a_{i} {\otimes} b_{i}\right)\right)\right)\right)\end{array}\right]\end{array}\right]\end{array}\right] \textrm{ if } A \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  B \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  \textrm{Dim}\left(A\right) = m ,  \textrm{Dim}\left(B\right) = 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
1Lambdaparameters: 31
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 68
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10, 11, 12
8Lambdaparameter: 71
body: 14
9Operationoperator: 16
operands: 15
10Operationoperator: 16
operands: 17
11Operationoperator: 66
operands: 18
12Operationoperator: 66
operands: 19
13ExprTuple71
14Conditionalvalue: 20
condition: 21
15ExprTuple45, 22
16Literal
17ExprTuple64, 22
18ExprTuple23, 110
19ExprTuple24, 111
20Operationoperator: 46
operand: 28
21Operationoperator: 88
operands: 26
22Literal
23Operationoperator: 27
operand: 45
24Operationoperator: 27
operand: 64
25ExprTuple28
26ExprTuple71, 29
27Literal
28Lambdaparameters: 40
body: 30
29Operationoperator: 96
operands: 31
30Conditionalvalue: 32
condition: 33
31ExprTuple45, 64
32Operationoperator: 46
operand: 36
33Operationoperator: 88
operands: 35
34ExprTuple36
35ExprTuple37, 38
36Lambdaparameters: 57
body: 39
37Operationoperator: 56
operands: 40
38Operationoperator: 58
operand: 45
39Conditionalvalue: 42
condition: 43
40ExprTuple44
41ExprTuple45
42Operationoperator: 46
operand: 50
43Operationoperator: 88
operands: 48
44ExprRangelambda_map: 49
start_index: 102
end_index: 110
45Variable
46Literal
47ExprTuple50
48ExprTuple51, 52
49Lambdaparameter: 94
body: 53
50Lambdaparameters: 54
body: 55
51Operationoperator: 56
operands: 57
52Operationoperator: 58
operand: 64
53IndexedVarvariable: 104
index: 94
54ExprTuple60
55Conditionalvalue: 61
condition: 62
56Literal
57ExprTuple63
58Literal
59ExprTuple64
60ExprRangelambda_map: 65
start_index: 102
end_index: 103
61Operationoperator: 66
operands: 67
62Operationoperator: 68
operands: 69
63ExprRangelambda_map: 70
start_index: 102
end_index: 111
64Variable
65Lambdaparameter: 94
body: 84
66Literal
67ExprTuple71, 72
68Literal
69ExprTuple73
70Lambdaparameter: 94
body: 74
71Variable
72Operationoperator: 75
operand: 78
73ExprRangelambda_map: 77
start_index: 102
end_index: 103
74IndexedVarvariable: 105
index: 94
75Literal
76ExprTuple78
77Lambdaparameter: 94
body: 79
78Lambdaparameter: 109
body: 80
79Operationoperator: 88
operands: 81
80Conditionalvalue: 82
condition: 83
81ExprTuple84, 85
82Operationoperator: 86
operands: 87
83Operationoperator: 88
operands: 89
84IndexedVarvariable: 95
index: 94
85Literal
86Literal
87ExprTuple91, 92
88Literal
89ExprTuple109, 93
90ExprTuple94
91IndexedVarvariable: 95
index: 109
92Operationoperator: 96
operands: 97
93Operationoperator: 98
operands: 99
94Variable
95Variable
96Literal
97ExprTuple100, 101
98Literal
99ExprTuple102, 103
100IndexedVarvariable: 104
index: 109
101IndexedVarvariable: 105
index: 109
102Literal
103Operationoperator: 107
operands: 108
104Variable
105Variable
106ExprTuple109
107Literal
108ExprTuple110, 111
109Variable
110Variable
111Variable