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 LinMap, OrthoNormBases, VecSum
from proveit.logic import 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(A, Conditional(Forall(instance_param_or_params = [m, n], instance_expr = 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(), domain = NaturalPos), InSet(A, LinMap(V, 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())
A \mapsto \left\{\forall_{m, n \in \mathbb{N}^+}~\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}\right] \textrm{ if } A \in \mathcal{L}\left(V, 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
0Lambdaparameter: 88
body: 2
1ExprTuple88
2Conditionalvalue: 3
condition: 4
3Operationoperator: 30
operand: 7
4Operationoperator: 85
operands: 6
5ExprTuple7
6ExprTuple88, 8
7Lambdaparameters: 9
body: 10
8Operationoperator: 11
operands: 12
9ExprTuple81, 102
10Conditionalvalue: 13
condition: 14
11Literal
12ExprTuple44, 62
13Operationoperator: 30
operand: 18
14Operationoperator: 16
operands: 17
15ExprTuple18
16Literal
17ExprTuple19, 20
18Lambdaparameters: 21
body: 22
19Operationoperator: 85
operands: 23
20Operationoperator: 85
operands: 24
21ExprTuple25
22Conditionalvalue: 26
condition: 27
23ExprTuple81, 28
24ExprTuple102, 28
25ExprRangelambda_map: 29
start_index: 101
end_index: 81
26Operationoperator: 30
operand: 33
27Operationoperator: 85
operands: 32
28Literal
29Lambdaparameter: 82
body: 63
30Literal
31ExprTuple33
32ExprTuple34, 35
33Lambdaparameters: 36
body: 37
34Operationoperator: 55
operands: 38
35Operationoperator: 57
operand: 44
36ExprTuple40
37Conditionalvalue: 41
condition: 42
38ExprTuple43
39ExprTuple44
40ExprRangelambda_map: 45
start_index: 101
end_index: 102
41Operationoperator: 46
operands: 47
42Operationoperator: 85
operands: 48
43ExprRangelambda_map: 49
start_index: 101
end_index: 81
44Variable
45Lambdaparameter: 82
body: 75
46Literal
47ExprTuple88, 50
48ExprTuple51, 52
49Lambdaparameter: 82
body: 53
50Operationoperator: 69
operand: 60
51Operationoperator: 55
operands: 56
52Operationoperator: 57
operand: 62
53Operationoperator: 93
operand: 63
54ExprTuple60
55Literal
56ExprTuple61
57Literal
58ExprTuple62
59ExprTuple63
60Lambdaparameter: 108
body: 64
61ExprRangelambda_map: 65
start_index: 101
end_index: 102
62Variable
63IndexedVarvariable: 105
index: 82
64Conditionalvalue: 66
condition: 67
65Lambdaparameter: 82
body: 68
66Operationoperator: 69
operand: 73
67Operationoperator: 85
operands: 71
68Operationoperator: 93
operand: 75
69Literal
70ExprTuple73
71ExprTuple108, 74
72ExprTuple75
73Lambdaparameter: 107
body: 76
74Operationoperator: 97
operands: 77
75IndexedVarvariable: 103
index: 82
76Conditionalvalue: 79
condition: 80
77ExprTuple101, 81
78ExprTuple82
79Operationoperator: 83
operands: 84
80Operationoperator: 85
operands: 86
81Variable
82Variable
83Literal
84ExprTuple87, 88, 89, 90, 91
85Literal
86ExprTuple107, 92
87Operationoperator: 95
operand: 99
88Variable
89Operationoperator: 93
operand: 100
90Operationoperator: 93
operand: 99
91Operationoperator: 95
operand: 100
92Operationoperator: 97
operands: 98
93Literal
94ExprTuple99
95Literal
96ExprTuple100
97Literal
98ExprTuple101, 102
99IndexedVarvariable: 103
index: 107
100IndexedVarvariable: 105
index: 108
101Literal
102Variable
103Variable
104ExprTuple107
105Variable
106ExprTuple108
107Variable
108Variable