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, Variable, k, l
from proveit.numbers import Add, Exp, Mult, Sum, e, frac, i, one, pi, subtract, two
from proveit.physics.quantum.QPE import SubIndexed, _alpha, _b_floor, _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(SubIndexed(_alpha, [Variable("_a", latex_format = r"{_{-}a}")]), Mult(frac(one, _two_pow_t), Sum(index_or_indices = [k], summand = Exp(Exp(e, Mult(two, pi, i, subtract(_phase, frac(Add(_b_floor, l), _two_pow_t)))), k), domain = _m_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(\alpha_{{_{-}a}}, \frac{1}{2^{t}} \cdot \left(\sum_{k = 0}^{2^{t} - 1} (\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\varphi - \frac{b_{\textit{f}} + l}{2^{t}}\right)})^{k}\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: 30
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Variable
7Operationoperator: 45
operands: 9
8Operationoperator: 10
operand: 12
9ExprTuple41, 48
10Literal
11ExprTuple12
12Lambdaparameter: 21
body: 14
13ExprTuple21
14Conditionalvalue: 15
condition: 16
15Operationoperator: 51
operands: 17
16Operationoperator: 18
operands: 19
17ExprTuple20, 21
18Literal
19ExprTuple21, 22
20Operationoperator: 51
operands: 23
21Variable
22Operationoperator: 24
operands: 25
23ExprTuple26, 27
24Literal
25ExprTuple28, 29
26Literal
27Operationoperator: 30
operands: 31
28Literal
29Operationoperator: 49
operands: 32
30Literal
31ExprTuple55, 33, 34, 35
32ExprTuple48, 36
33Literal
34Literal
35Operationoperator: 49
operands: 37
36Operationoperator: 42
operand: 41
37ExprTuple39, 40
38ExprTuple41
39Literal
40Operationoperator: 42
operand: 44
41Literal
42Literal
43ExprTuple44
44Operationoperator: 45
operands: 46
45Literal
46ExprTuple47, 48
47Operationoperator: 49
operands: 50
48Operationoperator: 51
operands: 52
49Literal
50ExprTuple53, 54
51Literal
52ExprTuple55, 56
53Literal
54Variable
55Literal
56Literal