logo

Expression of type Lambda

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, 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 = 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(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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 25
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 58
operands: 6
4Literal
5ExprTuple7, 8
6ExprTuple9, 10, 11, 12
7Operationoperator: 67
operands: 13
8Operationoperator: 37
operand: 21
9Operationoperator: 97
operands: 15
10Operationoperator: 97
operands: 16
11Operationoperator: 67
operands: 17
12Operationoperator: 67
operands: 18
13ExprTuple19, 20
14ExprTuple21
15ExprTuple71, 32
16ExprTuple73, 32
17ExprTuple22, 71
18ExprTuple23, 73
19Operationoperator: 24
operands: 25
20Operationoperator: 26
operand: 32
21Lambdaparameters: 46
body: 28
22Operationoperator: 30
operand: 71
23Operationoperator: 30
operand: 73
24Literal
25ExprTuple71, 73
26Literal
27ExprTuple32
28Conditionalvalue: 33
condition: 34
29ExprTuple71
30Literal
31ExprTuple73
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operand: 40
34Operationoperator: 97
operands: 39
35Literal
36ExprTuple54, 54
37Literal
38ExprTuple40
39ExprTuple41, 42
40Lambdaparameters: 43
body: 44
41Operationoperator: 45
operands: 46
42Operationoperator: 47
operand: 54
43ExprTuple49, 50
44Conditionalvalue: 51
condition: 52
45Literal
46ExprTuple53
47Literal
48ExprTuple54
49ExprRangelambda_map: 55
start_index: 111
end_index: 112
50ExprRangelambda_map: 56
start_index: 111
end_index: 112
51Operationoperator: 58
operands: 57
52Operationoperator: 58
operands: 59
53ExprRangelambda_map: 60
start_index: 111
end_index: 112
54Variable
55Lambdaparameter: 93
body: 84
56Lambdaparameter: 93
body: 85
57ExprTuple61, 62
58Literal
59ExprTuple63, 64
60Lambdaparameter: 93
body: 65
61Operationoperator: 67
operands: 66
62Operationoperator: 67
operands: 68
63ExprRangelambda_map: 69
start_index: 111
end_index: 112
64ExprRangelambda_map: 70
start_index: 111
end_index: 112
65IndexedVarvariable: 117
index: 93
66ExprTuple71, 72
67Literal
68ExprTuple73, 74
69Lambdaparameter: 93
body: 75
70Lambdaparameter: 93
body: 76
71Variable
72Operationoperator: 78
operand: 82
73Variable
74Operationoperator: 78
operand: 83
75Operationoperator: 97
operands: 80
76Operationoperator: 97
operands: 81
77ExprTuple82
78Literal
79ExprTuple83
80ExprTuple84, 86
81ExprTuple85, 86
82Lambdaparameter: 119
body: 87
83Lambdaparameter: 119
body: 88
84IndexedVarvariable: 103
index: 93
85IndexedVarvariable: 104
index: 93
86Literal
87Conditionalvalue: 90
condition: 92
88Conditionalvalue: 91
condition: 92
89ExprTuple93
90Operationoperator: 95
operands: 94
91Operationoperator: 95
operands: 96
92Operationoperator: 97
operands: 98
93Variable
94ExprTuple99, 101
95Literal
96ExprTuple100, 101
97Literal
98ExprTuple119, 102
99IndexedVarvariable: 103
index: 119
100IndexedVarvariable: 104
index: 119
101Operationoperator: 105
operands: 106
102Operationoperator: 107
operands: 108
103Variable
104Variable
105Literal
106ExprTuple109, 110
107Literal
108ExprTuple111, 112
109Operationoperator: 113
operand: 116
110Operationoperator: 114
operand: 116
111Literal
112Variable
113Literal
114Literal
115ExprTuple116
116IndexedVarvariable: 117
index: 119
117Variable
118ExprTuple119
119Variable