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 Conditional, Lambda, k, m
from proveit.logic import Equals, InSet
from proveit.numbers import Exp, Mult, Neg, e, frac, i, one, 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, _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = InSet(k, _m_domain)
expr = Equals(Lambda(k, Conditional(Qmult(NumBra(m, _t), InverseFourierTransform(_t), NumKet(k, _t)), sub_expr1)), Lambda(k, Conditional(Mult(frac(one, Exp(two, frac(_t, two))), Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t)))), sub_expr1))).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[k \mapsto \left\{{_{t}}\langle m \rvert \thinspace {\mathrm {FT}}^{\dag}_{t} \thinspace \lvert k \rangle_{t} \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\right..\right] =  \\ \left[k \mapsto \left\{\frac{1}{2^{\frac{t}{2}}} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}} \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\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
3Lambdaparameter: 58
body: 5
4Lambdaparameter: 58
body: 7
5Conditionalvalue: 8
condition: 10
6ExprTuple58
7Conditionalvalue: 9
condition: 10
8Operationoperator: 11
operands: 12
9Operationoperator: 52
operands: 13
10Operationoperator: 14
operands: 15
11Literal
12ExprTuple16, 17, 18
13ExprTuple19, 20
14Literal
15ExprTuple58, 21
16Operationoperator: 22
operands: 23
17Operationoperator: 24
operand: 61
18Operationoperator: 26
operands: 27
19Operationoperator: 45
operands: 28
20Operationoperator: 54
operands: 29
21Operationoperator: 30
operands: 31
22Literal
23ExprTuple59, 61
24Literal
25ExprTuple61
26Literal
27ExprTuple58, 61
28ExprTuple51, 32
29ExprTuple33, 34
30Literal
31ExprTuple35, 36
32Operationoperator: 54
operands: 37
33Literal
34Operationoperator: 47
operand: 42
35Literal
36Operationoperator: 39
operands: 40
37ExprTuple60, 41
38ExprTuple42
39Literal
40ExprTuple50, 43
41Operationoperator: 45
operands: 44
42Operationoperator: 45
operands: 46
43Operationoperator: 47
operand: 51
44ExprTuple61, 60
45Literal
46ExprTuple49, 50
47Literal
48ExprTuple51
49Operationoperator: 52
operands: 53
50Operationoperator: 54
operands: 55
51Literal
52Literal
53ExprTuple60, 56, 57, 58, 59
54Literal
55ExprTuple60, 61
56Literal
57Literal
58Variable
59Variable
60Literal
61Literal