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