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 k, l
from proveit.logic import Equals
from proveit.numbers import Exp, Mult, Sum, e, frac, i, one, pi, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _m_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = subtract(_delta_b_floor, frac(l, _two_pow_t))
sub_expr2 = Exp(e, Mult(two, pi, i, sub_expr1))
expr = Equals(Sum(index_or_indices = [k], summand = Exp(sub_expr2, k), domain = _m_domain), frac(subtract(one, Exp(e, Mult(two, pi, i, sub_expr1, _two_pow_t))), subtract(one, 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(\sum_{k = 0}^{2^{t} - 1} (\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right)})^{k}\right) = \frac{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right) \cdot 2^{t}}}{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: 5
operand: 8
4Operationoperator: 57
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameter: 24
body: 12
9Operationoperator: 46
operands: 13
10Operationoperator: 46
operands: 14
11ExprTuple24
12Conditionalvalue: 15
condition: 16
13ExprTuple48, 17
14ExprTuple48, 18
15Operationoperator: 61
operands: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 53
operand: 26
18Operationoperator: 53
operand: 27
19ExprTuple27, 24
20Literal
21ExprTuple24, 25
22ExprTuple26
23ExprTuple27
24Variable
25Operationoperator: 28
operands: 29
26Operationoperator: 61
operands: 30
27Operationoperator: 61
operands: 31
28Literal
29ExprTuple32, 33
30ExprTuple35, 34
31ExprTuple35, 36
32Literal
33Operationoperator: 46
operands: 37
34Operationoperator: 39
operands: 38
35Literal
36Operationoperator: 39
operands: 40
37ExprTuple60, 41
38ExprTuple63, 42, 43, 44, 60
39Literal
40ExprTuple63, 42, 43, 44
41Operationoperator: 53
operand: 48
42Literal
43Literal
44Operationoperator: 46
operands: 47
45ExprTuple48
46Literal
47ExprTuple49, 50
48Literal
49Operationoperator: 51
operand: 55
50Operationoperator: 53
operand: 56
51Literal
52ExprTuple55
53Literal
54ExprTuple56
55Literal
56Operationoperator: 57
operands: 58
57Literal
58ExprTuple59, 60
59Variable
60Operationoperator: 61
operands: 62
61Literal
62ExprTuple63, 64
63Literal
64Literal