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.logic import InSet
from proveit.numbers import Exp, Mult, e, frac, i, pi, subtract, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Lambda(k, Conditional(Exp(Exp(e, Mult(two, pi, i, subtract(_phase, frac(m, _two_pow_t)))), k), 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\{(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\varphi - \frac{m}{2^{t}}\right)})^{k} \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: 9
body: 2
1ExprTuple9
2Conditionalvalue: 3
condition: 4
3Operationoperator: 38
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple9, 10
8Operationoperator: 38
operands: 11
9Variable
10Operationoperator: 12
operands: 13
11ExprTuple14, 15
12Literal
13ExprTuple16, 17
14Literal
15Operationoperator: 18
operands: 19
16Literal
17Operationoperator: 25
operands: 20
18Literal
19ExprTuple40, 21, 22, 23
20ExprTuple37, 24
21Literal
22Literal
23Operationoperator: 25
operands: 26
24Operationoperator: 31
operand: 30
25Literal
26ExprTuple28, 29
27ExprTuple30
28Literal
29Operationoperator: 31
operand: 33
30Literal
31Literal
32ExprTuple33
33Operationoperator: 34
operands: 35
34Literal
35ExprTuple36, 37
36Variable
37Operationoperator: 38
operands: 39
38Literal
39ExprTuple40, 41
40Literal
41Literal