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, sub_expr2)
sub_expr4 = frac(one, Mult(four, sub_expr2))
expr = ExprTuple(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(frac(one, four), 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))))
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), \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: 69
operands: 3
2Operationoperator: 64
operands: 4
3ExprTuple5, 6
4ExprTuple7, 8
5Operationoperator: 20
operand: 13
6Operationoperator: 20
operand: 14
7Operationoperator: 35
operands: 11
8Operationoperator: 69
operands: 12
9ExprTuple13
10ExprTuple14
11ExprTuple81, 39
12ExprTuple15, 16
13Lambdaparameter: 55
body: 17
14Lambdaparameter: 55
body: 18
15Operationoperator: 20
operand: 23
16Operationoperator: 20
operand: 24
17Conditionalvalue: 22
condition: 30
18Conditionalvalue: 22
condition: 32
19ExprTuple23
20Literal
21ExprTuple24
22Operationoperator: 35
operands: 25
23Lambdaparameter: 55
body: 26
24Lambdaparameter: 55
body: 28
25ExprTuple81, 29
26Conditionalvalue: 31
condition: 30
27ExprTuple55
28Conditionalvalue: 31
condition: 32
29Operationoperator: 64
operands: 33
30Operationoperator: 37
operands: 34
31Operationoperator: 35
operands: 36
32Operationoperator: 37
operands: 38
33ExprTuple39, 41
34ExprTuple55, 40
35Literal
36ExprTuple81, 41
37Literal
38ExprTuple55, 42
39Literal
40Operationoperator: 45
operands: 43
41Operationoperator: 71
operands: 44
42Operationoperator: 45
operands: 46
43ExprTuple47, 48
44ExprTuple49, 76
45Literal
46ExprTuple54, 60
47Operationoperator: 69
operands: 50
48Operationoperator: 79
operand: 54
49Operationoperator: 69
operands: 52
50ExprTuple53, 81
51ExprTuple54
52ExprTuple55, 56
53Operationoperator: 79
operand: 60
54Operationoperator: 69
operands: 58
55Variable
56Operationoperator: 79
operand: 62
57ExprTuple60
58ExprTuple61, 81
59ExprTuple62
60Operationoperator: 71
operands: 63
61Variable
62Operationoperator: 64
operands: 65
63ExprTuple76, 66
64Literal
65ExprTuple67, 68
66Operationoperator: 69
operands: 70
67Operationoperator: 71
operands: 72
68Operationoperator: 73
operand: 78
69Literal
70ExprTuple77, 75
71Literal
72ExprTuple76, 77
73Literal
74ExprTuple78
75Operationoperator: 79
operand: 81
76Literal
77Literal
78Literal
79Literal
80ExprTuple81
81Literal