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 m
from proveit.logic import Forall
from proveit.numbers import Exp, LessEq, ModAbs, one, subtract, two
from proveit.physics.quantum.QPE import _b_floor, _m_domain, _n, _success_cond, _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [m], instance_expr = _success_cond, domain = _m_domain, condition = LessEq(ModAbs(subtract(m, _b_floor), _two_pow_t), subtract(Exp(two, subtract(_t, _n)), one)))
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_{m \in \{0~\ldotp \ldotp~2^{t} - 1\}~|~\left|m - b_{\textit{f}}\right|_{\textup{mod}\thinspace 2^{t}} \leq \left(2^{t - n} - 1\right)}~\left(\left|\frac{m}{2^{t}} - \varphi\right|_{\textup{mod}\thinspace 1} \leq 2^{-n}\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: 46
body: 5
4ExprTuple46
5Conditionalvalue: 6
condition: 7
6Operationoperator: 19
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple13, 14
11Operationoperator: 28
operands: 15
12Operationoperator: 49
operands: 16
13Operationoperator: 17
operands: 18
14Operationoperator: 19
operands: 20
15ExprTuple21, 56
16ExprTuple55, 59
17Literal
18ExprTuple46, 22
19Literal
20ExprTuple23, 24
21Operationoperator: 53
operands: 25
22Operationoperator: 26
operands: 27
23Operationoperator: 28
operands: 29
24Operationoperator: 53
operands: 30
25ExprTuple31, 32
26Literal
27ExprTuple33, 34
28Literal
29ExprTuple35, 44
30ExprTuple36, 45
31Operationoperator: 37
operands: 38
32Operationoperator: 60
operand: 43
33Literal
34Operationoperator: 53
operands: 40
35Operationoperator: 53
operands: 41
36Operationoperator: 49
operands: 42
37Literal
38ExprTuple46, 44
39ExprTuple43
40ExprTuple44, 45
41ExprTuple46, 47
42ExprTuple55, 48
43Literal
44Operationoperator: 49
operands: 50
45Operationoperator: 60
operand: 56
46Variable
47Operationoperator: 60
operand: 57
48Operationoperator: 53
operands: 54
49Literal
50ExprTuple55, 58
51ExprTuple56
52ExprTuple57
53Literal
54ExprTuple58, 59
55Literal
56Literal
57Literal
58Literal
59Operationoperator: 60
operand: 62
60Literal
61ExprTuple62
62Literal