# 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 Conditional, e, l
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Abs, Add, Exp, Interval, Neg, one, subtract, two
from proveit.physics.quantum.QPE import _neg_domain, _rel_indexed_alpha, _two_pow__t_minus_one

In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(Abs(_rel_indexed_alpha), two)
expr = Forall(instance_param_or_params = [l], instance_expr = Equals(Conditional(sub_expr1, InSet(l, _neg_domain)), Conditional(sub_expr1, InSet(l, Interval(Add(Neg(_two_pow__t_minus_one), one), subtract(Neg(e), one))))).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())

\forall_{l}~\left(\begin{array}{c} \begin{array}{l} \left\{\left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2} \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~-\left(e + 1\right)\}\right.. \\  = \left\{\left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2} \textrm{ if } l \in \{-2^{t - 1} + 1~\ldotp \ldotp~-e - 1\}\right.. \end{array} \end{array}\right)

In [5]:
stored_expr.style_options()

namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 44
body: 5
4ExprTuple44
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Conditionalvalue: 11
condition: 10
9Conditionalvalue: 11
condition: 12
10Operationoperator: 15
operands: 13
11Operationoperator: 47
operands: 14
12Operationoperator: 15
operands: 16
13ExprTuple44, 17
14ExprTuple18, 49
15Literal
16ExprTuple44, 19
17Operationoperator: 23
operands: 20
18Operationoperator: 21
operand: 26
19Operationoperator: 23
operands: 24
20ExprTuple27, 25
21Literal
22ExprTuple26
23Literal
24ExprTuple27, 28
25Operationoperator: 55
operand: 34
26Operationoperator: 30
operand: 35
27Operationoperator: 51
operands: 32
28Operationoperator: 51
operands: 33
29ExprTuple34
30Literal
31ExprTuple35
32ExprTuple36, 57
33ExprTuple37, 54
34Operationoperator: 51
operands: 38
35Operationoperator: 39
operands: 40
36Operationoperator: 55
operand: 45
37Operationoperator: 55
operand: 46
38ExprTuple46, 57
39Literal
40ExprTuple43, 44
41ExprTuple45
42ExprTuple46
43Literal
44Variable
45Operationoperator: 47
operands: 48
46Variable
47Literal
48ExprTuple49, 50
49Literal
50Operationoperator: 51
operands: 52
51Literal
52ExprTuple53, 54
53Literal
54Operationoperator: 55
operand: 57
55Literal
56ExprTuple57
57Literal