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, m
from proveit.logic import Equals
from proveit.numbers import Exp, Mod, Mult, Neg, Sum, e, frac, i, one, pi, two
from proveit.physics.quantum.QPE import _alpha_m_mod_two_pow_t, _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = frac(one, _two_pow_t)
sub_expr3 = Exp(e, Mult(two, pi, i, _phase, k))
expr = Equals(Equals(_alpha_m_mod_two_pow_t, Mult(sub_expr2, Sum(index_or_indices = sub_expr1, summand = Mult(Exp(e, Neg(frac(Mult(two, pi, i, k, Mod(m, _two_pow_t)), _two_pow_t))), sub_expr3), domain = _m_domain))), Equals(_alpha_m_mod_two_pow_t, Mult(sub_expr2, Sum(index_or_indices = sub_expr1, summand = Mult(Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t))), sub_expr3), domain = _m_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(\alpha_{m ~\textup{mod}~ 2^{t}} = \left(\frac{1}{2^{t}} \cdot \left(\sum_{k = 0}^{2^{t} - 1} \left(\mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot \left(m ~\textup{mod}~ 2^{t}\right)}{2^{t}}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k}\right)\right)\right)\right) = \left(\alpha_{m ~\textup{mod}~ 2^{t}} = \left(\frac{1}{2^{t}} \cdot \left(\sum_{k = 0}^{2^{t} - 1} \left(\mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k}\right)\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: 5
operands: 1
1ExprTuple2, 3
2Operationoperator: 5
operands: 4
3Operationoperator: 5
operands: 6
4ExprTuple8, 7
5Literal
6ExprTuple8, 9
7Operationoperator: 66
operands: 10
8Operationoperator: 11
operand: 68
9Operationoperator: 66
operands: 13
10ExprTuple15, 14
11Literal
12ExprTuple68
13ExprTuple15, 16
14Operationoperator: 19
operand: 21
15Operationoperator: 58
operands: 18
16Operationoperator: 19
operand: 22
17ExprTuple21
18ExprTuple64, 75
19Literal
20ExprTuple22
21Lambdaparameter: 71
body: 23
22Lambdaparameter: 71
body: 25
23Conditionalvalue: 26
condition: 28
24ExprTuple71
25Conditionalvalue: 27
condition: 28
26Operationoperator: 66
operands: 29
27Operationoperator: 66
operands: 30
28Operationoperator: 31
operands: 32
29ExprTuple33, 35
30ExprTuple34, 35
31Literal
32ExprTuple71, 36
33Operationoperator: 76
operands: 37
34Operationoperator: 76
operands: 38
35Operationoperator: 76
operands: 39
36Operationoperator: 40
operands: 41
37ExprTuple44, 42
38ExprTuple44, 43
39ExprTuple44, 45
40Literal
41ExprTuple46, 47
42Operationoperator: 60
operand: 53
43Operationoperator: 60
operand: 54
44Literal
45Operationoperator: 66
operands: 50
46Literal
47Operationoperator: 51
operands: 52
48ExprTuple53
49ExprTuple54
50ExprTuple78, 69, 70, 55, 71
51Literal
52ExprTuple75, 56
53Operationoperator: 58
operands: 57
54Operationoperator: 58
operands: 59
55Literal
56Operationoperator: 60
operand: 64
57ExprTuple62, 75
58Literal
59ExprTuple63, 75
60Literal
61ExprTuple64
62Operationoperator: 66
operands: 65
63Operationoperator: 66
operands: 67
64Literal
65ExprTuple78, 69, 70, 71, 68
66Literal
67ExprTuple78, 69, 70, 71, 74
68Operationoperator: 72
operands: 73
69Literal
70Literal
71Variable
72Literal
73ExprTuple74, 75
74Variable
75Operationoperator: 76
operands: 77
76Literal
77ExprTuple78, 79
78Literal
79Literal