logo

Expression of type Lambda

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, 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 = 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(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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 10
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 16
operand: 6
3Operationoperator: 58
operands: 5
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 27
body: 9
7Operationoperator: 26
operands: 10
8Operationoperator: 28
operand: 15
9Conditionalvalue: 12
condition: 13
10ExprTuple14
11ExprTuple15
12Operationoperator: 16
operand: 20
13Operationoperator: 58
operands: 18
14ExprRangelambda_map: 19
start_index: 72
end_index: 80
15Variable
16Literal
17ExprTuple20
18ExprTuple21, 22
19Lambdaparameter: 64
body: 23
20Lambdaparameters: 24
body: 25
21Operationoperator: 26
operands: 27
22Operationoperator: 28
operand: 34
23IndexedVarvariable: 74
index: 64
24ExprTuple30
25Conditionalvalue: 31
condition: 32
26Literal
27ExprTuple33
28Literal
29ExprTuple34
30ExprRangelambda_map: 35
start_index: 72
end_index: 73
31Operationoperator: 36
operands: 37
32Operationoperator: 38
operands: 39
33ExprRangelambda_map: 40
start_index: 72
end_index: 81
34Variable
35Lambdaparameter: 64
body: 54
36Literal
37ExprTuple41, 42
38Literal
39ExprTuple43
40Lambdaparameter: 64
body: 44
41Variable
42Operationoperator: 45
operand: 48
43ExprRangelambda_map: 47
start_index: 72
end_index: 73
44IndexedVarvariable: 75
index: 64
45Literal
46ExprTuple48
47Lambdaparameter: 64
body: 49
48Lambdaparameter: 79
body: 50
49Operationoperator: 58
operands: 51
50Conditionalvalue: 52
condition: 53
51ExprTuple54, 55
52Operationoperator: 56
operands: 57
53Operationoperator: 58
operands: 59
54IndexedVarvariable: 65
index: 64
55Literal
56Literal
57ExprTuple61, 62
58Literal
59ExprTuple79, 63
60ExprTuple64
61IndexedVarvariable: 65
index: 79
62Operationoperator: 66
operands: 67
63Operationoperator: 68
operands: 69
64Variable
65Variable
66Literal
67ExprTuple70, 71
68Literal
69ExprTuple72, 73
70IndexedVarvariable: 74
index: 79
71IndexedVarvariable: 75
index: 79
72Literal
73Operationoperator: 77
operands: 78
74Variable
75Variable
76ExprTuple79
77Literal
78ExprTuple80, 81
79Variable
80Variable
81Variable