logo

Expression of type Conditional

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, m
from proveit.logic import And, InSet
from proveit.numbers import Exp, LessEq, ModAbs, one, subtract, two
from proveit.physics.quantum.QPE import _b_floor, _m_domain, _n, _success_cond, _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(_success_cond, And(InSet(m, _m_domain), LessEq(ModAbs(subtract(m, _b_floor), _two_pow_t), subtract(Exp(two, subtract(_t, _n)), one))))
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|\frac{m}{2^{t}} - \varphi\right|_{\textup{mod}\thinspace 1} \leq 2^{-n} \textrm{ if } m \in \{0~\ldotp \ldotp~2^{t} - 1\} ,  \left|m - b_{\textit{f}}\right|_{\textup{mod}\thinspace 2^{t}} \leq \left(2^{t - n} - 1\right)\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 14
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple8, 9
6Operationoperator: 23
operands: 10
7Operationoperator: 44
operands: 11
8Operationoperator: 12
operands: 13
9Operationoperator: 14
operands: 15
10ExprTuple16, 51
11ExprTuple50, 54
12Literal
13ExprTuple41, 17
14Literal
15ExprTuple18, 19
16Operationoperator: 48
operands: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operands: 24
19Operationoperator: 48
operands: 25
20ExprTuple26, 27
21Literal
22ExprTuple28, 29
23Literal
24ExprTuple30, 39
25ExprTuple31, 40
26Operationoperator: 32
operands: 33
27Operationoperator: 55
operand: 38
28Literal
29Operationoperator: 48
operands: 35
30Operationoperator: 48
operands: 36
31Operationoperator: 44
operands: 37
32Literal
33ExprTuple41, 39
34ExprTuple38
35ExprTuple39, 40
36ExprTuple41, 42
37ExprTuple50, 43
38Literal
39Operationoperator: 44
operands: 45
40Operationoperator: 55
operand: 51
41Variable
42Operationoperator: 55
operand: 52
43Operationoperator: 48
operands: 49
44Literal
45ExprTuple50, 53
46ExprTuple51
47ExprTuple52
48Literal
49ExprTuple53, 54
50Literal
51Literal
52Literal
53Literal
54Operationoperator: 55
operand: 57
55Literal
56ExprTuple57
57Literal