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, MatrixSpace, OrthoNormBases, ScalarMult, VecSum, VecZero
from proveit.logic import And, CartExp, Equals, Exists, Forall, Iff, InSet, Set
from proveit.numbers import Complex, Interval, NaturalPos, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
sub_expr2 = MatrixSpace(field = Complex, rows = n, columns = n)
sub_expr3 = Interval(one, n)
sub_expr4 = Qmult(Ket(v_i), Bra(v_i))
expr = Lambda(n, 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(CartExp(Complex, n)))).with_wrapping()).with_wrapping_at(2), domain = sub_expr2, conditions = [Equals(Adj(A), A), Equals(Adj(B), B)]).with_wrapping(), InSet(n, NaturalPos)))
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())
n \mapsto \left\{\begin{array}{l}\forall_{A, B \in \mathbb{C}^{n \times n}~|~A^{\dagger} = A, B^{\dagger} = B}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left[A, B\right] = \vec{0}\left(\mathbb{C}^{n \times n}\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(\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}\right] \end{array} \end{array}\right)\end{array} \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 123
body: 2
1ExprTuple123
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 108
operands: 7
5Literal
6ExprTuple8
7ExprTuple123, 9
8Lambdaparameters: 34
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 67
operands: 15
13Literal
14ExprTuple16, 17
15ExprTuple18, 19, 20, 21
16Operationoperator: 78
operands: 22
17Operationoperator: 46
operand: 30
18Operationoperator: 108
operands: 24
19Operationoperator: 108
operands: 25
20Operationoperator: 78
operands: 26
21Operationoperator: 78
operands: 27
22ExprTuple28, 29
23ExprTuple30
24ExprTuple82, 41
25ExprTuple84, 41
26ExprTuple31, 82
27ExprTuple32, 84
28Operationoperator: 33
operands: 34
29Operationoperator: 35
operand: 41
30Lambdaparameters: 55
body: 37
31Operationoperator: 39
operand: 82
32Operationoperator: 39
operand: 84
33Literal
34ExprTuple82, 84
35Literal
36ExprTuple41
37Conditionalvalue: 42
condition: 43
38ExprTuple82
39Literal
40ExprTuple84
41Operationoperator: 44
operands: 45
42Operationoperator: 46
operand: 49
43Operationoperator: 108
operands: 48
44Literal
45NamedExprsfield: 97
rows: 123
columns: 123
46Literal
47ExprTuple49
48ExprTuple50, 51
49Lambdaparameters: 52
body: 53
50Operationoperator: 54
operands: 55
51Operationoperator: 56
operand: 63
52ExprTuple58, 59
53Conditionalvalue: 60
condition: 61
54Literal
55ExprTuple62
56Literal
57ExprTuple63
58ExprRangelambda_map: 64
start_index: 122
end_index: 123
59ExprRangelambda_map: 65
start_index: 122
end_index: 123
60Operationoperator: 67
operands: 66
61Operationoperator: 67
operands: 68
62ExprRangelambda_map: 69
start_index: 122
end_index: 123
63Operationoperator: 70
operands: 71
64Lambdaparameter: 104
body: 95
65Lambdaparameter: 104
body: 96
66ExprTuple72, 73
67Literal
68ExprTuple74, 75
69Lambdaparameter: 104
body: 76
70Literal
71ExprTuple97, 123
72Operationoperator: 78
operands: 77
73Operationoperator: 78
operands: 79
74ExprRangelambda_map: 80
start_index: 122
end_index: 123
75ExprRangelambda_map: 81
start_index: 122
end_index: 123
76IndexedVarvariable: 128
index: 104
77ExprTuple82, 83
78Literal
79ExprTuple84, 85
80Lambdaparameter: 104
body: 86
81Lambdaparameter: 104
body: 87
82Variable
83Operationoperator: 89
operand: 93
84Variable
85Operationoperator: 89
operand: 94
86Operationoperator: 108
operands: 91
87Operationoperator: 108
operands: 92
88ExprTuple93
89Literal
90ExprTuple94
91ExprTuple95, 97
92ExprTuple96, 97
93Lambdaparameter: 130
body: 98
94Lambdaparameter: 130
body: 99
95IndexedVarvariable: 114
index: 104
96IndexedVarvariable: 115
index: 104
97Literal
98Conditionalvalue: 101
condition: 103
99Conditionalvalue: 102
condition: 103
100ExprTuple104
101Operationoperator: 106
operands: 105
102Operationoperator: 106
operands: 107
103Operationoperator: 108
operands: 109
104Variable
105ExprTuple110, 112
106Literal
107ExprTuple111, 112
108Literal
109ExprTuple130, 113
110IndexedVarvariable: 114
index: 130
111IndexedVarvariable: 115
index: 130
112Operationoperator: 116
operands: 117
113Operationoperator: 118
operands: 119
114Variable
115Variable
116Literal
117ExprTuple120, 121
118Literal
119ExprTuple122, 123
120Operationoperator: 124
operand: 127
121Operationoperator: 125
operand: 127
122Literal
123Variable
124Literal
125Literal
126ExprTuple127
127IndexedVarvariable: 128
index: 130
128Variable
129ExprTuple130
130Variable