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 e, l
from proveit.logic import Forall
from proveit.numbers import Add, Exp, LessEq, Mult, Sum, four, frac, one, two
from proveit.physics.quantum.QPE import Pfail, _diff_l_scaled_delta_floor, _e_domain, _neg_domain, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
sub_expr2 = frac(one, Exp(_diff_l_scaled_delta_floor, two))
expr = Forall(instance_param_or_params = [e], instance_expr = LessEq(Pfail(e), Mult(frac(one, four), Add(Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _pos_domain)))), domain = _e_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_{e \in \{1~\ldotp \ldotp~2^{t - 1} - 2\}}~\left(\left[P_{\rm fail}\right]\left(e\right) \leq \left(\frac{1}{4} \cdot \left(\left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right) + \left(\sum_{l = e + 1}^{2^{t - 1}} \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right)\right)\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: 65
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 42
operands: 9
7Literal
8ExprTuple10, 11
9ExprTuple65, 12
10Operationoperator: 13
operand: 65
11Operationoperator: 68
operands: 15
12Operationoperator: 49
operands: 16
13Literal
14ExprTuple65
15ExprTuple17, 18
16ExprTuple85, 19
17Operationoperator: 40
operands: 20
18Operationoperator: 73
operands: 21
19Operationoperator: 73
operands: 22
20ExprTuple85, 23
21ExprTuple24, 25
22ExprTuple64, 26
23Literal
24Operationoperator: 28
operand: 31
25Operationoperator: 28
operand: 32
26Operationoperator: 83
operand: 80
27ExprTuple31
28Literal
29ExprTuple32
30ExprTuple80
31Lambdaparameter: 59
body: 33
32Lambdaparameter: 59
body: 35
33Conditionalvalue: 37
condition: 36
34ExprTuple59
35Conditionalvalue: 37
condition: 38
36Operationoperator: 42
operands: 39
37Operationoperator: 40
operands: 41
38Operationoperator: 42
operands: 43
39ExprTuple59, 44
40Literal
41ExprTuple85, 45
42Literal
43ExprTuple59, 46
44Operationoperator: 49
operands: 47
45Operationoperator: 75
operands: 48
46Operationoperator: 49
operands: 50
47ExprTuple51, 52
48ExprTuple53, 80
49Literal
50ExprTuple58, 64
51Operationoperator: 73
operands: 54
52Operationoperator: 83
operand: 58
53Operationoperator: 73
operands: 56
54ExprTuple57, 85
55ExprTuple58
56ExprTuple59, 60
57Operationoperator: 83
operand: 64
58Operationoperator: 73
operands: 62
59Variable
60Operationoperator: 83
operand: 66
61ExprTuple64
62ExprTuple65, 85
63ExprTuple66
64Operationoperator: 75
operands: 67
65Variable
66Operationoperator: 68
operands: 69
67ExprTuple80, 70
68Literal
69ExprTuple71, 72
70Operationoperator: 73
operands: 74
71Operationoperator: 75
operands: 76
72Operationoperator: 77
operand: 82
73Literal
74ExprTuple81, 79
75Literal
76ExprTuple80, 81
77Literal
78ExprTuple82
79Operationoperator: 83
operand: 85
80Literal
81Literal
82Literal
83Literal
84ExprTuple85
85Literal