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, _pos_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, _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\{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 \{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: 41
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7, 8
4Literal
5ExprTuple33, 9
6IndexedVarvariable: 10
index: 40
7Operationoperator: 11
operands: 12
8ExprRangelambda_map: 13
start_index: 40
end_index: 14
9Operationoperator: 15
operands: 16
10Variable
11Literal
12ExprTuple40, 17
13Lambdaparameter: 27
body: 18
14Literal
15Literal
16ExprTuple19, 20
17Operationoperator: 45
operands: 21
18IndexedVarvariable: 22
index: 27
19Operationoperator: 31
operands: 24
20Operationoperator: 45
operands: 25
21ExprTuple26, 49
22Variable
23ExprTuple27
24ExprTuple28, 40
25ExprTuple49, 29
26Operationoperator: 31
operands: 30
27Variable
28Variable
29Operationoperator: 31
operands: 32
30ExprTuple33, 34
31Literal
32ExprTuple50, 35
33Variable
34Operationoperator: 37
operand: 39
35Operationoperator: 37
operand: 40
36ExprTuple39
37Literal
38ExprTuple40
39Operationoperator: 41
operands: 42
40Literal
41Literal
42ExprTuple43, 44
43Operationoperator: 45
operands: 46
44Operationoperator: 47
operand: 51
45Literal
46ExprTuple49, 50
47Literal
48ExprTuple51
49Literal
50Literal
51Literal