# 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 Literal, k
from proveit.logic import Equals
from proveit.numbers import Add, Exp, Interval, Mult, Neg, Sum, e, frac, i, one, pi, two, zero
from proveit.physics.quantum import Ket
from proveit.physics.quantum.QPE import phase_, t_, two_pow_t

In [2]:
# build up the expression from sub-expressions
expr = Equals(Literal("Psi_1", latex_format = r"\Psi_{1}", theory = "proveit.physics.quantum.QPE"), Mult(frac(one, Exp(two, frac(t_, two))), Sum([k], Mult(Exp(e, Mult(two, pi, i, phase_, k)), Ket(k)), domain = Interval(zero, Add(two_pow_t, Neg(one))))))

Out[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(expr.latex())

\Psi_{1} = \left(\frac{1}{2^{\frac{t}{2}}} \cdot \left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle\right)\right)\right)

In [5]:
expr.style_options()

Out[5]:
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', '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
expr.expr_info()

Out[6]:
core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Literal
4Operationoperator: 35
operands: 5
5ExprTuple6, 7
6Operationoperator: 18
operands: 8
7Operationoperator: 9
operand: 12
8ExprTuple51, 11
9Literal
10ExprTuple12
11Operationoperator: 45
operands: 13
12Lambdaparameter: 42
body: 14
13ExprTuple49, 15
14Conditionalvalue: 16
condition: 17
15Operationoperator: 18
operands: 19
16Operationoperator: 35
operands: 20
17Operationoperator: 21
operands: 22
18Literal
19ExprTuple50, 49
20ExprTuple23, 24
21Literal
22ExprTuple42, 25
23Operationoperator: 45
operands: 26
24Operationoperator: 27
operand: 42
25Operationoperator: 29
operands: 30
26ExprTuple31, 32
27Literal
28ExprTuple42
29Literal
30ExprTuple33, 34
31Literal
32Operationoperator: 35
operands: 36
33Literal
34Operationoperator: 37
operands: 38
35Literal
36ExprTuple49, 39, 40, 41, 42
37Literal
38ExprTuple43, 44
39Literal
40Literal
41Literal
42Variable
43Operationoperator: 45
operands: 46
44Operationoperator: 47
operand: 51
45Literal
46ExprTuple49, 50
47Literal
48ExprTuple51
49Literal
50Literal
51Literal