logo

Expression of type ExprTuple

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, ExprTuple, 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, InSet
from proveit.numbers import Interval, 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 = ExprTuple(Lambda([x_1_to_n], Conditional(Equals(OrthoProj(Hspace, X), VecSum(index_or_indices = [i], summand = Qmult(Ket(x_i), Bra(x_i)), domain = Interval(one, n))), InSet(x_1_to_n_kets, OrthoNormBases(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())
\left(\left(x_{1}, x_{2}, \ldots, x_{n}\right) \mapsto \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) \textrm{ if } \left\{\lvert x_{1} \rangle, \lvert x_{2} \rangle, \ldots, \lvert x_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(\mathcal{H}\right)\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple4
3Conditionalvalue: 5
condition: 6
4ExprRangelambda_map: 7
start_index: 48
end_index: 49
5Operationoperator: 8
operands: 9
6Operationoperator: 34
operands: 10
7Lambdaparameter: 50
body: 40
8Literal
9ExprTuple11, 12
10ExprTuple13, 14
11Operationoperator: 15
operands: 16
12Operationoperator: 17
operand: 24
13Operationoperator: 19
operands: 20
14Operationoperator: 21
operand: 26
15Literal
16ExprTuple26, 23
17Literal
18ExprTuple24
19Literal
20ExprTuple25
21Literal
22ExprTuple26
23Variable
24Lambdaparameter: 53
body: 27
25ExprRangelambda_map: 28
start_index: 48
end_index: 49
26Variable
27Conditionalvalue: 29
condition: 30
28Lambdaparameter: 50
body: 31
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operands: 35
31Operationoperator: 41
operand: 40
32Literal
33ExprTuple37, 38
34Literal
35ExprTuple53, 39
36ExprTuple40
37Operationoperator: 41
operand: 47
38Operationoperator: 42
operand: 47
39Operationoperator: 44
operands: 45
40IndexedVarvariable: 51
index: 50
41Literal
42Literal
43ExprTuple47
44Literal
45ExprTuple48, 49
46ExprTuple50
47IndexedVarvariable: 51
index: 53
48Literal
49Variable
50Variable
51Variable
52ExprTuple53
53Variable