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
from proveit.logic import Equals
from proveit.physics.quantum.QPE import Psuccess, _success_prob_e
In [2]:
# build up the expression from sub-expressions
expr = Equals(Psuccess(e), _success_prob_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 success}\right]\left(e\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 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)\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: 118
body: 11
10ExprTuple118
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: 119
end_index: 120
25ExprRangelambda_map: 37
start_index: 119
end_index: 121
26ExprRangelambda_map: 38
start_index: 119
end_index: 120
27ExprRangelambda_map: 38
start_index: 101
end_index: 102
28ExprRangelambda_map: 39
start_index: 119
end_index: 120
29ExprRangelambda_map: 40
start_index: 119
end_index: 121
30ExprRangelambda_map: 41
start_index: 119
end_index: 120
31ExprRangelambda_map: 42
start_index: 119
end_index: 121
32Literal
33ExprTuple118, 43
34Literal
35ExprTuple44, 45
36Lambdaparameter: 100
body: 46
37Lambdaparameter: 100
body: 47
38Lambdaparameter: 100
body: 48
39Lambdaparameter: 100
body: 49
40Lambdaparameter: 100
body: 50
41Lambdaparameter: 100
body: 51
42Lambdaparameter: 100
body: 53
43Operationoperator: 91
operands: 54
44Operationoperator: 55
operands: 56
45Variable
46Operationoperator: 83
operands: 57
47Operationoperator: 64
operands: 58
48Operationoperator: 64
operands: 59
49Operationoperator: 60
operands: 61
50Operationoperator: 84
operands: 62
51Operationoperator: 64
operands: 63
52ExprTuple100
53Operationoperator: 64
operands: 65
54ExprTuple66, 67
55Literal
56ExprTuple68, 93
57NamedExprsstate: 69
58NamedExprselement: 70
targets: 78
59NamedExprselement: 71
targets: 72
60Literal
61NamedExprsbasis: 73
62NamedExprsoperation: 74
63NamedExprselement: 75
targets: 76
64Literal
65NamedExprselement: 77
targets: 78
66Literal
67Operationoperator: 113
operands: 79
68Operationoperator: 113
operands: 80
69Operationoperator: 81
operand: 96
70Operationoperator: 83
operands: 90
71Operationoperator: 84
operands: 85
72Operationoperator: 91
operands: 86
73Literal
74Literal
75Operationoperator: 89
operands: 87
76Operationoperator: 91
operands: 88
77Operationoperator: 89
operands: 90
78Operationoperator: 91
operands: 92
79ExprTuple93, 94
80ExprTuple118, 95
81Literal
82ExprTuple96
83Literal
84Literal
85NamedExprsoperation: 97
part: 100
86ExprTuple119, 102
87NamedExprsstate: 98
part: 100
88ExprTuple119, 120
89Literal
90NamedExprsstate: 99
part: 100
91Literal
92ExprTuple101, 102
93Operationoperator: 103
operands: 104
94Operationoperator: 106
operand: 119
95Operationoperator: 106
operand: 116
96Literal
97Operationoperator: 108
operands: 109
98Operationoperator: 110
operands: 111
99Literal
100Variable
101Operationoperator: 113
operands: 112
102Operationoperator: 113
operands: 114
103Literal
104ExprTuple115, 120
105ExprTuple119
106Literal
107ExprTuple116
108Literal
109ExprTuple117, 120
110Literal
111ExprTuple118, 120
112ExprTuple120, 119
113Literal
114ExprTuple120, 121
115Literal
116Literal
117Literal
118Variable
119Literal
120Literal
121Literal