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 b, l
from proveit.logic import Forall, NotEquals, NotInSet, Set
from proveit.numbers import Integer, frac, subtract, zero
from proveit.physics.quantum.QPE import _b_floor, _b_round, _delta_b, _full_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [b, l], instance_expr = NotInSet(subtract(_delta_b, frac(l, _two_pow_t)), Integer), domains = [Set(_b_floor, _b_round), _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_{b \in \left\{b_{\textit{f}}, b_{\textit{r}}\right\}, l \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\}~|~l \neq 0}~\left(\left(\delta_{b} - \frac{l}{2^{t}}\right) \notin \mathbb{Z}\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
3Lambdaparameters: 4
body: 5
4ExprTuple35, 43
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15, 16
12Operationoperator: 53
operands: 17
13Literal
14Operationoperator: 19
operands: 18
15Operationoperator: 19
operands: 20
16Operationoperator: 21
operands: 22
17ExprTuple23, 24
18ExprTuple35, 25
19Literal
20ExprTuple43, 26
21Literal
22ExprTuple43, 27
23Operationoperator: 28
operand: 35
24Operationoperator: 57
operand: 36
25Operationoperator: 31
operands: 32
26Operationoperator: 33
operands: 34
27Literal
28Literal
29ExprTuple35
30ExprTuple36
31Literal
32ExprTuple37, 38
33Literal
34ExprTuple39, 48
35Variable
36Operationoperator: 40
operands: 41
37Literal
38Literal
39Operationoperator: 53
operands: 42
40Literal
41ExprTuple43, 44
42ExprTuple45, 59
43Variable
44Operationoperator: 49
operands: 46
45Operationoperator: 57
operand: 48
46ExprTuple51, 55
47ExprTuple48
48Operationoperator: 49
operands: 50
49Literal
50ExprTuple51, 52
51Literal
52Operationoperator: 53
operands: 54
53Literal
54ExprTuple55, 56
55Literal
56Operationoperator: 57
operand: 59
57Literal
58ExprTuple59
59Literal