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, V, W, i, j, m, n
from proveit.core_expr_types import v_1_to_m, v_i, w_1_to_n, w_j
from proveit.linear_algebra import OrthoNormBases, VecSum
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_m_kets, w_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = Lambda([v_1_to_m], Conditional(Forall(instance_param_or_params = [w_1_to_n], instance_expr = 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))), condition = InSet(w_1_to_n_kets, OrthoNormBases(W))).with_wrapping(), InSet(v_1_to_m_kets, OrthoNormBases(V))))
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(v_{1}, v_{2}, \ldots, v_{m}\right) \mapsto \left\{\begin{array}{l}\forall_{w_{1}, w_{2}, \ldots, w_{n}~|~\left\{\lvert w_{1} \rangle, \lvert w_{2} \rangle, \ldots, \lvert w_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(W\right)}~\\
\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)\right)\end{array} \textrm{ if } \left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{m} \rangle\right\} \in \textrm{O.N.Bases}\left(V\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: 78
end_index: 58
4Operationoperator: 7
operand: 10
5Operationoperator: 62
operands: 9
6Lambdaparameter: 59
body: 40
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 13
body: 14
11Operationoperator: 32
operands: 15
12Operationoperator: 34
operand: 21
13ExprTuple17
14Conditionalvalue: 18
condition: 19
15ExprTuple20
16ExprTuple21
17ExprRangelambda_map: 22
start_index: 78
end_index: 79
18Operationoperator: 23
operands: 24
19Operationoperator: 62
operands: 25
20ExprRangelambda_map: 26
start_index: 78
end_index: 58
21Variable
22Lambdaparameter: 59
body: 52
23Literal
24ExprTuple65, 27
25ExprTuple28, 29
26Lambdaparameter: 59
body: 30
27Operationoperator: 46
operand: 37
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operand: 39
30Operationoperator: 70
operand: 40
31ExprTuple37
32Literal
33ExprTuple38
34Literal
35ExprTuple39
36ExprTuple40
37Lambdaparameter: 85
body: 41
38ExprRangelambda_map: 42
start_index: 78
end_index: 79
39Variable
40IndexedVarvariable: 82
index: 59
41Conditionalvalue: 43
condition: 44
42Lambdaparameter: 59
body: 45
43Operationoperator: 46
operand: 50
44Operationoperator: 62
operands: 48
45Operationoperator: 70
operand: 52
46Literal
47ExprTuple50
48ExprTuple85, 51
49ExprTuple52
50Lambdaparameter: 84
body: 53
51Operationoperator: 74
operands: 54
52IndexedVarvariable: 80
index: 59
53Conditionalvalue: 56
condition: 57
54ExprTuple78, 58
55ExprTuple59
56Operationoperator: 60
operands: 61
57Operationoperator: 62
operands: 63
58Variable
59Variable
60Literal
61ExprTuple64, 65, 66, 67, 68
62Literal
63ExprTuple84, 69
64Operationoperator: 72
operand: 76
65Variable
66Operationoperator: 70
operand: 77
67Operationoperator: 70
operand: 76
68Operationoperator: 72
operand: 77
69Operationoperator: 74
operands: 75
70Literal
71ExprTuple76
72Literal
73ExprTuple77
74Literal
75ExprTuple78, 79
76IndexedVarvariable: 80
index: 84
77IndexedVarvariable: 82
index: 85
78Literal
79Variable
80Variable
81ExprTuple84
82Variable
83ExprTuple85
84Variable
85Variable