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
from proveit.numbers import Abs, Exp, LessEq, Mult, four, frac, one, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_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 = _neg_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~-\left(e + 1\right)\}}~\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
11ExprTuple47, 14
12Operationoperator: 62
operands: 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15ExprTuple20, 66
16Literal
17ExprTuple61, 21
18Literal
19ExprTuple22, 23
20Operationoperator: 24
operand: 29
21Operationoperator: 55
operands: 26
22Operationoperator: 51
operands: 27
23Operationoperator: 57
operand: 33
24Literal
25ExprTuple29
26ExprTuple30, 31
27ExprTuple32, 61
28ExprTuple33
29Operationoperator: 34
operand: 39
30Literal
31Operationoperator: 62
operands: 36
32Operationoperator: 57
operand: 41
33Operationoperator: 51
operands: 38
34Literal
35ExprTuple39
36ExprTuple40, 66
37ExprTuple41
38ExprTuple42, 61
39Operationoperator: 43
operands: 44
40Operationoperator: 51
operands: 45
41Operationoperator: 62
operands: 46
42Variable
43Literal
44ExprTuple68, 47
45ExprTuple47, 48
46ExprTuple66, 49
47Variable
48Operationoperator: 57
operand: 53
49Operationoperator: 51
operands: 52
50ExprTuple53
51Literal
52ExprTuple67, 54
53Operationoperator: 55
operands: 56
54Operationoperator: 57
operand: 61
55Literal
56ExprTuple59, 60
57Literal
58ExprTuple61
59Operationoperator: 62
operands: 63
60Operationoperator: 64
operand: 68
61Literal
62Literal
63ExprTuple66, 67
64Literal
65ExprTuple68
66Literal
67Literal
68Literal