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 ExprRange, IndexedVar, Variable, a, c, l
from proveit.logic import Equals, Forall
from proveit.numbers import Complex, Exp, Mult, Sum, frac, one, two, zero
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [l]
sub_expr3 = IndexedVar(a, one)
sub_expr4 = ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, zero)
sub_expr5 = frac(one, Exp(_diff_l_scaled_delta_floor, two))
expr = Forall(instance_param_or_params = [sub_expr3, sub_expr4], instance_expr = Equals(Mult(sub_expr3, Sum(index_or_indices = sub_expr2, summand = sub_expr5, domain = _neg_domain), sub_expr4), Sum(index_or_indices = sub_expr2, summand = Mult(sub_expr3, sub_expr5, sub_expr4), domain = _neg_domain)).with_wrapping_at(2), domain = Complex).with_wrapping()
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())
\begin{array}{l}\forall_{a_{1}, c_{1}, c_{2}, \ldots, c_{0} \in \mathbb{C}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot \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)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right) =  \\ \left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \left(a_{1} \cdot \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right)\right) \end{array} \end{array}\right)\end{array}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('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
4ExprTuple34, 36
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15
12Operationoperator: 70
operands: 16
13Operationoperator: 23
operand: 21
14Operationoperator: 37
operands: 18
15ExprRangelambda_map: 19
start_index: 87
end_index: 43
16ExprTuple34, 20, 36
17ExprTuple21
18ExprTuple34, 29
19Lambdaparameter: 55
body: 22
20Operationoperator: 23
operand: 27
21Lambdaparameter: 61
body: 25
22Operationoperator: 37
operands: 26
23Literal
24ExprTuple27
25Conditionalvalue: 28
condition: 33
26ExprTuple46, 29
27Lambdaparameter: 61
body: 31
28Operationoperator: 70
operands: 32
29Literal
30ExprTuple61
31Conditionalvalue: 35
condition: 33
32ExprTuple34, 35, 36
33Operationoperator: 37
operands: 38
34IndexedVarvariable: 39
index: 87
35Operationoperator: 40
operands: 41
36ExprRangelambda_map: 42
start_index: 87
end_index: 43
37Literal
38ExprTuple61, 44
39Variable
40Literal
41ExprTuple87, 45
42Lambdaparameter: 55
body: 46
43Literal
44Operationoperator: 47
operands: 48
45Operationoperator: 77
operands: 49
46IndexedVarvariable: 50
index: 55
47Literal
48ExprTuple52, 53
49ExprTuple54, 82
50Variable
51ExprTuple55
52Operationoperator: 75
operands: 56
53Operationoperator: 85
operand: 60
54Operationoperator: 75
operands: 58
55Variable
56ExprTuple59, 87
57ExprTuple60
58ExprTuple61, 62
59Operationoperator: 85
operand: 66
60Operationoperator: 75
operands: 64
61Variable
62Operationoperator: 85
operand: 68
63ExprTuple66
64ExprTuple67, 87
65ExprTuple68
66Operationoperator: 77
operands: 69
67Variable
68Operationoperator: 70
operands: 71
69ExprTuple82, 72
70Literal
71ExprTuple73, 74
72Operationoperator: 75
operands: 76
73Operationoperator: 77
operands: 78
74Operationoperator: 79
operand: 84
75Literal
76ExprTuple83, 81
77Literal
78ExprTuple82, 83
79Literal
80ExprTuple84
81Operationoperator: 85
operand: 87
82Literal
83Literal
84Literal
85Literal
86ExprTuple87
87Literal