logo

Expression of type Forall

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 l
from proveit.logic import Forall, InSet, NotEquals
from proveit.numbers import Abs, IntervalOC, Mult, frac, pi, subtract, two, zero
from proveit.physics.quantum.QPE import _delta_b_floor, _full_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [l], instance_expr = InSet(Mult(pi, Abs(subtract(_delta_b_floor, frac(l, _two_pow_t)))), IntervalOC(zero, frac(pi, two))), domain = _full_domain, condition = NotEquals(l, zero))
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 \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\}~|~l \neq 0}~\left(\left(\pi \cdot \left|\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right|\right) \in \left(0,\frac{\pi}{2}\right]\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: 50
body: 5
4ExprTuple50
5Conditionalvalue: 6
condition: 7
6Operationoperator: 19
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple13, 14
11Operationoperator: 15
operands: 16
12Operationoperator: 17
operands: 18
13Operationoperator: 19
operands: 20
14Operationoperator: 21
operands: 22
15Literal
16ExprTuple33, 23
17Literal
18ExprTuple26, 24
19Literal
20ExprTuple50, 25
21Literal
22ExprTuple50, 26
23Operationoperator: 27
operand: 32
24Operationoperator: 47
operands: 29
25Operationoperator: 30
operands: 31
26Literal
27Literal
28ExprTuple32
29ExprTuple33, 57
30Literal
31ExprTuple34, 46
32Operationoperator: 55
operands: 35
33Literal
34Operationoperator: 55
operands: 36
35ExprTuple37, 38
36ExprTuple39, 62
37Operationoperator: 40
operand: 44
38Operationoperator: 60
operand: 45
39Operationoperator: 60
operand: 46
40Literal
41ExprTuple44
42ExprTuple45
43ExprTuple46
44Literal
45Operationoperator: 47
operands: 48
46Operationoperator: 53
operands: 49
47Literal
48ExprTuple50, 51
49ExprTuple57, 52
50Variable
51Operationoperator: 53
operands: 54
52Operationoperator: 55
operands: 56
53Literal
54ExprTuple57, 58
55Literal
56ExprTuple58, 59
57Literal
58Literal
59Operationoperator: 60
operand: 62
60Literal
61ExprTuple62
62Literal