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 l
from proveit.logic import Equals
from proveit.numbers import Abs, Exp, Mult, e, frac, i, one, pi, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _rel_indexed_alpha, _two_pow_t
from proveit.trigonometry import Sin
In [2]:
# build up the expression from sub-expressions
expr = Equals(Abs(_rel_indexed_alpha), Mult(frac(one, _two_pow_t), frac(Abs(subtract(one, Exp(e, Mult(two, pi, i, subtract(Mult(_two_pow_t, _delta_b_floor), l))))), Mult(two, Sin(Mult(pi, Abs(subtract(_delta_b_floor, frac(l, _two_pow_t)))))))))
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|\alpha_{b_{\textit{f}} \oplus l}\right| = \left(\frac{1}{2^{t}} \cdot \frac{\left|1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\left(2^{t} \cdot \delta_{b_{\textit{f}}}\right) - l\right)}\right|}{2 \cdot \sin{\left(\pi \cdot \left|\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right|\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: 34
operand: 7
4Operationoperator: 51
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Operationoperator: 10
operand: 14
8Operationoperator: 55
operands: 12
9Operationoperator: 55
operands: 13
10Literal
11ExprTuple14
12ExprTuple26, 59
13ExprTuple15, 16
14Operationoperator: 17
operands: 18
15Operationoperator: 34
operand: 21
16Operationoperator: 51
operands: 20
17Literal
18ExprTuple64, 58
19ExprTuple21
20ExprTuple65, 22
21Operationoperator: 45
operands: 23
22Operationoperator: 24
operand: 28
23ExprTuple26, 27
24Literal
25ExprTuple28
26Literal
27Operationoperator: 53
operand: 31
28Operationoperator: 51
operands: 30
29ExprTuple31
30ExprTuple41, 32
31Operationoperator: 62
operands: 33
32Operationoperator: 34
operand: 38
33ExprTuple36, 37
34Literal
35ExprTuple38
36Literal
37Operationoperator: 51
operands: 39
38Operationoperator: 45
operands: 40
39ExprTuple65, 41, 42, 43
40ExprTuple57, 44
41Literal
42Literal
43Operationoperator: 45
operands: 46
44Operationoperator: 53
operand: 50
45Literal
46ExprTuple48, 49
47ExprTuple50
48Operationoperator: 51
operands: 52
49Operationoperator: 53
operand: 58
50Operationoperator: 55
operands: 56
51Literal
52ExprTuple59, 57
53Literal
54ExprTuple58
55Literal
56ExprTuple58, 59
57Operationoperator: 60
operand: 64
58Variable
59Operationoperator: 62
operands: 63
60Literal
61ExprTuple64
62Literal
63ExprTuple65, 66
64Literal
65Literal
66Literal