logo

Expression of type Prob

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 SetOfAll
from proveit.numbers import ModAbs, greater, subtract
from proveit.physics.quantum.QPE import _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 = 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())
\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()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameter: 115
body: 8
7ExprTuple115
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16, 17, 18
13Literal
14ExprTuple19, 20
15ExprTuple21, 22
16ExprTuple23, 24
17ExprTuple25, 26
18ExprTuple27, 28
19Operationoperator: 29
operands: 30
20Operationoperator: 31
operands: 32
21ExprRangelambda_map: 33
start_index: 116
end_index: 117
22ExprRangelambda_map: 34
start_index: 116
end_index: 118
23ExprRangelambda_map: 35
start_index: 116
end_index: 117
24ExprRangelambda_map: 35
start_index: 98
end_index: 99
25ExprRangelambda_map: 36
start_index: 116
end_index: 117
26ExprRangelambda_map: 37
start_index: 116
end_index: 118
27ExprRangelambda_map: 38
start_index: 116
end_index: 117
28ExprRangelambda_map: 39
start_index: 116
end_index: 118
29Literal
30ExprTuple115, 40
31Literal
32ExprTuple41, 42
33Lambdaparameter: 97
body: 43
34Lambdaparameter: 97
body: 44
35Lambdaparameter: 97
body: 45
36Lambdaparameter: 97
body: 46
37Lambdaparameter: 97
body: 47
38Lambdaparameter: 97
body: 48
39Lambdaparameter: 97
body: 50
40Operationoperator: 88
operands: 51
41Variable
42Operationoperator: 52
operands: 53
43Operationoperator: 80
operands: 54
44Operationoperator: 61
operands: 55
45Operationoperator: 61
operands: 56
46Operationoperator: 57
operands: 58
47Operationoperator: 81
operands: 59
48Operationoperator: 61
operands: 60
49ExprTuple97
50Operationoperator: 61
operands: 62
51ExprTuple63, 64
52Literal
53ExprTuple65, 90
54NamedExprsstate: 66
55NamedExprselement: 67
targets: 75
56NamedExprselement: 68
targets: 69
57Literal
58NamedExprsbasis: 70
59NamedExprsoperation: 71
60NamedExprselement: 72
targets: 73
61Literal
62NamedExprselement: 74
targets: 75
63Literal
64Operationoperator: 110
operands: 76
65Operationoperator: 110
operands: 77
66Operationoperator: 78
operand: 93
67Operationoperator: 80
operands: 87
68Operationoperator: 81
operands: 82
69Operationoperator: 88
operands: 83
70Literal
71Literal
72Operationoperator: 86
operands: 84
73Operationoperator: 88
operands: 85
74Operationoperator: 86
operands: 87
75Operationoperator: 88
operands: 89
76ExprTuple90, 91
77ExprTuple115, 92
78Literal
79ExprTuple93
80Literal
81Literal
82NamedExprsoperation: 94
part: 97
83ExprTuple116, 99
84NamedExprsstate: 95
part: 97
85ExprTuple116, 117
86Literal
87NamedExprsstate: 96
part: 97
88Literal
89ExprTuple98, 99
90Operationoperator: 100
operands: 101
91Operationoperator: 103
operand: 116
92Operationoperator: 103
operand: 113
93Literal
94Operationoperator: 105
operands: 106
95Operationoperator: 107
operands: 108
96Literal
97Variable
98Operationoperator: 110
operands: 109
99Operationoperator: 110
operands: 111
100Literal
101ExprTuple112, 117
102ExprTuple116
103Literal
104ExprTuple113
105Literal
106ExprTuple114, 117
107Literal
108ExprTuple115, 117
109ExprTuple117, 116
110Literal
111ExprTuple117, 118
112Literal
113Literal
114Literal
115Variable
116Literal
117Literal
118Literal