# 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, Sum, two
from proveit.physics.quantum.QPE import Pfail, _neg_domain, _pos_domain, _rel_indexed_alpha
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
sub_expr2 = Exp(Abs(_rel_indexed_alpha), two)
expr = ExprTuple(Pfail(e), Add(Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _pos_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())
\left(\left[P_{\rm fail}\right]\left(e\right), \left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2}\right) + \left(\sum_{l = e + 1}^{2^{t - 1}} \left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2}\right)\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: 3
operand: 46
2Operationoperator: 53
operands: 5
3Literal
4ExprTuple46
5ExprTuple6, 7
6Operationoperator: 9
operand: 11
7Operationoperator: 9
operand: 12
8ExprTuple11
9Literal
10ExprTuple12
11Lambdaparameter: 48
body: 13
12Lambdaparameter: 48
body: 15
13Conditionalvalue: 17
condition: 16
14ExprTuple48
15Conditionalvalue: 17
condition: 18
16Operationoperator: 21
operands: 19
17Operationoperator: 49
operands: 20
18Operationoperator: 21
operands: 22
19ExprTuple48, 23
20ExprTuple24, 51
21Literal
22ExprTuple48, 25
23Operationoperator: 29
operands: 26
24Operationoperator: 27
operand: 33
25Operationoperator: 29
operands: 30
26ExprTuple31, 32
27Literal
28ExprTuple33
29Literal
30ExprTuple39, 45
31Operationoperator: 53
operands: 34
32Operationoperator: 57
operand: 39
33Operationoperator: 36
operand: 40
34ExprTuple38, 59
35ExprTuple39
36Literal
37ExprTuple40
38Operationoperator: 57
operand: 45
39Operationoperator: 53
operands: 42
40Operationoperator: 43
operands: 44
41ExprTuple45
42ExprTuple46, 59
43Literal
44ExprTuple47, 48
45Operationoperator: 49
operands: 50
46Variable
47Literal
48Variable
49Literal
50ExprTuple51, 52
51Literal
52Operationoperator: 53
operands: 54
53Literal
54ExprTuple55, 56
55Literal
56Operationoperator: 57
operand: 59
57Literal
58ExprTuple59
59Literal