logo

Expression of type Conditional

from the theory of proveit.physics.quantum.algebra

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 Conditional, ExprRange, IndexedVar, Variable, i, lambda_, m, n
from proveit.core_expr_types import a_i, b_1_to_n, b_i, lambda_i
from proveit.linear_algebra import OrthoNormBases, ScalarMult, VecSum
from proveit.logic import CartExp, Equals, Exists, InSet, Set
from proveit.numbers import Complex, Interval, Min, RealNonNeg, one
from proveit.physics.quantum import Ket, Qmult, var_ket_psi
from proveit.physics.quantum.algebra import a_1_to_m_kets, b_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Min(m, n)
expr = Conditional(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(var_ket_psi, VecSum(index_or_indices = [i], summand = ScalarMult(lambda_i, Qmult(Ket(a_i), Ket(b_i))), domain = Interval(one, sub_expr2))), domain = RealNonNeg).with_wrapping(), condition = InSet(Set(b_1_to_n_kets), OrthoNormBases(CartExp(Complex, n)))).with_wrapping(), InSet(Set(a_1_to_m_kets), OrthoNormBases(CartExp(Complex, m))))
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}\exists_{b_{1}, b_{2}, \ldots, b_{n}~|~\left\{\left\{\lvert b_{1} \rangle, \lvert b_{2} \rangle, \ldots, \lvert b_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{n}\right)}~\\
\left[\begin{array}{l}\exists_{\lambda_{1}, \lambda_{2}, \ldots, \lambda_{{\rm Min}\left(m, n\right)} \in \mathbb{R}^{\ge 0}}~\\
\left(\lvert \psi \rangle = \left(\sum_{i=1}^{{\rm Min}\left(m, n\right)} \left(\lambda_{i} \cdot \left(\lvert a_{i} \rangle \thinspace \lvert b_{i} \rangle\right)\right)\right)\right)\end{array}\right]\end{array} \textrm{ if } \left\{\left\{\lvert a_{1} \rangle, \lvert a_{2} \rangle, \ldots, \lvert a_{m} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{m}\right)\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: 18
operand: 5
2Operationoperator: 72
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 8
body: 9
6Operationoperator: 44
operand: 15
7Operationoperator: 30
operand: 16
8ExprTuple12
9Conditionalvalue: 13
condition: 14
10ExprTuple15
11ExprTuple16
12ExprRangelambda_map: 17
start_index: 86
end_index: 96
13Operationoperator: 18
operand: 23
14Operationoperator: 72
operands: 20
15Operationoperator: 44
operands: 21
16Operationoperator: 46
operands: 22
17Lambdaparameter: 78
body: 69
18Literal
19ExprTuple23
20ExprTuple24, 25
21ExprTuple26
22ExprTuple53, 95
23Lambdaparameters: 27
body: 28
24Operationoperator: 44
operand: 36
25Operationoperator: 30
operand: 37
26ExprRangelambda_map: 32
start_index: 86
end_index: 95
27ExprTuple33
28Conditionalvalue: 34
condition: 35
29ExprTuple36
30Literal
31ExprTuple37
32Lambdaparameter: 78
body: 38
33ExprRangelambda_map: 39
start_index: 86
end_index: 87
34Operationoperator: 40
operands: 41
35Operationoperator: 42
operands: 43
36Operationoperator: 44
operands: 45
37Operationoperator: 46
operands: 47
38Operationoperator: 89
operand: 54
39Lambdaparameter: 78
body: 67
40Literal
41ExprTuple49, 50
42Literal
43ExprTuple51
44Literal
45ExprTuple52
46Literal
47ExprTuple53, 96
48ExprTuple54
49Variable
50Operationoperator: 55
operand: 59
51ExprRangelambda_map: 57
start_index: 86
end_index: 87
52ExprRangelambda_map: 58
start_index: 86
end_index: 96
53Literal
54IndexedVarvariable: 97
index: 78
55Literal
56ExprTuple59
57Lambdaparameter: 78
body: 60
58Lambdaparameter: 78
body: 61
59Lambdaparameter: 100
body: 62
60Operationoperator: 72
operands: 63
61Operationoperator: 89
operand: 69
62Conditionalvalue: 65
condition: 66
63ExprTuple67, 68
64ExprTuple69
65Operationoperator: 70
operands: 71
66Operationoperator: 72
operands: 73
67IndexedVarvariable: 79
index: 78
68Literal
69IndexedVarvariable: 98
index: 78
70Literal
71ExprTuple75, 76
72Literal
73ExprTuple100, 77
74ExprTuple78
75IndexedVarvariable: 79
index: 100
76Operationoperator: 80
operands: 81
77Operationoperator: 82
operands: 83
78Variable
79Variable
80Literal
81ExprTuple84, 85
82Literal
83ExprTuple86, 87
84Operationoperator: 89
operand: 93
85Operationoperator: 89
operand: 94
86Literal
87Operationoperator: 91
operands: 92
88ExprTuple93
89Literal
90ExprTuple94
91Literal
92ExprTuple95, 96
93IndexedVarvariable: 97
index: 100
94IndexedVarvariable: 98
index: 100
95Variable
96Variable
97Variable
98Variable
99ExprTuple100
100Variable