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 OrthoNormBases, ScalarMult, TensorProd, VecSum
from proveit.logic import Equals, Exists, 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(v, Conditional(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(), InSet(v, TensorProd(A, B)))))
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(v \mapsto \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} \textrm{ if } v \in \left(A {\otimes} B\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: 51
body: 3
2ExprTuple51
3Conditionalvalue: 4
condition: 5
4Operationoperator: 26
operand: 8
5Operationoperator: 68
operands: 7
6ExprTuple8
7ExprTuple51, 9
8Lambdaparameters: 20
body: 10
9Operationoperator: 76
operands: 11
10Conditionalvalue: 12
condition: 13
11ExprTuple25, 44
12Operationoperator: 26
operand: 16
13Operationoperator: 68
operands: 15
14ExprTuple16
15ExprTuple17, 18
16Lambdaparameters: 37
body: 19
17Operationoperator: 36
operands: 20
18Operationoperator: 38
operand: 25
19Conditionalvalue: 22
condition: 23
20ExprTuple24
21ExprTuple25
22Operationoperator: 26
operand: 30
23Operationoperator: 68
operands: 28
24ExprRangelambda_map: 29
start_index: 82
end_index: 90
25Variable
26Literal
27ExprTuple30
28ExprTuple31, 32
29Lambdaparameter: 74
body: 33
30Lambdaparameters: 34
body: 35
31Operationoperator: 36
operands: 37
32Operationoperator: 38
operand: 44
33IndexedVarvariable: 84
index: 74
34ExprTuple40
35Conditionalvalue: 41
condition: 42
36Literal
37ExprTuple43
38Literal
39ExprTuple44
40ExprRangelambda_map: 45
start_index: 82
end_index: 83
41Operationoperator: 46
operands: 47
42Operationoperator: 48
operands: 49
43ExprRangelambda_map: 50
start_index: 82
end_index: 91
44Variable
45Lambdaparameter: 74
body: 64
46Literal
47ExprTuple51, 52
48Literal
49ExprTuple53
50Lambdaparameter: 74
body: 54
51Variable
52Operationoperator: 55
operand: 58
53ExprRangelambda_map: 57
start_index: 82
end_index: 83
54IndexedVarvariable: 85
index: 74
55Literal
56ExprTuple58
57Lambdaparameter: 74
body: 59
58Lambdaparameter: 89
body: 60
59Operationoperator: 68
operands: 61
60Conditionalvalue: 62
condition: 63
61ExprTuple64, 65
62Operationoperator: 66
operands: 67
63Operationoperator: 68
operands: 69
64IndexedVarvariable: 75
index: 74
65Literal
66Literal
67ExprTuple71, 72
68Literal
69ExprTuple89, 73
70ExprTuple74
71IndexedVarvariable: 75
index: 89
72Operationoperator: 76
operands: 77
73Operationoperator: 78
operands: 79
74Variable
75Variable
76Literal
77ExprTuple80, 81
78Literal
79ExprTuple82, 83
80IndexedVarvariable: 84
index: 89
81IndexedVarvariable: 85
index: 89
82Literal
83Operationoperator: 87
operands: 88
84Variable
85Variable
86ExprTuple89
87Literal
88ExprTuple90, 91
89Variable
90Variable
91Variable