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.
# 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 Equals, Forall, 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 = Forall(instance_param_or_params = [Hspace, X], instance_expr = 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), domain = 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())

\forall_{\mathcal{H}, X \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}}~\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]\right]

In [5]:
stored_expr.style_options()

namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Operationoperator: 21
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple47, 25
4Conditionalvalue: 5
condition: 6
5Operationoperator: 21
operand: 10
6Operationoperator: 8
operands: 9
7ExprTuple10
8Literal
9ExprTuple11, 12
10Lambdaparameter: 46
body: 14
11Operationoperator: 16
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple46
14Conditionalvalue: 18
condition: 19
15ExprTuple47, 20
16Literal
17ExprTuple25, 20
18Operationoperator: 21
operand: 24
19Operationoperator: 43
operands: 23
20Literal
21Literal
22ExprTuple24
23ExprTuple46, 25
24Lambdaparameter: 54
body: 26
25Variable
26Conditionalvalue: 27
condition: 28
27Operationoperator: 29
operands: 30
28Operationoperator: 43
operands: 31
29Literal
30ExprTuple32, 33
31ExprTuple34, 47
32Operationoperator: 48
operands: 35
33Lambdaparameter: 51
body: 37
34Operationoperator: 38
operand: 54
35ExprTuple46, 50
36ExprTuple51
37Conditionalvalue: 39
condition: 40
38Literal
39Operationoperator: 41
operands: 42
40Operationoperator: 43
operands: 44
41Literal
42ExprTuple45, 46
43Literal
44ExprTuple51, 47
45Operationoperator: 48
operands: 49
46Variable
47Variable
48Literal
49ExprTuple50, 51
50Operationoperator: 52
operand: 54
51Variable
52Literal
53ExprTuple54
54Variable