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 And, InSet, NotEquals
from proveit.numbers import Abs, IntervalOC, Mult, frac, pi, subtract, two, zero
from proveit.physics.quantum.QPE import _delta_b_floor, _full_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(InSet(Mult(pi, Abs(subtract(_delta_b_floor, frac(l, _two_pow_t)))), IntervalOC(zero, frac(pi, two))), And(InSet(l, _full_domain), NotEquals(l, zero)))
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(\pi \cdot \left|\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right|\right) \in \left(0,\frac{\pi}{2}\right] \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\} ,  l \neq 0\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: 10
operands: 11
7Operationoperator: 12
operands: 13
8Operationoperator: 14
operands: 15
9Operationoperator: 16
operands: 17
10Literal
11ExprTuple28, 18
12Literal
13ExprTuple21, 19
14Literal
15ExprTuple45, 20
16Literal
17ExprTuple45, 21
18Operationoperator: 22
operand: 27
19Operationoperator: 42
operands: 24
20Operationoperator: 25
operands: 26
21Literal
22Literal
23ExprTuple27
24ExprTuple28, 52
25Literal
26ExprTuple29, 41
27Operationoperator: 50
operands: 30
28Literal
29Operationoperator: 50
operands: 31
30ExprTuple32, 33
31ExprTuple34, 57
32Operationoperator: 35
operand: 39
33Operationoperator: 55
operand: 40
34Operationoperator: 55
operand: 41
35Literal
36ExprTuple39
37ExprTuple40
38ExprTuple41
39Literal
40Operationoperator: 42
operands: 43
41Operationoperator: 48
operands: 44
42Literal
43ExprTuple45, 46
44ExprTuple52, 47
45Variable
46Operationoperator: 48
operands: 49
47Operationoperator: 50
operands: 51
48Literal
49ExprTuple52, 53
50Literal
51ExprTuple53, 54
52Literal
53Literal
54Operationoperator: 55
operand: 57
55Literal
56ExprTuple57
57Literal