logo
In [1]:
import proveit
# Automation is not needed when only building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_theorem_expr # Load the stored theorem expression as 'stored_expr'
# import the special expression
from proveit.physics.quantum.QPE import _precision_guarantee
In [2]:
# check that the built expression is the same as the stored expression
assert _precision_guarantee.expr == stored_expr
assert _precision_guarantee.expr._style_id == stored_expr._style_id
print("Passed sanity check: _precision_guarantee matches stored_expr")
Passed sanity check: _precision_guarantee matches stored_expr
In [3]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left[\begin{array}{l}\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)\end{array}\right] \geq \left(1 - \epsilon\right)
In [4]:
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)normalreversed('with_direction_reversed', 'is_reversed')
In [5]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 35
operands: 1
1ExprTuple2, 3
2Operationoperator: 118
operands: 4
3Operationoperator: 5
operand: 8
4ExprTuple124, 7
5Literal
6ExprTuple8
7Operationoperator: 111
operand: 12
8Lambdaparameter: 123
body: 11
9ExprTuple12
10ExprTuple123
11Conditionalvalue: 13
condition: 14
12Literal
13Operationoperator: 15
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19, 20, 21, 22
17Literal
18ExprTuple23, 24
19ExprTuple25, 26
20ExprTuple27, 28
21ExprTuple29, 30
22ExprTuple31, 32
23Operationoperator: 33
operands: 34
24Operationoperator: 35
operands: 36
25ExprRangelambda_map: 37
start_index: 124
end_index: 129
26ExprRangelambda_map: 38
start_index: 124
end_index: 125
27ExprRangelambda_map: 39
start_index: 124
end_index: 129
28ExprRangelambda_map: 39
start_index: 106
end_index: 107
29ExprRangelambda_map: 40
start_index: 124
end_index: 129
30ExprRangelambda_map: 41
start_index: 124
end_index: 125
31ExprRangelambda_map: 42
start_index: 124
end_index: 129
32ExprRangelambda_map: 43
start_index: 124
end_index: 125
33Literal
34ExprTuple123, 44
35Literal
36ExprTuple45, 46
37Lambdaparameter: 105
body: 47
38Lambdaparameter: 105
body: 48
39Lambdaparameter: 105
body: 49
40Lambdaparameter: 105
body: 50
41Lambdaparameter: 105
body: 51
42Lambdaparameter: 105
body: 52
43Lambdaparameter: 105
body: 54
44Operationoperator: 95
operands: 55
45Operationoperator: 56
operands: 57
46Operationoperator: 126
operands: 58
47Operationoperator: 87
operands: 59
48Operationoperator: 66
operands: 60
49Operationoperator: 66
operands: 61
50Operationoperator: 62
operands: 63
51Operationoperator: 88
operands: 64
52Operationoperator: 66
operands: 65
53ExprTuple105
54Operationoperator: 66
operands: 67
55ExprTuple68, 69
56Literal
57ExprTuple70, 124
58ExprTuple128, 71
59NamedExprsstate: 72
60NamedExprselement: 73
targets: 81
61NamedExprselement: 74
targets: 75
62Literal
63NamedExprsbasis: 76
64NamedExprsoperation: 77
65NamedExprselement: 78
targets: 79
66Literal
67NamedExprselement: 80
targets: 81
68Literal
69Operationoperator: 118
operands: 82
70Operationoperator: 118
operands: 83
71Operationoperator: 111
operand: 100
72Operationoperator: 85
operand: 101
73Operationoperator: 87
operands: 94
74Operationoperator: 88
operands: 89
75Operationoperator: 95
operands: 90
76Literal
77Literal
78Operationoperator: 93
operands: 91
79Operationoperator: 95
operands: 92
80Operationoperator: 93
operands: 94
81Operationoperator: 95
operands: 96
82ExprTuple120, 97
83ExprTuple98, 99
84ExprTuple100
85Literal
86ExprTuple101
87Literal
88Literal
89NamedExprsoperation: 102
part: 105
90ExprTuple124, 107
91NamedExprsstate: 103
part: 105
92ExprTuple124, 129
93Literal
94NamedExprsstate: 104
part: 105
95Literal
96ExprTuple106, 107
97Operationoperator: 111
operand: 124
98Operationoperator: 109
operands: 110
99Operationoperator: 111
operand: 121
100Literal
101Literal
102Operationoperator: 113
operands: 114
103Operationoperator: 115
operands: 116
104Literal
105Variable
106Operationoperator: 118
operands: 117
107Operationoperator: 118
operands: 119
108ExprTuple124
109Literal
110ExprTuple123, 120
111Literal
112ExprTuple121
113Literal
114ExprTuple122, 129
115Literal
116ExprTuple123, 129
117ExprTuple129, 124
118Literal
119ExprTuple129, 125
120Operationoperator: 126
operands: 127
121Literal
122Literal
123Variable
124Literal
125Literal
126Literal
127ExprTuple128, 129
128Literal
129Literal