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 HilbertSpaces, LinMap, OrthoNormBases, VecSum
from proveit.logic import And, Equals, Forall, InClass, 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([V, W], Conditional(Forall(instance_param_or_params = [A], instance_expr = 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), domain = LinMap(V, W)), And(InClass(V, HilbertSpaces), InClass(W, HilbertSpaces))))
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, W\right) \mapsto \left\{\forall_{A \in \mathcal{L}\left(V, W\right)}~\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]\right] \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  W \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 24
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 42
operand: 6
3Operationoperator: 28
operands: 5
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 100
body: 10
7Operationoperator: 12
operands: 11
8Operationoperator: 12
operands: 13
9ExprTuple100
10Conditionalvalue: 14
condition: 15
11ExprTuple56, 16
12Literal
13ExprTuple74, 16
14Operationoperator: 42
operand: 19
15Operationoperator: 97
operands: 18
16Literal
17ExprTuple19
18ExprTuple100, 20
19Lambdaparameters: 21
body: 22
20Operationoperator: 23
operands: 24
21ExprTuple93, 114
22Conditionalvalue: 25
condition: 26
23Literal
24ExprTuple56, 74
25Operationoperator: 42
operand: 30
26Operationoperator: 28
operands: 29
27ExprTuple30
28Literal
29ExprTuple31, 32
30Lambdaparameters: 33
body: 34
31Operationoperator: 97
operands: 35
32Operationoperator: 97
operands: 36
33ExprTuple37
34Conditionalvalue: 38
condition: 39
35ExprTuple93, 40
36ExprTuple114, 40
37ExprRangelambda_map: 41
start_index: 113
end_index: 93
38Operationoperator: 42
operand: 45
39Operationoperator: 97
operands: 44
40Literal
41Lambdaparameter: 94
body: 75
42Literal
43ExprTuple45
44ExprTuple46, 47
45Lambdaparameters: 48
body: 49
46Operationoperator: 67
operands: 50
47Operationoperator: 69
operand: 56
48ExprTuple52
49Conditionalvalue: 53
condition: 54
50ExprTuple55
51ExprTuple56
52ExprRangelambda_map: 57
start_index: 113
end_index: 114
53Operationoperator: 58
operands: 59
54Operationoperator: 97
operands: 60
55ExprRangelambda_map: 61
start_index: 113
end_index: 93
56Variable
57Lambdaparameter: 94
body: 87
58Literal
59ExprTuple100, 62
60ExprTuple63, 64
61Lambdaparameter: 94
body: 65
62Operationoperator: 81
operand: 72
63Operationoperator: 67
operands: 68
64Operationoperator: 69
operand: 74
65Operationoperator: 105
operand: 75
66ExprTuple72
67Literal
68ExprTuple73
69Literal
70ExprTuple74
71ExprTuple75
72Lambdaparameter: 120
body: 76
73ExprRangelambda_map: 77
start_index: 113
end_index: 114
74Variable
75IndexedVarvariable: 117
index: 94
76Conditionalvalue: 78
condition: 79
77Lambdaparameter: 94
body: 80
78Operationoperator: 81
operand: 85
79Operationoperator: 97
operands: 83
80Operationoperator: 105
operand: 87
81Literal
82ExprTuple85
83ExprTuple120, 86
84ExprTuple87
85Lambdaparameter: 119
body: 88
86Operationoperator: 109
operands: 89
87IndexedVarvariable: 115
index: 94
88Conditionalvalue: 91
condition: 92
89ExprTuple113, 93
90ExprTuple94
91Operationoperator: 95
operands: 96
92Operationoperator: 97
operands: 98
93Variable
94Variable
95Literal
96ExprTuple99, 100, 101, 102, 103
97Literal
98ExprTuple119, 104
99Operationoperator: 107
operand: 111
100Variable
101Operationoperator: 105
operand: 112
102Operationoperator: 105
operand: 111
103Operationoperator: 107
operand: 112
104Operationoperator: 109
operands: 110
105Literal
106ExprTuple111
107Literal
108ExprTuple112
109Literal
110ExprTuple113, 114
111IndexedVarvariable: 115
index: 119
112IndexedVarvariable: 117
index: 120
113Literal
114Variable
115Variable
116ExprTuple119
117Variable
118ExprTuple120
119Variable
120Variable