# 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.logic import Equals
from proveit.numbers import one
from proveit.physics.quantum.QPE import _Psi_circuit
from proveit.statistics import Prob

In [2]:
# build up the expression from sub-expressions
expr = Equals(Prob(_Psi_circuit), 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())

\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert + \rangle} & \multigate{4}{\textrm{QPE}\left(U, t\right)} & \multiqout{3}{\lvert \Psi \rangle} \\
\qin{\lvert + \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & \ghostqout{\lvert \Psi \rangle} \\
\qin{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} & \ghost{\textrm{QPE}\left(U, t\right)} & \ghostqout{\lvert \Psi \rangle} \\
\qin{\lvert + \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & \ghostqout{\lvert \Psi \rangle} \\
\qin{\lvert u \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & \qout{\lvert u \rangle}
} \end{array}\right) = 1

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, 68
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Operationoperator: 7
operands: 8
7Literal
8ExprTuple9, 10, 11
9ExprTuple12, 13
10ExprTuple14, 15
11ExprTuple16, 17
12ExprRangelambda_map: 18
start_index: 68
end_index: 69
13ExprRangelambda_map: 19
start_index: 68
end_index: 70
14ExprRangelambda_map: 20
start_index: 68
end_index: 69
15ExprRangelambda_map: 20
start_index: 60
end_index: 61
16ExprRangelambda_map: 21
start_index: 68
end_index: 69
17ExprRangelambda_map: 22
start_index: 68
end_index: 70
18Lambdaparameter: 59
body: 23
19Lambdaparameter: 59
body: 24
20Lambdaparameter: 59
body: 25
21Lambdaparameter: 59
body: 26
22Lambdaparameter: 59
body: 28
23Operationoperator: 45
operands: 29
24Operationoperator: 33
operands: 30
25Operationoperator: 33
operands: 31
26Operationoperator: 33
operands: 32
27ExprTuple59
28Operationoperator: 33
operands: 34
30NamedExprselement: 36
targets: 42
31NamedExprselement: 37
targets: 38
32NamedExprselement: 39
targets: 40
33Literal
34NamedExprselement: 41
targets: 42
35Operationoperator: 43
operand: 55
36Operationoperator: 45
operands: 52
37Operationoperator: 46
operands: 47
38Operationoperator: 53
operands: 48
39Operationoperator: 51
operands: 49
40Operationoperator: 53
operands: 50
41Operationoperator: 51
operands: 52
42Operationoperator: 53
operands: 54
43Literal
44ExprTuple55
45Literal
46Literal
47NamedExprsoperation: 56
part: 59
48ExprTuple68, 61
part: 59
50ExprTuple68, 69
51Literal
part: 59
53Literal
54ExprTuple60, 61
55Literal
56Operationoperator: 62
operands: 63
57Literal
58Literal
59Variable
60Operationoperator: 65
operands: 64
61Operationoperator: 65
operands: 66
62Literal
63ExprTuple67, 69
64ExprTuple69, 68
65Literal
66ExprTuple69, 70
67Literal
68Literal
69Literal
70Literal