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, X, i, n
from proveit.core_expr_types import x_1_to_n, x_i
from proveit.linear_algebra import Hspace, OrthoNormBases, OrthoProj, 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(OrthoProj(Hspace, X), VecSum(index_or_indices = [i], summand = Qmult(Ket(x_i), Bra(x_i)), domain = Interval(one, n))), InSet(x_1_to_n_kets, OrthoNormBases(X))))
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\{\textrm{OrthoProj}\left(\mathcal{H}, X\right) = \left(\sum_{i=1}^{n} \left(\lvert x_{i} \rangle \thinspace \langle x_{i} \rvert\right)\right) \textrm{ if } \left\{\lvert x_{1} \rangle, \lvert x_{2} \rangle, \ldots, \lvert x_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(X\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: 47
end_index: 48
4Operationoperator: 7
operands: 8
5Operationoperator: 33
operands: 9
6Lambdaparameter: 49
body: 39
7Literal
8ExprTuple10, 11
9ExprTuple12, 13
10Operationoperator: 14
operands: 15
11Operationoperator: 16
operand: 23
12Operationoperator: 18
operands: 19
13Operationoperator: 20
operand: 25
14Literal
15ExprTuple22, 25
16Literal
17ExprTuple23
18Literal
19ExprTuple24
20Literal
21ExprTuple25
22Variable
23Lambdaparameter: 52
body: 26
24ExprRangelambda_map: 27
start_index: 47
end_index: 48
25Variable
26Conditionalvalue: 28
condition: 29
27Lambdaparameter: 49
body: 30
28Operationoperator: 31
operands: 32
29Operationoperator: 33
operands: 34
30Operationoperator: 40
operand: 39
31Literal
32ExprTuple36, 37
33Literal
34ExprTuple52, 38
35ExprTuple39
36Operationoperator: 40
operand: 46
37Operationoperator: 41
operand: 46
38Operationoperator: 43
operands: 44
39IndexedVarvariable: 50
index: 49
40Literal
41Literal
42ExprTuple46
43Literal
44ExprTuple47, 48
45ExprTuple49
46IndexedVarvariable: 50
index: 52
47Literal
48Variable
49Variable
50Variable
51ExprTuple52
52Variable