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 Conditional, ExprTuple, Lambda, e
from proveit.logic import Equals, InSet
from proveit.physics.quantum.QPE import Pfail, _e_domain, _fail_prob_e
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(e, Conditional(Equals(Pfail(e), _fail_prob_e), InSet(e, _e_domain))))
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(e \mapsto \left\{\left[P_{\rm fail}\right]\left(e\right) = \left[\begin{array}{l}\textrm{Prob}_{m \in \{0~\ldotp \ldotp~2^{t} - 1\}~|~\left|m - b_{\textit{f}}\right|_{\textup{mod}\thinspace 2^{t}} > 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)\end{array}\right] \textrm{ if } e \in \{1~\ldotp \ldotp~2^{t - 1} - 2\}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 59
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 46
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple59, 10
8Operationoperator: 11
operand: 59
9Operationoperator: 13
operand: 16
10Operationoperator: 106
operands: 15
11Literal
12ExprTuple59
13Literal
14ExprTuple16
15ExprTuple134, 17
16Lambdaparameter: 133
body: 19
17Operationoperator: 128
operands: 20
18ExprTuple133
19Conditionalvalue: 21
condition: 22
20ExprTuple23, 24
21Operationoperator: 25
operands: 26
22Operationoperator: 27
operands: 28
23Operationoperator: 118
operands: 29
24Operationoperator: 121
operand: 130
25Literal
26ExprTuple31, 32, 33, 34
27Literal
28ExprTuple35, 36
29ExprTuple130, 37
30ExprTuple130
31ExprTuple38, 39
32ExprTuple40, 41
33ExprTuple42, 43
34ExprTuple44, 45
35Operationoperator: 46
operands: 47
36Operationoperator: 48
operands: 49
37Operationoperator: 128
operands: 50
38ExprRangelambda_map: 51
start_index: 134
end_index: 135
39ExprRangelambda_map: 52
start_index: 134
end_index: 136
40ExprRangelambda_map: 53
start_index: 134
end_index: 135
41ExprRangelambda_map: 53
start_index: 116
end_index: 117
42ExprRangelambda_map: 54
start_index: 134
end_index: 135
43ExprRangelambda_map: 55
start_index: 134
end_index: 136
44ExprRangelambda_map: 56
start_index: 134
end_index: 135
45ExprRangelambda_map: 57
start_index: 134
end_index: 136
46Literal
47ExprTuple133, 58
48Literal
49ExprTuple59, 60
50ExprTuple135, 109
51Lambdaparameter: 115
body: 61
52Lambdaparameter: 115
body: 62
53Lambdaparameter: 115
body: 63
54Lambdaparameter: 115
body: 64
55Lambdaparameter: 115
body: 65
56Lambdaparameter: 115
body: 66
57Lambdaparameter: 115
body: 68
58Operationoperator: 106
operands: 69
59Variable
60Operationoperator: 70
operands: 71
61Operationoperator: 98
operands: 72
62Operationoperator: 79
operands: 73
63Operationoperator: 79
operands: 74
64Operationoperator: 75
operands: 76
65Operationoperator: 99
operands: 77
66Operationoperator: 79
operands: 78
67ExprTuple115
68Operationoperator: 79
operands: 80
69ExprTuple81, 82
70Literal
71ExprTuple83, 108
72NamedExprsstate: 84
73NamedExprselement: 85
targets: 93
74NamedExprselement: 86
targets: 87
75Literal
76NamedExprsbasis: 88
77NamedExprsoperation: 89
78NamedExprselement: 90
targets: 91
79Literal
80NamedExprselement: 92
targets: 93
81Literal
82Operationoperator: 128
operands: 94
83Operationoperator: 128
operands: 95
84Operationoperator: 96
operand: 111
85Operationoperator: 98
operands: 105
86Operationoperator: 99
operands: 100
87Operationoperator: 106
operands: 101
88Literal
89Literal
90Operationoperator: 104
operands: 102
91Operationoperator: 106
operands: 103
92Operationoperator: 104
operands: 105
93Operationoperator: 106
operands: 107
94ExprTuple108, 109
95ExprTuple133, 110
96Literal
97ExprTuple111
98Literal
99Literal
100NamedExprsoperation: 112
part: 115
101ExprTuple134, 117
102NamedExprsstate: 113
part: 115
103ExprTuple134, 135
104Literal
105NamedExprsstate: 114
part: 115
106Literal
107ExprTuple116, 117
108Operationoperator: 118
operands: 119
109Operationoperator: 121
operand: 134
110Operationoperator: 121
operand: 131
111Literal
112Operationoperator: 123
operands: 124
113Operationoperator: 125
operands: 126
114Literal
115Variable
116Operationoperator: 128
operands: 127
117Operationoperator: 128
operands: 129
118Literal
119ExprTuple130, 135
120ExprTuple134
121Literal
122ExprTuple131
123Literal
124ExprTuple132, 135
125Literal
126ExprTuple133, 135
127ExprTuple135, 134
128Literal
129ExprTuple135, 136
130Literal
131Literal
132Literal
133Variable
134Literal
135Literal
136Literal