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 Conditional, Lambda, M, i, n
from proveit.core_expr_types import a_1_to_n, a_i, v_1_to_n, v_i
from proveit.linear_algebra import Adj, Dim, HilbertSpaces, Hspace, LinMap, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import And, Equals, Exists, Forall, Iff, InClass, InSet, Set
from proveit.numbers import Complex, Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Adj(M)
expr = Lambda(Hspace, Conditional(Forall(instance_param_or_params = [M], instance_expr = Iff(Equals(Qmult(sub_expr1, M), Qmult(M, sub_expr1)), Exists(instance_param_or_params = [v_1_to_n], instance_expr = Exists(instance_param_or_params = [a_1_to_n], instance_expr = Equals(M, VecSum(index_or_indices = [i], summand = ScalarMult(a_i, Qmult(Ket(v_i), Bra(v_i))), domain = Interval(one, n))), domain = Complex).with_wrapping(), condition = InSet(Set(v_1_to_n_kets), OrthoNormBases(Hspace))).with_wrapping()).with_wrapping_at(2), domain = LinMap(Hspace, Hspace)), And(InClass(Hspace, HilbertSpaces), Equals(Dim(Hspace), n))))
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())
\mathcal{H} \mapsto \left\{\forall_{M \in \mathcal{L}\left(\mathcal{H}, \mathcal{H}\right)}~\left(\begin{array}{c} \begin{array}{l} \left(\left(M^{\dagger} \thinspace M\right) = \left(M \thinspace M^{\dagger}\right)\right) \Leftrightarrow  \\ \left[\begin{array}{l}\exists_{v_{1}, v_{2}, \ldots, v_{n}~|~\left\{\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathcal{H}\right)}~\\
\left[\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n} \in \mathbb{C}}~\\
\left(M = \left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right)\end{array}\right]\end{array}\right] \end{array} \end{array}\right) \textrm{ if } \mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  \textrm{Dim}\left(\mathcal{H}\right) = n\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 58
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 62
operands: 6
4Literal
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameter: 66
body: 10
8Operationoperator: 11
operands: 12
9Operationoperator: 60
operands: 13
10Conditionalvalue: 14
condition: 15
11Literal
12ExprTuple58, 16
13ExprTuple17, 102
14Operationoperator: 18
operands: 19
15Operationoperator: 87
operands: 20
16Literal
17Operationoperator: 21
operand: 58
18Literal
19ExprTuple22, 23
20ExprTuple66, 24
21Literal
22Operationoperator: 60
operands: 25
23Operationoperator: 43
operand: 31
24Operationoperator: 27
operands: 28
25ExprTuple29, 30
26ExprTuple31
27Literal
28ExprTuple58, 58
29Operationoperator: 95
operands: 32
30Operationoperator: 95
operands: 33
31Lambdaparameters: 34
body: 35
32ExprTuple36, 66
33ExprTuple66, 36
34ExprTuple37
35Conditionalvalue: 38
condition: 39
36Operationoperator: 40
operand: 66
37ExprRangelambda_map: 42
start_index: 101
end_index: 102
38Operationoperator: 43
operand: 46
39Operationoperator: 87
operands: 45
40Literal
41ExprTuple66
42Lambdaparameter: 93
body: 84
43Literal
44ExprTuple46
45ExprTuple47, 48
46Lambdaparameters: 49
body: 50
47Operationoperator: 64
operand: 57
48Operationoperator: 52
operand: 58
49ExprTuple54
50Conditionalvalue: 55
condition: 56
51ExprTuple57
52Literal
53ExprTuple58
54ExprRangelambda_map: 59
start_index: 101
end_index: 102
55Operationoperator: 60
operands: 61
56Operationoperator: 62
operands: 63
57Operationoperator: 64
operands: 65
58Variable
59Lambdaparameter: 93
body: 82
60Literal
61ExprTuple66, 67
62Literal
63ExprTuple68
64Literal
65ExprTuple69
66Variable
67Operationoperator: 70
operand: 74
68ExprRangelambda_map: 72
start_index: 101
end_index: 102
69ExprRangelambda_map: 73
start_index: 101
end_index: 102
70Literal
71ExprTuple74
72Lambdaparameter: 93
body: 75
73Lambdaparameter: 93
body: 76
74Lambdaparameter: 109
body: 77
75Operationoperator: 87
operands: 78
76Operationoperator: 103
operand: 84
77Conditionalvalue: 80
condition: 81
78ExprTuple82, 83
79ExprTuple84
80Operationoperator: 85
operands: 86
81Operationoperator: 87
operands: 88
82IndexedVarvariable: 94
index: 93
83Literal
84IndexedVarvariable: 107
index: 93
85Literal
86ExprTuple90, 91
87Literal
88ExprTuple109, 92
89ExprTuple93
90IndexedVarvariable: 94
index: 109
91Operationoperator: 95
operands: 96
92Operationoperator: 97
operands: 98
93Variable
94Variable
95Literal
96ExprTuple99, 100
97Literal
98ExprTuple101, 102
99Operationoperator: 103
operand: 106
100Operationoperator: 104
operand: 106
101Literal
102Variable
103Literal
104Literal
105ExprTuple106
106IndexedVarvariable: 107
index: 109
107Variable
108ExprTuple109
109Variable