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(sub_expr3, Mult(sub_expr3, 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(\frac{1}{2^{\frac{t}{2}}} \cdot \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 \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\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: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 60
operands: 5
4Operationoperator: 60
operands: 6
5ExprTuple28, 7
6ExprTuple28, 8
7Operationoperator: 14
operand: 11
8Operationoperator: 60
operands: 10
9ExprTuple11
10ExprTuple28, 12
11Lambdaparameter: 66
body: 13
12Operationoperator: 14
operand: 17
13Conditionalvalue: 16
condition: 23
14Literal
15ExprTuple17
16Operationoperator: 60
operands: 18
17Lambdaparameter: 66
body: 20
18ExprTuple29, 21
19ExprTuple66
20Conditionalvalue: 22
condition: 23
21Operationoperator: 60
operands: 24
22Operationoperator: 60
operands: 25
23Operationoperator: 26
operands: 27
24ExprTuple28, 30
25ExprTuple29, 30
26Literal
27ExprTuple66, 31
28Operationoperator: 53
operands: 32
29Operationoperator: 62
operands: 33
30Operationoperator: 62
operands: 34
31Operationoperator: 35
operands: 36
32ExprTuple59, 37
33ExprTuple39, 38
34ExprTuple39, 40
35Literal
36ExprTuple41, 42
37Operationoperator: 62
operands: 43
38Operationoperator: 60
operands: 44
39Literal
40Operationoperator: 55
operand: 50
41Literal
42Operationoperator: 46
operands: 47
43ExprTuple68, 48
44ExprTuple68, 64, 65, 49, 66
45ExprTuple50
46Literal
47ExprTuple58, 51
48Operationoperator: 53
operands: 52
49Literal
50Operationoperator: 53
operands: 54
51Operationoperator: 55
operand: 59
52ExprTuple69, 68
53Literal
54ExprTuple57, 58
55Literal
56ExprTuple59
57Operationoperator: 60
operands: 61
58Operationoperator: 62
operands: 63
59Literal
60Literal
61ExprTuple68, 64, 65, 66, 67
62Literal
63ExprTuple68, 69
64Literal
65Literal
66Variable
67Variable
68Literal
69Literal