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