logo

Expression of type ExprTuple

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 ExprTuple, e, m
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
expr = ExprTuple(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)), subtract(one, Pfail(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(\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), 1 - \left[P_{\rm fail}\right]\left(e\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 3
operand: 6
2Operationoperator: 115
operands: 5
3Literal
4ExprTuple6
5ExprTuple121, 7
6Lambdaparameter: 120
body: 9
7Operationoperator: 108
operand: 13
8ExprTuple120
9Conditionalvalue: 11
condition: 12
10ExprTuple13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operand: 47
14Literal
15ExprTuple20, 21, 22, 23
16Literal
17ExprTuple24, 25
18Literal
19ExprTuple47
20ExprTuple26, 27
21ExprTuple28, 29
22ExprTuple30, 31
23ExprTuple32, 33
24Operationoperator: 34
operands: 35
25Operationoperator: 36
operands: 37
26ExprRangelambda_map: 38
start_index: 121
end_index: 122
27ExprRangelambda_map: 39
start_index: 121
end_index: 123
28ExprRangelambda_map: 40
start_index: 121
end_index: 122
29ExprRangelambda_map: 40
start_index: 103
end_index: 104
30ExprRangelambda_map: 41
start_index: 121
end_index: 122
31ExprRangelambda_map: 42
start_index: 121
end_index: 123
32ExprRangelambda_map: 43
start_index: 121
end_index: 122
33ExprRangelambda_map: 44
start_index: 121
end_index: 123
34Literal
35ExprTuple120, 45
36Literal
37ExprTuple46, 47
38Lambdaparameter: 102
body: 48
39Lambdaparameter: 102
body: 49
40Lambdaparameter: 102
body: 50
41Lambdaparameter: 102
body: 51
42Lambdaparameter: 102
body: 52
43Lambdaparameter: 102
body: 53
44Lambdaparameter: 102
body: 55
45Operationoperator: 93
operands: 56
46Operationoperator: 57
operands: 58
47Variable
48Operationoperator: 85
operands: 59
49Operationoperator: 66
operands: 60
50Operationoperator: 66
operands: 61
51Operationoperator: 62
operands: 63
52Operationoperator: 86
operands: 64
53Operationoperator: 66
operands: 65
54ExprTuple102
55Operationoperator: 66
operands: 67
56ExprTuple68, 69
57Literal
58ExprTuple70, 95
59NamedExprsstate: 71
60NamedExprselement: 72
targets: 80
61NamedExprselement: 73
targets: 74
62Literal
63NamedExprsbasis: 75
64NamedExprsoperation: 76
65NamedExprselement: 77
targets: 78
66Literal
67NamedExprselement: 79
targets: 80
68Literal
69Operationoperator: 115
operands: 81
70Operationoperator: 115
operands: 82
71Operationoperator: 83
operand: 98
72Operationoperator: 85
operands: 92
73Operationoperator: 86
operands: 87
74Operationoperator: 93
operands: 88
75Literal
76Literal
77Operationoperator: 91
operands: 89
78Operationoperator: 93
operands: 90
79Operationoperator: 91
operands: 92
80Operationoperator: 93
operands: 94
81ExprTuple95, 96
82ExprTuple120, 97
83Literal
84ExprTuple98
85Literal
86Literal
87NamedExprsoperation: 99
part: 102
88ExprTuple121, 104
89NamedExprsstate: 100
part: 102
90ExprTuple121, 122
91Literal
92NamedExprsstate: 101
part: 102
93Literal
94ExprTuple103, 104
95Operationoperator: 105
operands: 106
96Operationoperator: 108
operand: 121
97Operationoperator: 108
operand: 118
98Literal
99Operationoperator: 110
operands: 111
100Operationoperator: 112
operands: 113
101Literal
102Variable
103Operationoperator: 115
operands: 114
104Operationoperator: 115
operands: 116
105Literal
106ExprTuple117, 122
107ExprTuple121
108Literal
109ExprTuple118
110Literal
111ExprTuple119, 122
112Literal
113ExprTuple120, 122
114ExprTuple122, 121
115Literal
116ExprTuple122, 123
117Literal
118Literal
119Literal
120Variable
121Literal
122Literal
123Literal