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, i, n
from proveit.core_expr_types import x_1_to_n, x_i
from proveit.linear_algebra import Hspace, Identity, OrthoNormBases, 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(VecSum(index_or_indices = [i], summand = Qmult(Ket(x_i), Bra(x_i)), domain = Interval(one, n)), Identity(Hspace)), 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\{\left(\sum_{i=1}^{n} \left(\lvert x_{i} \rangle \thinspace \langle x_{i} \rvert\right)\right) = I_{\mathcal{H}} \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: 46
end_index: 47
5Operationoperator: 8
operands: 9
6Operationoperator: 32
operands: 10
7Lambdaparameter: 48
body: 38
8Literal
9ExprTuple11, 12
10ExprTuple13, 14
11Operationoperator: 15
operand: 22
12Operationoperator: 17
operand: 24
13Operationoperator: 18
operands: 19
14Operationoperator: 20
operand: 24
15Literal
16ExprTuple22
17Literal
18Literal
19ExprTuple23
20Literal
21ExprTuple24
22Lambdaparameter: 51
body: 25
23ExprRangelambda_map: 26
start_index: 46
end_index: 47
24Variable
25Conditionalvalue: 27
condition: 28
26Lambdaparameter: 48
body: 29
27Operationoperator: 30
operands: 31
28Operationoperator: 32
operands: 33
29Operationoperator: 39
operand: 38
30Literal
31ExprTuple35, 36
32Literal
33ExprTuple51, 37
34ExprTuple38
35Operationoperator: 39
operand: 45
36Operationoperator: 40
operand: 45
37Operationoperator: 42
operands: 43
38IndexedVarvariable: 49
index: 48
39Literal
40Literal
41ExprTuple45
42Literal
43ExprTuple46, 47
44ExprTuple48
45IndexedVarvariable: 49
index: 51
46Literal
47Variable
48Variable
49Variable
50ExprTuple51
51Variable