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, Mult, Neg, Sum, e, frac, i, one, pi, subtract, 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)
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, m), _two_pow_t))), Exp(e, Mult(two, pi, i, _phase, k))), domain = _m_domain))), Equals(_alpha_m_mod_two_pow_t, Mult(sub_expr2, Sum(index_or_indices = sub_expr1, summand = Exp(Exp(e, Mult(two, pi, i, subtract(_phase, frac(m, _two_pow_t)))), k), 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 m}{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} (\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\varphi - \frac{m}{2^{t}}\right)})^{k}\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: 65
operands: 10
8Operationoperator: 11
operand: 15
9Operationoperator: 65
operands: 13
10ExprTuple16, 14
11Literal
12ExprTuple15
13ExprTuple16, 17
14Operationoperator: 21
operand: 23
15Operationoperator: 19
operands: 74
16Operationoperator: 73
operands: 20
17Operationoperator: 21
operand: 24
18ExprTuple23
19Literal
20ExprTuple64, 76
21Literal
22ExprTuple24
23Lambdaparameter: 71
body: 25
24Lambdaparameter: 71
body: 27
25Conditionalvalue: 28
condition: 30
26ExprTuple71
27Conditionalvalue: 29
condition: 30
28Operationoperator: 65
operands: 31
29Operationoperator: 77
operands: 32
30Operationoperator: 33
operands: 34
31ExprTuple35, 36
32ExprTuple37, 71
33Literal
34ExprTuple71, 38
35Operationoperator: 77
operands: 39
36Operationoperator: 77
operands: 40
37Operationoperator: 77
operands: 41
38Operationoperator: 42
operands: 43
39ExprTuple46, 44
40ExprTuple46, 45
41ExprTuple46, 47
42Literal
43ExprTuple48, 49
44Operationoperator: 67
operand: 54
45Operationoperator: 65
operands: 51
46Literal
47Operationoperator: 65
operands: 52
48Literal
49Operationoperator: 58
operands: 53
50ExprTuple54
51ExprTuple79, 69, 70, 62, 71
52ExprTuple79, 69, 70, 55
53ExprTuple76, 56
54Operationoperator: 73
operands: 57
55Operationoperator: 58
operands: 59
56Operationoperator: 67
operand: 64
57ExprTuple61, 76
58Literal
59ExprTuple62, 63
60ExprTuple64
61Operationoperator: 65
operands: 66
62Literal
63Operationoperator: 67
operand: 72
64Literal
65Literal
66ExprTuple79, 69, 70, 71, 75
67Literal
68ExprTuple72
69Literal
70Literal
71Variable
72Operationoperator: 73
operands: 74
73Literal
74ExprTuple75, 76
75Variable
76Operationoperator: 77
operands: 78
77Literal
78ExprTuple79, 80
79Literal
80Literal