logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(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(\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..\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
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple46, 24
3Conditionalvalue: 4
condition: 5
4Operationoperator: 20
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 45
body: 13
10Operationoperator: 15
operands: 14
11Operationoperator: 15
operands: 16
12ExprTuple45
13Conditionalvalue: 17
condition: 18
14ExprTuple46, 19
15Literal
16ExprTuple24, 19
17Operationoperator: 20
operand: 23
18Operationoperator: 42
operands: 22
19Literal
20Literal
21ExprTuple23
22ExprTuple45, 24
23Lambdaparameter: 53
body: 25
24Variable
25Conditionalvalue: 26
condition: 27
26Operationoperator: 28
operands: 29
27Operationoperator: 42
operands: 30
28Literal
29ExprTuple31, 32
30ExprTuple33, 46
31Operationoperator: 47
operands: 34
32Lambdaparameter: 50
body: 36
33Operationoperator: 37
operand: 53
34ExprTuple45, 49
35ExprTuple50
36Conditionalvalue: 38
condition: 39
37Literal
38Operationoperator: 40
operands: 41
39Operationoperator: 42
operands: 43
40Literal
41ExprTuple44, 45
42Literal
43ExprTuple50, 46
44Operationoperator: 47
operands: 48
45Variable
46Variable
47Literal
48ExprTuple49, 50
49Operationoperator: 51
operand: 53
50Variable
51Literal
52ExprTuple53
53Variable