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 HilbertSpaces, Hspace, ScalarMult
from proveit.logic import And, Equals, Forall, InClass, InSet
from proveit.physics.quantum import Qmult, bra_varphi, ket_varphi, var_ket_psi, var_ket_v, varphi
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [var_ket_psi], instance_expr = 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)), domain = X), And(InClass(Hspace, HilbertSpaces), InClass(X, 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\{\forall_{\lvert \psi \rangle \in X}~\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)\right] \textrm{ if } \mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  X \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}\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: 17
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8
6Lambdaparameter: 42
body: 10
7Operationoperator: 12
operands: 11
8Operationoperator: 12
operands: 13
9ExprTuple42
10Conditionalvalue: 14
condition: 15
11ExprTuple43, 16
12Literal
13ExprTuple21, 16
14Operationoperator: 17
operand: 20
15Operationoperator: 39
operands: 19
16Literal
17Literal
18ExprTuple20
19ExprTuple42, 21
20Lambdaparameter: 50
body: 22
21Variable
22Conditionalvalue: 23
condition: 24
23Operationoperator: 25
operands: 26
24Operationoperator: 39
operands: 27
25Literal
26ExprTuple28, 29
27ExprTuple30, 43
28Operationoperator: 44
operands: 31
29Lambdaparameter: 47
body: 33
30Operationoperator: 34
operand: 50
31ExprTuple42, 46
32ExprTuple47
33Conditionalvalue: 35
condition: 36
34Literal
35Operationoperator: 37
operands: 38
36Operationoperator: 39
operands: 40
37Literal
38ExprTuple41, 42
39Literal
40ExprTuple47, 43
41Operationoperator: 44
operands: 45
42Variable
43Variable
44Literal
45ExprTuple46, 47
46Operationoperator: 48
operand: 50
47Variable
48Literal
49ExprTuple50
50Variable