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, m
from proveit.numbers import Exp, Mult, Sum, e, frac, i, one, pi, two
from proveit.physics.quantum import NumBra, NumKet, Qmult
from proveit.physics.quantum.QFT import InverseFourierTransform
from proveit.physics.quantum.QPE import _alpha_m, _m_domain, _phase, _t
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(_alpha_m, Mult(frac(one, Exp(two, frac(_t, two))), Sum(index_or_indices = [k], summand = Mult(Exp(e, Mult(two, pi, i, _phase, k)), Qmult(NumBra(m, _t), InverseFourierTransform(_t), NumKet(k, _t))), 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_{m}, \frac{1}{2^{\frac{t}{2}}} \cdot \left(\sum_{k = 0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \left({_{t}}\langle m \rvert \thinspace {\mathrm {FT}}^{\dag}_{t} \thinspace \lvert k \rangle_{t}\right)\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: 3
operand: 52
2Operationoperator: 39
operands: 5
3Literal
4ExprTuple52
5ExprTuple6, 7
6Operationoperator: 19
operands: 8
7Operationoperator: 9
operand: 12
8ExprTuple62, 11
9Literal
10ExprTuple12
11Operationoperator: 56
operands: 13
12Lambdaparameter: 53
body: 15
13ExprTuple60, 16
14ExprTuple53
15Conditionalvalue: 17
condition: 18
16Operationoperator: 19
operands: 20
17Operationoperator: 39
operands: 21
18Operationoperator: 22
operands: 23
19Literal
20ExprTuple61, 60
21ExprTuple24, 25
22Literal
23ExprTuple53, 26
24Operationoperator: 56
operands: 27
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27ExprTuple32, 33
28Literal
29ExprTuple34, 35, 36
30Literal
31ExprTuple37, 38
32Literal
33Operationoperator: 39
operands: 40
34Operationoperator: 41
operands: 42
35Operationoperator: 43
operand: 61
36Operationoperator: 45
operands: 46
37Literal
38Operationoperator: 47
operands: 48
39Literal
40ExprTuple60, 49, 50, 51, 53
41Literal
42ExprTuple52, 61
43Literal
44ExprTuple61
45Literal
46ExprTuple53, 61
47Literal
48ExprTuple54, 55
49Literal
50Literal
51Literal
52Variable
53Variable
54Operationoperator: 56
operands: 57
55Operationoperator: 58
operand: 62
56Literal
57ExprTuple60, 61
58Literal
59ExprTuple62
60Literal
61Literal
62Literal