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 = Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _pos_domain)
expr = ExprTuple(Add(Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = _neg_domain), sub_expr3), Add(Sum(index_or_indices = sub_expr1, summand = frac(one, Mult(four, Exp(_diff_l_scaled_delta_floor, two))), domain = _neg_domain), sub_expr3))
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}} \left|\alpha_{b_{\textit{f}} \oplus l}\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: 68
operands: 3
2Operationoperator: 68
operands: 4
3ExprTuple5, 7
4ExprTuple6, 7
5Operationoperator: 10
operand: 12
6Operationoperator: 10
operand: 13
7Operationoperator: 10
operand: 14
8ExprTuple12
9ExprTuple13
10Literal
11ExprTuple14
12Lambdaparameter: 61
body: 15
13Lambdaparameter: 61
body: 16
14Lambdaparameter: 61
body: 18
15Conditionalvalue: 21
condition: 20
16Conditionalvalue: 19
condition: 20
17ExprTuple61
18Conditionalvalue: 21
condition: 22
19Operationoperator: 23
operands: 24
20Operationoperator: 27
operands: 25
21Operationoperator: 73
operands: 26
22Operationoperator: 27
operands: 28
23Literal
24ExprTuple82, 29
25ExprTuple61, 30
26ExprTuple31, 79
27Literal
28ExprTuple61, 32
29Operationoperator: 66
operands: 33
30Operationoperator: 37
operands: 34
31Operationoperator: 35
operand: 43
32Operationoperator: 37
operands: 38
33ExprTuple39, 40
34ExprTuple41, 42
35Literal
36ExprTuple43
37Literal
38ExprTuple51, 59
39Literal
40Operationoperator: 73
operands: 44
41Operationoperator: 68
operands: 45
42Operationoperator: 77
operand: 51
43Operationoperator: 47
operand: 52
44ExprTuple49, 79
45ExprTuple50, 82
46ExprTuple51
47Literal
48ExprTuple52
49Operationoperator: 68
operands: 53
50Operationoperator: 77
operand: 59
51Operationoperator: 68
operands: 55
52Operationoperator: 56
operands: 57
53ExprTuple61, 58
54ExprTuple59
55ExprTuple60, 82
56Literal
57ExprTuple81, 61
58Operationoperator: 77
operand: 64
59Operationoperator: 73
operands: 63
60Variable
61Variable
62ExprTuple64
63ExprTuple79, 65
64Operationoperator: 66
operands: 67
65Operationoperator: 68
operands: 69
66Literal
67ExprTuple70, 71
68Literal
69ExprTuple80, 72
70Operationoperator: 73
operands: 74
71Operationoperator: 75
operand: 81
72Operationoperator: 77
operand: 82
73Literal
74ExprTuple79, 80
75Literal
76ExprTuple81
77Literal
78ExprTuple82
79Literal
80Literal
81Literal
82Literal