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 HilbertSpaces, Hspace, OrthoNormBases, OrthoProj, VecSum
from proveit.logic import Equals, Forall, InClass, 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(Hspace, Conditional(Forall(instance_param_or_params = [X], instance_expr = 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(Hspace))).with_wrapping(), domain = NaturalPos), condition = SubsetEq(X, Hspace)), InClass(Hspace, HilbertSpaces)))
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())
\mathcal{H} \mapsto \left\{\forall_{X~|~X \subseteq \mathcal{H}}~\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(\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}\right]\right] \textrm{ if } \mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 50
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 21
operand: 7
3Operationoperator: 5
operands: 6
4ExprTuple7
5Literal
6ExprTuple50, 8
7Lambdaparameter: 47
body: 10
8Literal
9ExprTuple47
10Conditionalvalue: 11
condition: 12
11Operationoperator: 21
operand: 16
12Operationoperator: 14
operands: 15
13ExprTuple16
14Literal
15ExprTuple47, 50
16Lambdaparameter: 73
body: 18
17ExprTuple73
18Conditionalvalue: 19
condition: 20
19Operationoperator: 21
operand: 24
20Operationoperator: 58
operands: 23
21Literal
22ExprTuple24
23ExprTuple73, 25
24Lambdaparameters: 26
body: 27
25Literal
26ExprTuple28
27Conditionalvalue: 29
condition: 30
28ExprRangelambda_map: 31
start_index: 72
end_index: 73
29Operationoperator: 32
operands: 33
30Operationoperator: 58
operands: 34
31Lambdaparameter: 74
body: 64
32Literal
33ExprTuple35, 36
34ExprTuple37, 38
35Operationoperator: 39
operands: 40
36Operationoperator: 41
operand: 48
37Operationoperator: 43
operands: 44
38Operationoperator: 45
operand: 50
39Literal
40ExprTuple50, 47
41Literal
42ExprTuple48
43Literal
44ExprTuple49
45Literal
46ExprTuple50
47Variable
48Lambdaparameter: 77
body: 51
49ExprRangelambda_map: 52
start_index: 72
end_index: 73
50Variable
51Conditionalvalue: 53
condition: 54
52Lambdaparameter: 74
body: 55
53Operationoperator: 56
operands: 57
54Operationoperator: 58
operands: 59
55Operationoperator: 65
operand: 64
56Literal
57ExprTuple61, 62
58Literal
59ExprTuple77, 63
60ExprTuple64
61Operationoperator: 65
operand: 71
62Operationoperator: 66
operand: 71
63Operationoperator: 68
operands: 69
64IndexedVarvariable: 75
index: 74
65Literal
66Literal
67ExprTuple71
68Literal
69ExprTuple72, 73
70ExprTuple74
71IndexedVarvariable: 75
index: 77
72Literal
73Variable
74Variable
75Variable
76ExprTuple77
77Variable