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, 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 = Exp(_diff_l_scaled_delta_floor, two)
sub_expr4 = frac(one, sub_expr3)
sub_expr5 = Mult(sub_expr2, Sum(index_or_indices = sub_expr1, summand = sub_expr4, domain = _neg_domain))
expr = ExprTuple(Add(sub_expr5, Sum(index_or_indices = sub_expr1, summand = frac(one, Mult(four, sub_expr3)), domain = _pos_domain)), Add(sub_expr5, Mult(sub_expr2, Sum(index_or_indices = sub_expr1, summand = sub_expr4, 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())
\left(\left(\frac{1}{4} \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)\right) + \left(\sum_{l = e + 1}^{2^{t - 1}} \frac{1}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right), \left(\frac{1}{4} \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)\right) + \left(\frac{1}{4} \cdot \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)
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: 67
operands: 3
2Operationoperator: 67
operands: 4
3ExprTuple6, 5
4ExprTuple6, 7
5Operationoperator: 18
operand: 11
6Operationoperator: 62
operands: 9
7Operationoperator: 62
operands: 10
8ExprTuple11
9ExprTuple13, 12
10ExprTuple13, 14
11Lambdaparameter: 53
body: 15
12Operationoperator: 18
operand: 21
13Operationoperator: 33
operands: 17
14Operationoperator: 18
operand: 22
15Conditionalvalue: 20
condition: 30
16ExprTuple21
17ExprTuple79, 37
18Literal
19ExprTuple22
20Operationoperator: 33
operands: 23
21Lambdaparameter: 53
body: 24
22Lambdaparameter: 53
body: 26
23ExprTuple79, 27
24Conditionalvalue: 29
condition: 28
25ExprTuple53
26Conditionalvalue: 29
condition: 30
27Operationoperator: 62
operands: 31
28Operationoperator: 35
operands: 32
29Operationoperator: 33
operands: 34
30Operationoperator: 35
operands: 36
31ExprTuple37, 39
32ExprTuple53, 38
33Literal
34ExprTuple79, 39
35Literal
36ExprTuple53, 40
37Literal
38Operationoperator: 43
operands: 41
39Operationoperator: 69
operands: 42
40Operationoperator: 43
operands: 44
41ExprTuple45, 46
42ExprTuple47, 74
43Literal
44ExprTuple52, 58
45Operationoperator: 67
operands: 48
46Operationoperator: 77
operand: 52
47Operationoperator: 67
operands: 50
48ExprTuple51, 79
49ExprTuple52
50ExprTuple53, 54
51Operationoperator: 77
operand: 58
52Operationoperator: 67
operands: 56
53Variable
54Operationoperator: 77
operand: 60
55ExprTuple58
56ExprTuple59, 79
57ExprTuple60
58Operationoperator: 69
operands: 61
59Variable
60Operationoperator: 62
operands: 63
61ExprTuple74, 64
62Literal
63ExprTuple65, 66
64Operationoperator: 67
operands: 68
65Operationoperator: 69
operands: 70
66Operationoperator: 71
operand: 76
67Literal
68ExprTuple75, 73
69Literal
70ExprTuple74, 75
71Literal
72ExprTuple76
73Operationoperator: 77
operand: 79
74Literal
75Literal
76Literal
77Literal
78ExprTuple79
79Literal