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 = [a_1_to_m], instance_expr = 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(), condition = InSet(Set(a_1_to_m), OrthoNormBases(A))).with_wrapping(), InSet(v, TensorProd(A, 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_{a_{1}, a_{2}, \ldots, a_{m}~|~\left\{a_{1}, a_{2}, \ldots, a_{m}\right\} \in \textrm{O.N.Bases}\left(A\right)}~\\
\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}\right]\end{array} \textrm{ if } v \in \left(A {\otimes} 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: 23
operand: 5
2Operationoperator: 65
operands: 4
3ExprTuple5
4ExprTuple48, 6
5Lambdaparameters: 17
body: 7
6Operationoperator: 73
operands: 8
7Conditionalvalue: 9
condition: 10
8ExprTuple22, 41
9Operationoperator: 23
operand: 13
10Operationoperator: 65
operands: 12
11ExprTuple13
12ExprTuple14, 15
13Lambdaparameters: 34
body: 16
14Operationoperator: 33
operands: 17
15Operationoperator: 35
operand: 22
16Conditionalvalue: 19
condition: 20
17ExprTuple21
18ExprTuple22
19Operationoperator: 23
operand: 27
20Operationoperator: 65
operands: 25
21ExprRangelambda_map: 26
start_index: 79
end_index: 87
22Variable
23Literal
24ExprTuple27
25ExprTuple28, 29
26Lambdaparameter: 71
body: 30
27Lambdaparameters: 31
body: 32
28Operationoperator: 33
operands: 34
29Operationoperator: 35
operand: 41
30IndexedVarvariable: 81
index: 71
31ExprTuple37
32Conditionalvalue: 38
condition: 39
33Literal
34ExprTuple40
35Literal
36ExprTuple41
37ExprRangelambda_map: 42
start_index: 79
end_index: 80
38Operationoperator: 43
operands: 44
39Operationoperator: 45
operands: 46
40ExprRangelambda_map: 47
start_index: 79
end_index: 88
41Variable
42Lambdaparameter: 71
body: 61
43Literal
44ExprTuple48, 49
45Literal
46ExprTuple50
47Lambdaparameter: 71
body: 51
48Variable
49Operationoperator: 52
operand: 55
50ExprRangelambda_map: 54
start_index: 79
end_index: 80
51IndexedVarvariable: 82
index: 71
52Literal
53ExprTuple55
54Lambdaparameter: 71
body: 56
55Lambdaparameter: 86
body: 57
56Operationoperator: 65
operands: 58
57Conditionalvalue: 59
condition: 60
58ExprTuple61, 62
59Operationoperator: 63
operands: 64
60Operationoperator: 65
operands: 66
61IndexedVarvariable: 72
index: 71
62Literal
63Literal
64ExprTuple68, 69
65Literal
66ExprTuple86, 70
67ExprTuple71
68IndexedVarvariable: 72
index: 86
69Operationoperator: 73
operands: 74
70Operationoperator: 75
operands: 76
71Variable
72Variable
73Literal
74ExprTuple77, 78
75Literal
76ExprTuple79, 80
77IndexedVarvariable: 81
index: 86
78IndexedVarvariable: 82
index: 86
79Literal
80Operationoperator: 84
operands: 85
81Variable
82Variable
83ExprTuple86
84Literal
85ExprTuple87, 88
86Variable
87Variable
88Variable