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, k
from proveit.logic import InSet
from proveit.numbers import Add, Exp, Mult, Neg, e, frac, i, pi, two
from proveit.physics.quantum.QPE import _b_floor, _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, Add(frac(_b_floor, _two_pow_t), _delta_b_floor, Neg(Variable("_a", latex_format = r"{_{-}a}"))))), 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(\frac{b_{\textit{f}}}{2^{t}} + \delta_{b_{\textit{f}}} - {_{-}a}\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
20ExprTuple38, 24
21Literal
22Literal
23Operationoperator: 25
operands: 26
24Operationoperator: 36
operand: 31
25Literal
26ExprTuple28, 29, 30
27ExprTuple31
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operand: 39
30Operationoperator: 36
operand: 40
31Literal
32Literal
33ExprTuple39, 38
34Literal
35ExprTuple39
36Literal
37ExprTuple40
38Operationoperator: 41
operands: 42
39Literal
40Variable
41Literal
42ExprTuple43, 44
43Literal
44Literal