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
from proveit.numbers import IntervalCO, Neg, frac, one, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _full_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = frac(one, two)
expr = Forall(instance_param_or_params = [l], instance_expr = InSet(subtract(_delta_b_floor, frac(l, _two_pow_t)), IntervalCO(Neg(sub_expr1), sub_expr1)), domain = _full_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())
\forall_{l \in \{-2^{t - 1} + 1~\ldotp \ldotp~2^{t - 1}\}}~\left(\left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right) \in \left[-\frac{1}{2},\frac{1}{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: 36
body: 5
4ExprTuple36
5Conditionalvalue: 6
condition: 7
6Operationoperator: 9
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple36, 13
11Operationoperator: 44
operands: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple19, 20
15Literal
16ExprTuple21, 30
17Literal
18ExprTuple22, 38
19Operationoperator: 23
operand: 28
20Operationoperator: 48
operand: 29
21Operationoperator: 48
operand: 30
22Operationoperator: 44
operands: 27
23Literal
24ExprTuple28
25ExprTuple29
26ExprTuple30
27ExprTuple31, 50
28Literal
29Operationoperator: 33
operands: 32
30Operationoperator: 33
operands: 34
31Operationoperator: 48
operand: 38
32ExprTuple36, 37
33Literal
34ExprTuple50, 42
35ExprTuple38
36Variable
37Operationoperator: 40
operands: 39
38Operationoperator: 40
operands: 41
39ExprTuple42, 46
40Literal
41ExprTuple42, 43
42Literal
43Operationoperator: 44
operands: 45
44Literal
45ExprTuple46, 47
46Literal
47Operationoperator: 48
operand: 50
48Literal
49ExprTuple50
50Literal