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 Conditional, ExprTuple, k, m
from proveit.linear_algebra import ScalarMult
from proveit.logic import InSet
from proveit.numbers import Exp, Mult, 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 = Qmult(NumBra(m, _t), InverseFourierTransform(_t), ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, _t)))
expr = ExprTuple(Conditional(sub_expr1, InSet(k, _m_domain)), sub_expr1)
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({_{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) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}, {_{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)
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
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8, 9, 10
6Literal
7ExprTuple43, 11
8Operationoperator: 12
operands: 13
9Operationoperator: 14
operand: 45
10Operationoperator: 16
operands: 17
11Operationoperator: 18
operands: 19
12Literal
13ExprTuple20, 45
14Literal
15ExprTuple45
16Literal
17ExprTuple21, 22
18Literal
19ExprTuple23, 24
20Variable
21Operationoperator: 36
operands: 25
22Operationoperator: 26
operands: 27
23Literal
24Operationoperator: 28
operands: 29
25ExprTuple30, 31
26Literal
27ExprTuple43, 45
28Literal
29ExprTuple32, 33
30Literal
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operand: 46
34Literal
35ExprTuple44, 40, 41, 42, 43
36Literal
37ExprTuple44, 45
38Literal
39ExprTuple46
40Literal
41Literal
42Literal
43Variable
44Literal
45Literal
46Literal