logo

Expression of type ExprTuple

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 ExprTuple, Variable, l
from proveit.numbers import Add, Exp, Mult, Sum, four, frac, one, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
sub_expr2 = frac(one, four)
sub_expr3 = frac(one, Exp(_diff_l_scaled_delta_floor, two))
expr = ExprTuple(Mult(sub_expr2, Add(Sum(index_or_indices = sub_expr1, summand = sub_expr3, domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = sub_expr3, domain = _pos_domain))), Mult(sub_expr2, Add(Sum(index_or_indices = sub_expr1, summand = frac(one, Exp(l, two)), domain = _neg_domain), Variable("_a", latex_format = r"{_{-}a}"))))
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())
\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), \frac{1}{4} \cdot \left(\left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \frac{1}{l^{2}}\right) + {_{-}a}\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 62
operands: 3
2Operationoperator: 62
operands: 4
3ExprTuple6, 5
4ExprTuple6, 7
5Operationoperator: 72
operands: 8
6Operationoperator: 33
operands: 9
7Operationoperator: 72
operands: 10
8ExprTuple11, 12
9ExprTuple80, 13
10ExprTuple14, 15
11Operationoperator: 18
operand: 20
12Operationoperator: 18
operand: 21
13Literal
14Operationoperator: 18
operand: 22
15Variable
16ExprTuple20
17ExprTuple21
18Literal
19ExprTuple22
20Lambdaparameter: 52
body: 23
21Lambdaparameter: 52
body: 24
22Lambdaparameter: 52
body: 26
23Conditionalvalue: 27
condition: 30
24Conditionalvalue: 27
condition: 28
25ExprTuple52
26Conditionalvalue: 29
condition: 30
27Operationoperator: 33
operands: 31
28Operationoperator: 35
operands: 32
29Operationoperator: 33
operands: 34
30Operationoperator: 35
operands: 36
31ExprTuple80, 37
32ExprTuple52, 38
33Literal
34ExprTuple80, 39
35Literal
36ExprTuple52, 40
37Operationoperator: 68
operands: 41
38Operationoperator: 44
operands: 42
39Operationoperator: 68
operands: 43
40Operationoperator: 44
operands: 45
41ExprTuple46, 74
42ExprTuple55, 60
43ExprTuple52, 74
44Literal
45ExprTuple47, 48
46Operationoperator: 72
operands: 49
47Operationoperator: 72
operands: 50
48Operationoperator: 78
operand: 55
49ExprTuple52, 53
50ExprTuple54, 80
51ExprTuple55
52Variable
53Operationoperator: 78
operand: 59
54Operationoperator: 78
operand: 60
55Operationoperator: 72
operands: 58
56ExprTuple59
57ExprTuple60
58ExprTuple61, 80
59Operationoperator: 62
operands: 63
60Operationoperator: 68
operands: 64
61Variable
62Literal
63ExprTuple65, 66
64ExprTuple74, 67
65Operationoperator: 68
operands: 69
66Operationoperator: 70
operand: 75
67Operationoperator: 72
operands: 73
68Literal
69ExprTuple74, 76
70Literal
71ExprTuple75
72Literal
73ExprTuple76, 77
74Literal
75Literal
76Literal
77Operationoperator: 78
operand: 80
78Literal
79ExprTuple80
80Literal