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, e, l
from proveit.logic import And, Iff, InSet, Union
from proveit.numbers import ModAbs, greater
from proveit.physics.quantum.QPE import _e_domain, _full_domain, _neg_domain, _pos_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = greater(ModAbs(l, _two_pow_t), e)
expr = Lambda(e, Conditional(Iff(And(InSet(l, Union(_neg_domain, _pos_domain)), sub_expr1), And(InSet(l, _full_domain), sub_expr1)).with_wrapping_at(1), InSet(e, _e_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())
e \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(\left(l \in \left(\{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\right)\} \cup \{e + 1~\ldotp \ldotp~2^{t - 1}\}\right)\right) \land \left(\left|l\right|_{\textup{mod}\thinspace 2^{t}} > e\right)\right) \\  \Leftrightarrow \left(\left(l \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\}\right) \land \left(\left|l\right|_{\textup{mod}\thinspace 2^{t}} > e\right)\right) \end{array} \end{array} \textrm{ if } e \in \{1~\ldotp \ldotp~2^{t - 1} - 2\}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 52
body: 2
1ExprTuple52
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 20
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple52, 10
8Operationoperator: 12
operands: 11
9Operationoperator: 12
operands: 13
10Operationoperator: 40
operands: 14
11ExprTuple15, 17
12Literal
13ExprTuple16, 17
14ExprTuple63, 18
15Operationoperator: 20
operands: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operands: 23
18Operationoperator: 57
operands: 24
19ExprTuple37, 25
20Literal
21ExprTuple37, 26
22Literal
23ExprTuple52, 27
24ExprTuple51, 28
25Operationoperator: 29
operands: 30
26Operationoperator: 40
operands: 31
27Operationoperator: 32
operands: 33
28Operationoperator: 61
operand: 55
29Literal
30ExprTuple35, 36
31ExprTuple43, 51
32Literal
33ExprTuple37, 38
34ExprTuple55
35Operationoperator: 40
operands: 39
36Operationoperator: 40
operands: 41
37Variable
38Operationoperator: 53
operands: 42
39ExprTuple43, 44
40Literal
41ExprTuple48, 51
42ExprTuple55, 59
43Operationoperator: 57
operands: 45
44Operationoperator: 61
operand: 48
45ExprTuple47, 63
46ExprTuple48
47Operationoperator: 61
operand: 51
48Operationoperator: 57
operands: 50
49ExprTuple51
50ExprTuple52, 63
51Operationoperator: 53
operands: 54
52Variable
53Literal
54ExprTuple55, 56
55Literal
56Operationoperator: 57
operands: 58
57Literal
58ExprTuple59, 60
59Literal
60Operationoperator: 61
operand: 63
61Literal
62ExprTuple63
63Literal