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, Hspace, LinMap, OrthoNormBases, ScalarMult, VecSum
from proveit.logic import Equals, Exists, Iff, 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(M, Conditional(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), InSet(M, LinMap(Hspace, Hspace))))
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())
M \mapsto \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} \textrm{ if } M \in \mathcal{L}\left(\mathcal{H}, \mathcal{H}\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: 51
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 72
operands: 6
4Literal
5ExprTuple7, 8
6ExprTuple51, 9
7Operationoperator: 45
operands: 10
8Operationoperator: 28
operand: 16
9Operationoperator: 12
operands: 13
10ExprTuple14, 15
11ExprTuple16
12Literal
13ExprTuple43, 43
14Operationoperator: 80
operands: 17
15Operationoperator: 80
operands: 18
16Lambdaparameters: 19
body: 20
17ExprTuple21, 51
18ExprTuple51, 21
19ExprTuple22
20Conditionalvalue: 23
condition: 24
21Operationoperator: 25
operand: 51
22ExprRangelambda_map: 27
start_index: 86
end_index: 87
23Operationoperator: 28
operand: 31
24Operationoperator: 72
operands: 30
25Literal
26ExprTuple51
27Lambdaparameter: 78
body: 69
28Literal
29ExprTuple31
30ExprTuple32, 33
31Lambdaparameters: 34
body: 35
32Operationoperator: 49
operand: 42
33Operationoperator: 37
operand: 43
34ExprTuple39
35Conditionalvalue: 40
condition: 41
36ExprTuple42
37Literal
38ExprTuple43
39ExprRangelambda_map: 44
start_index: 86
end_index: 87
40Operationoperator: 45
operands: 46
41Operationoperator: 47
operands: 48
42Operationoperator: 49
operands: 50
43Variable
44Lambdaparameter: 78
body: 67
45Literal
46ExprTuple51, 52
47Literal
48ExprTuple53
49Literal
50ExprTuple54
51Variable
52Operationoperator: 55
operand: 59
53ExprRangelambda_map: 57
start_index: 86
end_index: 87
54ExprRangelambda_map: 58
start_index: 86
end_index: 87
55Literal
56ExprTuple59
57Lambdaparameter: 78
body: 60
58Lambdaparameter: 78
body: 61
59Lambdaparameter: 94
body: 62
60Operationoperator: 72
operands: 63
61Operationoperator: 88
operand: 69
62Conditionalvalue: 65
condition: 66
63ExprTuple67, 68
64ExprTuple69
65Operationoperator: 70
operands: 71
66Operationoperator: 72
operands: 73
67IndexedVarvariable: 79
index: 78
68Literal
69IndexedVarvariable: 92
index: 78
70Literal
71ExprTuple75, 76
72Literal
73ExprTuple94, 77
74ExprTuple78
75IndexedVarvariable: 79
index: 94
76Operationoperator: 80
operands: 81
77Operationoperator: 82
operands: 83
78Variable
79Variable
80Literal
81ExprTuple84, 85
82Literal
83ExprTuple86, 87
84Operationoperator: 88
operand: 91
85Operationoperator: 89
operand: 91
86Literal
87Variable
88Literal
89Literal
90ExprTuple91
91IndexedVarvariable: 92
index: 94
92Variable
93ExprTuple94
94Variable