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 OrthoNormBases, ScalarMult, VecSum
from proveit.logic import And, CartExp, 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(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_{v_{1}, v_{2}, \ldots, v_{n}~|~\left\{v_{1}, v_{2}, \ldots, v_{n}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{n}\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: 68
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: 82
end_index: 83
19ExprRangelambda_map: 25
start_index: 82
end_index: 83
20Operationoperator: 27
operands: 26
21Operationoperator: 27
operands: 28
22ExprRangelambda_map: 29
start_index: 82
end_index: 83
23Operationoperator: 30
operands: 31
24Lambdaparameter: 64
body: 55
25Lambdaparameter: 64
body: 56
26ExprTuple32, 33
27Literal
28ExprTuple34, 35
29Lambdaparameter: 64
body: 36
30Literal
31ExprTuple57, 83
32Operationoperator: 38
operands: 37
33Operationoperator: 38
operands: 39
34ExprRangelambda_map: 40
start_index: 82
end_index: 83
35ExprRangelambda_map: 41
start_index: 82
end_index: 83
36IndexedVarvariable: 88
index: 64
37ExprTuple42, 43
38Literal
39ExprTuple44, 45
40Lambdaparameter: 64
body: 46
41Lambdaparameter: 64
body: 47
42Variable
43Operationoperator: 49
operand: 53
44Variable
45Operationoperator: 49
operand: 54
46Operationoperator: 68
operands: 51
47Operationoperator: 68
operands: 52
48ExprTuple53
49Literal
50ExprTuple54
51ExprTuple55, 57
52ExprTuple56, 57
53Lambdaparameter: 90
body: 58
54Lambdaparameter: 90
body: 59
55IndexedVarvariable: 74
index: 64
56IndexedVarvariable: 75
index: 64
57Literal
58Conditionalvalue: 61
condition: 63
59Conditionalvalue: 62
condition: 63
60ExprTuple64
61Operationoperator: 66
operands: 65
62Operationoperator: 66
operands: 67
63Operationoperator: 68
operands: 69
64Variable
65ExprTuple70, 72
66Literal
67ExprTuple71, 72
68Literal
69ExprTuple90, 73
70IndexedVarvariable: 74
index: 90
71IndexedVarvariable: 75
index: 90
72Operationoperator: 76
operands: 77
73Operationoperator: 78
operands: 79
74Variable
75Variable
76Literal
77ExprTuple80, 81
78Literal
79ExprTuple82, 83
80Operationoperator: 84
operand: 87
81Operationoperator: 85
operand: 87
82Literal
83Variable
84Literal
85Literal
86ExprTuple87
87IndexedVarvariable: 88
index: 90
88Variable
89ExprTuple90
90Variable