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 And, Equals, Forall, InSet
from proveit.numbers import Interval, NaturalPos, 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([m, n], Conditional(Forall(instance_param_or_params = [v_1_to_m], instance_expr = 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(), condition = InSet(v_1_to_m_kets, OrthoNormBases(V))).with_wrapping(), And(InSet(m, NaturalPos), 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())
\left(m, n\right) \mapsto \left\{\begin{array}{l}\forall_{v_{1}, v_{2}, \ldots, v_{m}~|~\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{m} \rangle\right\} \in \textrm{O.N.Bases}\left(V\right)}~\\
\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}\right]\end{array} \textrm{ if } m \in \mathbb{N}^+ ,  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
0Lambdaparameters: 1
body: 2
1ExprTuple71, 92
2Conditionalvalue: 3
condition: 4
3Operationoperator: 20
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 75
operands: 13
10Operationoperator: 75
operands: 14
11ExprTuple15
12Conditionalvalue: 16
condition: 17
13ExprTuple71, 18
14ExprTuple92, 18
15ExprRangelambda_map: 19
start_index: 91
end_index: 71
16Operationoperator: 20
operand: 23
17Operationoperator: 75
operands: 22
18Literal
19Lambdaparameter: 72
body: 53
20Literal
21ExprTuple23
22ExprTuple24, 25
23Lambdaparameters: 26
body: 27
24Operationoperator: 45
operands: 28
25Operationoperator: 47
operand: 34
26ExprTuple30
27Conditionalvalue: 31
condition: 32
28ExprTuple33
29ExprTuple34
30ExprRangelambda_map: 35
start_index: 91
end_index: 92
31Operationoperator: 36
operands: 37
32Operationoperator: 75
operands: 38
33ExprRangelambda_map: 39
start_index: 91
end_index: 71
34Variable
35Lambdaparameter: 72
body: 65
36Literal
37ExprTuple78, 40
38ExprTuple41, 42
39Lambdaparameter: 72
body: 43
40Operationoperator: 59
operand: 50
41Operationoperator: 45
operands: 46
42Operationoperator: 47
operand: 52
43Operationoperator: 83
operand: 53
44ExprTuple50
45Literal
46ExprTuple51
47Literal
48ExprTuple52
49ExprTuple53
50Lambdaparameter: 98
body: 54
51ExprRangelambda_map: 55
start_index: 91
end_index: 92
52Variable
53IndexedVarvariable: 95
index: 72
54Conditionalvalue: 56
condition: 57
55Lambdaparameter: 72
body: 58
56Operationoperator: 59
operand: 63
57Operationoperator: 75
operands: 61
58Operationoperator: 83
operand: 65
59Literal
60ExprTuple63
61ExprTuple98, 64
62ExprTuple65
63Lambdaparameter: 97
body: 66
64Operationoperator: 87
operands: 67
65IndexedVarvariable: 93
index: 72
66Conditionalvalue: 69
condition: 70
67ExprTuple91, 71
68ExprTuple72
69Operationoperator: 73
operands: 74
70Operationoperator: 75
operands: 76
71Variable
72Variable
73Literal
74ExprTuple77, 78, 79, 80, 81
75Literal
76ExprTuple97, 82
77Operationoperator: 85
operand: 89
78Variable
79Operationoperator: 83
operand: 90
80Operationoperator: 83
operand: 89
81Operationoperator: 85
operand: 90
82Operationoperator: 87
operands: 88
83Literal
84ExprTuple89
85Literal
86ExprTuple90
87Literal
88ExprTuple91, 92
89IndexedVarvariable: 93
index: 97
90IndexedVarvariable: 95
index: 98
91Literal
92Variable
93Variable
94ExprTuple97
95Variable
96ExprTuple98
97Variable
98Variable