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 InSet
from proveit.numbers import IntervalCO, Neg, frac, one, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _full_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = frac(one, two)
expr = Lambda(l, Conditional(InSet(subtract(_delta_b_floor, frac(l, _two_pow_t)), IntervalCO(Neg(sub_expr1), sub_expr1)), InSet(l, _full_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\{\left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right) \in \left[-\frac{1}{2},\frac{1}{2}\right) \textrm{ if } l \in \{-2^{t - 1} + 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: 33
body: 2
1ExprTuple33
2Conditionalvalue: 3
condition: 4
3Operationoperator: 6
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple33, 10
8Operationoperator: 41
operands: 11
9Operationoperator: 12
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple16, 17
12Literal
13ExprTuple18, 27
14Literal
15ExprTuple19, 35
16Operationoperator: 20
operand: 25
17Operationoperator: 45
operand: 26
18Operationoperator: 45
operand: 27
19Operationoperator: 41
operands: 24
20Literal
21ExprTuple25
22ExprTuple26
23ExprTuple27
24ExprTuple28, 47
25Literal
26Operationoperator: 30
operands: 29
27Operationoperator: 30
operands: 31
28Operationoperator: 45
operand: 35
29ExprTuple33, 34
30Literal
31ExprTuple47, 39
32ExprTuple35
33Variable
34Operationoperator: 37
operands: 36
35Operationoperator: 37
operands: 38
36ExprTuple39, 43
37Literal
38ExprTuple39, 40
39Literal
40Operationoperator: 41
operands: 42
41Literal
42ExprTuple43, 44
43Literal
44Operationoperator: 45
operand: 47
45Literal
46ExprTuple47
47Literal