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, ExprRange, IndexedVar, Variable, a, c, l
from proveit.logic import InSet
from proveit.numbers import Exp, Mult, frac, one, two, zero
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Mult(IndexedVar(a, one), frac(one, Exp(_diff_l_scaled_delta_floor, two)), ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, zero)), 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\{a_{1} \cdot \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0} \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: 41
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7, 8
4Literal
5ExprTuple33, 9
6IndexedVarvariable: 10
index: 57
7Operationoperator: 11
operands: 12
8ExprRangelambda_map: 13
start_index: 57
end_index: 14
9Operationoperator: 15
operands: 16
10Variable
11Literal
12ExprTuple57, 17
13Lambdaparameter: 27
body: 18
14Literal
15Literal
16ExprTuple19, 20
17Operationoperator: 48
operands: 21
18IndexedVarvariable: 22
index: 27
19Operationoperator: 43
operands: 24
20Operationoperator: 52
operand: 29
21ExprTuple26, 54
22Variable
23ExprTuple27
24ExprTuple28, 57
25ExprTuple29
26Operationoperator: 43
operands: 30
27Variable
28Operationoperator: 52
operand: 35
29Operationoperator: 43
operands: 32
30ExprTuple33, 34
31ExprTuple35
32ExprTuple36, 57
33Variable
34Operationoperator: 52
operand: 39
35Operationoperator: 48
operands: 38
36Variable
37ExprTuple39
38ExprTuple54, 40
39Operationoperator: 41
operands: 42
40Operationoperator: 43
operands: 44
41Literal
42ExprTuple45, 46
43Literal
44ExprTuple55, 47
45Operationoperator: 48
operands: 49
46Operationoperator: 50
operand: 56
47Operationoperator: 52
operand: 57
48Literal
49ExprTuple54, 55
50Literal
51ExprTuple56
52Literal
53ExprTuple57
54Literal
55Literal
56Literal
57Literal