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, m
from proveit.logic import And, InSet
from proveit.numbers import Exp, LessEq, ModAbs, one, subtract, two
from proveit.physics.quantum.QPE import _b_floor, _m_domain, _n, _success_cond, _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Lambda(m, Conditional(_success_cond, And(InSet(m, _m_domain), LessEq(ModAbs(subtract(m, _b_floor), _two_pow_t), subtract(Exp(two, subtract(_t, _n)), one)))))
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())
m \mapsto \left\{\left|\frac{m}{2^{t}} - \varphi\right|_{\textup{mod}\thinspace 1} \leq 2^{-n} \textrm{ if } m \in \{0~\ldotp \ldotp~2^{t} - 1\} ,  \left|m - b_{\textit{f}}\right|_{\textup{mod}\thinspace 2^{t}} \leq \left(2^{t - n} - 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: 43
body: 2
1ExprTuple43
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Operationoperator: 25
operands: 12
9Operationoperator: 46
operands: 13
10Operationoperator: 14
operands: 15
11Operationoperator: 16
operands: 17
12ExprTuple18, 53
13ExprTuple52, 56
14Literal
15ExprTuple43, 19
16Literal
17ExprTuple20, 21
18Operationoperator: 50
operands: 22
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operands: 26
21Operationoperator: 50
operands: 27
22ExprTuple28, 29
23Literal
24ExprTuple30, 31
25Literal
26ExprTuple32, 41
27ExprTuple33, 42
28Operationoperator: 34
operands: 35
29Operationoperator: 57
operand: 40
30Literal
31Operationoperator: 50
operands: 37
32Operationoperator: 50
operands: 38
33Operationoperator: 46
operands: 39
34Literal
35ExprTuple43, 41
36ExprTuple40
37ExprTuple41, 42
38ExprTuple43, 44
39ExprTuple52, 45
40Literal
41Operationoperator: 46
operands: 47
42Operationoperator: 57
operand: 53
43Variable
44Operationoperator: 57
operand: 54
45Operationoperator: 50
operands: 51
46Literal
47ExprTuple52, 55
48ExprTuple53
49ExprTuple54
50Literal
51ExprTuple55, 56
52Literal
53Literal
54Literal
55Literal
56Operationoperator: 57
operand: 59
57Literal
58ExprTuple59
59Literal