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, Dim, HilbertSpaces, Hspace, LinMap, OrthoNormBases, ScalarMult, VecSum, VecZero
from proveit.logic import And, Equals, Exists, Forall, Iff, InClass, 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(Hspace, Conditional(Forall(instance_param_or_params = [A, B], instance_expr = 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), domain = sub_expr2, conditions = [Equals(Adj(A), A), Equals(Adj(B), B)]).with_wrapping(), And(InClass(Hspace, HilbertSpaces), Equals(Dim(Hspace), n)))))
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(\mathcal{H} \mapsto \left\{\begin{array}{l}\forall_{A, B \in \mathcal{L}\left(\mathcal{H}, \mathcal{H}\right)~|~A^{\dagger} = A, B^{\dagger} = B}~\\
\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}\right)\end{array} \textrm{ if } \mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  \textrm{Dim}\left(\mathcal{H}\right) = n\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
1Lambdaparameter: 70
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 74
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 41
body: 11
9Operationoperator: 12
operands: 13
10Operationoperator: 83
operands: 14
11Conditionalvalue: 15
condition: 16
12Literal
13ExprTuple70, 17
14ExprTuple18, 128
15Operationoperator: 19
operands: 20
16Operationoperator: 74
operands: 21
17Literal
18Operationoperator: 22
operand: 70
19Literal
20ExprTuple23, 24
21ExprTuple25, 26, 27, 28
22Literal
23Operationoperator: 83
operands: 29
24Operationoperator: 53
operand: 37
25Operationoperator: 113
operands: 31
26Operationoperator: 113
operands: 32
27Operationoperator: 83
operands: 33
28Operationoperator: 83
operands: 34
29ExprTuple35, 36
30ExprTuple37
31ExprTuple87, 48
32ExprTuple89, 48
33ExprTuple38, 87
34ExprTuple39, 89
35Operationoperator: 40
operands: 41
36Operationoperator: 42
operand: 48
37Lambdaparameters: 62
body: 44
38Operationoperator: 46
operand: 87
39Operationoperator: 46
operand: 89
40Literal
41ExprTuple87, 89
42Literal
43ExprTuple48
44Conditionalvalue: 49
condition: 50
45ExprTuple87
46Literal
47ExprTuple89
48Operationoperator: 51
operands: 52
49Operationoperator: 53
operand: 56
50Operationoperator: 113
operands: 55
51Literal
52ExprTuple70, 70
53Literal
54ExprTuple56
55ExprTuple57, 58
56Lambdaparameters: 59
body: 60
57Operationoperator: 61
operands: 62
58Operationoperator: 63
operand: 70
59ExprTuple65, 66
60Conditionalvalue: 67
condition: 68
61Literal
62ExprTuple69
63Literal
64ExprTuple70
65ExprRangelambda_map: 71
start_index: 127
end_index: 128
66ExprRangelambda_map: 72
start_index: 127
end_index: 128
67Operationoperator: 74
operands: 73
68Operationoperator: 74
operands: 75
69ExprRangelambda_map: 76
start_index: 127
end_index: 128
70Variable
71Lambdaparameter: 109
body: 100
72Lambdaparameter: 109
body: 101
73ExprTuple77, 78
74Literal
75ExprTuple79, 80
76Lambdaparameter: 109
body: 81
77Operationoperator: 83
operands: 82
78Operationoperator: 83
operands: 84
79ExprRangelambda_map: 85
start_index: 127
end_index: 128
80ExprRangelambda_map: 86
start_index: 127
end_index: 128
81IndexedVarvariable: 133
index: 109
82ExprTuple87, 88
83Literal
84ExprTuple89, 90
85Lambdaparameter: 109
body: 91
86Lambdaparameter: 109
body: 92
87Variable
88Operationoperator: 94
operand: 98
89Variable
90Operationoperator: 94
operand: 99
91Operationoperator: 113
operands: 96
92Operationoperator: 113
operands: 97
93ExprTuple98
94Literal
95ExprTuple99
96ExprTuple100, 102
97ExprTuple101, 102
98Lambdaparameter: 135
body: 103
99Lambdaparameter: 135
body: 104
100IndexedVarvariable: 119
index: 109
101IndexedVarvariable: 120
index: 109
102Literal
103Conditionalvalue: 106
condition: 108
104Conditionalvalue: 107
condition: 108
105ExprTuple109
106Operationoperator: 111
operands: 110
107Operationoperator: 111
operands: 112
108Operationoperator: 113
operands: 114
109Variable
110ExprTuple115, 117
111Literal
112ExprTuple116, 117
113Literal
114ExprTuple135, 118
115IndexedVarvariable: 119
index: 135
116IndexedVarvariable: 120
index: 135
117Operationoperator: 121
operands: 122
118Operationoperator: 123
operands: 124
119Variable
120Variable
121Literal
122ExprTuple125, 126
123Literal
124ExprTuple127, 128
125Operationoperator: 129
operand: 132
126Operationoperator: 130
operand: 132
127Literal
128Variable
129Literal
130Literal
131ExprTuple132
132IndexedVarvariable: 133
index: 135
133Variable
134ExprTuple135
135Variable