logo

Expression of type Exists

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 ExprRange, IndexedVar, Variable, i, lambda_, m, n
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, 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 = 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(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(), condition = InSet(Set(a_1_to_m_kets), OrthoNormBases(CartExp(Complex, m)))).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_{a_{1}, a_{2}, \ldots, a_{m}~|~\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)}~\\
\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}\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: 24
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple5
4Conditionalvalue: 6
condition: 7
5ExprRangelambda_map: 8
start_index: 92
end_index: 101
6Operationoperator: 24
operand: 11
7Operationoperator: 78
operands: 10
8Lambdaparameter: 84
body: 60
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameters: 14
body: 15
12Operationoperator: 50
operand: 21
13Operationoperator: 36
operand: 22
14ExprTuple18
15Conditionalvalue: 19
condition: 20
16ExprTuple21
17ExprTuple22
18ExprRangelambda_map: 23
start_index: 92
end_index: 102
19Operationoperator: 24
operand: 29
20Operationoperator: 78
operands: 26
21Operationoperator: 50
operands: 27
22Operationoperator: 52
operands: 28
23Lambdaparameter: 84
body: 75
24Literal
25ExprTuple29
26ExprTuple30, 31
27ExprTuple32
28ExprTuple59, 101
29Lambdaparameters: 33
body: 34
30Operationoperator: 50
operand: 42
31Operationoperator: 36
operand: 43
32ExprRangelambda_map: 38
start_index: 92
end_index: 101
33ExprTuple39
34Conditionalvalue: 40
condition: 41
35ExprTuple42
36Literal
37ExprTuple43
38Lambdaparameter: 84
body: 44
39ExprRangelambda_map: 45
start_index: 92
end_index: 93
40Operationoperator: 46
operands: 47
41Operationoperator: 48
operands: 49
42Operationoperator: 50
operands: 51
43Operationoperator: 52
operands: 53
44Operationoperator: 95
operand: 60
45Lambdaparameter: 84
body: 73
46Literal
47ExprTuple55, 56
48Literal
49ExprTuple57
50Literal
51ExprTuple58
52Literal
53ExprTuple59, 102
54ExprTuple60
55Variable
56Operationoperator: 61
operand: 65
57ExprRangelambda_map: 63
start_index: 92
end_index: 93
58ExprRangelambda_map: 64
start_index: 92
end_index: 102
59Literal
60IndexedVarvariable: 103
index: 84
61Literal
62ExprTuple65
63Lambdaparameter: 84
body: 66
64Lambdaparameter: 84
body: 67
65Lambdaparameter: 106
body: 68
66Operationoperator: 78
operands: 69
67Operationoperator: 95
operand: 75
68Conditionalvalue: 71
condition: 72
69ExprTuple73, 74
70ExprTuple75
71Operationoperator: 76
operands: 77
72Operationoperator: 78
operands: 79
73IndexedVarvariable: 85
index: 84
74Literal
75IndexedVarvariable: 104
index: 84
76Literal
77ExprTuple81, 82
78Literal
79ExprTuple106, 83
80ExprTuple84
81IndexedVarvariable: 85
index: 106
82Operationoperator: 86
operands: 87
83Operationoperator: 88
operands: 89
84Variable
85Variable
86Literal
87ExprTuple90, 91
88Literal
89ExprTuple92, 93
90Operationoperator: 95
operand: 99
91Operationoperator: 95
operand: 100
92Literal
93Operationoperator: 97
operands: 98
94ExprTuple99
95Literal
96ExprTuple100
97Literal
98ExprTuple101, 102
99IndexedVarvariable: 103
index: 106
100IndexedVarvariable: 104
index: 106
101Variable
102Variable
103Variable
104Variable
105ExprTuple106
106Variable