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, e, l
from proveit.numbers import Add, Exp, Interval, Mult, Sum, four, frac, one, subtract, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain, _pos_domain, _two_pow__t_minus_one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
sub_expr2 = frac(one, four)
sub_expr3 = frac(one, Exp(l, two))
sub_expr4 = frac(one, Exp(_diff_l_scaled_delta_floor, two))
expr = ExprTuple(Mult(sub_expr2, Add(Sum(index_or_indices = sub_expr1, summand = sub_expr4, domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = sub_expr4, domain = _pos_domain))), 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 = Interval(e, subtract(_two_pow__t_minus_one, one))))))
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) + \left(\sum_{l = e}^{2^{t - 1} - 1} \frac{1}{l^{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: 71
operands: 3
2Operationoperator: 71
operands: 4
3ExprTuple6, 5
4ExprTuple6, 7
5Operationoperator: 81
operands: 8
6Operationoperator: 38
operands: 9
7Operationoperator: 81
operands: 10
8ExprTuple11, 12
9ExprTuple89, 13
10ExprTuple14, 15
11Operationoperator: 19
operand: 21
12Operationoperator: 19
operand: 22
13Literal
14Operationoperator: 19
operand: 23
15Operationoperator: 19
operand: 24
16ExprTuple21
17ExprTuple22
18ExprTuple23
19Literal
20ExprTuple24
21Lambdaparameter: 61
body: 25
22Lambdaparameter: 61
body: 26
23Lambdaparameter: 61
body: 27
24Lambdaparameter: 61
body: 29
25Conditionalvalue: 30
condition: 32
26Conditionalvalue: 30
condition: 31
27Conditionalvalue: 33
condition: 32
28ExprTuple61
29Conditionalvalue: 33
condition: 34
30Operationoperator: 38
operands: 35
31Operationoperator: 40
operands: 36
32Operationoperator: 40
operands: 37
33Operationoperator: 38
operands: 39
34Operationoperator: 40
operands: 41
35ExprTuple89, 42
36ExprTuple61, 43
37ExprTuple61, 44
38Literal
39ExprTuple89, 45
40Literal
41ExprTuple61, 46
42Operationoperator: 77
operands: 47
43Operationoperator: 51
operands: 48
44Operationoperator: 51
operands: 49
45Operationoperator: 77
operands: 50
46Operationoperator: 51
operands: 52
47ExprTuple53, 83
48ExprTuple64, 69
49ExprTuple54, 55
50ExprTuple61, 83
51Literal
52ExprTuple70, 56
53Operationoperator: 81
operands: 57
54Operationoperator: 81
operands: 58
55Operationoperator: 87
operand: 64
56Operationoperator: 81
operands: 60
57ExprTuple61, 62
58ExprTuple63, 89
59ExprTuple64
60ExprTuple69, 86
61Variable
62Operationoperator: 87
operand: 68
63Operationoperator: 87
operand: 69
64Operationoperator: 81
operands: 67
65ExprTuple68
66ExprTuple69
67ExprTuple70, 89
68Operationoperator: 71
operands: 72
69Operationoperator: 77
operands: 73
70Variable
71Literal
72ExprTuple74, 75
73ExprTuple83, 76
74Operationoperator: 77
operands: 78
75Operationoperator: 79
operand: 84
76Operationoperator: 81
operands: 82
77Literal
78ExprTuple83, 85
79Literal
80ExprTuple84
81Literal
82ExprTuple85, 86
83Literal
84Literal
85Literal
86Operationoperator: 87
operand: 89
87Literal
88ExprTuple89
89Literal