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 Equals, Exists, Forall, Iff, InSet, Set
from proveit.numbers import Complex, Interval, NaturalPos, 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(n, Conditional(Forall(instance_param_or_params = [Hspace], instance_expr = 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)), domain = HilbertSpaces, condition = Equals(Dim(Hspace), n)).with_wrapping(), 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())
n \mapsto \left\{\begin{array}{l}\forall_{\mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}~|~\textrm{Dim}\left(\mathcal{H}\right) = n}~\\
\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)\right]\end{array} \textrm{ if } 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
0Lambdaparameter: 110
body: 2
1ExprTuple110
2Conditionalvalue: 3
condition: 4
3Operationoperator: 12
operand: 7
4Operationoperator: 95
operands: 6
5ExprTuple7
6ExprTuple110, 8
7Lambdaparameter: 66
body: 9
8Literal
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operand: 15
11Operationoperator: 70
operands: 14
12Literal
13ExprTuple15
14ExprTuple16, 17
15Lambdaparameter: 74
body: 18
16Operationoperator: 19
operands: 20
17Operationoperator: 68
operands: 21
18Conditionalvalue: 22
condition: 23
19Literal
20ExprTuple66, 24
21ExprTuple25, 110
22Operationoperator: 26
operands: 27
23Operationoperator: 95
operands: 28
24Literal
25Operationoperator: 29
operand: 66
26Literal
27ExprTuple30, 31
28ExprTuple74, 32
29Literal
30Operationoperator: 68
operands: 33
31Operationoperator: 51
operand: 39
32Operationoperator: 35
operands: 36
33ExprTuple37, 38
34ExprTuple39
35Literal
36ExprTuple66, 66
37Operationoperator: 103
operands: 40
38Operationoperator: 103
operands: 41
39Lambdaparameters: 42
body: 43
40ExprTuple44, 74
41ExprTuple74, 44
42ExprTuple45
43Conditionalvalue: 46
condition: 47
44Operationoperator: 48
operand: 74
45ExprRangelambda_map: 50
start_index: 109
end_index: 110
46Operationoperator: 51
operand: 54
47Operationoperator: 95
operands: 53
48Literal
49ExprTuple74
50Lambdaparameter: 101
body: 92
51Literal
52ExprTuple54
53ExprTuple55, 56
54Lambdaparameters: 57
body: 58
55Operationoperator: 72
operand: 65
56Operationoperator: 60
operand: 66
57ExprTuple62
58Conditionalvalue: 63
condition: 64
59ExprTuple65
60Literal
61ExprTuple66
62ExprRangelambda_map: 67
start_index: 109
end_index: 110
63Operationoperator: 68
operands: 69
64Operationoperator: 70
operands: 71
65Operationoperator: 72
operands: 73
66Variable
67Lambdaparameter: 101
body: 90
68Literal
69ExprTuple74, 75
70Literal
71ExprTuple76
72Literal
73ExprTuple77
74Variable
75Operationoperator: 78
operand: 82
76ExprRangelambda_map: 80
start_index: 109
end_index: 110
77ExprRangelambda_map: 81
start_index: 109
end_index: 110
78Literal
79ExprTuple82
80Lambdaparameter: 101
body: 83
81Lambdaparameter: 101
body: 84
82Lambdaparameter: 117
body: 85
83Operationoperator: 95
operands: 86
84Operationoperator: 111
operand: 92
85Conditionalvalue: 88
condition: 89
86ExprTuple90, 91
87ExprTuple92
88Operationoperator: 93
operands: 94
89Operationoperator: 95
operands: 96
90IndexedVarvariable: 102
index: 101
91Literal
92IndexedVarvariable: 115
index: 101
93Literal
94ExprTuple98, 99
95Literal
96ExprTuple117, 100
97ExprTuple101
98IndexedVarvariable: 102
index: 117
99Operationoperator: 103
operands: 104
100Operationoperator: 105
operands: 106
101Variable
102Variable
103Literal
104ExprTuple107, 108
105Literal
106ExprTuple109, 110
107Operationoperator: 111
operand: 114
108Operationoperator: 112
operand: 114
109Literal
110Variable
111Literal
112Literal
113ExprTuple114
114IndexedVarvariable: 115
index: 117
115Variable
116ExprTuple117
117Variable