logo

Expression of type ExprTuple

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, ExprTuple, Lambda, 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 = ExprTuple(Lambda([A, B], 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(\left(A, B\right) \mapsto \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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 26
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 59
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple10, 11, 12, 13
8Operationoperator: 68
operands: 14
9Operationoperator: 38
operand: 22
10Operationoperator: 98
operands: 16
11Operationoperator: 98
operands: 17
12Operationoperator: 68
operands: 18
13Operationoperator: 68
operands: 19
14ExprTuple20, 21
15ExprTuple22
16ExprTuple72, 33
17ExprTuple74, 33
18ExprTuple23, 72
19ExprTuple24, 74
20Operationoperator: 25
operands: 26
21Operationoperator: 27
operand: 33
22Lambdaparameters: 47
body: 29
23Operationoperator: 31
operand: 72
24Operationoperator: 31
operand: 74
25Literal
26ExprTuple72, 74
27Literal
28ExprTuple33
29Conditionalvalue: 34
condition: 35
30ExprTuple72
31Literal
32ExprTuple74
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operand: 41
35Operationoperator: 98
operands: 40
36Literal
37ExprTuple55, 55
38Literal
39ExprTuple41
40ExprTuple42, 43
41Lambdaparameters: 44
body: 45
42Operationoperator: 46
operands: 47
43Operationoperator: 48
operand: 55
44ExprTuple50, 51
45Conditionalvalue: 52
condition: 53
46Literal
47ExprTuple54
48Literal
49ExprTuple55
50ExprRangelambda_map: 56
start_index: 112
end_index: 113
51ExprRangelambda_map: 57
start_index: 112
end_index: 113
52Operationoperator: 59
operands: 58
53Operationoperator: 59
operands: 60
54ExprRangelambda_map: 61
start_index: 112
end_index: 113
55Variable
56Lambdaparameter: 94
body: 85
57Lambdaparameter: 94
body: 86
58ExprTuple62, 63
59Literal
60ExprTuple64, 65
61Lambdaparameter: 94
body: 66
62Operationoperator: 68
operands: 67
63Operationoperator: 68
operands: 69
64ExprRangelambda_map: 70
start_index: 112
end_index: 113
65ExprRangelambda_map: 71
start_index: 112
end_index: 113
66IndexedVarvariable: 118
index: 94
67ExprTuple72, 73
68Literal
69ExprTuple74, 75
70Lambdaparameter: 94
body: 76
71Lambdaparameter: 94
body: 77
72Variable
73Operationoperator: 79
operand: 83
74Variable
75Operationoperator: 79
operand: 84
76Operationoperator: 98
operands: 81
77Operationoperator: 98
operands: 82
78ExprTuple83
79Literal
80ExprTuple84
81ExprTuple85, 87
82ExprTuple86, 87
83Lambdaparameter: 120
body: 88
84Lambdaparameter: 120
body: 89
85IndexedVarvariable: 104
index: 94
86IndexedVarvariable: 105
index: 94
87Literal
88Conditionalvalue: 91
condition: 93
89Conditionalvalue: 92
condition: 93
90ExprTuple94
91Operationoperator: 96
operands: 95
92Operationoperator: 96
operands: 97
93Operationoperator: 98
operands: 99
94Variable
95ExprTuple100, 102
96Literal
97ExprTuple101, 102
98Literal
99ExprTuple120, 103
100IndexedVarvariable: 104
index: 120
101IndexedVarvariable: 105
index: 120
102Operationoperator: 106
operands: 107
103Operationoperator: 108
operands: 109
104Variable
105Variable
106Literal
107ExprTuple110, 111
108Literal
109ExprTuple112, 113
110Operationoperator: 114
operand: 117
111Operationoperator: 115
operand: 117
112Literal
113Variable
114Literal
115Literal
116ExprTuple117
117IndexedVarvariable: 118
index: 120
118Variable
119ExprTuple120
120Variable