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 = frac(one, Exp(_diff_l_scaled_delta_floor, two))
sub_expr4 = Sum(index_or_indices = sub_expr1, summand = sub_expr3, domain = _pos_domain)
sub_expr5 = Sum(index_or_indices = sub_expr1, summand = sub_expr3, domain = _neg_domain)
expr = ExprTuple(Add(Mult(sub_expr2, sub_expr5), Mult(sub_expr2, sub_expr4)), Mult(sub_expr2, Add(sub_expr5, sub_expr4)))
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(\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), \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)\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: 61
operands: 3
2Operationoperator: 56
operands: 4
3ExprTuple5, 6
4ExprTuple11, 7
5Operationoperator: 56
operands: 8
6Operationoperator: 56
operands: 9
7Operationoperator: 61
operands: 10
8ExprTuple11, 12
9ExprTuple11, 13
10ExprTuple12, 13
11Operationoperator: 28
operands: 14
12Operationoperator: 16
operand: 19
13Operationoperator: 16
operand: 20
14ExprTuple73, 18
15ExprTuple19
16Literal
17ExprTuple20
18Literal
19Lambdaparameter: 47
body: 21
20Lambdaparameter: 47
body: 23
21Conditionalvalue: 25
condition: 24
22ExprTuple47
23Conditionalvalue: 25
condition: 26
24Operationoperator: 30
operands: 27
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27ExprTuple47, 32
28Literal
29ExprTuple73, 33
30Literal
31ExprTuple47, 34
32Operationoperator: 37
operands: 35
33Operationoperator: 63
operands: 36
34Operationoperator: 37
operands: 38
35ExprTuple39, 40
36ExprTuple41, 68
37Literal
38ExprTuple46, 52
39Operationoperator: 61
operands: 42
40Operationoperator: 71
operand: 46
41Operationoperator: 61
operands: 44
42ExprTuple45, 73
43ExprTuple46
44ExprTuple47, 48
45Operationoperator: 71
operand: 52
46Operationoperator: 61
operands: 50
47Variable
48Operationoperator: 71
operand: 54
49ExprTuple52
50ExprTuple53, 73
51ExprTuple54
52Operationoperator: 63
operands: 55
53Variable
54Operationoperator: 56
operands: 57
55ExprTuple68, 58
56Literal
57ExprTuple59, 60
58Operationoperator: 61
operands: 62
59Operationoperator: 63
operands: 64
60Operationoperator: 65
operand: 70
61Literal
62ExprTuple69, 67
63Literal
64ExprTuple68, 69
65Literal
66ExprTuple70
67Operationoperator: 71
operand: 73
68Literal
69Literal
70Literal
71Literal
72ExprTuple73
73Literal