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, InSet, Set
from proveit.numbers import Interval, Min, NaturalPos, 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([m, n], Conditional(Forall(instance_param_or_params = [A, B], instance_expr = 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)), domain = HilbertSpaces, conditions = [Equals(Dim(A), m), Equals(Dim(B), n)]).with_wrapping(), And(InSet(m, NaturalPos), 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(\left(m, n\right) \mapsto \left\{\begin{array}{l}\forall_{A, B \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}~|~\textrm{Dim}\left(A\right) = m, \textrm{Dim}\left(B\right) = n}~\\
\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]\right]\end{array} \textrm{ if } m \in \mathbb{N}^+ ,  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
1Lambdaparameters: 119
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operand: 7
4Operationoperator: 79
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 42
body: 10
8Operationoperator: 99
operands: 11
9Operationoperator: 99
operands: 12
10Conditionalvalue: 13
condition: 14
11ExprTuple121, 15
12ExprTuple122, 15
13Operationoperator: 16
operand: 19
14Operationoperator: 79
operands: 18
15Literal
16Literal
17ExprTuple19
18ExprTuple20, 21, 22, 23
19Lambdaparameter: 82
body: 25
20Operationoperator: 27
operands: 26
21Operationoperator: 27
operands: 28
22Operationoperator: 77
operands: 29
23Operationoperator: 77
operands: 30
24ExprTuple82
25Conditionalvalue: 31
condition: 32
26ExprTuple56, 33
27Literal
28ExprTuple75, 33
29ExprTuple34, 121
30ExprTuple35, 122
31Operationoperator: 57
operand: 39
32Operationoperator: 99
operands: 37
33Literal
34Operationoperator: 38
operand: 56
35Operationoperator: 38
operand: 75
36ExprTuple39
37ExprTuple82, 40
38Literal
39Lambdaparameters: 51
body: 41
40Operationoperator: 107
operands: 42
41Conditionalvalue: 43
condition: 44
42ExprTuple56, 75
43Operationoperator: 57
operand: 47
44Operationoperator: 99
operands: 46
45ExprTuple47
46ExprTuple48, 49
47Lambdaparameters: 68
body: 50
48Operationoperator: 67
operands: 51
49Operationoperator: 69
operand: 56
50Conditionalvalue: 53
condition: 54
51ExprTuple55
52ExprTuple56
53Operationoperator: 57
operand: 61
54Operationoperator: 99
operands: 59
55ExprRangelambda_map: 60
start_index: 113
end_index: 121
56Variable
57Literal
58ExprTuple61
59ExprTuple62, 63
60Lambdaparameter: 105
body: 64
61Lambdaparameters: 65
body: 66
62Operationoperator: 67
operands: 68
63Operationoperator: 69
operand: 75
64IndexedVarvariable: 115
index: 105
65ExprTuple71
66Conditionalvalue: 72
condition: 73
67Literal
68ExprTuple74
69Literal
70ExprTuple75
71ExprRangelambda_map: 76
start_index: 113
end_index: 114
72Operationoperator: 77
operands: 78
73Operationoperator: 79
operands: 80
74ExprRangelambda_map: 81
start_index: 113
end_index: 122
75Variable
76Lambdaparameter: 105
body: 95
77Literal
78ExprTuple82, 83
79Literal
80ExprTuple84
81Lambdaparameter: 105
body: 85
82Variable
83Operationoperator: 86
operand: 89
84ExprRangelambda_map: 88
start_index: 113
end_index: 114
85IndexedVarvariable: 116
index: 105
86Literal
87ExprTuple89
88Lambdaparameter: 105
body: 90
89Lambdaparameter: 120
body: 91
90Operationoperator: 99
operands: 92
91Conditionalvalue: 93
condition: 94
92ExprTuple95, 96
93Operationoperator: 97
operands: 98
94Operationoperator: 99
operands: 100
95IndexedVarvariable: 106
index: 105
96Literal
97Literal
98ExprTuple102, 103
99Literal
100ExprTuple120, 104
101ExprTuple105
102IndexedVarvariable: 106
index: 120
103Operationoperator: 107
operands: 108
104Operationoperator: 109
operands: 110
105Variable
106Variable
107Literal
108ExprTuple111, 112
109Literal
110ExprTuple113, 114
111IndexedVarvariable: 115
index: 120
112IndexedVarvariable: 116
index: 120
113Literal
114Operationoperator: 118
operands: 119
115Variable
116Variable
117ExprTuple120
118Literal
119ExprTuple121, 122
120Variable
121Variable
122Variable