logo

Expression of type Conditional

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, 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 = 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\{\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()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operands: 4
2Operationoperator: 18
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple50, 8
6Operationoperator: 10
operands: 9
7Operationoperator: 10
operands: 11
8Operationoperator: 38
operands: 12
9ExprTuple13, 15
10Literal
11ExprTuple14, 15
12ExprTuple61, 16
13Operationoperator: 18
operands: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 20
operands: 21
16Operationoperator: 55
operands: 22
17ExprTuple35, 23
18Literal
19ExprTuple35, 24
20Literal
21ExprTuple50, 25
22ExprTuple49, 26
23Operationoperator: 27
operands: 28
24Operationoperator: 38
operands: 29
25Operationoperator: 30
operands: 31
26Operationoperator: 59
operand: 53
27Literal
28ExprTuple33, 34
29ExprTuple41, 49
30Literal
31ExprTuple35, 36
32ExprTuple53
33Operationoperator: 38
operands: 37
34Operationoperator: 38
operands: 39
35Variable
36Operationoperator: 51
operands: 40
37ExprTuple41, 42
38Literal
39ExprTuple46, 49
40ExprTuple53, 57
41Operationoperator: 55
operands: 43
42Operationoperator: 59
operand: 46
43ExprTuple45, 61
44ExprTuple46
45Operationoperator: 59
operand: 49
46Operationoperator: 55
operands: 48
47ExprTuple49
48ExprTuple50, 61
49Operationoperator: 51
operands: 52
50Variable
51Literal
52ExprTuple53, 54
53Literal
54Operationoperator: 55
operands: 56
55Literal
56ExprTuple57, 58
57Literal
58Operationoperator: 59
operand: 61
59Literal
60ExprTuple61
61Literal