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, k
from proveit.logic import InSet
from proveit.numbers import Abs, Exp, LessEq, Mult, four, frac, one, subtract, two
from proveit.physics.quantum.QPE import ModAdd, SubIndexed, _alpha, _b_floor, _delta_b_floor, _pos_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(LessEq(Exp(Abs(SubIndexed(_alpha, [ModAdd(_b_floor, k)])), two), frac(one, Mult(four, Exp(subtract(k, Mult(_two_pow_t, _delta_b_floor)), two)))), InSet(k, _pos_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|\alpha_{b_{\textit{f}} \oplus k}\right|^{2} \leq \frac{1}{4 \cdot \left(k - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} \textrm{ if } k \in \{e + 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: 3
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple41, 9
7Operationoperator: 51
operands: 10
8Operationoperator: 11
operands: 12
9Operationoperator: 13
operands: 14
10ExprTuple15, 55
11Literal
12ExprTuple43, 16
13Literal
14ExprTuple17, 18
15Operationoperator: 19
operand: 24
16Operationoperator: 47
operands: 21
17Operationoperator: 38
operands: 22
18Operationoperator: 51
operands: 23
19Literal
20ExprTuple24
21ExprTuple25, 26
22ExprTuple27, 43
23ExprTuple55, 28
24Operationoperator: 29
operand: 33
25Literal
26Operationoperator: 51
operands: 31
27Variable
28Operationoperator: 38
operands: 32
29Literal
30ExprTuple33
31ExprTuple34, 55
32ExprTuple56, 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35Operationoperator: 44
operand: 43
36Literal
37ExprTuple57, 41
38Literal
39ExprTuple41, 42
40ExprTuple43
41Variable
42Operationoperator: 44
operand: 46
43Literal
44Literal
45ExprTuple46
46Operationoperator: 47
operands: 48
47Literal
48ExprTuple49, 50
49Operationoperator: 51
operands: 52
50Operationoperator: 53
operand: 57
51Literal
52ExprTuple55, 56
53Literal
54ExprTuple57
55Literal
56Literal
57Literal