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 = Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t)))
expr = Equals(Mult(Exp(frac(one, Exp(two, frac(_t, two))), two), Sum(index_or_indices = sub_expr1, summand = Mult(sub_expr2, sub_expr3), domain = _m_domain)), Mult(frac(one, _two_pow_t), Sum(index_or_indices = sub_expr1, summand = Mult(sub_expr3, sub_expr2), domain = _m_domain))).with_wrapping_at(2)
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())
\begin{array}{c} \begin{array}{l} \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) =  \\ \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) \end{array} \end{array}
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.()(2)('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
5ExprTuple7, 8
6ExprTuple9, 10
7Operationoperator: 62
operands: 11
8Operationoperator: 14
operand: 17
9Operationoperator: 53
operands: 13
10Operationoperator: 14
operand: 18
11ExprTuple16, 68
12ExprTuple17
13ExprTuple59, 58
14Literal
15ExprTuple18
16Operationoperator: 53
operands: 19
17Lambdaparameter: 66
body: 20
18Lambdaparameter: 66
body: 22
19ExprTuple59, 23
20Conditionalvalue: 24
condition: 26
21ExprTuple66
22Conditionalvalue: 25
condition: 26
23Operationoperator: 62
operands: 27
24Operationoperator: 60
operands: 28
25Operationoperator: 60
operands: 29
26Operationoperator: 30
operands: 31
27ExprTuple68, 32
28ExprTuple34, 33
29ExprTuple33, 34
30Literal
31ExprTuple66, 35
32Operationoperator: 53
operands: 36
33Operationoperator: 62
operands: 37
34Operationoperator: 62
operands: 38
35Operationoperator: 39
operands: 40
36ExprTuple69, 68
37ExprTuple42, 41
38ExprTuple42, 43
39Literal
40ExprTuple44, 45
41Operationoperator: 55
operand: 50
42Literal
43Operationoperator: 60
operands: 47
44Literal
45Operationoperator: 48
operands: 49
46ExprTuple50
47ExprTuple68, 64, 65, 51, 66
48Literal
49ExprTuple58, 52
50Operationoperator: 53
operands: 54
51Literal
52Operationoperator: 55
operand: 59
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