logo

Expression of type LessEq

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.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]
expr = LessEq(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = _phase_est_circuit, domain = _m_domain, condition = LessEq(ModAbs(subtract(m, _b_floor), _two_pow_t), _e_value)), ProbOfAll(instance_param_or_params = sub_expr1, instance_element = _phase_est_circuit, domain = _m_domain, condition = _success_cond)).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 \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}
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: 38
operands: 1
1ExprTuple2, 3
2Operationoperator: 5
operand: 7
3Operationoperator: 5
operand: 8
4ExprTuple7
5Literal
6ExprTuple8
7Lambdaparameter: 138
body: 9
8Lambdaparameter: 138
body: 11
9Conditionalvalue: 13
condition: 12
10ExprTuple138
11Conditionalvalue: 13
condition: 14
12Operationoperator: 18
operands: 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15ExprTuple25, 20
16Literal
17ExprTuple21, 22, 23, 24
18Literal
19ExprTuple25, 26
20Operationoperator: 38
operands: 27
21ExprTuple28, 29
22ExprTuple30, 31
23ExprTuple32, 33
24ExprTuple34, 35
25Operationoperator: 36
operands: 37
26Operationoperator: 38
operands: 39
27ExprTuple40, 41
28ExprRangelambda_map: 42
start_index: 139
end_index: 145
29ExprRangelambda_map: 43
start_index: 139
end_index: 140
30ExprRangelambda_map: 44
start_index: 139
end_index: 145
31ExprRangelambda_map: 44
start_index: 118
end_index: 119
32ExprRangelambda_map: 45
start_index: 139
end_index: 145
33ExprRangelambda_map: 46
start_index: 139
end_index: 140
34ExprRangelambda_map: 47
start_index: 139
end_index: 145
35ExprRangelambda_map: 48
start_index: 139
end_index: 140
36Literal
37ExprTuple138, 49
38Literal
39ExprTuple50, 51
40Operationoperator: 63
operands: 52
41Operationoperator: 131
operands: 53
42Lambdaparameter: 117
body: 54
43Lambdaparameter: 117
body: 55
44Lambdaparameter: 117
body: 56
45Lambdaparameter: 117
body: 57
46Lambdaparameter: 117
body: 58
47Lambdaparameter: 117
body: 59
48Lambdaparameter: 117
body: 61
49Operationoperator: 106
operands: 62
50Operationoperator: 63
operands: 64
51Operationoperator: 141
operands: 65
52ExprTuple66, 133
53ExprTuple67, 108
54Operationoperator: 98
operands: 68
55Operationoperator: 75
operands: 69
56Operationoperator: 75
operands: 70
57Operationoperator: 71
operands: 72
58Operationoperator: 99
operands: 73
59Operationoperator: 75
operands: 74
60ExprTuple117
61Operationoperator: 75
operands: 76
62ExprTuple77, 78
63Literal
64ExprTuple79, 139
65ExprTuple144, 125
66Operationoperator: 131
operands: 80
67Operationoperator: 141
operands: 81
68NamedExprsstate: 82
69NamedExprselement: 83
targets: 91
70NamedExprselement: 84
targets: 85
71Literal
72NamedExprsbasis: 86
73NamedExprsoperation: 87
74NamedExprselement: 88
targets: 89
75Literal
76NamedExprselement: 90
targets: 91
77Literal
78Operationoperator: 131
operands: 92
79Operationoperator: 131
operands: 93
80ExprTuple138, 94
81ExprTuple144, 95
82Operationoperator: 96
operand: 113
83Operationoperator: 98
operands: 105
84Operationoperator: 99
operands: 100
85Operationoperator: 106
operands: 101
86Literal
87Literal
88Operationoperator: 104
operands: 102
89Operationoperator: 106
operands: 103
90Operationoperator: 104
operands: 105
91Operationoperator: 106
operands: 107
92ExprTuple133, 108
93ExprTuple109, 110
94Operationoperator: 135
operand: 124
95Operationoperator: 131
operands: 112
96Literal
97ExprTuple113
98Literal
99Literal
100NamedExprsoperation: 114
part: 117
101ExprTuple139, 119
102NamedExprsstate: 115
part: 117
103ExprTuple139, 145
104Literal
105NamedExprsstate: 116
part: 117
106Literal
107ExprTuple118, 119
108Operationoperator: 135
operand: 139
109Operationoperator: 121
operands: 122
110Operationoperator: 135
operand: 134
111ExprTuple124
112ExprTuple145, 125
113Literal
114Operationoperator: 126
operands: 127
115Operationoperator: 128
operands: 129
116Literal
117Variable
118Operationoperator: 131
operands: 130
119Operationoperator: 131
operands: 132
120ExprTuple139
121Literal
122ExprTuple138, 133
123ExprTuple134
124Literal
125Operationoperator: 135
operand: 143
126Literal
127ExprTuple137, 145
128Literal
129ExprTuple138, 145
130ExprTuple145, 139
131Literal
132ExprTuple145, 140
133Operationoperator: 141
operands: 142
134Literal
135Literal
136ExprTuple143
137Literal
138Variable
139Literal
140Literal
141Literal
142ExprTuple144, 145
143Literal
144Literal
145Literal