# 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.
# import Expression classes needed to build the expression
from proveit import Conditional, Lambda, l
from proveit.logic import InSet
from proveit.numbers import Abs, Exp, two
from proveit.physics.quantum.QPE import _neg_domain, _rel_indexed_alpha

In [2]:
# build up the expression from sub-expressions
expr = Lambda(l, Conditional(Exp(Abs(_rel_indexed_alpha), two), InSet(l, _neg_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())

l \mapsto \left\{\left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2} \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\right)\}\right..

In [5]:
stored_expr.style_options()

no style options
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Lambdaparameter: 29
body: 2
1ExprTuple29
2Conditionalvalue: 3
condition: 4
3Operationoperator: 32
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 34
6Literal
7ExprTuple29, 9
8Operationoperator: 10
operand: 14
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14
12Literal
13ExprTuple15, 16
14Operationoperator: 17
operand: 21
15Operationoperator: 36
operands: 19
16Operationoperator: 40
operand: 23
17Literal
18ExprTuple21
19ExprTuple22, 42
20ExprTuple23
21Operationoperator: 24
operands: 25
22Operationoperator: 40
operand: 30
23Operationoperator: 36
operands: 27
24Literal
25ExprTuple28, 29
26ExprTuple30
27ExprTuple31, 42
28Literal
29Variable
30Operationoperator: 32
operands: 33
31Variable
32Literal
33ExprTuple34, 35
34Literal
35Operationoperator: 36
operands: 37
36Literal
37ExprTuple38, 39
38Literal
39Operationoperator: 40
operand: 42
40Literal
41ExprTuple42
42Literal