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, SubsetEq
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(X, Conditional(Forall(instance_param_or_params = [n], instance_expr = 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(), domain = NaturalPos), SubsetEq(X, 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(X \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(\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}\right] \textrm{ if } X \subseteq \mathcal{H}\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: 40
body: 3
2ExprTuple40
3Conditionalvalue: 4
condition: 5
4Operationoperator: 14
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple40, 43
9Lambdaparameter: 66
body: 11
10ExprTuple66
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operand: 17
13Operationoperator: 51
operands: 16
14Literal
15ExprTuple17
16ExprTuple66, 18
17Lambdaparameters: 19
body: 20
18Literal
19ExprTuple21
20Conditionalvalue: 22
condition: 23
21ExprRangelambda_map: 24
start_index: 65
end_index: 66
22Operationoperator: 25
operands: 26
23Operationoperator: 51
operands: 27
24Lambdaparameter: 67
body: 57
25Literal
26ExprTuple28, 29
27ExprTuple30, 31
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operand: 41
30Operationoperator: 36
operands: 37
31Operationoperator: 38
operand: 43
32Literal
33ExprTuple43, 40
34Literal
35ExprTuple41
36Literal
37ExprTuple42
38Literal
39ExprTuple43
40Variable
41Lambdaparameter: 70
body: 44
42ExprRangelambda_map: 45
start_index: 65
end_index: 66
43Variable
44Conditionalvalue: 46
condition: 47
45Lambdaparameter: 67
body: 48
46Operationoperator: 49
operands: 50
47Operationoperator: 51
operands: 52
48Operationoperator: 58
operand: 57
49Literal
50ExprTuple54, 55
51Literal
52ExprTuple70, 56
53ExprTuple57
54Operationoperator: 58
operand: 64
55Operationoperator: 59
operand: 64
56Operationoperator: 61
operands: 62
57IndexedVarvariable: 68
index: 67
58Literal
59Literal
60ExprTuple64
61Literal
62ExprTuple65, 66
63ExprTuple67
64IndexedVarvariable: 68
index: 70
65Literal
66Variable
67Variable
68Variable
69ExprTuple70
70Variable