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 HilbertSpaces, Hspace, Identity, OrthoNormBases, VecSum
from proveit.logic import Equals, Forall, InClass, 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(Hspace, Conditional(Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [x_1_to_n], instance_expr = Equals(VecSum(index_or_indices = [i], summand = Qmult(Ket(x_i), Bra(x_i)), domain = Interval(one, n)), Identity(Hspace)), condition = InSet(x_1_to_n_kets, OrthoNormBases(Hspace))).with_wrapping(), domain = NaturalPos), 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_{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(\left(\sum_{i=1}^{n} \left(\lvert x_{i} \rangle \thinspace \langle x_{i} \rvert\right)\right) = I_{\mathcal{H}}\right)\end{array}\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: 40
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 13
operand: 7
3Operationoperator: 5
operands: 6
4ExprTuple7
5Literal
6ExprTuple40, 8
7Lambdaparameter: 63
body: 10
8Literal
9ExprTuple63
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operand: 16
12Operationoperator: 48
operands: 15
13Literal
14ExprTuple16
15ExprTuple63, 17
16Lambdaparameters: 18
body: 19
17Literal
18ExprTuple20
19Conditionalvalue: 21
condition: 22
20ExprRangelambda_map: 23
start_index: 62
end_index: 63
21Operationoperator: 24
operands: 25
22Operationoperator: 48
operands: 26
23Lambdaparameter: 64
body: 54
24Literal
25ExprTuple27, 28
26ExprTuple29, 30
27Operationoperator: 31
operand: 38
28Operationoperator: 33
operand: 40
29Operationoperator: 34
operands: 35
30Operationoperator: 36
operand: 40
31Literal
32ExprTuple38
33Literal
34Literal
35ExprTuple39
36Literal
37ExprTuple40
38Lambdaparameter: 67
body: 41
39ExprRangelambda_map: 42
start_index: 62
end_index: 63
40Variable
41Conditionalvalue: 43
condition: 44
42Lambdaparameter: 64
body: 45
43Operationoperator: 46
operands: 47
44Operationoperator: 48
operands: 49
45Operationoperator: 55
operand: 54
46Literal
47ExprTuple51, 52
48Literal
49ExprTuple67, 53
50ExprTuple54
51Operationoperator: 55
operand: 61
52Operationoperator: 56
operand: 61
53Operationoperator: 58
operands: 59
54IndexedVarvariable: 65
index: 64
55Literal
56Literal
57ExprTuple61
58Literal
59ExprTuple62, 63
60ExprTuple64
61IndexedVarvariable: 65
index: 67
62Literal
63Variable
64Variable
65Variable
66ExprTuple67
67Variable