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 HilbertSpaces, Hspace, OrthoNormBases, OrthoProj, VecSum
from proveit.logic import Equals, Forall, InClass, 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(Hspace, Conditional(Forall(instance_param_or_params = [X], instance_expr = 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), condition = SubsetEq(X, Hspace)), 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_{X~|~X \subseteq \mathcal{H}}~\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]\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: 51
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 22
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple51, 9
8Lambdaparameter: 48
body: 11
9Literal
10ExprTuple48
11Conditionalvalue: 12
condition: 13
12Operationoperator: 22
operand: 17
13Operationoperator: 15
operands: 16
14ExprTuple17
15Literal
16ExprTuple48, 51
17Lambdaparameter: 74
body: 19
18ExprTuple74
19Conditionalvalue: 20
condition: 21
20Operationoperator: 22
operand: 25
21Operationoperator: 59
operands: 24
22Literal
23ExprTuple25
24ExprTuple74, 26
25Lambdaparameters: 27
body: 28
26Literal
27ExprTuple29
28Conditionalvalue: 30
condition: 31
29ExprRangelambda_map: 32
start_index: 73
end_index: 74
30Operationoperator: 33
operands: 34
31Operationoperator: 59
operands: 35
32Lambdaparameter: 75
body: 65
33Literal
34ExprTuple36, 37
35ExprTuple38, 39
36Operationoperator: 40
operands: 41
37Operationoperator: 42
operand: 49
38Operationoperator: 44
operands: 45
39Operationoperator: 46
operand: 51
40Literal
41ExprTuple51, 48
42Literal
43ExprTuple49
44Literal
45ExprTuple50
46Literal
47ExprTuple51
48Variable
49Lambdaparameter: 78
body: 52
50ExprRangelambda_map: 53
start_index: 73
end_index: 74
51Variable
52Conditionalvalue: 54
condition: 55
53Lambdaparameter: 75
body: 56
54Operationoperator: 57
operands: 58
55Operationoperator: 59
operands: 60
56Operationoperator: 66
operand: 65
57Literal
58ExprTuple62, 63
59Literal
60ExprTuple78, 64
61ExprTuple65
62Operationoperator: 66
operand: 72
63Operationoperator: 67
operand: 72
64Operationoperator: 69
operands: 70
65IndexedVarvariable: 76
index: 75
66Literal
67Literal
68ExprTuple72
69Literal
70ExprTuple73, 74
71ExprTuple75
72IndexedVarvariable: 76
index: 78
73Literal
74Variable
75Variable
76Variable
77ExprTuple78
78Variable