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, t
from proveit.linear_algebra import ScalarMult, VecSum
from proveit.logic import Equals
from proveit.numbers import Add, Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = Add(t, one)
sub_expr3 = Add(k, two_pow_t)
expr = Equals(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, sub_expr2)), domain = Interval(two_pow_t, subtract(Mult(two, two_pow_t), one))), VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, sub_expr3)), NumKet(sub_expr3, sub_expr2)), domain = Interval(zero, subtract(two_pow_t, one))))
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(\sum_{k=2^{t}}^{\left(2 \cdot 2^{t}\right) - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t + 1}\right)\right) = \left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot \left(k + 2^{t}\right)} \cdot \lvert k + 2^{t} \rangle_{t + 1}\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: 6
operand: 8
4Operationoperator: 6
operand: 9
5ExprTuple8
6Literal
7ExprTuple9
8Lambdaparameter: 61
body: 10
9Lambdaparameter: 61
body: 12
10Conditionalvalue: 13
condition: 14
11ExprTuple61
12Conditionalvalue: 15
condition: 16
13Operationoperator: 19
operands: 17
14Operationoperator: 21
operands: 18
15Operationoperator: 19
operands: 20
16Operationoperator: 21
operands: 22
17ExprTuple23, 24
18ExprTuple61, 25
19Literal
20ExprTuple26, 27
21Literal
22ExprTuple61, 28
23Operationoperator: 64
operands: 29
24Operationoperator: 33
operands: 30
25Operationoperator: 35
operands: 31
26Operationoperator: 64
operands: 32
27Operationoperator: 33
operands: 34
28Operationoperator: 35
operands: 36
29ExprTuple39, 37
30ExprTuple61, 41
31ExprTuple62, 38
32ExprTuple39, 40
33Literal
34ExprTuple53, 41
35Literal
36ExprTuple42, 43
37Operationoperator: 55
operands: 44
38Operationoperator: 57
operands: 45
39Literal
40Operationoperator: 55
operands: 46
41Operationoperator: 57
operands: 47
42Literal
43Operationoperator: 57
operands: 48
44ExprTuple66, 50, 51, 52, 61
45ExprTuple49, 54
46ExprTuple66, 50, 51, 52, 53
47ExprTuple67, 63
48ExprTuple62, 54
49Operationoperator: 55
operands: 56
50Literal
51Literal
52Literal
53Operationoperator: 57
operands: 58
54Operationoperator: 59
operand: 63
55Literal
56ExprTuple66, 62
57Literal
58ExprTuple61, 62
59Literal
60ExprTuple63
61Variable
62Operationoperator: 64
operands: 65
63Literal
64Literal
65ExprTuple66, 67
66Literal
67Variable