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 And, InSet, NotEquals
from proveit.numbers import Abs, IntervalOC, Mult, frac, pi, subtract, two, zero
from proveit.physics.quantum.QPE import _delta_b_floor, _full_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Lambda(l, Conditional(InSet(Mult(pi, Abs(subtract(_delta_b_floor, frac(l, _two_pow_t)))), IntervalOC(zero, frac(pi, two))), And(InSet(l, _full_domain), NotEquals(l, zero))))
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(\pi \cdot \left|\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right|\right) \in \left(0,\frac{\pi}{2}\right] \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\} ,  l \neq 0\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 47
body: 2
1ExprTuple47
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Operationoperator: 12
operands: 13
9Operationoperator: 14
operands: 15
10Operationoperator: 16
operands: 17
11Operationoperator: 18
operands: 19
12Literal
13ExprTuple30, 20
14Literal
15ExprTuple23, 21
16Literal
17ExprTuple47, 22
18Literal
19ExprTuple47, 23
20Operationoperator: 24
operand: 29
21Operationoperator: 44
operands: 26
22Operationoperator: 27
operands: 28
23Literal
24Literal
25ExprTuple29
26ExprTuple30, 54
27Literal
28ExprTuple31, 43
29Operationoperator: 52
operands: 32
30Literal
31Operationoperator: 52
operands: 33
32ExprTuple34, 35
33ExprTuple36, 59
34Operationoperator: 37
operand: 41
35Operationoperator: 57
operand: 42
36Operationoperator: 57
operand: 43
37Literal
38ExprTuple41
39ExprTuple42
40ExprTuple43
41Literal
42Operationoperator: 44
operands: 45
43Operationoperator: 50
operands: 46
44Literal
45ExprTuple47, 48
46ExprTuple54, 49
47Variable
48Operationoperator: 50
operands: 51
49Operationoperator: 52
operands: 53
50Literal
51ExprTuple54, 55
52Literal
53ExprTuple55, 56
54Literal
55Literal
56Operationoperator: 57
operand: 59
57Literal
58ExprTuple59
59Literal