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, k, m
from proveit.linear_algebra import ScalarMult
from proveit.logic import Equals, InSet
from proveit.numbers import Exp, Mult, e, i, pi, two
from proveit.physics.quantum import NumBra, NumKet, Qmult
from proveit.physics.quantum.QFT import InverseFourierTransform
from proveit.physics.quantum.QPE import _m_domain, _phase, _t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = NumBra(m, _t)
sub_expr2 = InverseFourierTransform(_t)
sub_expr3 = NumKet(k, _t)
sub_expr4 = Exp(e, Mult(two, pi, i, _phase, k))
expr = Lambda(k, Conditional(Equals(Qmult(sub_expr1, sub_expr2, ScalarMult(sub_expr4, sub_expr3)), Mult(sub_expr4, Qmult(sub_expr1, sub_expr2, sub_expr3))), InSet(k, _m_domain)))
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())
k \mapsto \left\{\left({_{t}}\langle m \rvert \thinspace {\mathrm {FT}}^{\dag}_{t} \thinspace \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t}\right)\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left({_{t}}\langle m \rvert \thinspace {\mathrm {FT}}^{\dag}_{t} \thinspace \lvert k \rangle_{t}\right)\right) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 54
body: 2
1ExprTuple54
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple54, 11
9Operationoperator: 22
operands: 12
10Operationoperator: 48
operands: 13
11Operationoperator: 14
operands: 15
12ExprTuple27, 28, 16
13ExprTuple26, 17
14Literal
15ExprTuple18, 19
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operands: 23
18Literal
19Operationoperator: 24
operands: 25
20Literal
21ExprTuple26, 29
22Literal
23ExprTuple27, 28, 29
24Literal
25ExprTuple30, 31
26Operationoperator: 39
operands: 32
27Operationoperator: 33
operands: 34
28Operationoperator: 35
operand: 46
29Operationoperator: 37
operands: 38
30Operationoperator: 39
operands: 40
31Operationoperator: 41
operand: 47
32ExprTuple43, 44
33Literal
34ExprTuple45, 46
35Literal
36ExprTuple46
37Literal
38ExprTuple54, 46
39Literal
40ExprTuple50, 46
41Literal
42ExprTuple47
43Literal
44Operationoperator: 48
operands: 49
45Variable
46Literal
47Literal
48Literal
49ExprTuple50, 51, 52, 53, 54
50Literal
51Literal
52Literal
53Literal
54Variable