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 Equals, InSet
from proveit.numbers import Exp, Mult, four, frac, one, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(_diff_l_scaled_delta_floor, two)
expr = Conditional(Equals(frac(one, Mult(four, sub_expr1)), Mult(frac(one, four), frac(one, sub_expr1))), InSet(l, _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}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}} = \left(\frac{1}{4} \cdot \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right) \textrm{ if } l \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
6ExprTuple36, 9
7Operationoperator: 21
operands: 10
8Operationoperator: 42
operands: 11
9Operationoperator: 12
operands: 13
10ExprTuple38, 14
11ExprTuple15, 16
12Literal
13ExprTuple17, 18
14Operationoperator: 42
operands: 19
15Operationoperator: 21
operands: 20
16Operationoperator: 21
operands: 22
17Operationoperator: 33
operands: 23
18Operationoperator: 46
operands: 24
19ExprTuple25, 26
20ExprTuple38, 25
21Literal
22ExprTuple38, 26
23ExprTuple27, 38
24ExprTuple50, 28
25Literal
26Operationoperator: 46
operands: 29
27Variable
28Operationoperator: 33
operands: 30
29ExprTuple31, 50
30ExprTuple51, 32
31Operationoperator: 33
operands: 34
32Operationoperator: 39
operand: 38
33Literal
34ExprTuple36, 37
35ExprTuple38
36Variable
37Operationoperator: 39
operand: 41
38Literal
39Literal
40ExprTuple41
41Operationoperator: 42
operands: 43
42Literal
43ExprTuple44, 45
44Operationoperator: 46
operands: 47
45Operationoperator: 48
operand: 52
46Literal
47ExprTuple50, 51
48Literal
49ExprTuple52
50Literal
51Literal
52Literal