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 Exists, 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([A, B], Conditional(Exists(instance_param_or_params = [Hspace, X, Y], instance_expr = InSet([Qmult(A), Qmult(B)], Set([sub_expr1, Hspace], [X, LinMap(Hspace, Complex)], [LinMap(X, Y), sub_expr1], [Complex, QmultCodomain], [QmultCodomain, Complex])), domain = HilbertSpaces), InClass(Qmult(A, B), QmultCodomain)))
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(A, B\right) \mapsto \left\{\exists_{\mathcal{H}, X, Y \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}}~\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\}\right) \textrm{ if } \left(A \thinspace B\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 11
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 29
operands: 6
4Literal
5ExprTuple7
6ExprTuple8, 45
7Lambdaparameters: 9
body: 10
8Operationoperator: 32
operands: 11
9ExprTuple52, 53, 51
10Conditionalvalue: 12
condition: 13
11ExprTuple40, 41
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple20, 21, 22
18ExprTuple23, 24
19Operationoperator: 25
operands: 26
20Operationoperator: 29
operands: 27
21Operationoperator: 29
operands: 28
22Operationoperator: 29
operands: 30
23Operationoperator: 32
operand: 40
24Operationoperator: 32
operand: 41
25Literal
26ExprTuple34, 35, 36, 37, 38
27ExprTuple52, 39
28ExprTuple53, 39
29Literal
30ExprTuple51, 39
31ExprTuple40
32Literal
33ExprTuple41
34ExprTuple44, 52
35ExprTuple53, 42
36ExprTuple43, 44
37ExprTuple50, 45
38ExprTuple45, 50
39Literal
40Variable
41Variable
42Operationoperator: 48
operands: 46
43Operationoperator: 48
operands: 47
44Operationoperator: 48
operands: 49
45Literal
46ExprTuple52, 50
47ExprTuple53, 51
48Literal
49ExprTuple52, 53
50Literal
51Variable
52Variable
53Variable