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 Exp, LessEq, Mult, frac, one, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _pos_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(LessEq(frac(one, Exp(subtract(k, Mult(_two_pow_t, _delta_b_floor)), two)), frac(one, Exp(subtract(k, one), 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\{\frac{1}{\left(k - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} \leq \frac{1}{\left(k - 1\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
6ExprTuple32, 9
7Operationoperator: 11
operands: 10
8Operationoperator: 11
operands: 12
9Operationoperator: 13
operands: 14
10ExprTuple38, 15
11Literal
12ExprTuple38, 16
13Literal
14ExprTuple17, 18
15Operationoperator: 43
operands: 19
16Operationoperator: 43
operands: 20
17Operationoperator: 29
operands: 21
18Operationoperator: 43
operands: 22
19ExprTuple23, 47
20ExprTuple24, 47
21ExprTuple25, 38
22ExprTuple47, 26
23Operationoperator: 29
operands: 27
24Operationoperator: 29
operands: 28
25Variable
26Operationoperator: 29
operands: 30
27ExprTuple32, 31
28ExprTuple32, 33
29Literal
30ExprTuple48, 33
31Operationoperator: 35
operand: 37
32Variable
33Operationoperator: 35
operand: 38
34ExprTuple37
35Literal
36ExprTuple38
37Operationoperator: 39
operands: 40
38Literal
39Literal
40ExprTuple41, 42
41Operationoperator: 43
operands: 44
42Operationoperator: 45
operand: 49
43Literal
44ExprTuple47, 48
45Literal
46ExprTuple49
47Literal
48Literal
49Literal