logo

Expression of type Lambda

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, Lambda, 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 = Lambda(l, 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())
l \mapsto \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()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 35
body: 2
1ExprTuple35
2Conditionalvalue: 3
condition: 4
3Operationoperator: 43
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9, 10
6Literal
7ExprTuple35, 11
8IndexedVarvariable: 12
index: 42
9Operationoperator: 13
operands: 14
10ExprRangelambda_map: 15
start_index: 42
end_index: 16
11Operationoperator: 17
operands: 18
12Variable
13Literal
14ExprTuple42, 19
15Lambdaparameter: 29
body: 20
16Literal
17Literal
18ExprTuple21, 22
19Operationoperator: 47
operands: 23
20IndexedVarvariable: 24
index: 29
21Operationoperator: 33
operands: 26
22Operationoperator: 47
operands: 27
23ExprTuple28, 51
24Variable
25ExprTuple29
26ExprTuple30, 42
27ExprTuple51, 31
28Operationoperator: 33
operands: 32
29Variable
30Variable
31Operationoperator: 33
operands: 34
32ExprTuple35, 36
33Literal
34ExprTuple52, 37
35Variable
36Operationoperator: 39
operand: 41
37Operationoperator: 39
operand: 42
38ExprTuple41
39Literal
40ExprTuple42
41Operationoperator: 43
operands: 44
42Literal
43Literal
44ExprTuple45, 46
45Operationoperator: 47
operands: 48
46Operationoperator: 49
operand: 53
47Literal
48ExprTuple51, 52
49Literal
50ExprTuple53
51Literal
52Literal
53Literal