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 ExprRange, Variable, k, m
from proveit.core_expr_types import Len
from proveit.linear_algebra import ScalarMult, VecSum
from proveit.logic import Equals
from proveit.numbers import Exp, Mult, e, i, one, pi, three, two
from proveit.physics.quantum import NumBra, NumKet
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 = Variable("_a", latex_format = r"{_{-}a}")
expr = Equals(Len(operands = [NumBra(m, _t), InverseFourierTransform(_t), VecSum(index_or_indices = [k], summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, _t)), domain = _m_domain)]), Len(operands = [ExprRange(sub_expr1, sub_expr1, one, three)]))
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({_{t}}\langle m \rvert, {\mathrm {FT}}^{\dag}_{t}, \sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t}\right)\right)| = |\left(1, 2, \ldots, 3\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
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9, 10
6Literal
7ExprTuple11
8Operationoperator: 12
operands: 13
9Operationoperator: 14
operand: 59
10Operationoperator: 16
operand: 21
11ExprRangelambda_map: 18
start_index: 60
end_index: 19
12Literal
13ExprTuple20, 59
14Literal
15ExprTuple59
16Literal
17ExprTuple21
18Lambdaparameter: 25
body: 25
19Literal
20Variable
21Lambdaparameter: 51
body: 24
22ExprTuple25
23ExprTuple51
24Conditionalvalue: 26
condition: 27
25Variable
26Operationoperator: 28
operands: 29
27Operationoperator: 30
operands: 31
28Literal
29ExprTuple32, 33
30Literal
31ExprTuple51, 34
32Operationoperator: 54
operands: 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35ExprTuple40, 41
36Literal
37ExprTuple51, 59
38Literal
39ExprTuple42, 43
40Literal
41Operationoperator: 44
operands: 45
42Literal
43Operationoperator: 46
operands: 47
44Literal
45ExprTuple58, 48, 49, 50, 51
46Literal
47ExprTuple52, 53
48Literal
49Literal
50Literal
51Variable
52Operationoperator: 54
operands: 55
53Operationoperator: 56
operand: 60
54Literal
55ExprTuple58, 59
56Literal
57ExprTuple60
58Literal
59Literal
60Literal