logo

Expression of type Conditional

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, 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 = 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\{\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()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 15
operand: 5
2Operationoperator: 57
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 26
body: 8
6Operationoperator: 25
operands: 9
7Operationoperator: 27
operand: 14
8Conditionalvalue: 11
condition: 12
9ExprTuple13
10ExprTuple14
11Operationoperator: 15
operand: 19
12Operationoperator: 57
operands: 17
13ExprRangelambda_map: 18
start_index: 71
end_index: 79
14Variable
15Literal
16ExprTuple19
17ExprTuple20, 21
18Lambdaparameter: 63
body: 22
19Lambdaparameters: 23
body: 24
20Operationoperator: 25
operands: 26
21Operationoperator: 27
operand: 33
22IndexedVarvariable: 73
index: 63
23ExprTuple29
24Conditionalvalue: 30
condition: 31
25Literal
26ExprTuple32
27Literal
28ExprTuple33
29ExprRangelambda_map: 34
start_index: 71
end_index: 72
30Operationoperator: 35
operands: 36
31Operationoperator: 37
operands: 38
32ExprRangelambda_map: 39
start_index: 71
end_index: 80
33Variable
34Lambdaparameter: 63
body: 53
35Literal
36ExprTuple40, 41
37Literal
38ExprTuple42
39Lambdaparameter: 63
body: 43
40Variable
41Operationoperator: 44
operand: 47
42ExprRangelambda_map: 46
start_index: 71
end_index: 72
43IndexedVarvariable: 74
index: 63
44Literal
45ExprTuple47
46Lambdaparameter: 63
body: 48
47Lambdaparameter: 78
body: 49
48Operationoperator: 57
operands: 50
49Conditionalvalue: 51
condition: 52
50ExprTuple53, 54
51Operationoperator: 55
operands: 56
52Operationoperator: 57
operands: 58
53IndexedVarvariable: 64
index: 63
54Literal
55Literal
56ExprTuple60, 61
57Literal
58ExprTuple78, 62
59ExprTuple63
60IndexedVarvariable: 64
index: 78
61Operationoperator: 65
operands: 66
62Operationoperator: 67
operands: 68
63Variable
64Variable
65Literal
66ExprTuple69, 70
67Literal
68ExprTuple71, 72
69IndexedVarvariable: 73
index: 78
70IndexedVarvariable: 74
index: 78
71Literal
72Operationoperator: 76
operands: 77
73Variable
74Variable
75ExprTuple78
76Literal
77ExprTuple79, 80
78Variable
79Variable
80Variable