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 e, m
from proveit.logic import Equals
from proveit.numbers import LessEq, ModAbs, one, subtract
from proveit.physics.quantum.QPE import Pfail, _b_floor, _m_domain, _phase_est_circuit, _two_pow_t
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
expr = Equals(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)), subtract(one, Pfail(e))).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[\textrm{Prob}_{m \in \{0~\ldotp \ldotp~2^{t} - 1\}~|~\left|m - b_{\textit{f}}\right|_{\textup{mod}\thinspace 2^{t}} \leq e}~\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)\right] =  \\ \left(1 - \left[P_{\rm fail}\right]\left(e\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
3Operationoperator: 5
operand: 8
4Operationoperator: 117
operands: 7
5Literal
6ExprTuple8
7ExprTuple123, 9
8Lambdaparameter: 122
body: 11
9Operationoperator: 110
operand: 15
10ExprTuple122
11Conditionalvalue: 13
condition: 14
12ExprTuple15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 20
operand: 49
16Literal
17ExprTuple22, 23, 24, 25
18Literal
19ExprTuple26, 27
20Literal
21ExprTuple49
22ExprTuple28, 29
23ExprTuple30, 31
24ExprTuple32, 33
25ExprTuple34, 35
26Operationoperator: 36
operands: 37
27Operationoperator: 38
operands: 39
28ExprRangelambda_map: 40
start_index: 123
end_index: 124
29ExprRangelambda_map: 41
start_index: 123
end_index: 125
30ExprRangelambda_map: 42
start_index: 123
end_index: 124
31ExprRangelambda_map: 42
start_index: 105
end_index: 106
32ExprRangelambda_map: 43
start_index: 123
end_index: 124
33ExprRangelambda_map: 44
start_index: 123
end_index: 125
34ExprRangelambda_map: 45
start_index: 123
end_index: 124
35ExprRangelambda_map: 46
start_index: 123
end_index: 125
36Literal
37ExprTuple122, 47
38Literal
39ExprTuple48, 49
40Lambdaparameter: 104
body: 50
41Lambdaparameter: 104
body: 51
42Lambdaparameter: 104
body: 52
43Lambdaparameter: 104
body: 53
44Lambdaparameter: 104
body: 54
45Lambdaparameter: 104
body: 55
46Lambdaparameter: 104
body: 57
47Operationoperator: 95
operands: 58
48Operationoperator: 59
operands: 60
49Variable
50Operationoperator: 87
operands: 61
51Operationoperator: 68
operands: 62
52Operationoperator: 68
operands: 63
53Operationoperator: 64
operands: 65
54Operationoperator: 88
operands: 66
55Operationoperator: 68
operands: 67
56ExprTuple104
57Operationoperator: 68
operands: 69
58ExprTuple70, 71
59Literal
60ExprTuple72, 97
61NamedExprsstate: 73
62NamedExprselement: 74
targets: 82
63NamedExprselement: 75
targets: 76
64Literal
65NamedExprsbasis: 77
66NamedExprsoperation: 78
67NamedExprselement: 79
targets: 80
68Literal
69NamedExprselement: 81
targets: 82
70Literal
71Operationoperator: 117
operands: 83
72Operationoperator: 117
operands: 84
73Operationoperator: 85
operand: 100
74Operationoperator: 87
operands: 94
75Operationoperator: 88
operands: 89
76Operationoperator: 95
operands: 90
77Literal
78Literal
79Operationoperator: 93
operands: 91
80Operationoperator: 95
operands: 92
81Operationoperator: 93
operands: 94
82Operationoperator: 95
operands: 96
83ExprTuple97, 98
84ExprTuple122, 99
85Literal
86ExprTuple100
87Literal
88Literal
89NamedExprsoperation: 101
part: 104
90ExprTuple123, 106
91NamedExprsstate: 102
part: 104
92ExprTuple123, 124
93Literal
94NamedExprsstate: 103
part: 104
95Literal
96ExprTuple105, 106
97Operationoperator: 107
operands: 108
98Operationoperator: 110
operand: 123
99Operationoperator: 110
operand: 120
100Literal
101Operationoperator: 112
operands: 113
102Operationoperator: 114
operands: 115
103Literal
104Variable
105Operationoperator: 117
operands: 116
106Operationoperator: 117
operands: 118
107Literal
108ExprTuple119, 124
109ExprTuple123
110Literal
111ExprTuple120
112Literal
113ExprTuple121, 124
114Literal
115ExprTuple122, 124
116ExprTuple124, 123
117Literal
118ExprTuple124, 125
119Literal
120Literal
121Literal
122Variable
123Literal
124Literal
125Literal