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 Lambda, X
from proveit.linear_algebra import Hspace
from proveit.logic import Forall, InClass, InSet
from proveit.physics.quantum import Qmult, QmultCodomain, bra_varphi, ket_varphi, var_ket_psi, varphi
In [2]:
# build up the expression from sub-expressions
expr = Lambda([Hspace, X], Forall(instance_param_or_params = [var_ket_psi], instance_expr = Forall(instance_param_or_params = [varphi], instance_expr = InClass(Qmult(var_ket_psi, bra_varphi), QmultCodomain), condition = InSet(ket_varphi, X)), domain = Hspace))
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 \mathcal{H}}~\left[\forall_{\varphi~|~\lvert \varphi \rangle \in X}~\left(\left(\lvert \psi \rangle \thinspace \langle \varphi \rvert\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\right)\right]\right]
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple13, 24
2Operationoperator: 9
operand: 4
3ExprTuple4
4Lambdaparameter: 28
body: 6
5ExprTuple28
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operand: 12
8Operationoperator: 19
operands: 11
9Literal
10ExprTuple12
11ExprTuple28, 13
12Lambdaparameter: 32
body: 14
13Variable
14Conditionalvalue: 15
condition: 16
15Operationoperator: 17
operands: 18
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 24
21Operationoperator: 25
operands: 26
22Literal
23Operationoperator: 27
operand: 32
24Variable
25Literal
26ExprTuple28, 29
27Literal
28Variable
29Operationoperator: 30
operand: 32
30Literal
31ExprTuple32
32Variable