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, SubsetEq
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(X, Conditional(Forall(instance_param_or_params = [n], instance_expr = 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(X))).with_wrapping(), domain = NaturalPos), SubsetEq(X, 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())
X \mapsto \left\{\forall_{n \in \mathbb{N}^+}~\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(X\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}\right] \textrm{ if } X \subseteq \mathcal{H}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 41
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 12
operand: 7
3Operationoperator: 5
operands: 6
4ExprTuple7
5Literal
6ExprTuple41, 38
7Lambdaparameter: 64
body: 9
8ExprTuple64
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operand: 15
11Operationoperator: 49
operands: 14
12Literal
13ExprTuple15
14ExprTuple64, 16
15Lambdaparameters: 17
body: 18
16Literal
17ExprTuple19
18Conditionalvalue: 20
condition: 21
19ExprRangelambda_map: 22
start_index: 63
end_index: 64
20Operationoperator: 23
operands: 24
21Operationoperator: 49
operands: 25
22Lambdaparameter: 65
body: 55
23Literal
24ExprTuple26, 27
25ExprTuple28, 29
26Operationoperator: 30
operands: 31
27Operationoperator: 32
operand: 39
28Operationoperator: 34
operands: 35
29Operationoperator: 36
operand: 41
30Literal
31ExprTuple38, 41
32Literal
33ExprTuple39
34Literal
35ExprTuple40
36Literal
37ExprTuple41
38Variable
39Lambdaparameter: 68
body: 42
40ExprRangelambda_map: 43
start_index: 63
end_index: 64
41Variable
42Conditionalvalue: 44
condition: 45
43Lambdaparameter: 65
body: 46
44Operationoperator: 47
operands: 48
45Operationoperator: 49
operands: 50
46Operationoperator: 56
operand: 55
47Literal
48ExprTuple52, 53
49Literal
50ExprTuple68, 54
51ExprTuple55
52Operationoperator: 56
operand: 62
53Operationoperator: 57
operand: 62
54Operationoperator: 59
operands: 60
55IndexedVarvariable: 66
index: 65
56Literal
57Literal
58ExprTuple62
59Literal
60ExprTuple63, 64
61ExprTuple65
62IndexedVarvariable: 66
index: 68
63Literal
64Variable
65Variable
66Variable
67ExprTuple68
68Variable