# 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 ExprTuple, e, l
from proveit.numbers import Abs, Add, Exp, Interval, Neg, Sum, one, subtract, two
from proveit.physics.quantum.QPE import _neg_domain, _rel_indexed_alpha, _two_pow__t_minus_one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
sub_expr2 = Exp(Abs(_rel_indexed_alpha), two)
expr = ExprTuple(Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = Interval(Add(Neg(_two_pow__t_minus_one), one), subtract(Neg(e), one))))
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())
\left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2}, \sum_{l = -2^{t - 1} + 1}^{-e - 1} \left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 4
operand: 6
2Operationoperator: 4
operand: 7
3ExprTuple6
4Literal
5ExprTuple7
6Lambdaparameter: 45
body: 8
7Lambdaparameter: 45
body: 10
8Conditionalvalue: 12
condition: 11
9ExprTuple45
10Conditionalvalue: 12
condition: 13
11Operationoperator: 16
operands: 14
12Operationoperator: 48
operands: 15
13Operationoperator: 16
operands: 17
14ExprTuple45, 18
15ExprTuple19, 50
16Literal
17ExprTuple45, 20
18Operationoperator: 24
operands: 21
19Operationoperator: 22
operand: 27
20Operationoperator: 24
operands: 25
21ExprTuple28, 26
22Literal
23ExprTuple27
24Literal
25ExprTuple28, 29
26Operationoperator: 56
operand: 35
27Operationoperator: 31
operand: 36
28Operationoperator: 52
operands: 33
29Operationoperator: 52
operands: 34
30ExprTuple35
31Literal
32ExprTuple36
33ExprTuple37, 58
34ExprTuple38, 55
35Operationoperator: 52
operands: 39
36Operationoperator: 40
operands: 41
37Operationoperator: 56
operand: 46
38Operationoperator: 56
operand: 47
39ExprTuple47, 58
40Literal
41ExprTuple44, 45
42ExprTuple46
43ExprTuple47
44Literal
45Variable
46Operationoperator: 48
operands: 49
47Variable
48Literal
49ExprTuple50, 51
50Literal
51Operationoperator: 52
operands: 53
52Literal
53ExprTuple54, 55
54Literal
55Operationoperator: 56
operand: 58
56Literal
57ExprTuple58
58Literal