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 Lambda, e, l
from proveit.logic import And, Forall, 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(l, Forall(instance_param_or_params = [e], instance_expr = Iff(And(InSet(l, Union(_neg_domain, _pos_domain)), sub_expr1), And(InSet(l, _full_domain), sub_expr1)).with_wrapping_at(1), domain = _e_domain).with_wrapping())
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[\begin{array}{l}\forall_{e \in \{1~\ldotp \ldotp~2^{t - 1} - 2\}}~\\
\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}\right)\end{array}\right]
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 42
body: 2
1ExprTuple42
2Operationoperator: 3
operand: 5
3Literal
4ExprTuple5
5Lambdaparameter: 57
body: 7
6ExprTuple57
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 25
operands: 12
10Literal
11ExprTuple13, 14
12ExprTuple57, 15
13Operationoperator: 17
operands: 16
14Operationoperator: 17
operands: 18
15Operationoperator: 45
operands: 19
16ExprTuple20, 22
17Literal
18ExprTuple21, 22
19ExprTuple68, 23
20Operationoperator: 25
operands: 24
21Operationoperator: 25
operands: 26
22Operationoperator: 27
operands: 28
23Operationoperator: 62
operands: 29
24ExprTuple42, 30
25Literal
26ExprTuple42, 31
27Literal
28ExprTuple57, 32
29ExprTuple56, 33
30Operationoperator: 34
operands: 35
31Operationoperator: 45
operands: 36
32Operationoperator: 37
operands: 38
33Operationoperator: 66
operand: 60
34Literal
35ExprTuple40, 41
36ExprTuple48, 56
37Literal
38ExprTuple42, 43
39ExprTuple60
40Operationoperator: 45
operands: 44
41Operationoperator: 45
operands: 46
42Variable
43Operationoperator: 58
operands: 47
44ExprTuple48, 49
45Literal
46ExprTuple53, 56
47ExprTuple60, 64
48Operationoperator: 62
operands: 50
49Operationoperator: 66
operand: 53
50ExprTuple52, 68
51ExprTuple53
52Operationoperator: 66
operand: 56
53Operationoperator: 62
operands: 55
54ExprTuple56
55ExprTuple57, 68
56Operationoperator: 58
operands: 59
57Variable
58Literal
59ExprTuple60, 61
60Literal
61Operationoperator: 62
operands: 63
62Literal
63ExprTuple64, 65
64Literal
65Operationoperator: 66
operand: 68
66Literal
67ExprTuple68
68Literal