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 B, 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 = 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()
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_{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}
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: 6
operand: 2
1ExprTuple2
2Lambdaparameters: 15
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 46
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 14
operands: 15
11Operationoperator: 16
operand: 22
12ExprTuple18
13Conditionalvalue: 19
condition: 20
14Literal
15ExprTuple21
16Literal
17ExprTuple22
18ExprRangelambda_map: 23
start_index: 60
end_index: 61
19Operationoperator: 24
operands: 25
20Operationoperator: 26
operands: 27
21ExprRangelambda_map: 28
start_index: 60
end_index: 69
22Variable
23Lambdaparameter: 52
body: 42
24Literal
25ExprTuple29, 30
26Literal
27ExprTuple31
28Lambdaparameter: 52
body: 32
29Variable
30Operationoperator: 33
operand: 36
31ExprRangelambda_map: 35
start_index: 60
end_index: 61
32IndexedVarvariable: 63
index: 52
33Literal
34ExprTuple36
35Lambdaparameter: 52
body: 37
36Lambdaparameter: 67
body: 38
37Operationoperator: 46
operands: 39
38Conditionalvalue: 40
condition: 41
39ExprTuple42, 43
40Operationoperator: 44
operands: 45
41Operationoperator: 46
operands: 47
42IndexedVarvariable: 53
index: 52
43Literal
44Literal
45ExprTuple49, 50
46Literal
47ExprTuple67, 51
48ExprTuple52
49IndexedVarvariable: 53
index: 67
50Operationoperator: 54
operands: 55
51Operationoperator: 56
operands: 57
52Variable
53Variable
54Literal
55ExprTuple58, 59
56Literal
57ExprTuple60, 61
58IndexedVarvariable: 62
index: 67
59IndexedVarvariable: 63
index: 67
60Literal
61Operationoperator: 65
operands: 66
62Variable
63Variable
64ExprTuple67
65Literal
66ExprTuple68, 69
67Variable
68Variable
69Variable