logo

Expression of type Conditional

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, 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 = 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\{\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..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 11
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple37, 40
6Lambdaparameter: 63
body: 8
7ExprTuple63
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operand: 14
10Operationoperator: 48
operands: 13
11Literal
12ExprTuple14
13ExprTuple63, 15
14Lambdaparameters: 16
body: 17
15Literal
16ExprTuple18
17Conditionalvalue: 19
condition: 20
18ExprRangelambda_map: 21
start_index: 62
end_index: 63
19Operationoperator: 22
operands: 23
20Operationoperator: 48
operands: 24
21Lambdaparameter: 64
body: 54
22Literal
23ExprTuple25, 26
24ExprTuple27, 28
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operand: 38
27Operationoperator: 33
operands: 34
28Operationoperator: 35
operand: 40
29Literal
30ExprTuple40, 37
31Literal
32ExprTuple38
33Literal
34ExprTuple39
35Literal
36ExprTuple40
37Variable
38Lambdaparameter: 67
body: 41
39ExprRangelambda_map: 42
start_index: 62
end_index: 63
40Variable
41Conditionalvalue: 43
condition: 44
42Lambdaparameter: 64
body: 45
43Operationoperator: 46
operands: 47
44Operationoperator: 48
operands: 49
45Operationoperator: 55
operand: 54
46Literal
47ExprTuple51, 52
48Literal
49ExprTuple67, 53
50ExprTuple54
51Operationoperator: 55
operand: 61
52Operationoperator: 56
operand: 61
53Operationoperator: 58
operands: 59
54IndexedVarvariable: 65
index: 64
55Literal
56Literal
57ExprTuple61
58Literal
59ExprTuple62, 63
60ExprTuple64
61IndexedVarvariable: 65
index: 67
62Literal
63Variable
64Variable
65Variable
66ExprTuple67
67Variable