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_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 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 = [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()
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_{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}
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: 9
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple5
4Conditionalvalue: 6
condition: 7
5ExprRangelambda_map: 8
start_index: 70
end_index: 80
6Operationoperator: 9
operand: 12
7Operationoperator: 56
operands: 11
8Lambdaparameter: 62
body: 53
9Literal
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameters: 15
body: 16
13Operationoperator: 30
operand: 23
14Operationoperator: 18
operand: 24
15ExprTuple20
16Conditionalvalue: 21
condition: 22
17ExprTuple23
18Literal
19ExprTuple24
20ExprRangelambda_map: 25
start_index: 70
end_index: 71
21Operationoperator: 26
operands: 27
22Operationoperator: 28
operands: 29
23Operationoperator: 30
operands: 31
24Operationoperator: 32
operands: 33
25Lambdaparameter: 62
body: 51
26Literal
27ExprTuple34, 35
28Literal
29ExprTuple36
30Literal
31ExprTuple37
32Literal
33ExprTuple38, 80
34Variable
35Operationoperator: 39
operand: 43
36ExprRangelambda_map: 41
start_index: 70
end_index: 71
37ExprRangelambda_map: 42
start_index: 70
end_index: 80
38Literal
39Literal
40ExprTuple43
41Lambdaparameter: 62
body: 44
42Lambdaparameter: 62
body: 45
43Lambdaparameter: 84
body: 46
44Operationoperator: 56
operands: 47
45Operationoperator: 73
operand: 53
46Conditionalvalue: 49
condition: 50
47ExprTuple51, 52
48ExprTuple53
49Operationoperator: 54
operands: 55
50Operationoperator: 56
operands: 57
51IndexedVarvariable: 63
index: 62
52Literal
53IndexedVarvariable: 82
index: 62
54Literal
55ExprTuple59, 60
56Literal
57ExprTuple84, 61
58ExprTuple62
59IndexedVarvariable: 63
index: 84
60Operationoperator: 64
operands: 65
61Operationoperator: 66
operands: 67
62Variable
63Variable
64Literal
65ExprTuple68, 69
66Literal
67ExprTuple70, 71
68Operationoperator: 73
operand: 77
69Operationoperator: 73
operand: 78
70Literal
71Operationoperator: 75
operands: 76
72ExprTuple77
73Literal
74ExprTuple78
75Literal
76ExprTuple79, 80
77IndexedVarvariable: 81
index: 84
78IndexedVarvariable: 82
index: 84
79Variable
80Variable
81Variable
82Variable
83ExprTuple84
84Variable