logo

Expression of type Forall

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, Forall, 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 = Forall(instance_param_or_params = [v], instance_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(), domain = 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())
\forall_{v \in A {\otimes} B}~\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}\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 53
body: 5
4ExprTuple53
5Conditionalvalue: 6
condition: 7
6Operationoperator: 28
operand: 10
7Operationoperator: 70
operands: 9
8ExprTuple10
9ExprTuple53, 11
10Lambdaparameters: 22
body: 12
11Operationoperator: 78
operands: 13
12Conditionalvalue: 14
condition: 15
13ExprTuple27, 46
14Operationoperator: 28
operand: 18
15Operationoperator: 70
operands: 17
16ExprTuple18
17ExprTuple19, 20
18Lambdaparameters: 39
body: 21
19Operationoperator: 38
operands: 22
20Operationoperator: 40
operand: 27
21Conditionalvalue: 24
condition: 25
22ExprTuple26
23ExprTuple27
24Operationoperator: 28
operand: 32
25Operationoperator: 70
operands: 30
26ExprRangelambda_map: 31
start_index: 84
end_index: 92
27Variable
28Literal
29ExprTuple32
30ExprTuple33, 34
31Lambdaparameter: 76
body: 35
32Lambdaparameters: 36
body: 37
33Operationoperator: 38
operands: 39
34Operationoperator: 40
operand: 46
35IndexedVarvariable: 86
index: 76
36ExprTuple42
37Conditionalvalue: 43
condition: 44
38Literal
39ExprTuple45
40Literal
41ExprTuple46
42ExprRangelambda_map: 47
start_index: 84
end_index: 85
43Operationoperator: 48
operands: 49
44Operationoperator: 50
operands: 51
45ExprRangelambda_map: 52
start_index: 84
end_index: 93
46Variable
47Lambdaparameter: 76
body: 66
48Literal
49ExprTuple53, 54
50Literal
51ExprTuple55
52Lambdaparameter: 76
body: 56
53Variable
54Operationoperator: 57
operand: 60
55ExprRangelambda_map: 59
start_index: 84
end_index: 85
56IndexedVarvariable: 87
index: 76
57Literal
58ExprTuple60
59Lambdaparameter: 76
body: 61
60Lambdaparameter: 91
body: 62
61Operationoperator: 70
operands: 63
62Conditionalvalue: 64
condition: 65
63ExprTuple66, 67
64Operationoperator: 68
operands: 69
65Operationoperator: 70
operands: 71
66IndexedVarvariable: 77
index: 76
67Literal
68Literal
69ExprTuple73, 74
70Literal
71ExprTuple91, 75
72ExprTuple76
73IndexedVarvariable: 77
index: 91
74Operationoperator: 78
operands: 79
75Operationoperator: 80
operands: 81
76Variable
77Variable
78Literal
79ExprTuple82, 83
80Literal
81ExprTuple84, 85
82IndexedVarvariable: 86
index: 91
83IndexedVarvariable: 87
index: 91
84Literal
85Operationoperator: 89
operands: 90
86Variable
87Variable
88ExprTuple91
89Literal
90ExprTuple92, 93
91Variable
92Variable
93Variable