logo

Expression of type Lambda

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 And, Equals, Forall, InClass, InSet
from proveit.physics.quantum import HilbertSpaces, 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 = Lambda([Hspace, X], 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))))
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(\mathcal{H}, X\right) \mapsto \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()
Out[5]:
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
Out[6]:
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple45, 23
2Conditionalvalue: 3
condition: 4
3Operationoperator: 19
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9, 10
8Lambdaparameter: 44
body: 12
9Operationoperator: 14
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple44
12Conditionalvalue: 16
condition: 17
13ExprTuple45, 18
14Literal
15ExprTuple23, 18
16Operationoperator: 19
operand: 22
17Operationoperator: 41
operands: 21
18Literal
19Literal
20ExprTuple22
21ExprTuple44, 23
22Lambdaparameter: 52
body: 24
23Variable
24Conditionalvalue: 25
condition: 26
25Operationoperator: 27
operands: 28
26Operationoperator: 41
operands: 29
27Literal
28ExprTuple30, 31
29ExprTuple32, 45
30Operationoperator: 46
operands: 33
31Lambdaparameter: 49
body: 35
32Operationoperator: 36
operand: 52
33ExprTuple44, 48
34ExprTuple49
35Conditionalvalue: 37
condition: 38
36Literal
37Operationoperator: 39
operands: 40
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple43, 44
41Literal
42ExprTuple49, 45
43Operationoperator: 46
operands: 47
44Variable
45Variable
46Literal
47ExprTuple48, 49
48Operationoperator: 50
operand: 52
49Variable
50Literal
51ExprTuple52
52Variable