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, _pos_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, _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\{\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 \{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: 38
body: 2
1ExprTuple38
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple38, 11
9Operationoperator: 23
operands: 12
10Operationoperator: 44
operands: 13
11Operationoperator: 14
operands: 15
12ExprTuple40, 16
13ExprTuple17, 18
14Literal
15ExprTuple19, 20
16Operationoperator: 44
operands: 21
17Operationoperator: 23
operands: 22
18Operationoperator: 23
operands: 24
19Operationoperator: 35
operands: 25
20Operationoperator: 48
operands: 26
21ExprTuple27, 28
22ExprTuple40, 27
23Literal
24ExprTuple40, 28
25ExprTuple29, 40
26ExprTuple52, 30
27Literal
28Operationoperator: 48
operands: 31
29Variable
30Operationoperator: 35
operands: 32
31ExprTuple33, 52
32ExprTuple53, 34
33Operationoperator: 35
operands: 36
34Operationoperator: 41
operand: 40
35Literal
36ExprTuple38, 39
37ExprTuple40
38Variable
39Operationoperator: 41
operand: 43
40Literal
41Literal
42ExprTuple43
43Operationoperator: 44
operands: 45
44Literal
45ExprTuple46, 47
46Operationoperator: 48
operands: 49
47Operationoperator: 50
operand: 54
48Literal
49ExprTuple52, 53
50Literal
51ExprTuple54
52Literal
53Literal
54Literal