logo

Expression of type Exists

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, 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 = 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()
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())
\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}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 18
operand: 2
1ExprTuple2
2Lambdaparameters: 12
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 18
operand: 8
5Operationoperator: 60
operands: 7
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 29
body: 11
9Operationoperator: 28
operands: 12
10Operationoperator: 30
operand: 17
11Conditionalvalue: 14
condition: 15
12ExprTuple16
13ExprTuple17
14Operationoperator: 18
operand: 22
15Operationoperator: 60
operands: 20
16ExprRangelambda_map: 21
start_index: 74
end_index: 82
17Variable
18Literal
19ExprTuple22
20ExprTuple23, 24
21Lambdaparameter: 66
body: 25
22Lambdaparameters: 26
body: 27
23Operationoperator: 28
operands: 29
24Operationoperator: 30
operand: 36
25IndexedVarvariable: 76
index: 66
26ExprTuple32
27Conditionalvalue: 33
condition: 34
28Literal
29ExprTuple35
30Literal
31ExprTuple36
32ExprRangelambda_map: 37
start_index: 74
end_index: 75
33Operationoperator: 38
operands: 39
34Operationoperator: 40
operands: 41
35ExprRangelambda_map: 42
start_index: 74
end_index: 83
36Variable
37Lambdaparameter: 66
body: 56
38Literal
39ExprTuple43, 44
40Literal
41ExprTuple45
42Lambdaparameter: 66
body: 46
43Variable
44Operationoperator: 47
operand: 50
45ExprRangelambda_map: 49
start_index: 74
end_index: 75
46IndexedVarvariable: 77
index: 66
47Literal
48ExprTuple50
49Lambdaparameter: 66
body: 51
50Lambdaparameter: 81
body: 52
51Operationoperator: 60
operands: 53
52Conditionalvalue: 54
condition: 55
53ExprTuple56, 57
54Operationoperator: 58
operands: 59
55Operationoperator: 60
operands: 61
56IndexedVarvariable: 67
index: 66
57Literal
58Literal
59ExprTuple63, 64
60Literal
61ExprTuple81, 65
62ExprTuple66
63IndexedVarvariable: 67
index: 81
64Operationoperator: 68
operands: 69
65Operationoperator: 70
operands: 71
66Variable
67Variable
68Literal
69ExprTuple72, 73
70Literal
71ExprTuple74, 75
72IndexedVarvariable: 76
index: 81
73IndexedVarvariable: 77
index: 81
74Literal
75Operationoperator: 79
operands: 80
76Variable
77Variable
78ExprTuple81
79Literal
80ExprTuple82, 83
81Variable
82Variable
83Variable