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 B, Conditional, ExprRange, IndexedVar, 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 = 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\{\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..
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: 3
operand: 6
2Operationoperator: 43
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 9
body: 10
7Operationoperator: 11
operands: 12
8Operationoperator: 13
operand: 19
9ExprTuple15
10Conditionalvalue: 16
condition: 17
11Literal
12ExprTuple18
13Literal
14ExprTuple19
15ExprRangelambda_map: 20
start_index: 57
end_index: 58
16Operationoperator: 21
operands: 22
17Operationoperator: 23
operands: 24
18ExprRangelambda_map: 25
start_index: 57
end_index: 66
19Variable
20Lambdaparameter: 49
body: 39
21Literal
22ExprTuple26, 27
23Literal
24ExprTuple28
25Lambdaparameter: 49
body: 29
26Variable
27Operationoperator: 30
operand: 33
28ExprRangelambda_map: 32
start_index: 57
end_index: 58
29IndexedVarvariable: 60
index: 49
30Literal
31ExprTuple33
32Lambdaparameter: 49
body: 34
33Lambdaparameter: 64
body: 35
34Operationoperator: 43
operands: 36
35Conditionalvalue: 37
condition: 38
36ExprTuple39, 40
37Operationoperator: 41
operands: 42
38Operationoperator: 43
operands: 44
39IndexedVarvariable: 50
index: 49
40Literal
41Literal
42ExprTuple46, 47
43Literal
44ExprTuple64, 48
45ExprTuple49
46IndexedVarvariable: 50
index: 64
47Operationoperator: 51
operands: 52
48Operationoperator: 53
operands: 54
49Variable
50Variable
51Literal
52ExprTuple55, 56
53Literal
54ExprTuple57, 58
55IndexedVarvariable: 59
index: 64
56IndexedVarvariable: 60
index: 64
57Literal
58Operationoperator: 62
operands: 63
59Variable
60Variable
61ExprTuple64
62Literal
63ExprTuple65, 66
64Variable
65Variable
66Variable