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_i
from proveit.linear_algebra import Hspace, OrthoNormBases, OrthoProj, VecSum
from proveit.logic import Equals, InSet
from proveit.numbers import Interval, 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(Equals(OrthoProj(Hspace, X), VecSum(index_or_indices = [i], summand = Qmult(Ket(x_i), Bra(x_i)), domain = Interval(one, n))), InSet(x_1_to_n_kets, OrthoNormBases(X)))
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\{\textrm{OrthoProj}\left(\mathcal{H}, X\right) = \left(\sum_{i=1}^{n} \left(\lvert x_{i} \rangle \thinspace \langle x_{i} \rvert\right)\right) \textrm{ if } \left\{\lvert x_{1} \rangle, \lvert x_{2} \rangle, \ldots, \lvert x_{n} \rangle\right\} \in \textrm{O.N.Bases}\left(X\right)\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
operands: 4
2Operationoperator: 29
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple8, 9
6Operationoperator: 10
operands: 11
7Operationoperator: 12
operand: 19
8Operationoperator: 14
operands: 15
9Operationoperator: 16
operand: 21
10Literal
11ExprTuple18, 21
12Literal
13ExprTuple19
14Literal
15ExprTuple20
16Literal
17ExprTuple21
18Variable
19Lambdaparameter: 48
body: 22
20ExprRangelambda_map: 23
start_index: 43
end_index: 44
21Variable
22Conditionalvalue: 24
condition: 25
23Lambdaparameter: 45
body: 26
24Operationoperator: 27
operands: 28
25Operationoperator: 29
operands: 30
26Operationoperator: 36
operand: 35
27Literal
28ExprTuple32, 33
29Literal
30ExprTuple48, 34
31ExprTuple35
32Operationoperator: 36
operand: 42
33Operationoperator: 37
operand: 42
34Operationoperator: 39
operands: 40
35IndexedVarvariable: 46
index: 45
36Literal
37Literal
38ExprTuple42
39Literal
40ExprTuple43, 44
41ExprTuple45
42IndexedVarvariable: 46
index: 48
43Literal
44Variable
45Variable
46Variable
47ExprTuple48
48Variable