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, _neg_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, _neg_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 \{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\right)\}\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
6ExprTuple37, 9
7Operationoperator: 21
operands: 10
8Operationoperator: 45
operands: 11
9Operationoperator: 12
operands: 13
10ExprTuple51, 14
11ExprTuple15, 16
12Literal
13ExprTuple17, 18
14Operationoperator: 45
operands: 19
15Operationoperator: 21
operands: 20
16Operationoperator: 21
operands: 22
17Operationoperator: 41
operands: 23
18Operationoperator: 47
operand: 28
19ExprTuple25, 26
20ExprTuple51, 25
21Literal
22ExprTuple51, 26
23ExprTuple27, 51
24ExprTuple28
25Literal
26Operationoperator: 52
operands: 29
27Operationoperator: 47
operand: 33
28Operationoperator: 41
operands: 31
29ExprTuple32, 56
30ExprTuple33
31ExprTuple34, 51
32Operationoperator: 41
operands: 35
33Operationoperator: 52
operands: 36
34Variable
35ExprTuple37, 38
36ExprTuple56, 39
37Variable
38Operationoperator: 47
operand: 43
39Operationoperator: 41
operands: 42
40ExprTuple43
41Literal
42ExprTuple57, 44
43Operationoperator: 45
operands: 46
44Operationoperator: 47
operand: 51
45Literal
46ExprTuple49, 50
47Literal
48ExprTuple51
49Operationoperator: 52
operands: 53
50Operationoperator: 54
operand: 58
51Literal
52Literal
53ExprTuple56, 57
54Literal
55ExprTuple58
56Literal
57Literal
58Literal