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 A, B, i, n
from proveit.core_expr_types import a_1_to_n, a_i, b_1_to_n, b_i, v_1_to_n, v_i
from proveit.linear_algebra import Hspace, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import And, Equals, Exists, InSet, Set
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
sub_expr2 = Interval(one, n)
sub_expr3 = Qmult(Ket(v_i), Bra(v_i))
expr = Exists(instance_param_or_params = [v_1_to_n], instance_expr = Exists(instance_param_or_params = [a_1_to_n, b_1_to_n], instance_expr = And(Equals(A, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(a_i, sub_expr3), domain = sub_expr2)), Equals(B, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(b_i, sub_expr3), domain = sub_expr2))).with_wrapping_at(2), domain = Complex).with_wrapping(), condition = InSet(Set(v_1_to_n), OrthoNormBases(Hspace))).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_{v_{1}, v_{2}, \ldots, v_{n}~|~\left\{v_{1}, v_{2}, \ldots, v_{n}\right\} \in \textrm{O.N.Bases}\left(\mathcal{H}\right)}~\\
\left[\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n}, b_{1}, b_{2}, \ldots, b_{n} \in \mathbb{C}}~\\
\left(\begin{array}{c} \left(A = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right) \land  \\ \left(B = \left(\sum_{i=1}^{n} \left(b_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\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: 6
operand: 2
1ExprTuple2
2Lambdaparameters: 15
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 66
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 14
operands: 15
11Operationoperator: 16
operand: 23
12ExprTuple18, 19
13Conditionalvalue: 20
condition: 21
14Literal
15ExprTuple22
16Literal
17ExprTuple23
18ExprRangelambda_map: 24
start_index: 80
end_index: 81
19ExprRangelambda_map: 25
start_index: 80
end_index: 81
20Operationoperator: 27
operands: 26
21Operationoperator: 27
operands: 28
22ExprRangelambda_map: 29
start_index: 80
end_index: 81
23Variable
24Lambdaparameter: 62
body: 53
25Lambdaparameter: 62
body: 54
26ExprTuple30, 31
27Literal
28ExprTuple32, 33
29Lambdaparameter: 62
body: 34
30Operationoperator: 36
operands: 35
31Operationoperator: 36
operands: 37
32ExprRangelambda_map: 38
start_index: 80
end_index: 81
33ExprRangelambda_map: 39
start_index: 80
end_index: 81
34IndexedVarvariable: 86
index: 62
35ExprTuple40, 41
36Literal
37ExprTuple42, 43
38Lambdaparameter: 62
body: 44
39Lambdaparameter: 62
body: 45
40Variable
41Operationoperator: 47
operand: 51
42Variable
43Operationoperator: 47
operand: 52
44Operationoperator: 66
operands: 49
45Operationoperator: 66
operands: 50
46ExprTuple51
47Literal
48ExprTuple52
49ExprTuple53, 55
50ExprTuple54, 55
51Lambdaparameter: 88
body: 56
52Lambdaparameter: 88
body: 57
53IndexedVarvariable: 72
index: 62
54IndexedVarvariable: 73
index: 62
55Literal
56Conditionalvalue: 59
condition: 61
57Conditionalvalue: 60
condition: 61
58ExprTuple62
59Operationoperator: 64
operands: 63
60Operationoperator: 64
operands: 65
61Operationoperator: 66
operands: 67
62Variable
63ExprTuple68, 70
64Literal
65ExprTuple69, 70
66Literal
67ExprTuple88, 71
68IndexedVarvariable: 72
index: 88
69IndexedVarvariable: 73
index: 88
70Operationoperator: 74
operands: 75
71Operationoperator: 76
operands: 77
72Variable
73Variable
74Literal
75ExprTuple78, 79
76Literal
77ExprTuple80, 81
78Operationoperator: 82
operand: 85
79Operationoperator: 83
operand: 85
80Literal
81Variable
82Literal
83Literal
84ExprTuple85
85IndexedVarvariable: 86
index: 88
86Variable
87ExprTuple88
88Variable