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 HilbertSpaces, Hspace, Identity, OrthoNormBases, VecSum
from proveit.logic import Equals, Forall, InClass, 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(Hspace, Conditional(Forall(instance_param_or_params = [n], instance_expr = 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(), domain = NaturalPos), InClass(Hspace, HilbertSpaces))))
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(\mathcal{H} \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(\left(\sum_{i=1}^{n} \left(\lvert x_{i} \rangle \thinspace \langle x_{i} \rvert\right)\right) = I_{\mathcal{H}}\right)\end{array}\right] \textrm{ if } \mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}\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: 41
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 14
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple41, 9
8Lambdaparameter: 64
body: 11
9Literal
10ExprTuple64
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operand: 17
13Operationoperator: 49
operands: 16
14Literal
15ExprTuple17
16ExprTuple64, 18
17Lambdaparameters: 19
body: 20
18Literal
19ExprTuple21
20Conditionalvalue: 22
condition: 23
21ExprRangelambda_map: 24
start_index: 63
end_index: 64
22Operationoperator: 25
operands: 26
23Operationoperator: 49
operands: 27
24Lambdaparameter: 65
body: 55
25Literal
26ExprTuple28, 29
27ExprTuple30, 31
28Operationoperator: 32
operand: 39
29Operationoperator: 34
operand: 41
30Operationoperator: 35
operands: 36
31Operationoperator: 37
operand: 41
32Literal
33ExprTuple39
34Literal
35Literal
36ExprTuple40
37Literal
38ExprTuple41
39Lambdaparameter: 68
body: 42
40ExprRangelambda_map: 43
start_index: 63
end_index: 64
41Variable
42Conditionalvalue: 44
condition: 45
43Lambdaparameter: 65
body: 46
44Operationoperator: 47
operands: 48
45Operationoperator: 49
operands: 50
46Operationoperator: 56
operand: 55
47Literal
48ExprTuple52, 53
49Literal
50ExprTuple68, 54
51ExprTuple55
52Operationoperator: 56
operand: 62
53Operationoperator: 57
operand: 62
54Operationoperator: 59
operands: 60
55IndexedVarvariable: 66
index: 65
56Literal
57Literal
58ExprTuple62
59Literal
60ExprTuple63, 64
61ExprTuple65
62IndexedVarvariable: 66
index: 68
63Literal
64Variable
65Variable
66Variable
67ExprTuple68
68Variable