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
from proveit.linear_algebra import HilbertSpaces, TensorProd
from proveit.logic import And, Forall, InClass, InSet
from proveit.physics.quantum import Qmult, var_ket_psi, var_ket_varphi
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [A, B]
expr = Lambda(sub_expr1, Conditional(Forall(instance_param_or_params = [var_ket_psi, var_ket_varphi], instance_expr = InSet(Qmult(var_ket_psi, var_ket_varphi), TensorProd(A, B)), domains = sub_expr1), And(InClass(A, HilbertSpaces), InClass(B, 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(A, B\right) \mapsto \left\{\forall_{\lvert \psi \rangle \in A, \lvert \varphi \rangle \in B}~\left(\left(\lvert \psi \rangle \thinspace \lvert \varphi \rangle\right) \in \left(A {\otimes} B\right)\right) \textrm{ if } A \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  B \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: 27
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 18
operands: 6
4Literal
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 25
body: 10
8Operationoperator: 12
operands: 11
9Operationoperator: 12
operands: 13
10Conditionalvalue: 14
condition: 15
11ExprTuple32, 16
12Literal
13ExprTuple34, 16
14Operationoperator: 29
operands: 17
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple22, 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Operationoperator: 29
operands: 28
23Operationoperator: 29
operands: 30
24Literal
25ExprTuple31, 33
26Literal
27ExprTuple32, 34
28ExprTuple31, 32
29Literal
30ExprTuple33, 34
31Variable
32Variable
33Variable
34Variable