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, NotEquals
from proveit.numbers import Abs, Exp, LessEq, Mult, four, frac, one, two, zero
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _full_domain, _rel_indexed_alpha
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [l], instance_expr = LessEq(Exp(Abs(_rel_indexed_alpha), two), frac(one, Mult(four, Exp(_diff_l_scaled_delta_floor, 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|\alpha_{b_{\textit{f}} \oplus l}\right|^{2} \leq \frac{1}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\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: 47
body: 5
4ExprTuple47
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15
12Operationoperator: 61
operands: 16
13Operationoperator: 17
operands: 18
14Operationoperator: 19
operands: 20
15Operationoperator: 21
operands: 22
16ExprTuple23, 67
17Literal
18ExprTuple70, 24
19Literal
20ExprTuple47, 25
21Literal
22ExprTuple47, 26
23Operationoperator: 27
operand: 32
24Operationoperator: 54
operands: 29
25Operationoperator: 30
operands: 31
26Literal
27Literal
28ExprTuple32
29ExprTuple33, 34
30Literal
31ExprTuple35, 49
32Operationoperator: 36
operand: 40
33Literal
34Operationoperator: 61
operands: 38
35Operationoperator: 56
operands: 39
36Literal
37ExprTuple40
38ExprTuple41, 67
39ExprTuple42, 70
40Operationoperator: 43
operands: 44
41Operationoperator: 56
operands: 45
42Operationoperator: 65
operand: 49
43Literal
44ExprTuple69, 47
45ExprTuple47, 48
46ExprTuple49
47Variable
48Operationoperator: 65
operand: 52
49Operationoperator: 61
operands: 51
50ExprTuple52
51ExprTuple67, 53
52Operationoperator: 54
operands: 55
53Operationoperator: 56
operands: 57
54Literal
55ExprTuple58, 59
56Literal
57ExprTuple68, 60
58Operationoperator: 61
operands: 62
59Operationoperator: 63
operand: 69
60Operationoperator: 65
operand: 70
61Literal
62ExprTuple67, 68
63Literal
64ExprTuple69
65Literal
66ExprTuple70
67Literal
68Literal
69Literal
70Literal