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 B, Conditional, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, i, lambda_, m, n, v
from proveit.core_expr_types import 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([b_1_to_n], Conditional(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(), InSet(Set(b_1_to_n), OrthoNormBases(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(\left(b_{1}, b_{2}, \ldots, b_{n}\right) \mapsto \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} \textrm{ if } \left\{b_{1}, b_{2}, \ldots, b_{n}\right\} \in \textrm{O.N.Bases}\left(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
1Lambdaparameters: 14
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 45
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 13
operands: 14
10Operationoperator: 15
operand: 21
11ExprTuple17
12Conditionalvalue: 18
condition: 19
13Literal
14ExprTuple20
15Literal
16ExprTuple21
17ExprRangelambda_map: 22
start_index: 59
end_index: 60
18Operationoperator: 23
operands: 24
19Operationoperator: 25
operands: 26
20ExprRangelambda_map: 27
start_index: 59
end_index: 68
21Variable
22Lambdaparameter: 51
body: 41
23Literal
24ExprTuple28, 29
25Literal
26ExprTuple30
27Lambdaparameter: 51
body: 31
28Variable
29Operationoperator: 32
operand: 35
30ExprRangelambda_map: 34
start_index: 59
end_index: 60
31IndexedVarvariable: 62
index: 51
32Literal
33ExprTuple35
34Lambdaparameter: 51
body: 36
35Lambdaparameter: 66
body: 37
36Operationoperator: 45
operands: 38
37Conditionalvalue: 39
condition: 40
38ExprTuple41, 42
39Operationoperator: 43
operands: 44
40Operationoperator: 45
operands: 46
41IndexedVarvariable: 52
index: 51
42Literal
43Literal
44ExprTuple48, 49
45Literal
46ExprTuple66, 50
47ExprTuple51
48IndexedVarvariable: 52
index: 66
49Operationoperator: 53
operands: 54
50Operationoperator: 55
operands: 56
51Variable
52Variable
53Literal
54ExprTuple57, 58
55Literal
56ExprTuple59, 60
57IndexedVarvariable: 61
index: 66
58IndexedVarvariable: 62
index: 66
59Literal
60Operationoperator: 64
operands: 65
61Variable
62Variable
63ExprTuple66
64Literal
65ExprTuple67, 68
66Variable
67Variable
68Variable