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
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 = [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(X))).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\{\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(X\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} \textrm{ if } n \in \mathbb{N}^+\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: 3
operand: 6
2Operationoperator: 40
operands: 5
3Literal
4ExprTuple6
5ExprTuple55, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple10
9Conditionalvalue: 11
condition: 12
10ExprRangelambda_map: 13
start_index: 54
end_index: 55
11Operationoperator: 14
operands: 15
12Operationoperator: 40
operands: 16
13Lambdaparameter: 56
body: 46
14Literal
15ExprTuple17, 18
16ExprTuple19, 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operand: 30
19Operationoperator: 25
operands: 26
20Operationoperator: 27
operand: 32
21Literal
22ExprTuple29, 32
23Literal
24ExprTuple30
25Literal
26ExprTuple31
27Literal
28ExprTuple32
29Variable
30Lambdaparameter: 59
body: 33
31ExprRangelambda_map: 34
start_index: 54
end_index: 55
32Variable
33Conditionalvalue: 35
condition: 36
34Lambdaparameter: 56
body: 37
35Operationoperator: 38
operands: 39
36Operationoperator: 40
operands: 41
37Operationoperator: 47
operand: 46
38Literal
39ExprTuple43, 44
40Literal
41ExprTuple59, 45
42ExprTuple46
43Operationoperator: 47
operand: 53
44Operationoperator: 48
operand: 53
45Operationoperator: 50
operands: 51
46IndexedVarvariable: 57
index: 56
47Literal
48Literal
49ExprTuple53
50Literal
51ExprTuple54, 55
52ExprTuple56
53IndexedVarvariable: 57
index: 59
54Literal
55Variable
56Variable
57Variable
58ExprTuple59
59Variable