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