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, l
from proveit.logic import InSet
from proveit.numbers import Exp, Mult, e, frac, i, pi, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _m_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Lambda(k, Conditional(Exp(Exp(e, Mult(two, pi, i, subtract(_delta_b_floor, frac(l, _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(\delta_{b_{\textit{f}}} - \frac{l}{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: 41
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple9, 10
8Operationoperator: 41
operands: 11
9Variable
10Operationoperator: 12
operands: 13
11ExprTuple14, 15
12Literal
13ExprTuple16, 17
14Literal
15Operationoperator: 18
operands: 19
16Literal
17Operationoperator: 25
operands: 20
18Literal
19ExprTuple43, 21, 22, 23
20ExprTuple40, 24
21Literal
22Literal
23Operationoperator: 25
operands: 26
24Operationoperator: 33
operand: 30
25Literal
26ExprTuple28, 29
27ExprTuple30
28Operationoperator: 31
operand: 35
29Operationoperator: 33
operand: 36
30Literal
31Literal
32ExprTuple35
33Literal
34ExprTuple36
35Literal
36Operationoperator: 37
operands: 38
37Literal
38ExprTuple39, 40
39Variable
40Operationoperator: 41
operands: 42
41Literal
42ExprTuple43, 44
43Literal
44Literal