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