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.linear_algebra import ScalarMult, VecSum
from proveit.logic import Equals
from proveit.numbers import Exp, Mult, Sum, e, i, pi, two
from proveit.physics.quantum import NumBra, NumKet, Qmult
from proveit.physics.quantum.QFT import InverseFourierTransform
from proveit.physics.quantum.QPE import _m_domain, _phase, _t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = NumBra(m, _t)
sub_expr3 = InverseFourierTransform(_t)
sub_expr4 = NumKet(k, _t)
sub_expr5 = Exp(e, Mult(two, pi, i, _phase, k))
expr = Equals(VecSum(index_or_indices = sub_expr1, summand = Qmult(sub_expr2, sub_expr3, ScalarMult(sub_expr5, sub_expr4)), domain = _m_domain), Sum(index_or_indices = sub_expr1, summand = Mult(sub_expr5, Qmult(sub_expr2, sub_expr3, 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(\sum_{k=0}^{2^{t} - 1} \left({_{t}}\langle m \rvert \thinspace {\mathrm {FT}}^{\dag}_{t} \thinspace \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t}\right)\right)\right) = \left(\sum_{k = 0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left({_{t}}\langle m \rvert \thinspace {\mathrm {FT}}^{\dag}_{t} \thinspace \lvert k \rangle_{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: 5
operand: 9
4Operationoperator: 7
operand: 10
5Literal
6ExprTuple9
7Literal
8ExprTuple10
9Lambdaparameter: 59
body: 11
10Lambdaparameter: 59
body: 13
11Conditionalvalue: 14
condition: 16
12ExprTuple59
13Conditionalvalue: 15
condition: 16
14Operationoperator: 26
operands: 17
15Operationoperator: 50
operands: 18
16Operationoperator: 19
operands: 20
17ExprTuple31, 32, 21
18ExprTuple30, 22
19Literal
20ExprTuple59, 23
21Operationoperator: 24
operands: 25
22Operationoperator: 26
operands: 27
23Operationoperator: 28
operands: 29
24Literal
25ExprTuple30, 33
26Literal
27ExprTuple31, 32, 33
28Literal
29ExprTuple34, 35
30Operationoperator: 52
operands: 36
31Operationoperator: 37
operands: 38
32Operationoperator: 39
operand: 61
33Operationoperator: 41
operands: 42
34Literal
35Operationoperator: 43
operands: 44
36ExprTuple45, 46
37Literal
38ExprTuple47, 61
39Literal
40ExprTuple61
41Literal
42ExprTuple59, 61
43Literal
44ExprTuple48, 49
45Literal
46Operationoperator: 50
operands: 51
47Variable
48Operationoperator: 52
operands: 53
49Operationoperator: 54
operand: 62
50Literal
51ExprTuple60, 56, 57, 58, 59
52Literal
53ExprTuple60, 61
54Literal
55ExprTuple62
56Literal
57Literal
58Literal
59Variable
60Literal
61Literal
62Literal