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, _two_pow_t
from proveit.trigonometry import Sin
In [2]:
# build up the expression from sub-expressions
sub_expr1 = frac(one, _two_pow_t)
sub_expr2 = subtract(_delta_b_floor, frac(l, _two_pow_t))
sub_expr3 = subtract(one, Exp(e, Mult(two, pi, i, subtract(Mult(_two_pow_t, _delta_b_floor), l))))
expr = Equals(Abs(Mult(sub_expr1, frac(sub_expr3, subtract(one, Exp(e, Mult(two, pi, i, sub_expr2)))))), Mult(sub_expr1, frac(Abs(sub_expr3), Mult(two, Sin(Mult(pi, Abs(sub_expr2)))))))
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|\frac{1}{2^{t}} \cdot \frac{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\left(2^{t} \cdot \delta_{b_{\textit{f}}}\right) - l\right)}}{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right)}}\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: 38
operand: 7
4Operationoperator: 56
operands: 6
5ExprTuple7
6ExprTuple11, 8
7Operationoperator: 56
operands: 9
8Operationoperator: 62
operands: 10
9ExprTuple11, 12
10ExprTuple13, 14
11Operationoperator: 62
operands: 15
12Operationoperator: 62
operands: 16
13Operationoperator: 38
operand: 20
14Operationoperator: 56
operands: 18
15ExprTuple27, 67
16ExprTuple20, 19
17ExprTuple20
18ExprTuple71, 21
19Operationoperator: 50
operands: 22
20Operationoperator: 50
operands: 23
21Operationoperator: 24
operand: 29
22ExprTuple27, 26
23ExprTuple27, 28
24Literal
25ExprTuple29
26Operationoperator: 58
operand: 33
27Literal
28Operationoperator: 58
operand: 34
29Operationoperator: 56
operands: 32
30ExprTuple33
31ExprTuple34
32ExprTuple46, 35
33Operationoperator: 69
operands: 36
34Operationoperator: 69
operands: 37
35Operationoperator: 38
operand: 45
36ExprTuple41, 40
37ExprTuple41, 42
38Literal
39ExprTuple45
40Operationoperator: 56
operands: 43
41Literal
42Operationoperator: 56
operands: 44
43ExprTuple71, 46, 47, 45
44ExprTuple71, 46, 47, 48
45Operationoperator: 50
operands: 49
46Literal
47Literal
48Operationoperator: 50
operands: 51
49ExprTuple61, 52
50Literal
51ExprTuple53, 54
52Operationoperator: 58
operand: 60
53Operationoperator: 56
operands: 57
54Operationoperator: 58
operand: 66
55ExprTuple60
56Literal
57ExprTuple67, 61
58Literal
59ExprTuple66
60Operationoperator: 62
operands: 63
61Operationoperator: 64
operand: 68
62Literal
63ExprTuple66, 67
64Literal
65ExprTuple68
66Variable
67Operationoperator: 69
operands: 70
68Literal
69Literal
70ExprTuple71, 72
71Literal
72Literal