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, Lambda, 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 = Lambda(l, 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())
l \mapsto \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()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 39
body: 2
1ExprTuple39
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple39, 11
9Operationoperator: 23
operands: 12
10Operationoperator: 47
operands: 13
11Operationoperator: 14
operands: 15
12ExprTuple53, 16
13ExprTuple17, 18
14Literal
15ExprTuple19, 20
16Operationoperator: 47
operands: 21
17Operationoperator: 23
operands: 22
18Operationoperator: 23
operands: 24
19Operationoperator: 43
operands: 25
20Operationoperator: 49
operand: 30
21ExprTuple27, 28
22ExprTuple53, 27
23Literal
24ExprTuple53, 28
25ExprTuple29, 53
26ExprTuple30
27Literal
28Operationoperator: 54
operands: 31
29Operationoperator: 49
operand: 35
30Operationoperator: 43
operands: 33
31ExprTuple34, 58
32ExprTuple35
33ExprTuple36, 53
34Operationoperator: 43
operands: 37
35Operationoperator: 54
operands: 38
36Variable
37ExprTuple39, 40
38ExprTuple58, 41
39Variable
40Operationoperator: 49
operand: 45
41Operationoperator: 43
operands: 44
42ExprTuple45
43Literal
44ExprTuple59, 46
45Operationoperator: 47
operands: 48
46Operationoperator: 49
operand: 53
47Literal
48ExprTuple51, 52
49Literal
50ExprTuple53
51Operationoperator: 54
operands: 55
52Operationoperator: 56
operand: 60
53Literal
54Literal
55ExprTuple58, 59
56Literal
57ExprTuple60
58Literal
59Literal
60Literal