logo

Expression of type Implies

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, Forall, Implies, TRUE
from proveit.numbers import LessEq, ModAbs, one, subtract
from proveit.physics.quantum.QPE import Pfail, _b_floor, _m_domain, _phase_est_circuit, _two_pow_t
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [m]
expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = TRUE, domain = _m_domain), Equals(ProbOfAll(instance_param_or_params = sub_expr1, instance_element = _phase_est_circuit, domain = _m_domain, condition = LessEq(ModAbs(subtract(m, _b_floor), _two_pow_t), e)), subtract(one, Pfail(e))).with_wrapping_at(2)).with_wrapping_at(2)
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}{c} \begin{array}{l} \left[\forall_{m \in \{0~\ldotp \ldotp~2^{t} - 1\}}~\top\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[\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)\right] =  \\ \left(1 - \left[P_{\rm fail}\right]\left(e\right)\right) \end{array} \end{array}\right) \end{array} \end{array}
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.()(2)('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: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 131
body: 12
10Operationoperator: 13
operand: 17
11Operationoperator: 126
operands: 15
12Conditionalvalue: 16
condition: 35
13Literal
14ExprTuple17
15ExprTuple132, 18
16Literal
17Lambdaparameter: 131
body: 20
18Operationoperator: 119
operand: 24
19ExprTuple131
20Conditionalvalue: 22
condition: 23
21ExprTuple24
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operands: 28
24Operationoperator: 29
operand: 58
25Literal
26ExprTuple31, 32, 33, 34
27Literal
28ExprTuple35, 36
29Literal
30ExprTuple58
31ExprTuple37, 38
32ExprTuple39, 40
33ExprTuple41, 42
34ExprTuple43, 44
35Operationoperator: 45
operands: 46
36Operationoperator: 47
operands: 48
37ExprRangelambda_map: 49
start_index: 132
end_index: 133
38ExprRangelambda_map: 50
start_index: 132
end_index: 134
39ExprRangelambda_map: 51
start_index: 132
end_index: 133
40ExprRangelambda_map: 51
start_index: 114
end_index: 115
41ExprRangelambda_map: 52
start_index: 132
end_index: 133
42ExprRangelambda_map: 53
start_index: 132
end_index: 134
43ExprRangelambda_map: 54
start_index: 132
end_index: 133
44ExprRangelambda_map: 55
start_index: 132
end_index: 134
45Literal
46ExprTuple131, 56
47Literal
48ExprTuple57, 58
49Lambdaparameter: 113
body: 59
50Lambdaparameter: 113
body: 60
51Lambdaparameter: 113
body: 61
52Lambdaparameter: 113
body: 62
53Lambdaparameter: 113
body: 63
54Lambdaparameter: 113
body: 64
55Lambdaparameter: 113
body: 66
56Operationoperator: 104
operands: 67
57Operationoperator: 68
operands: 69
58Variable
59Operationoperator: 96
operands: 70
60Operationoperator: 77
operands: 71
61Operationoperator: 77
operands: 72
62Operationoperator: 73
operands: 74
63Operationoperator: 97
operands: 75
64Operationoperator: 77
operands: 76
65ExprTuple113
66Operationoperator: 77
operands: 78
67ExprTuple79, 80
68Literal
69ExprTuple81, 106
70NamedExprsstate: 82
71NamedExprselement: 83
targets: 91
72NamedExprselement: 84
targets: 85
73Literal
74NamedExprsbasis: 86
75NamedExprsoperation: 87
76NamedExprselement: 88
targets: 89
77Literal
78NamedExprselement: 90
targets: 91
79Literal
80Operationoperator: 126
operands: 92
81Operationoperator: 126
operands: 93
82Operationoperator: 94
operand: 109
83Operationoperator: 96
operands: 103
84Operationoperator: 97
operands: 98
85Operationoperator: 104
operands: 99
86Literal
87Literal
88Operationoperator: 102
operands: 100
89Operationoperator: 104
operands: 101
90Operationoperator: 102
operands: 103
91Operationoperator: 104
operands: 105
92ExprTuple106, 107
93ExprTuple131, 108
94Literal
95ExprTuple109
96Literal
97Literal
98NamedExprsoperation: 110
part: 113
99ExprTuple132, 115
100NamedExprsstate: 111
part: 113
101ExprTuple132, 133
102Literal
103NamedExprsstate: 112
part: 113
104Literal
105ExprTuple114, 115
106Operationoperator: 116
operands: 117
107Operationoperator: 119
operand: 132
108Operationoperator: 119
operand: 129
109Literal
110Operationoperator: 121
operands: 122
111Operationoperator: 123
operands: 124
112Literal
113Variable
114Operationoperator: 126
operands: 125
115Operationoperator: 126
operands: 127
116Literal
117ExprTuple128, 133
118ExprTuple132
119Literal
120ExprTuple129
121Literal
122ExprTuple130, 133
123Literal
124ExprTuple131, 133
125ExprTuple133, 132
126Literal
127ExprTuple133, 134
128Literal
129Literal
130Literal
131Variable
132Literal
133Literal
134Literal