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 A, B, Conditional, Lambda, X, Y
from proveit.linear_algebra import HilbertSpaces, Hspace, LinMap
from proveit.logic import And, InClass, InSet, Set
from proveit.numbers import Complex
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = LinMap(Hspace, X)
expr = Lambda([Hspace, X, Y], Conditional(InSet([Qmult(A), Qmult(B)], Set([sub_expr1, Hspace], [X, LinMap(Hspace, Complex)], [LinMap(X, Y), sub_expr1], [Complex, QmultCodomain], [QmultCodomain, Complex])), And(InClass(Hspace, HilbertSpaces), InClass(X, HilbertSpaces), InClass(Y, 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(\mathcal{H}, X, Y\right) \mapsto \left\{\left(\left[A\right], \left[B\right]\right) \in \left\{\left(\mathcal{L}\left(\mathcal{H}, X\right), \mathcal{H}\right), \left(X, \mathcal{L}\left(\mathcal{H}, \mathbb{C}\right)\right), \left(\mathcal{L}\left(X, Y\right), \mathcal{L}\left(\mathcal{H}, X\right)\right), \left(\mathbb{C}, \mathcal{Q^*}\right), \left(\mathcal{Q^*}, \mathbb{C}\right)\right\} \textrm{ if } \mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  X \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  Y \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}\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
1ExprTuple43, 44, 42
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13
9ExprTuple14, 15
10Operationoperator: 16
operands: 17
11Operationoperator: 20
operands: 18
12Operationoperator: 20
operands: 19
13Operationoperator: 20
operands: 21
14Operationoperator: 23
operand: 31
15Operationoperator: 23
operand: 32
16Literal
17ExprTuple25, 26, 27, 28, 29
18ExprTuple43, 30
19ExprTuple44, 30
20Literal
21ExprTuple42, 30
22ExprTuple31
23Literal
24ExprTuple32
25ExprTuple35, 43
26ExprTuple44, 33
27ExprTuple34, 35
28ExprTuple41, 36
29ExprTuple36, 41
30Literal
31Variable
32Variable
33Operationoperator: 39
operands: 37
34Operationoperator: 39
operands: 38
35Operationoperator: 39
operands: 40
36Literal
37ExprTuple43, 41
38ExprTuple44, 42
39Literal
40ExprTuple43, 44
41Literal
42Variable
43Variable
44Variable