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.
# import Expression classes needed to build the expression
from proveit import e, l
from proveit.logic import And, Iff, InSet, Union
from proveit.numbers import ModAbs, greater
from proveit.physics.quantum.QPE import _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 = Iff(And(InSet(l, Union(_neg_domain, _pos_domain)), sub_expr1), And(InSet(l, _full_domain), sub_expr1)).with_wrapping_at(1)

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())

\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}

In [5]:
stored_expr.style_options()

namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()(1)('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 6
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 10
6Literal
7ExprTuple9, 10
8Operationoperator: 12
operands: 11
9Operationoperator: 12
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple26, 16
12Literal
13ExprTuple26, 17
14Literal
15ExprTuple41, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 29
operands: 21
18Operationoperator: 22
operands: 23
19Literal
20ExprTuple24, 25
21ExprTuple32, 40
22Literal
23ExprTuple26, 27
24Operationoperator: 29
operands: 28
25Operationoperator: 29
operands: 30
26Variable
27Operationoperator: 42
operands: 31
28ExprTuple32, 33
29Literal
30ExprTuple37, 40
31ExprTuple44, 48
32Operationoperator: 46
operands: 34
33Operationoperator: 50
operand: 37
34ExprTuple36, 52
35ExprTuple37
36Operationoperator: 50
operand: 40
37Operationoperator: 46
operands: 39
38ExprTuple40
39ExprTuple41, 52
40Operationoperator: 42
operands: 43
41Variable
42Literal
43ExprTuple44, 45
44Literal
45Operationoperator: 46
operands: 47
46Literal
47ExprTuple48, 49
48Literal
49Operationoperator: 50
operand: 52
50Literal
51ExprTuple52
52Literal