logo

Expression of type SubsetEq

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 SetOfAll, SubsetEq
from proveit.numbers import ModAbs, greater, subtract
from proveit.physics.quantum.QPE import _b_floor, _m_domain, _phase_est_circuit, _sample_space, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = SubsetEq(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)), _sample_space)
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\{\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\}} \subseteq \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\}_{m \in \{0~\ldotp \ldotp~2^{t} - 1\}}
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: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 6
operand: 8
4Operationoperator: 6
operand: 9
5ExprTuple8
6Literal
7ExprTuple9
8Lambdaparameter: 119
body: 10
9Lambdaparameter: 119
body: 12
10Conditionalvalue: 14
condition: 13
11ExprTuple119
12Conditionalvalue: 14
condition: 19
13Operationoperator: 15
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple21, 22, 23, 24
19Operationoperator: 25
operands: 26
20Operationoperator: 27
operands: 28
21ExprTuple29, 30
22ExprTuple31, 32
23ExprTuple33, 34
24ExprTuple35, 36
25Literal
26ExprTuple119, 37
27Literal
28ExprTuple38, 39
29ExprRangelambda_map: 40
start_index: 120
end_index: 121
30ExprRangelambda_map: 41
start_index: 120
end_index: 122
31ExprRangelambda_map: 42
start_index: 120
end_index: 121
32ExprRangelambda_map: 42
start_index: 107
end_index: 108
33ExprRangelambda_map: 43
start_index: 120
end_index: 121
34ExprRangelambda_map: 44
start_index: 120
end_index: 122
35ExprRangelambda_map: 45
start_index: 120
end_index: 121
36ExprRangelambda_map: 46
start_index: 120
end_index: 122
37Operationoperator: 95
operands: 47
38Variable
39Operationoperator: 48
operands: 49
40Lambdaparameter: 106
body: 50
41Lambdaparameter: 106
body: 51
42Lambdaparameter: 106
body: 52
43Lambdaparameter: 106
body: 53
44Lambdaparameter: 106
body: 54
45Lambdaparameter: 106
body: 55
46Lambdaparameter: 106
body: 57
47ExprTuple58, 59
48Literal
49ExprTuple60, 82
50Operationoperator: 87
operands: 61
51Operationoperator: 68
operands: 62
52Operationoperator: 68
operands: 63
53Operationoperator: 64
operands: 65
54Operationoperator: 88
operands: 66
55Operationoperator: 68
operands: 67
56ExprTuple106
57Operationoperator: 68
operands: 69
58Literal
59Operationoperator: 116
operands: 70
60Operationoperator: 116
operands: 71
61NamedExprsstate: 72
62NamedExprselement: 73
targets: 81
63NamedExprselement: 74
targets: 75
64Literal
65NamedExprsbasis: 76
66NamedExprsoperation: 77
67NamedExprselement: 78
targets: 79
68Literal
69NamedExprselement: 80
targets: 81
70ExprTuple82, 83
71ExprTuple119, 84
72Operationoperator: 85
operand: 102
73Operationoperator: 87
operands: 94
74Operationoperator: 88
operands: 89
75Operationoperator: 95
operands: 90
76Literal
77Literal
78Operationoperator: 93
operands: 91
79Operationoperator: 95
operands: 92
80Operationoperator: 93
operands: 94
81Operationoperator: 95
operands: 96
82Operationoperator: 97
operands: 98
83Operationoperator: 100
operand: 120
84Operationoperator: 100
operand: 110
85Literal
86ExprTuple102
87Literal
88Literal
89NamedExprsoperation: 103
part: 106
90ExprTuple120, 108
91NamedExprsstate: 104
part: 106
92ExprTuple120, 121
93Literal
94NamedExprsstate: 105
part: 106
95Literal
96ExprTuple107, 108
97Literal
98ExprTuple109, 121
99ExprTuple120
100Literal
101ExprTuple110
102Literal
103Operationoperator: 111
operands: 112
104Operationoperator: 113
operands: 114
105Literal
106Variable
107Operationoperator: 116
operands: 115
108Operationoperator: 116
operands: 117
109Literal
110Literal
111Literal
112ExprTuple118, 121
113Literal
114ExprTuple119, 121
115ExprTuple121, 120
116Literal
117ExprTuple121, 122
118Literal
119Variable
120Literal
121Literal
122Literal