logo

Expression of type Lambda

from the theory of proveit.physics.quantum.QPE

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, Variable, t
from proveit.linear_algebra import ScalarMult, VecAdd
from proveit.logic import CartExp, InSet
from proveit.numbers import Add, Complex, Exp, Interval, Mult, Neg, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import _phase
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(sub_expr1, Conditional(InSet(ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1))), CartExp(Complex, Exp(two, one))), InSet(sub_expr1, Interval(Add(Neg(t), two), zero))))
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())
{_{-}a} \mapsto \left\{\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{-{_{-}a}} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) \in \mathbb{C}^{2^{1}} \textrm{ if } {_{-}a} \in \{-t + 2~\ldotp \ldotp~0\}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 60
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 5
operands: 4
3Operationoperator: 5
operands: 6
4ExprTuple7, 8
5Literal
6ExprTuple60, 9
7Operationoperator: 32
operands: 10
8Operationoperator: 11
operands: 12
9Operationoperator: 13
operands: 14
10ExprTuple15, 16
11Literal
12ExprTuple17, 18
13Literal
14ExprTuple19, 36
15Operationoperator: 40
operands: 20
16Operationoperator: 21
operands: 22
17Literal
18Operationoperator: 54
operands: 23
19Operationoperator: 24
operands: 25
20ExprTuple47, 26
21Literal
22ExprTuple27, 28
23ExprTuple56, 47
24Literal
25ExprTuple29, 56
26Operationoperator: 54
operands: 30
27Operationoperator: 43
operand: 36
28Operationoperator: 32
operands: 33
29Operationoperator: 58
operand: 39
30ExprTuple56, 35
31ExprTuple36
32Literal
33ExprTuple37, 38
34ExprTuple39
35Operationoperator: 40
operands: 41
36Literal
37Operationoperator: 54
operands: 42
38Operationoperator: 43
operand: 47
39Variable
40Literal
41ExprTuple47, 56
42ExprTuple45, 46
43Literal
44ExprTuple47
45Literal
46Operationoperator: 48
operands: 49
47Literal
48Literal
49ExprTuple56, 50, 51, 52, 53
50Literal
51Literal
52Operationoperator: 54
operands: 55
53Literal
54Literal
55ExprTuple56, 57
56Literal
57Operationoperator: 58
operand: 60
58Literal
59ExprTuple60
60Variable