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, k, l
from proveit.numbers import Exp, Mult, Sum, e, frac, i, one, pi, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _m_domain, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = subtract(_delta_b_floor, frac(l, _two_pow_t))
sub_expr2 = Exp(e, Mult(two, pi, i, sub_expr1))
expr = ExprTuple(Sum(index_or_indices = [k], summand = Exp(sub_expr2, k), domain = _m_domain), frac(subtract(one, Exp(e, Mult(two, pi, i, sub_expr1, _two_pow_t))), subtract(one, sub_expr2)))
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(\sum_{k = 0}^{2^{t} - 1} (\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right)})^{k}, \frac{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right) \cdot 2^{t}}}{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\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: 3
operand: 6
2Operationoperator: 55
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 22
body: 10
7Operationoperator: 44
operands: 11
8Operationoperator: 44
operands: 12
9ExprTuple22
10Conditionalvalue: 13
condition: 14
11ExprTuple46, 15
12ExprTuple46, 16
13Operationoperator: 59
operands: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 51
operand: 24
16Operationoperator: 51
operand: 25
17ExprTuple25, 22
18Literal
19ExprTuple22, 23
20ExprTuple24
21ExprTuple25
22Variable
23Operationoperator: 26
operands: 27
24Operationoperator: 59
operands: 28
25Operationoperator: 59
operands: 29
26Literal
27ExprTuple30, 31
28ExprTuple33, 32
29ExprTuple33, 34
30Literal
31Operationoperator: 44
operands: 35
32Operationoperator: 37
operands: 36
33Literal
34Operationoperator: 37
operands: 38
35ExprTuple58, 39
36ExprTuple61, 40, 41, 42, 58
37Literal
38ExprTuple61, 40, 41, 42
39Operationoperator: 51
operand: 46
40Literal
41Literal
42Operationoperator: 44
operands: 45
43ExprTuple46
44Literal
45ExprTuple47, 48
46Literal
47Operationoperator: 49
operand: 53
48Operationoperator: 51
operand: 54
49Literal
50ExprTuple53
51Literal
52ExprTuple54
53Literal
54Operationoperator: 55
operands: 56
55Literal
56ExprTuple57, 58
57Variable
58Operationoperator: 59
operands: 60
59Literal
60ExprTuple61, 62
61Literal
62Literal