logo

Expression of type InSet

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 InSet, 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, prob_domain
In [2]:
# build up the expression from sub-expressions
expr = InSet(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))), prob_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())
\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 \left[0,1\right]
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.()()('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: 34
operands: 1
1ExprTuple2, 3
2Operationoperator: 4
operand: 8
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8
6Literal
7ExprTuple68, 121
8Operationoperator: 9
operand: 11
9Literal
10ExprTuple11
11Lambdaparameter: 120
body: 13
12ExprTuple120
13Conditionalvalue: 14
condition: 15
14Operationoperator: 16
operands: 17
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20, 21, 22, 23
18Literal
19ExprTuple24, 25
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
46Variable
47Operationoperator: 57
operands: 58
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