logo

Expression of type Implies

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 Forall, Implies
from proveit.numbers import LessEq, ModAbs, subtract
from proveit.physics.quantum.QPE import _b_floor, _e_value, _m_domain, _phase_est_circuit, _success_cond, _two_pow_t
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [m]
sub_expr2 = LessEq(ModAbs(subtract(m, _b_floor), _two_pow_t), _e_value)
expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = _success_cond, domain = _m_domain, condition = sub_expr2), LessEq(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = _phase_est_circuit, domain = _m_domain, condition = sub_expr2), ProbOfAll(instance_param_or_params = sub_expr1, instance_element = _phase_est_circuit, domain = _m_domain, condition = _success_cond)).with_wrapping_at(2)).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[\forall_{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(\left|\frac{m}{2^{t}} - \varphi\right|_{\textup{mod}\thinspace 1} \leq 2^{-n}\right)\right] \Rightarrow  \\ \left(\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 \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)\right] \leq  \\ \left[\textrm{Prob}_{m \in \{0~\ldotp \ldotp~2^{t} - 1\}~|~\left|\frac{m}{2^{t}} - \varphi\right|_{\textup{mod}\thinspace 1} \leq 2^{-n}}~\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] \end{array} \end{array}\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: 46
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameter: 146
body: 11
9Operationoperator: 13
operand: 15
10Operationoperator: 13
operand: 16
11Conditionalvalue: 34
condition: 20
12ExprTuple15
13Literal
14ExprTuple16
15Lambdaparameter: 146
body: 17
16Lambdaparameter: 146
body: 19
17Conditionalvalue: 21
condition: 20
18ExprTuple146
19Conditionalvalue: 21
condition: 22
20Operationoperator: 26
operands: 23
21Operationoperator: 24
operands: 25
22Operationoperator: 26
operands: 27
23ExprTuple33, 28
24Literal
25ExprTuple29, 30, 31, 32
26Literal
27ExprTuple33, 34
28Operationoperator: 46
operands: 35
29ExprTuple36, 37
30ExprTuple38, 39
31ExprTuple40, 41
32ExprTuple42, 43
33Operationoperator: 44
operands: 45
34Operationoperator: 46
operands: 47
35ExprTuple48, 49
36ExprRangelambda_map: 50
start_index: 147
end_index: 153
37ExprRangelambda_map: 51
start_index: 147
end_index: 148
38ExprRangelambda_map: 52
start_index: 147
end_index: 153
39ExprRangelambda_map: 52
start_index: 126
end_index: 127
40ExprRangelambda_map: 53
start_index: 147
end_index: 153
41ExprRangelambda_map: 54
start_index: 147
end_index: 148
42ExprRangelambda_map: 55
start_index: 147
end_index: 153
43ExprRangelambda_map: 56
start_index: 147
end_index: 148
44Literal
45ExprTuple146, 57
46Literal
47ExprTuple58, 59
48Operationoperator: 71
operands: 60
49Operationoperator: 139
operands: 61
50Lambdaparameter: 125
body: 62
51Lambdaparameter: 125
body: 63
52Lambdaparameter: 125
body: 64
53Lambdaparameter: 125
body: 65
54Lambdaparameter: 125
body: 66
55Lambdaparameter: 125
body: 67
56Lambdaparameter: 125
body: 69
57Operationoperator: 114
operands: 70
58Operationoperator: 71
operands: 72
59Operationoperator: 149
operands: 73
60ExprTuple74, 141
61ExprTuple75, 116
62Operationoperator: 106
operands: 76
63Operationoperator: 83
operands: 77
64Operationoperator: 83
operands: 78
65Operationoperator: 79
operands: 80
66Operationoperator: 107
operands: 81
67Operationoperator: 83
operands: 82
68ExprTuple125
69Operationoperator: 83
operands: 84
70ExprTuple85, 86
71Literal
72ExprTuple87, 147
73ExprTuple152, 133
74Operationoperator: 139
operands: 88
75Operationoperator: 149
operands: 89
76NamedExprsstate: 90
77NamedExprselement: 91
targets: 99
78NamedExprselement: 92
targets: 93
79Literal
80NamedExprsbasis: 94
81NamedExprsoperation: 95
82NamedExprselement: 96
targets: 97
83Literal
84NamedExprselement: 98
targets: 99
85Literal
86Operationoperator: 139
operands: 100
87Operationoperator: 139
operands: 101
88ExprTuple146, 102
89ExprTuple152, 103
90Operationoperator: 104
operand: 121
91Operationoperator: 106
operands: 113
92Operationoperator: 107
operands: 108
93Operationoperator: 114
operands: 109
94Literal
95Literal
96Operationoperator: 112
operands: 110
97Operationoperator: 114
operands: 111
98Operationoperator: 112
operands: 113
99Operationoperator: 114
operands: 115
100ExprTuple141, 116
101ExprTuple117, 118
102Operationoperator: 143
operand: 132
103Operationoperator: 139
operands: 120
104Literal
105ExprTuple121
106Literal
107Literal
108NamedExprsoperation: 122
part: 125
109ExprTuple147, 127
110NamedExprsstate: 123
part: 125
111ExprTuple147, 153
112Literal
113NamedExprsstate: 124
part: 125
114Literal
115ExprTuple126, 127
116Operationoperator: 143
operand: 147
117Operationoperator: 129
operands: 130
118Operationoperator: 143
operand: 142
119ExprTuple132
120ExprTuple153, 133
121Literal
122Operationoperator: 134
operands: 135
123Operationoperator: 136
operands: 137
124Literal
125Variable
126Operationoperator: 139
operands: 138
127Operationoperator: 139
operands: 140
128ExprTuple147
129Literal
130ExprTuple146, 141
131ExprTuple142
132Literal
133Operationoperator: 143
operand: 151
134Literal
135ExprTuple145, 153
136Literal
137ExprTuple146, 153
138ExprTuple153, 147
139Literal
140ExprTuple153, 148
141Operationoperator: 149
operands: 150
142Literal
143Literal
144ExprTuple151
145Literal
146Variable
147Literal
148Literal
149Literal
150ExprTuple152, 153
151Literal
152Literal
153Literal