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, Forall, 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 = ExprTuple(Lambda(n, Conditional(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(), InSet(n, NaturalPos))))
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(n \mapsto \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} \textrm{ if } n \in \mathbb{N}^+\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
1Lambdaparameter: 58
body: 3
2ExprTuple58
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 43
operands: 8
6Literal
7ExprTuple9
8ExprTuple58, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple13
12Conditionalvalue: 14
condition: 15
13ExprRangelambda_map: 16
start_index: 57
end_index: 58
14Operationoperator: 17
operands: 18
15Operationoperator: 43
operands: 19
16Lambdaparameter: 59
body: 49
17Literal
18ExprTuple20, 21
19ExprTuple22, 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operand: 33
22Operationoperator: 28
operands: 29
23Operationoperator: 30
operand: 35
24Literal
25ExprTuple35, 32
26Literal
27ExprTuple33
28Literal
29ExprTuple34
30Literal
31ExprTuple35
32Variable
33Lambdaparameter: 62
body: 36
34ExprRangelambda_map: 37
start_index: 57
end_index: 58
35Variable
36Conditionalvalue: 38
condition: 39
37Lambdaparameter: 59
body: 40
38Operationoperator: 41
operands: 42
39Operationoperator: 43
operands: 44
40Operationoperator: 50
operand: 49
41Literal
42ExprTuple46, 47
43Literal
44ExprTuple62, 48
45ExprTuple49
46Operationoperator: 50
operand: 56
47Operationoperator: 51
operand: 56
48Operationoperator: 53
operands: 54
49IndexedVarvariable: 60
index: 59
50Literal
51Literal
52ExprTuple56
53Literal
54ExprTuple57, 58
55ExprTuple59
56IndexedVarvariable: 60
index: 62
57Literal
58Variable
59Variable
60Variable
61ExprTuple62
62Variable