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 Conditional, Lambda, U, alpha, n
from proveit.linear_algebra import Norm, Unitary
from proveit.logic import CartExp, Equals, Forall, InSet
from proveit.numbers import Complex, RealNonNeg
from proveit.physics.quantum import Qmult, var_ket_psi
In [2]:
# build up the expression from sub-expressions
expr = Lambda(U, Conditional(Forall(instance_param_or_params = [alpha], instance_expr = Forall(instance_param_or_params = [var_ket_psi], instance_expr = Equals(Norm(Qmult(U, var_ket_psi)), alpha), domain = CartExp(Complex, n), condition = Equals(Norm(var_ket_psi), alpha)), domain = RealNonNeg), InSet(U, Unitary(n))))
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())
U \mapsto \left\{\forall_{\alpha \in \mathbb{R}^{\ge 0}}~\left[\forall_{\lvert \psi \rangle \in \mathbb{C}^{n}~|~\left \|\lvert \psi \rangle\right \| = \alpha}~\left(\left \|U \thinspace \lvert \psi \rangle\right \| = \alpha\right)\right] \textrm{ if } U \in \textrm{U}\left(n\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 44
body: 2
1ExprTuple44
2Conditionalvalue: 3
condition: 4
3Operationoperator: 15
operand: 7
4Operationoperator: 30
operands: 6
5ExprTuple7
6ExprTuple44, 8
7Lambdaparameter: 37
body: 10
8Operationoperator: 11
operand: 46
9ExprTuple37
10Conditionalvalue: 13
condition: 14
11Literal
12ExprTuple46
13Operationoperator: 15
operand: 18
14Operationoperator: 30
operands: 17
15Literal
16ExprTuple18
17ExprTuple37, 19
18Lambdaparameter: 47
body: 20
19Literal
20Conditionalvalue: 21
condition: 22
21Operationoperator: 32
operands: 23
22Operationoperator: 24
operands: 25
23ExprTuple26, 37
24Literal
25ExprTuple27, 28
26Operationoperator: 42
operand: 34
27Operationoperator: 30
operands: 31
28Operationoperator: 32
operands: 33
29ExprTuple34
30Literal
31ExprTuple47, 35
32Literal
33ExprTuple36, 37
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operands: 41
36Operationoperator: 42
operand: 47
37Variable
38Literal
39ExprTuple44, 47
40Literal
41ExprTuple45, 46
42Literal
43ExprTuple47
44Variable
45Literal
46Variable
47Variable