logo

Expression of type ExprTuple

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 ExprTuple, 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 = ExprTuple(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())
\left(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]\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 43
body: 3
2ExprTuple43
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameter: 58
body: 8
7ExprTuple58
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 26
operands: 13
11Literal
12ExprTuple14, 15
13ExprTuple58, 16
14Operationoperator: 18
operands: 17
15Operationoperator: 18
operands: 19
16Operationoperator: 46
operands: 20
17ExprTuple21, 23
18Literal
19ExprTuple22, 23
20ExprTuple69, 24
21Operationoperator: 26
operands: 25
22Operationoperator: 26
operands: 27
23Operationoperator: 28
operands: 29
24Operationoperator: 63
operands: 30
25ExprTuple43, 31
26Literal
27ExprTuple43, 32
28Literal
29ExprTuple58, 33
30ExprTuple57, 34
31Operationoperator: 35
operands: 36
32Operationoperator: 46
operands: 37
33Operationoperator: 38
operands: 39
34Operationoperator: 67
operand: 61
35Literal
36ExprTuple41, 42
37ExprTuple49, 57
38Literal
39ExprTuple43, 44
40ExprTuple61
41Operationoperator: 46
operands: 45
42Operationoperator: 46
operands: 47
43Variable
44Operationoperator: 59
operands: 48
45ExprTuple49, 50
46Literal
47ExprTuple54, 57
48ExprTuple61, 65
49Operationoperator: 63
operands: 51
50Operationoperator: 67
operand: 54
51ExprTuple53, 69
52ExprTuple54
53Operationoperator: 67
operand: 57
54Operationoperator: 63
operands: 56
55ExprTuple57
56ExprTuple58, 69
57Operationoperator: 59
operands: 60
58Variable
59Literal
60ExprTuple61, 62
61Literal
62Operationoperator: 63
operands: 64
63Literal
64ExprTuple65, 66
65Literal
66Operationoperator: 67
operand: 69
67Literal
68ExprTuple69
69Literal