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, l
from proveit.logic import InSet
from proveit.numbers import IntervalCO, Neg, frac, one, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _full_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = frac(one, two)
expr = Conditional(InSet(subtract(_delta_b_floor, frac(l, _two_pow_t)), IntervalCO(Neg(sub_expr1), sub_expr1)), InSet(l, _full_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\{\left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right) \in \left[-\frac{1}{2},\frac{1}{2}\right) \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\}\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: 4
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple31, 8
6Operationoperator: 39
operands: 9
7Operationoperator: 10
operands: 11
8Operationoperator: 12
operands: 13
9ExprTuple14, 15
10Literal
11ExprTuple16, 25
12Literal
13ExprTuple17, 33
14Operationoperator: 18
operand: 23
15Operationoperator: 43
operand: 24
16Operationoperator: 43
operand: 25
17Operationoperator: 39
operands: 22
18Literal
19ExprTuple23
20ExprTuple24
21ExprTuple25
22ExprTuple26, 45
23Literal
24Operationoperator: 28
operands: 27
25Operationoperator: 28
operands: 29
26Operationoperator: 43
operand: 33
27ExprTuple31, 32
28Literal
29ExprTuple45, 37
30ExprTuple33
31Variable
32Operationoperator: 35
operands: 34
33Operationoperator: 35
operands: 36
34ExprTuple37, 41
35Literal
36ExprTuple37, 38
37Literal
38Operationoperator: 39
operands: 40
39Literal
40ExprTuple41, 42
41Literal
42Operationoperator: 43
operand: 45
43Literal
44ExprTuple45
45Literal