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 Conditional, ExprTuple, 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 = ExprTuple(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())
\left(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..\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: 53
body: 3
2ExprTuple53
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 21
operands: 8
6Literal
7ExprTuple9, 10
8ExprTuple53, 11
9Operationoperator: 13
operands: 12
10Operationoperator: 13
operands: 14
11Operationoperator: 41
operands: 15
12ExprTuple16, 18
13Literal
14ExprTuple17, 18
15ExprTuple64, 19
16Operationoperator: 21
operands: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operands: 24
19Operationoperator: 58
operands: 25
20ExprTuple38, 26
21Literal
22ExprTuple38, 27
23Literal
24ExprTuple53, 28
25ExprTuple52, 29
26Operationoperator: 30
operands: 31
27Operationoperator: 41
operands: 32
28Operationoperator: 33
operands: 34
29Operationoperator: 62
operand: 56
30Literal
31ExprTuple36, 37
32ExprTuple44, 52
33Literal
34ExprTuple38, 39
35ExprTuple56
36Operationoperator: 41
operands: 40
37Operationoperator: 41
operands: 42
38Variable
39Operationoperator: 54
operands: 43
40ExprTuple44, 45
41Literal
42ExprTuple49, 52
43ExprTuple56, 60
44Operationoperator: 58
operands: 46
45Operationoperator: 62
operand: 49
46ExprTuple48, 64
47ExprTuple49
48Operationoperator: 62
operand: 52
49Operationoperator: 58
operands: 51
50ExprTuple52
51ExprTuple53, 64
52Operationoperator: 54
operands: 55
53Variable
54Literal
55ExprTuple56, 57
56Literal
57Operationoperator: 58
operands: 59
58Literal
59ExprTuple60, 61
60Literal
61Operationoperator: 62
operand: 64
62Literal
63ExprTuple64
64Literal