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 m
from proveit.logic import Equals
from proveit.numbers import LessEq, ModAbs, subtract
from proveit.physics.quantum.QPE import Psuccess, _b_floor, _e_value, _m_domain, _phase_est_circuit, _two_pow_t
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
expr = Equals(Psuccess(_e_value), ProbOfAll(instance_param_or_params = [m], instance_element = _phase_est_circuit, domain = _m_domain, condition = LessEq(ModAbs(subtract(m, _b_floor), _two_pow_t), _e_value)).with_wrapping())
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[P_{\rm success}\right]\left(2^{t - n} - 1\right) = \left[\begin{array}{l}\textrm{Prob}_{m \in \{0~\ldotp \ldotp~2^{t} - 1\}~|~\left|m - b_{\textit{f}}\right|_{\textup{mod}\thinspace 2^{t}} \leq \left(2^{t - n} - 1\right)}~\\
\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert + \rangle} & \multigate{4}{\textrm{QPE}\left(U, t\right)} & \meter & \multiqout{3}{\lvert m \rangle_{t}} \\
\qin{\lvert + \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & \meter & \ghostqout{\lvert m \rangle_{t}} \\
\qin{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} & \ghost{\textrm{QPE}\left(U, t\right)} & \measure{\begin{array}{c}:\\ \left(t - 3\right) \times \\:\end{array}} \qw & \ghostqout{\lvert m \rangle_{t}} \\
\qin{\lvert + \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & \meter & \ghostqout{\lvert m \rangle_{t}} \\
\qin{\lvert u \rangle} & \ghost{\textrm{QPE}\left(U, t\right)} & { /^{s} } \qw & \qout{\lvert u \rangle}
} \end{array}\right)\end{array}\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: 45
4Operationoperator: 7
operand: 9
5Literal
6ExprTuple45
7Literal
8ExprTuple9
9Lambdaparameter: 123
body: 11
10ExprTuple123
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19, 20, 21
16Literal
17ExprTuple22, 23
18ExprTuple24, 25
19ExprTuple26, 27
20ExprTuple28, 29
21ExprTuple30, 31
22Operationoperator: 32
operands: 33
23Operationoperator: 34
operands: 35
24ExprRangelambda_map: 36
start_index: 124
end_index: 125
25ExprRangelambda_map: 37
start_index: 124
end_index: 126
26ExprRangelambda_map: 38
start_index: 124
end_index: 125
27ExprRangelambda_map: 38
start_index: 105
end_index: 106
28ExprRangelambda_map: 39
start_index: 124
end_index: 125
29ExprRangelambda_map: 40
start_index: 124
end_index: 126
30ExprRangelambda_map: 41
start_index: 124
end_index: 125
31ExprRangelambda_map: 42
start_index: 124
end_index: 126
32Literal
33ExprTuple123, 43
34Literal
35ExprTuple44, 45
36Lambdaparameter: 104
body: 46
37Lambdaparameter: 104
body: 47
38Lambdaparameter: 104
body: 48
39Lambdaparameter: 104
body: 49
40Lambdaparameter: 104
body: 50
41Lambdaparameter: 104
body: 51
42Lambdaparameter: 104
body: 53
43Operationoperator: 94
operands: 54
44Operationoperator: 55
operands: 56
45Operationoperator: 117
operands: 57
46Operationoperator: 86
operands: 58
47Operationoperator: 65
operands: 59
48Operationoperator: 65
operands: 60
49Operationoperator: 61
operands: 62
50Operationoperator: 87
operands: 63
51Operationoperator: 65
operands: 64
52ExprTuple104
53Operationoperator: 65
operands: 66
54ExprTuple67, 68
55Literal
56ExprTuple69, 96
57ExprTuple70, 97
58NamedExprsstate: 71
59NamedExprselement: 72
targets: 80
60NamedExprselement: 73
targets: 74
61Literal
62NamedExprsbasis: 75
63NamedExprsoperation: 76
64NamedExprselement: 77
targets: 78
65Literal
66NamedExprselement: 79
targets: 80
67Literal
68Operationoperator: 117
operands: 81
69Operationoperator: 117
operands: 82
70Operationoperator: 107
operands: 83
71Operationoperator: 84
operand: 100
72Operationoperator: 86
operands: 93
73Operationoperator: 87
operands: 88
74Operationoperator: 94
operands: 89
75Literal
76Literal
77Operationoperator: 92
operands: 90
78Operationoperator: 94
operands: 91
79Operationoperator: 92
operands: 93
80Operationoperator: 94
operands: 95
81ExprTuple96, 97
82ExprTuple123, 98
83ExprTuple119, 99
84Literal
85ExprTuple100
86Literal
87Literal
88NamedExprsoperation: 101
part: 104
89ExprTuple124, 106
90NamedExprsstate: 102
part: 104
91ExprTuple124, 125
92Literal
93NamedExprsstate: 103
part: 104
94Literal
95ExprTuple105, 106
96Operationoperator: 107
operands: 108
97Operationoperator: 127
operand: 124
98Operationoperator: 127
operand: 120
99Operationoperator: 117
operands: 111
100Literal
101Operationoperator: 112
operands: 113
102Operationoperator: 114
operands: 115
103Literal
104Variable
105Operationoperator: 117
operands: 116
106Operationoperator: 117
operands: 118
107Literal
108ExprTuple119, 125
109ExprTuple124
110ExprTuple120
111ExprTuple125, 121
112Literal
113ExprTuple122, 125
114Literal
115ExprTuple123, 125
116ExprTuple125, 124
117Literal
118ExprTuple125, 126
119Literal
120Literal
121Operationoperator: 127
operand: 129
122Literal
123Variable
124Literal
125Literal
126Literal
127Literal
128ExprTuple129
129Literal