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(Hspace))).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(\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] \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: 39
body: 2
1ExprTuple39
2Conditionalvalue: 3
condition: 4
3Operationoperator: 13
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple39, 42
8Lambdaparameter: 65
body: 10
9ExprTuple65
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operand: 16
12Operationoperator: 50
operands: 15
13Literal
14ExprTuple16
15ExprTuple65, 17
16Lambdaparameters: 18
body: 19
17Literal
18ExprTuple20
19Conditionalvalue: 21
condition: 22
20ExprRangelambda_map: 23
start_index: 64
end_index: 65
21Operationoperator: 24
operands: 25
22Operationoperator: 50
operands: 26
23Lambdaparameter: 66
body: 56
24Literal
25ExprTuple27, 28
26ExprTuple29, 30
27Operationoperator: 31
operands: 32
28Operationoperator: 33
operand: 40
29Operationoperator: 35
operands: 36
30Operationoperator: 37
operand: 42
31Literal
32ExprTuple42, 39
33Literal
34ExprTuple40
35Literal
36ExprTuple41
37Literal
38ExprTuple42
39Variable
40Lambdaparameter: 69
body: 43
41ExprRangelambda_map: 44
start_index: 64
end_index: 65
42Variable
43Conditionalvalue: 45
condition: 46
44Lambdaparameter: 66
body: 47
45Operationoperator: 48
operands: 49
46Operationoperator: 50
operands: 51
47Operationoperator: 57
operand: 56
48Literal
49ExprTuple53, 54
50Literal
51ExprTuple69, 55
52ExprTuple56
53Operationoperator: 57
operand: 63
54Operationoperator: 58
operand: 63
55Operationoperator: 60
operands: 61
56IndexedVarvariable: 67
index: 66
57Literal
58Literal
59ExprTuple63
60Literal
61ExprTuple64, 65
62ExprTuple66
63IndexedVarvariable: 67
index: 69
64Literal
65Variable
66Variable
67Variable
68ExprTuple69
69Variable