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, b, l
from proveit.logic import And, InSet, NotEquals, NotInSet, Set
from proveit.numbers import Integer, frac, subtract, zero
from proveit.physics.quantum.QPE import _b_floor, _b_round, _delta_b, _full_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(NotInSet(subtract(_delta_b, frac(l, _two_pow_t)), Integer), And(InSet(b, Set(_b_floor, _b_round)), 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(\delta_{b} - \frac{l}{2^{t}}\right) \notin \mathbb{Z} \textrm{ if } b \in \left\{b_{\textit{f}}, b_{\textit{r}}\right\} ,  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: 3
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9, 10, 11
7Operationoperator: 48
operands: 12
8Literal
9Operationoperator: 14
operands: 13
10Operationoperator: 14
operands: 15
11Operationoperator: 16
operands: 17
12ExprTuple18, 19
13ExprTuple30, 20
14Literal
15ExprTuple38, 21
16Literal
17ExprTuple38, 22
18Operationoperator: 23
operand: 30
19Operationoperator: 52
operand: 31
20Operationoperator: 26
operands: 27
21Operationoperator: 28
operands: 29
22Literal
23Literal
24ExprTuple30
25ExprTuple31
26Literal
27ExprTuple32, 33
28Literal
29ExprTuple34, 43
30Variable
31Operationoperator: 35
operands: 36
32Literal
33Literal
34Operationoperator: 48
operands: 37
35Literal
36ExprTuple38, 39
37ExprTuple40, 54
38Variable
39Operationoperator: 44
operands: 41
40Operationoperator: 52
operand: 43
41ExprTuple46, 50
42ExprTuple43
43Operationoperator: 44
operands: 45
44Literal
45ExprTuple46, 47
46Literal
47Operationoperator: 48
operands: 49
48Literal
49ExprTuple50, 51
50Literal
51Operationoperator: 52
operand: 54
52Literal
53ExprTuple54
54Literal