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, NaturalPos, RealNonNeg
from proveit.physics.quantum import Qmult, var_ket_psi
In [2]:
# build up the expression from sub-expressions
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [U], instance_expr = 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), domain = Unitary(n)), InSet(n, NaturalPos)))
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())
n \mapsto \left\{\forall_{U \in \textrm{U}\left(n\right)}~\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]\right] \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 53
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 22
operand: 6
3Operationoperator: 37
operands: 5
4ExprTuple6
5ExprTuple53, 7
6Lambdaparameter: 51
body: 9
7Literal
8ExprTuple51
9Conditionalvalue: 10
condition: 11
10Operationoperator: 22
operand: 14
11Operationoperator: 37
operands: 13
12ExprTuple14
13ExprTuple51, 15
14Lambdaparameter: 44
body: 17
15Operationoperator: 18
operand: 53
16ExprTuple44
17Conditionalvalue: 20
condition: 21
18Literal
19ExprTuple53
20Operationoperator: 22
operand: 25
21Operationoperator: 37
operands: 24
22Literal
23ExprTuple25
24ExprTuple44, 26
25Lambdaparameter: 54
body: 27
26Literal
27Conditionalvalue: 28
condition: 29
28Operationoperator: 39
operands: 30
29Operationoperator: 31
operands: 32
30ExprTuple33, 44
31Literal
32ExprTuple34, 35
33Operationoperator: 49
operand: 41
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operands: 40
36ExprTuple41
37Literal
38ExprTuple54, 42
39Literal
40ExprTuple43, 44
41Operationoperator: 45
operands: 46
42Operationoperator: 47
operands: 48
43Operationoperator: 49
operand: 54
44Variable
45Literal
46ExprTuple51, 54
47Literal
48ExprTuple52, 53
49Literal
50ExprTuple54
51Variable
52Literal
53Variable
54Variable