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 Dim, HilbertSpaces, OrthoNormBases, ScalarMult, TensorProd, VecSum
from proveit.logic import And, Equals, Exists, Forall, InSet, Set
from proveit.numbers import Interval, Min, NaturalPos, 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(Forall(instance_param_or_params = [A, B], instance_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)), domain = HilbertSpaces, conditions = [Equals(Dim(A), m), Equals(Dim(B), n)]).with_wrapping(), And(InSet(m, NaturalPos), InSet(n, NaturalPos)))
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}\forall_{A, B \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}~|~\textrm{Dim}\left(A\right) = m, \textrm{Dim}\left(B\right) = n}~\\
\left[\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]\right]\end{array} \textrm{ if } m \in \mathbb{N}^+ ,  n \in \mathbb{N}^+\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: 14
operand: 5
2Operationoperator: 77
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 40
body: 8
6Operationoperator: 97
operands: 9
7Operationoperator: 97
operands: 10
8Conditionalvalue: 11
condition: 12
9ExprTuple119, 13
10ExprTuple120, 13
11Operationoperator: 14
operand: 17
12Operationoperator: 77
operands: 16
13Literal
14Literal
15ExprTuple17
16ExprTuple18, 19, 20, 21
17Lambdaparameter: 80
body: 23
18Operationoperator: 25
operands: 24
19Operationoperator: 25
operands: 26
20Operationoperator: 75
operands: 27
21Operationoperator: 75
operands: 28
22ExprTuple80
23Conditionalvalue: 29
condition: 30
24ExprTuple54, 31
25Literal
26ExprTuple73, 31
27ExprTuple32, 119
28ExprTuple33, 120
29Operationoperator: 55
operand: 37
30Operationoperator: 97
operands: 35
31Literal
32Operationoperator: 36
operand: 54
33Operationoperator: 36
operand: 73
34ExprTuple37
35ExprTuple80, 38
36Literal
37Lambdaparameters: 49
body: 39
38Operationoperator: 105
operands: 40
39Conditionalvalue: 41
condition: 42
40ExprTuple54, 73
41Operationoperator: 55
operand: 45
42Operationoperator: 97
operands: 44
43ExprTuple45
44ExprTuple46, 47
45Lambdaparameters: 66
body: 48
46Operationoperator: 65
operands: 49
47Operationoperator: 67
operand: 54
48Conditionalvalue: 51
condition: 52
49ExprTuple53
50ExprTuple54
51Operationoperator: 55
operand: 59
52Operationoperator: 97
operands: 57
53ExprRangelambda_map: 58
start_index: 111
end_index: 119
54Variable
55Literal
56ExprTuple59
57ExprTuple60, 61
58Lambdaparameter: 103
body: 62
59Lambdaparameters: 63
body: 64
60Operationoperator: 65
operands: 66
61Operationoperator: 67
operand: 73
62IndexedVarvariable: 113
index: 103
63ExprTuple69
64Conditionalvalue: 70
condition: 71
65Literal
66ExprTuple72
67Literal
68ExprTuple73
69ExprRangelambda_map: 74
start_index: 111
end_index: 112
70Operationoperator: 75
operands: 76
71Operationoperator: 77
operands: 78
72ExprRangelambda_map: 79
start_index: 111
end_index: 120
73Variable
74Lambdaparameter: 103
body: 93
75Literal
76ExprTuple80, 81
77Literal
78ExprTuple82
79Lambdaparameter: 103
body: 83
80Variable
81Operationoperator: 84
operand: 87
82ExprRangelambda_map: 86
start_index: 111
end_index: 112
83IndexedVarvariable: 114
index: 103
84Literal
85ExprTuple87
86Lambdaparameter: 103
body: 88
87Lambdaparameter: 118
body: 89
88Operationoperator: 97
operands: 90
89Conditionalvalue: 91
condition: 92
90ExprTuple93, 94
91Operationoperator: 95
operands: 96
92Operationoperator: 97
operands: 98
93IndexedVarvariable: 104
index: 103
94Literal
95Literal
96ExprTuple100, 101
97Literal
98ExprTuple118, 102
99ExprTuple103
100IndexedVarvariable: 104
index: 118
101Operationoperator: 105
operands: 106
102Operationoperator: 107
operands: 108
103Variable
104Variable
105Literal
106ExprTuple109, 110
107Literal
108ExprTuple111, 112
109IndexedVarvariable: 113
index: 118
110IndexedVarvariable: 114
index: 118
111Literal
112Operationoperator: 116
operands: 117
113Variable
114Variable
115ExprTuple118
116Literal
117ExprTuple119, 120
118Variable
119Variable
120Variable