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, Lambda, X
from proveit.linear_algebra import ScalarMult
from proveit.logic import Equals, Forall, InSet
from proveit.physics.quantum import Qmult, bra_varphi, ket_varphi, var_ket_psi, var_ket_v, varphi
from proveit.physics.quantum.algebra import Hspace
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [varphi], instance_expr = Equals(Qmult(var_ket_psi, bra_varphi), Lambda(var_ket_v, Conditional(ScalarMult(Qmult(bra_varphi, var_ket_v), var_ket_psi), InSet(var_ket_v, Hspace)))), condition = InSet(ket_varphi, Hspace)), InSet(var_ket_psi, X))
Out[2]:
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_{\varphi~|~\lvert \varphi \rangle \in \mathcal{H}}~\left(\left(\lvert \psi \rangle \thinspace \langle \varphi \rvert\right) = \left[\lvert v \rangle \mapsto \left\{\left(\langle \varphi \rvert \thinspace \lvert v \rangle\right) \cdot \lvert \psi \rangle \textrm{ if } \lvert v \rangle \in \mathcal{H}\right..\right]\right) \textrm{ if } \lvert \psi \rangle \in X\right..
In [5]:
stored_expr.style_options()
Out[5]:
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()
Out[6]:
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 6
2Operationoperator: 25
operands: 5
3Literal
4ExprTuple6
5ExprTuple28, 7
6Lambdaparameter: 36
body: 8
7Variable
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 25
operands: 13
11Literal
12ExprTuple14, 15
13ExprTuple16, 29
14Operationoperator: 30
operands: 17
15Lambdaparameter: 33
body: 19
16Operationoperator: 20
operand: 36
17ExprTuple28, 32
18ExprTuple33
19Conditionalvalue: 21
condition: 22
20Literal
21Operationoperator: 23
operands: 24
22Operationoperator: 25
operands: 26
23Literal
24ExprTuple27, 28
25Literal
26ExprTuple33, 29
27Operationoperator: 30
operands: 31
28Variable
29Variable
30Literal
31ExprTuple32, 33
32Operationoperator: 34
operand: 36
33Variable
34Literal
35ExprTuple36
36Variable