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, InClass, 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(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)), And(InClass(A, HilbertSpaces), InClass(B, HilbertSpaces), Equals(Dim(A), m), Equals(Dim(B), n)))
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\{\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] \textrm{ if } A \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  B \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  \textrm{Dim}\left(A\right) = m ,  \textrm{Dim}\left(B\right) = 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: 3
operand: 6
2Operationoperator: 66
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8, 9, 10
6Lambdaparameter: 69
body: 12
7Operationoperator: 14
operands: 13
8Operationoperator: 14
operands: 15
9Operationoperator: 64
operands: 16
10Operationoperator: 64
operands: 17
11ExprTuple69
12Conditionalvalue: 18
condition: 19
13ExprTuple43, 20
14Literal
15ExprTuple62, 20
16ExprTuple21, 108
17ExprTuple22, 109
18Operationoperator: 44
operand: 26
19Operationoperator: 86
operands: 24
20Literal
21Operationoperator: 25
operand: 43
22Operationoperator: 25
operand: 62
23ExprTuple26
24ExprTuple69, 27
25Literal
26Lambdaparameters: 38
body: 28
27Operationoperator: 94
operands: 29
28Conditionalvalue: 30
condition: 31
29ExprTuple43, 62
30Operationoperator: 44
operand: 34
31Operationoperator: 86
operands: 33
32ExprTuple34
33ExprTuple35, 36
34Lambdaparameters: 55
body: 37
35Operationoperator: 54
operands: 38
36Operationoperator: 56
operand: 43
37Conditionalvalue: 40
condition: 41
38ExprTuple42
39ExprTuple43
40Operationoperator: 44
operand: 48
41Operationoperator: 86
operands: 46
42ExprRangelambda_map: 47
start_index: 100
end_index: 108
43Variable
44Literal
45ExprTuple48
46ExprTuple49, 50
47Lambdaparameter: 92
body: 51
48Lambdaparameters: 52
body: 53
49Operationoperator: 54
operands: 55
50Operationoperator: 56
operand: 62
51IndexedVarvariable: 102
index: 92
52ExprTuple58
53Conditionalvalue: 59
condition: 60
54Literal
55ExprTuple61
56Literal
57ExprTuple62
58ExprRangelambda_map: 63
start_index: 100
end_index: 101
59Operationoperator: 64
operands: 65
60Operationoperator: 66
operands: 67
61ExprRangelambda_map: 68
start_index: 100
end_index: 109
62Variable
63Lambdaparameter: 92
body: 82
64Literal
65ExprTuple69, 70
66Literal
67ExprTuple71
68Lambdaparameter: 92
body: 72
69Variable
70Operationoperator: 73
operand: 76
71ExprRangelambda_map: 75
start_index: 100
end_index: 101
72IndexedVarvariable: 103
index: 92
73Literal
74ExprTuple76
75Lambdaparameter: 92
body: 77
76Lambdaparameter: 107
body: 78
77Operationoperator: 86
operands: 79
78Conditionalvalue: 80
condition: 81
79ExprTuple82, 83
80Operationoperator: 84
operands: 85
81Operationoperator: 86
operands: 87
82IndexedVarvariable: 93
index: 92
83Literal
84Literal
85ExprTuple89, 90
86Literal
87ExprTuple107, 91
88ExprTuple92
89IndexedVarvariable: 93
index: 107
90Operationoperator: 94
operands: 95
91Operationoperator: 96
operands: 97
92Variable
93Variable
94Literal
95ExprTuple98, 99
96Literal
97ExprTuple100, 101
98IndexedVarvariable: 102
index: 107
99IndexedVarvariable: 103
index: 107
100Literal
101Operationoperator: 105
operands: 106
102Variable
103Variable
104ExprTuple107
105Literal
106ExprTuple108, 109
107Variable
108Variable
109Variable