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([a_1_to_m], Conditional(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(), InSet(Set(a_1_to_m), OrthoNormBases(A)))))
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_{1}, a_{2}, \ldots, a_{m}\right) \mapsto \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} \textrm{ if } \left\{a_{1}, a_{2}, \ldots, a_{m}\right\} \in \textrm{O.N.Bases}\left(A\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: 11
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 17
operand: 7
4Operationoperator: 59
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 28
body: 10
8Operationoperator: 27
operands: 11
9Operationoperator: 29
operand: 16
10Conditionalvalue: 13
condition: 14
11ExprTuple15
12ExprTuple16
13Operationoperator: 17
operand: 21
14Operationoperator: 59
operands: 19
15ExprRangelambda_map: 20
start_index: 73
end_index: 81
16Variable
17Literal
18ExprTuple21
19ExprTuple22, 23
20Lambdaparameter: 65
body: 24
21Lambdaparameters: 25
body: 26
22Operationoperator: 27
operands: 28
23Operationoperator: 29
operand: 35
24IndexedVarvariable: 75
index: 65
25ExprTuple31
26Conditionalvalue: 32
condition: 33
27Literal
28ExprTuple34
29Literal
30ExprTuple35
31ExprRangelambda_map: 36
start_index: 73
end_index: 74
32Operationoperator: 37
operands: 38
33Operationoperator: 39
operands: 40
34ExprRangelambda_map: 41
start_index: 73
end_index: 82
35Variable
36Lambdaparameter: 65
body: 55
37Literal
38ExprTuple42, 43
39Literal
40ExprTuple44
41Lambdaparameter: 65
body: 45
42Variable
43Operationoperator: 46
operand: 49
44ExprRangelambda_map: 48
start_index: 73
end_index: 74
45IndexedVarvariable: 76
index: 65
46Literal
47ExprTuple49
48Lambdaparameter: 65
body: 50
49Lambdaparameter: 80
body: 51
50Operationoperator: 59
operands: 52
51Conditionalvalue: 53
condition: 54
52ExprTuple55, 56
53Operationoperator: 57
operands: 58
54Operationoperator: 59
operands: 60
55IndexedVarvariable: 66
index: 65
56Literal
57Literal
58ExprTuple62, 63
59Literal
60ExprTuple80, 64
61ExprTuple65
62IndexedVarvariable: 66
index: 80
63Operationoperator: 67
operands: 68
64Operationoperator: 69
operands: 70
65Variable
66Variable
67Literal
68ExprTuple71, 72
69Literal
70ExprTuple73, 74
71IndexedVarvariable: 75
index: 80
72IndexedVarvariable: 76
index: 80
73Literal
74Operationoperator: 78
operands: 79
75Variable
76Variable
77ExprTuple80
78Literal
79ExprTuple81, 82
80Variable
81Variable
82Variable