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, Conditional, Lambda, W, i, j, m, n
from proveit.core_expr_types import v_i, w_1_to_n, w_j
from proveit.linear_algebra import OrthoNormBases, VecSum
from proveit.logic import Equals, InSet
from proveit.numbers import Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import w_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = Lambda([w_1_to_n], Conditional(Equals(A, VecSum(index_or_indices = [i], summand = VecSum(index_or_indices = [j], summand = Qmult(Bra(w_j), A, Ket(v_i), Ket(w_j), Bra(v_i)), domain = Interval(one, n)), domain = Interval(one, m))), InSet(w_1_to_n_kets, OrthoNormBases(W))))
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(w_{1}, w_{2}, \ldots, w_{n}\right) \mapsto \left\{A = \left(\sum_{i=1}^{m} \left(\sum_{j=1}^{n} \left(\langle w_{j} \rvert \thinspace A \thinspace \lvert v_{i} \rangle \thinspace \lvert w_{j} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right) \textrm{ if } \left\{\lvert w_{1} \rangle, \lvert w_{2} \rangle, \ldots, \lvert w_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(W\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple3
2Conditionalvalue: 4
condition: 5
3ExprRangelambda_map: 6
start_index: 58
end_index: 59
4Operationoperator: 7
operands: 8
5Operationoperator: 42
operands: 9
6Lambdaparameter: 39
body: 32
7Literal
8ExprTuple45, 10
9ExprTuple11, 12
10Operationoperator: 26
operand: 18
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operand: 20
13ExprTuple18
14Literal
15ExprTuple19
16Literal
17ExprTuple20
18Lambdaparameter: 65
body: 21
19ExprRangelambda_map: 22
start_index: 58
end_index: 59
20Variable
21Conditionalvalue: 23
condition: 24
22Lambdaparameter: 39
body: 25
23Operationoperator: 26
operand: 30
24Operationoperator: 42
operands: 28
25Operationoperator: 50
operand: 32
26Literal
27ExprTuple30
28ExprTuple65, 31
29ExprTuple32
30Lambdaparameter: 64
body: 33
31Operationoperator: 54
operands: 34
32IndexedVarvariable: 60
index: 39
33Conditionalvalue: 36
condition: 37
34ExprTuple58, 38
35ExprTuple39
36Operationoperator: 40
operands: 41
37Operationoperator: 42
operands: 43
38Variable
39Variable
40Literal
41ExprTuple44, 45, 46, 47, 48
42Literal
43ExprTuple64, 49
44Operationoperator: 52
operand: 56
45Variable
46Operationoperator: 50
operand: 57
47Operationoperator: 50
operand: 56
48Operationoperator: 52
operand: 57
49Operationoperator: 54
operands: 55
50Literal
51ExprTuple56
52Literal
53ExprTuple57
54Literal
55ExprTuple58, 59
56IndexedVarvariable: 60
index: 64
57IndexedVarvariable: 62
index: 65
58Literal
59Variable
60Variable
61ExprTuple64
62Variable
63ExprTuple65
64Variable
65Variable