logo

Expression of type ProbOfAll

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, _two_pow_t
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
expr = ProbOfAll(instance_param_or_params = [m], instance_element = _phase_est_circuit, domain = _m_domain, condition = LessEq(ModAbs(subtract(m, _b_floor), _two_pow_t), _e_value)).with_wrapping()
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}{l}\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)\end{array}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 117
body: 5
4ExprTuple117
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13, 14, 15
10Literal
11ExprTuple16, 17
12ExprTuple18, 19
13ExprTuple20, 21
14ExprTuple22, 23
15ExprTuple24, 25
16Operationoperator: 26
operands: 27
17Operationoperator: 28
operands: 29
18ExprRangelambda_map: 30
start_index: 118
end_index: 119
19ExprRangelambda_map: 31
start_index: 118
end_index: 120
20ExprRangelambda_map: 32
start_index: 118
end_index: 119
21ExprRangelambda_map: 32
start_index: 99
end_index: 100
22ExprRangelambda_map: 33
start_index: 118
end_index: 119
23ExprRangelambda_map: 34
start_index: 118
end_index: 120
24ExprRangelambda_map: 35
start_index: 118
end_index: 119
25ExprRangelambda_map: 36
start_index: 118
end_index: 120
26Literal
27ExprTuple117, 37
28Literal
29ExprTuple38, 39
30Lambdaparameter: 98
body: 40
31Lambdaparameter: 98
body: 41
32Lambdaparameter: 98
body: 42
33Lambdaparameter: 98
body: 43
34Lambdaparameter: 98
body: 44
35Lambdaparameter: 98
body: 45
36Lambdaparameter: 98
body: 47
37Operationoperator: 88
operands: 48
38Operationoperator: 49
operands: 50
39Operationoperator: 111
operands: 51
40Operationoperator: 80
operands: 52
41Operationoperator: 59
operands: 53
42Operationoperator: 59
operands: 54
43Operationoperator: 55
operands: 56
44Operationoperator: 81
operands: 57
45Operationoperator: 59
operands: 58
46ExprTuple98
47Operationoperator: 59
operands: 60
48ExprTuple61, 62
49Literal
50ExprTuple63, 90
51ExprTuple64, 91
52NamedExprsstate: 65
53NamedExprselement: 66
targets: 74
54NamedExprselement: 67
targets: 68
55Literal
56NamedExprsbasis: 69
57NamedExprsoperation: 70
58NamedExprselement: 71
targets: 72
59Literal
60NamedExprselement: 73
targets: 74
61Literal
62Operationoperator: 111
operands: 75
63Operationoperator: 111
operands: 76
64Operationoperator: 101
operands: 77
65Operationoperator: 78
operand: 94
66Operationoperator: 80
operands: 87
67Operationoperator: 81
operands: 82
68Operationoperator: 88
operands: 83
69Literal
70Literal
71Operationoperator: 86
operands: 84
72Operationoperator: 88
operands: 85
73Operationoperator: 86
operands: 87
74Operationoperator: 88
operands: 89
75ExprTuple90, 91
76ExprTuple117, 92
77ExprTuple113, 93
78Literal
79ExprTuple94
80Literal
81Literal
82NamedExprsoperation: 95
part: 98
83ExprTuple118, 100
84NamedExprsstate: 96
part: 98
85ExprTuple118, 119
86Literal
87NamedExprsstate: 97
part: 98
88Literal
89ExprTuple99, 100
90Operationoperator: 101
operands: 102
91Operationoperator: 121
operand: 118
92Operationoperator: 121
operand: 114
93Operationoperator: 111
operands: 105
94Literal
95Operationoperator: 106
operands: 107
96Operationoperator: 108
operands: 109
97Literal
98Variable
99Operationoperator: 111
operands: 110
100Operationoperator: 111
operands: 112
101Literal
102ExprTuple113, 119
103ExprTuple118
104ExprTuple114
105ExprTuple119, 115
106Literal
107ExprTuple116, 119
108Literal
109ExprTuple117, 119
110ExprTuple119, 118
111Literal
112ExprTuple119, 120
113Literal
114Literal
115Operationoperator: 121
operand: 123
116Literal
117Variable
118Literal
119Literal
120Literal
121Literal
122ExprTuple123
123Literal