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, 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(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(), 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(\left(\sum_{i=1}^{n} \left(\lvert x_{i} \rangle \thinspace \langle x_{i} \rvert\right)\right) = I_{\mathcal{H}}\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: 56
body: 3
2ExprTuple56
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 41
operands: 8
6Literal
7ExprTuple9
8ExprTuple56, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple13
12Conditionalvalue: 14
condition: 15
13ExprRangelambda_map: 16
start_index: 55
end_index: 56
14Operationoperator: 17
operands: 18
15Operationoperator: 41
operands: 19
16Lambdaparameter: 57
body: 47
17Literal
18ExprTuple20, 21
19ExprTuple22, 23
20Operationoperator: 24
operand: 31
21Operationoperator: 26
operand: 33
22Operationoperator: 27
operands: 28
23Operationoperator: 29
operand: 33
24Literal
25ExprTuple31
26Literal
27Literal
28ExprTuple32
29Literal
30ExprTuple33
31Lambdaparameter: 60
body: 34
32ExprRangelambda_map: 35
start_index: 55
end_index: 56
33Variable
34Conditionalvalue: 36
condition: 37
35Lambdaparameter: 57
body: 38
36Operationoperator: 39
operands: 40
37Operationoperator: 41
operands: 42
38Operationoperator: 48
operand: 47
39Literal
40ExprTuple44, 45
41Literal
42ExprTuple60, 46
43ExprTuple47
44Operationoperator: 48
operand: 54
45Operationoperator: 49
operand: 54
46Operationoperator: 51
operands: 52
47IndexedVarvariable: 58
index: 57
48Literal
49Literal
50ExprTuple54
51Literal
52ExprTuple55, 56
53ExprTuple57
54IndexedVarvariable: 58
index: 60
55Literal
56Variable
57Variable
58Variable
59ExprTuple60
60Variable