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 Abs, Add, Exp, Mult, Sum, four, frac, one, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain, _pos_domain, _rel_indexed_alpha
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
sub_expr2 = Exp(Abs(_rel_indexed_alpha), two)
sub_expr3 = frac(one, Mult(four, Exp(_diff_l_scaled_delta_floor, two)))
expr = ExprTuple(Add(Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _pos_domain)), 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)} \left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2}\right) + \left(\sum_{l = e + 1}^{2^{t - 1}} \left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2}\right), \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)\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: 70
operands: 3
2Operationoperator: 70
operands: 4
3ExprTuple5, 6
4ExprTuple7, 8
5Operationoperator: 12
operand: 14
6Operationoperator: 12
operand: 15
7Operationoperator: 12
operand: 16
8Operationoperator: 12
operand: 17
9ExprTuple14
10ExprTuple15
11ExprTuple16
12Literal
13ExprTuple17
14Lambdaparameter: 64
body: 18
15Lambdaparameter: 64
body: 19
16Lambdaparameter: 64
body: 20
17Lambdaparameter: 64
body: 22
18Conditionalvalue: 23
condition: 24
19Conditionalvalue: 23
condition: 26
20Conditionalvalue: 25
condition: 24
21ExprTuple64
22Conditionalvalue: 25
condition: 26
23Operationoperator: 79
operands: 27
24Operationoperator: 31
operands: 28
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operands: 32
27ExprTuple33, 84
28ExprTuple64, 34
29Literal
30ExprTuple83, 35
31Literal
32ExprTuple64, 36
33Operationoperator: 37
operand: 43
34Operationoperator: 41
operands: 39
35Operationoperator: 72
operands: 40
36Operationoperator: 41
operands: 42
37Literal
38ExprTuple43
39ExprTuple44, 45
40ExprTuple46, 47
41Literal
42ExprTuple55, 62
43Operationoperator: 48
operand: 53
44Operationoperator: 70
operands: 50
45Operationoperator: 77
operand: 55
46Literal
47Operationoperator: 79
operands: 52
48Literal
49ExprTuple53
50ExprTuple54, 83
51ExprTuple55
52ExprTuple56, 84
53Operationoperator: 57
operands: 58
54Operationoperator: 77
operand: 62
55Operationoperator: 70
operands: 60
56Operationoperator: 70
operands: 61
57Literal
58ExprTuple86, 64
59ExprTuple62
60ExprTuple63, 83
61ExprTuple64, 65
62Operationoperator: 79
operands: 66
63Variable
64Variable
65Operationoperator: 77
operand: 69
66ExprTuple84, 68
67ExprTuple69
68Operationoperator: 70
operands: 71
69Operationoperator: 72
operands: 73
70Literal
71ExprTuple85, 74
72Literal
73ExprTuple75, 76
74Operationoperator: 77
operand: 83
75Operationoperator: 79
operands: 80
76Operationoperator: 81
operand: 86
77Literal
78ExprTuple83
79Literal
80ExprTuple84, 85
81Literal
82ExprTuple86
83Literal
84Literal
85Literal
86Literal