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, Forall, InSet
from proveit.numbers import Interval, NaturalPos, 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(n, Conditional(Forall(instance_param_or_params = [x_1_to_n], instance_expr = Equals(OrthoProj(Hspace, X), VecSum(index_or_indices = [i], summand = Qmult(Ket(x_i), Bra(x_i)), domain = Interval(one, n))), condition = InSet(x_1_to_n_kets, OrthoNormBases(Hspace))).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_{x_{1}, x_{2}, \ldots, x_{n}~|~\left\{\lvert x_{1} \rangle, \lvert x_{2} \rangle, \ldots, \lvert x_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(\mathcal{H}\right)}~\\
\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)\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: 57
body: 2
1ExprTuple57
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 42
operands: 7
5Literal
6ExprTuple8
7ExprTuple57, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple12
11Conditionalvalue: 13
condition: 14
12ExprRangelambda_map: 15
start_index: 56
end_index: 57
13Operationoperator: 16
operands: 17
14Operationoperator: 42
operands: 18
15Lambdaparameter: 58
body: 48
16Literal
17ExprTuple19, 20
18ExprTuple21, 22
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operand: 32
21Operationoperator: 27
operands: 28
22Operationoperator: 29
operand: 34
23Literal
24ExprTuple34, 31
25Literal
26ExprTuple32
27Literal
28ExprTuple33
29Literal
30ExprTuple34
31Variable
32Lambdaparameter: 61
body: 35
33ExprRangelambda_map: 36
start_index: 56
end_index: 57
34Variable
35Conditionalvalue: 37
condition: 38
36Lambdaparameter: 58
body: 39
37Operationoperator: 40
operands: 41
38Operationoperator: 42
operands: 43
39Operationoperator: 49
operand: 48
40Literal
41ExprTuple45, 46
42Literal
43ExprTuple61, 47
44ExprTuple48
45Operationoperator: 49
operand: 55
46Operationoperator: 50
operand: 55
47Operationoperator: 52
operands: 53
48IndexedVarvariable: 59
index: 58
49Literal
50Literal
51ExprTuple55
52Literal
53ExprTuple56, 57
54ExprTuple58
55IndexedVarvariable: 59
index: 61
56Literal
57Variable
58Variable
59Variable
60ExprTuple61
61Variable