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, i, n
from proveit.core_expr_types import x_1_to_n, x_i
from proveit.linear_algebra import Hspace, Identity, OrthoNormBases, VecSum
from proveit.logic import Equals, InSet
from proveit.numbers import Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import x_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = Lambda([x_1_to_n], Conditional(Equals(VecSum(index_or_indices = [i], summand = Qmult(Ket(x_i), Bra(x_i)), domain = Interval(one, n)), Identity(Hspace)), InSet(x_1_to_n_kets, OrthoNormBases(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())
\left(x_{1}, x_{2}, \ldots, x_{n}\right) \mapsto \left\{\left(\sum_{i=1}^{n} \left(\lvert x_{i} \rangle \thinspace \langle x_{i} \rvert\right)\right) = I_{\mathcal{H}} \textrm{ if } \left\{\lvert x_{1} \rangle, \lvert x_{2} \rangle, \ldots, \lvert x_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(\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
0Lambdaparameters: 1
body: 2
1ExprTuple3
2Conditionalvalue: 4
condition: 5
3ExprRangelambda_map: 6
start_index: 45
end_index: 46
4Operationoperator: 7
operands: 8
5Operationoperator: 31
operands: 9
6Lambdaparameter: 47
body: 37
7Literal
8ExprTuple10, 11
9ExprTuple12, 13
10Operationoperator: 14
operand: 21
11Operationoperator: 16
operand: 23
12Operationoperator: 17
operands: 18
13Operationoperator: 19
operand: 23
14Literal
15ExprTuple21
16Literal
17Literal
18ExprTuple22
19Literal
20ExprTuple23
21Lambdaparameter: 50
body: 24
22ExprRangelambda_map: 25
start_index: 45
end_index: 46
23Variable
24Conditionalvalue: 26
condition: 27
25Lambdaparameter: 47
body: 28
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operands: 32
28Operationoperator: 38
operand: 37
29Literal
30ExprTuple34, 35
31Literal
32ExprTuple50, 36
33ExprTuple37
34Operationoperator: 38
operand: 44
35Operationoperator: 39
operand: 44
36Operationoperator: 41
operands: 42
37IndexedVarvariable: 48
index: 47
38Literal
39Literal
40ExprTuple44
41Literal
42ExprTuple45, 46
43ExprTuple47
44IndexedVarvariable: 48
index: 50
45Literal
46Variable
47Variable
48Variable
49ExprTuple50
50Variable