logo

Expression of type Sum

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.numbers import Exp, Mult, Sum, frac, one, two, zero
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Sum(index_or_indices = [l], summand = Mult(IndexedVar(a, one), frac(one, Exp(_diff_l_scaled_delta_floor, two)), ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, zero)), domain = _pos_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())
\sum_{l = e + 1}^{2^{t - 1}} \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)
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: 38
body: 5
4ExprTuple38
5Conditionalvalue: 6
condition: 7
6Operationoperator: 46
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12, 13
9Literal
10ExprTuple38, 14
11IndexedVarvariable: 15
index: 45
12Operationoperator: 16
operands: 17
13ExprRangelambda_map: 18
start_index: 45
end_index: 19
14Operationoperator: 20
operands: 21
15Variable
16Literal
17ExprTuple45, 22
18Lambdaparameter: 32
body: 23
19Literal
20Literal
21ExprTuple24, 25
22Operationoperator: 50
operands: 26
23IndexedVarvariable: 27
index: 32
24Operationoperator: 36
operands: 29
25Operationoperator: 50
operands: 30
26ExprTuple31, 54
27Variable
28ExprTuple32
29ExprTuple33, 45
30ExprTuple54, 34
31Operationoperator: 36
operands: 35
32Variable
33Variable
34Operationoperator: 36
operands: 37
35ExprTuple38, 39
36Literal
37ExprTuple55, 40
38Variable
39Operationoperator: 42
operand: 44
40Operationoperator: 42
operand: 45
41ExprTuple44
42Literal
43ExprTuple45
44Operationoperator: 46
operands: 47
45Literal
46Literal
47ExprTuple48, 49
48Operationoperator: 50
operands: 51
49Operationoperator: 52
operand: 56
50Literal
51ExprTuple54, 55
52Literal
53ExprTuple56
54Literal
55Literal
56Literal