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 A, B, Conditional, 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 Adj, Commutator, Hspace, LinMap, OrthoNormBases, ScalarMult, VecSum, VecZero
from proveit.logic import And, Equals, Exists, Iff, 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 = LinMap(Hspace, Hspace)
sub_expr3 = Interval(one, n)
sub_expr4 = Qmult(Ket(v_i), Bra(v_i))
expr = Conditional(Iff(Equals(Commutator(A, B), VecZero(sub_expr2)), 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_expr4), domain = sub_expr3)), Equals(B, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(b_i, sub_expr4), domain = sub_expr3))).with_wrapping_at(2), domain = Complex).with_wrapping(), condition = InSet(Set(v_1_to_n), OrthoNormBases(Hspace))).with_wrapping()).with_wrapping_at(2), And(InSet(A, sub_expr2), InSet(B, sub_expr2), Equals(Adj(A), A), Equals(Adj(B), B)))
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}{c} \begin{array}{l} \left(\left[A, B\right] = \vec{0}\left(\mathcal{L}\left(\mathcal{H}, \mathcal{H}\right)\right)\right) \Leftrightarrow  \\ \left[\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}\right] \end{array} \end{array} \textrm{ if } A \in \mathcal{L}\left(\mathcal{H}, \mathcal{H}\right) ,  B \in \mathcal{L}\left(\mathcal{H}, \mathcal{H}\right) ,  A^{\dagger} = A ,  B^{\dagger} = B\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: 3
operands: 4
2Operationoperator: 57
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple8, 9, 10, 11
6Operationoperator: 66
operands: 12
7Operationoperator: 36
operand: 20
8Operationoperator: 96
operands: 14
9Operationoperator: 96
operands: 15
10Operationoperator: 66
operands: 16
11Operationoperator: 66
operands: 17
12ExprTuple18, 19
13ExprTuple20
14ExprTuple70, 31
15ExprTuple72, 31
16ExprTuple21, 70
17ExprTuple22, 72
18Operationoperator: 23
operands: 24
19Operationoperator: 25
operand: 31
20Lambdaparameters: 45
body: 27
21Operationoperator: 29
operand: 70
22Operationoperator: 29
operand: 72
23Literal
24ExprTuple70, 72
25Literal
26ExprTuple31
27Conditionalvalue: 32
condition: 33
28ExprTuple70
29Literal
30ExprTuple72
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operand: 39
33Operationoperator: 96
operands: 38
34Literal
35ExprTuple53, 53
36Literal
37ExprTuple39
38ExprTuple40, 41
39Lambdaparameters: 42
body: 43
40Operationoperator: 44
operands: 45
41Operationoperator: 46
operand: 53
42ExprTuple48, 49
43Conditionalvalue: 50
condition: 51
44Literal
45ExprTuple52
46Literal
47ExprTuple53
48ExprRangelambda_map: 54
start_index: 110
end_index: 111
49ExprRangelambda_map: 55
start_index: 110
end_index: 111
50Operationoperator: 57
operands: 56
51Operationoperator: 57
operands: 58
52ExprRangelambda_map: 59
start_index: 110
end_index: 111
53Variable
54Lambdaparameter: 92
body: 83
55Lambdaparameter: 92
body: 84
56ExprTuple60, 61
57Literal
58ExprTuple62, 63
59Lambdaparameter: 92
body: 64
60Operationoperator: 66
operands: 65
61Operationoperator: 66
operands: 67
62ExprRangelambda_map: 68
start_index: 110
end_index: 111
63ExprRangelambda_map: 69
start_index: 110
end_index: 111
64IndexedVarvariable: 116
index: 92
65ExprTuple70, 71
66Literal
67ExprTuple72, 73
68Lambdaparameter: 92
body: 74
69Lambdaparameter: 92
body: 75
70Variable
71Operationoperator: 77
operand: 81
72Variable
73Operationoperator: 77
operand: 82
74Operationoperator: 96
operands: 79
75Operationoperator: 96
operands: 80
76ExprTuple81
77Literal
78ExprTuple82
79ExprTuple83, 85
80ExprTuple84, 85
81Lambdaparameter: 118
body: 86
82Lambdaparameter: 118
body: 87
83IndexedVarvariable: 102
index: 92
84IndexedVarvariable: 103
index: 92
85Literal
86Conditionalvalue: 89
condition: 91
87Conditionalvalue: 90
condition: 91
88ExprTuple92
89Operationoperator: 94
operands: 93
90Operationoperator: 94
operands: 95
91Operationoperator: 96
operands: 97
92Variable
93ExprTuple98, 100
94Literal
95ExprTuple99, 100
96Literal
97ExprTuple118, 101
98IndexedVarvariable: 102
index: 118
99IndexedVarvariable: 103
index: 118
100Operationoperator: 104
operands: 105
101Operationoperator: 106
operands: 107
102Variable
103Variable
104Literal
105ExprTuple108, 109
106Literal
107ExprTuple110, 111
108Operationoperator: 112
operand: 115
109Operationoperator: 113
operand: 115
110Literal
111Variable
112Literal
113Literal
114ExprTuple115
115IndexedVarvariable: 116
index: 118
116Variable
117ExprTuple118
118Variable