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, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = Exp(e, Mult(two, pi, i, _phase, k))
sub_expr3 = frac(one, Exp(two, frac(_t, two)))
sub_expr4 = Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t)))
expr = Equals(Mult(sub_expr3, Sum(index_or_indices = sub_expr1, summand = Mult(sub_expr2, Mult(sub_expr3, sub_expr4)), domain = _m_domain)), Mult(Exp(sub_expr3, two), Sum(index_or_indices = sub_expr1, summand = Mult(sub_expr2, sub_expr4), 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(\frac{1}{2^{\frac{t}{2}}} \cdot \left(\sum_{k = 0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left(\frac{1}{2^{\frac{t}{2}}} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\right)\right)\right)\right) = \left(\left(\frac{1}{2^{\frac{t}{2}}}\right)^{2} \cdot \left(\sum_{k = 0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{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: 60
operands: 5
4Operationoperator: 60
operands: 6
5ExprTuple33, 7
6ExprTuple8, 9
7Operationoperator: 12
operand: 14
8Operationoperator: 62
operands: 11
9Operationoperator: 12
operand: 15
10ExprTuple14
11ExprTuple33, 68
12Literal
13ExprTuple15
14Lambdaparameter: 66
body: 16
15Lambdaparameter: 66
body: 18
16Conditionalvalue: 19
condition: 21
17ExprTuple66
18Conditionalvalue: 20
condition: 21
19Operationoperator: 60
operands: 22
20Operationoperator: 60
operands: 23
21Operationoperator: 24
operands: 25
22ExprTuple27, 26
23ExprTuple27, 34
24Literal
25ExprTuple66, 28
26Operationoperator: 60
operands: 29
27Operationoperator: 62
operands: 30
28Operationoperator: 31
operands: 32
29ExprTuple33, 34
30ExprTuple44, 35
31Literal
32ExprTuple36, 37
33Operationoperator: 56
operands: 38
34Operationoperator: 62
operands: 39
35Operationoperator: 60
operands: 40
36Literal
37Operationoperator: 41
operands: 42
38ExprTuple54, 43
39ExprTuple44, 45
40ExprTuple68, 64, 65, 46, 66
41Literal
42ExprTuple59, 47
43Operationoperator: 62
operands: 48
44Literal
45Operationoperator: 50
operand: 53
46Literal
47Operationoperator: 50
operand: 54
48ExprTuple68, 52
49ExprTuple53
50Literal
51ExprTuple54
52Operationoperator: 56
operands: 55
53Operationoperator: 56
operands: 57
54Literal
55ExprTuple69, 68
56Literal
57ExprTuple58, 59
58Operationoperator: 60
operands: 61
59Operationoperator: 62
operands: 63
60Literal
61ExprTuple68, 64, 65, 66, 67
62Literal
63ExprTuple68, 69
64Literal
65Literal
66Variable
67Variable
68Literal
69Literal