logo

Expression of type Equals

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 e, l
from proveit.logic import Equals
from proveit.numbers import Abs, Add, Exp, Interval, Neg, Sum, one, subtract, two
from proveit.physics.quantum.QPE import Pfail, _pos_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 = Equals(Pfail(e), Add(Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = Interval(Add(Neg(_two_pow__t_minus_one), one), subtract(Neg(e), one))), 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[P_{\rm fail}\right]\left(e\right) = \left(\left(\sum_{l = -2^{t - 1} + 1}^{-e - 1} \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
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 5
operand: 49
4Operationoperator: 56
operands: 6
5Literal
6ExprTuple7, 8
7Operationoperator: 10
operand: 12
8Operationoperator: 10
operand: 13
9ExprTuple12
10Literal
11ExprTuple13
12Lambdaparameter: 51
body: 14
13Lambdaparameter: 51
body: 16
14Conditionalvalue: 18
condition: 17
15ExprTuple51
16Conditionalvalue: 18
condition: 19
17Operationoperator: 22
operands: 20
18Operationoperator: 52
operands: 21
19Operationoperator: 22
operands: 23
20ExprTuple51, 24
21ExprTuple25, 54
22Literal
23ExprTuple51, 26
24Operationoperator: 30
operands: 27
25Operationoperator: 28
operand: 34
26Operationoperator: 30
operands: 31
27ExprTuple32, 33
28Literal
29ExprTuple34
30Literal
31ExprTuple35, 48
32Operationoperator: 56
operands: 36
33Operationoperator: 56
operands: 37
34Operationoperator: 38
operand: 43
35Operationoperator: 56
operands: 40
36ExprTuple41, 62
37ExprTuple42, 59
38Literal
39ExprTuple43
40ExprTuple49, 62
41Operationoperator: 60
operand: 48
42Operationoperator: 60
operand: 49
43Operationoperator: 46
operands: 47
44ExprTuple48
45ExprTuple49
46Literal
47ExprTuple50, 51
48Operationoperator: 52
operands: 53
49Variable
50Literal
51Variable
52Literal
53ExprTuple54, 55
54Literal
55Operationoperator: 56
operands: 57
56Literal
57ExprTuple58, 59
58Literal
59Operationoperator: 60
operand: 62
60Literal
61ExprTuple62
62Literal