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, Lambda, 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
expr = ExprTuple(Lambda(k, Conditional(Qmult(NumBra(m, _t), InverseFourierTransform(_t), ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, _t))), InSet(k, _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(k \mapsto \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\}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 45
body: 3
2ExprTuple45
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11, 12
8Literal
9ExprTuple45, 13
10Operationoperator: 14
operands: 15
11Operationoperator: 16
operand: 47
12Operationoperator: 18
operands: 19
13Operationoperator: 20
operands: 21
14Literal
15ExprTuple22, 47
16Literal
17ExprTuple47
18Literal
19ExprTuple23, 24
20Literal
21ExprTuple25, 26
22Variable
23Operationoperator: 38
operands: 27
24Operationoperator: 28
operands: 29
25Literal
26Operationoperator: 30
operands: 31
27ExprTuple32, 33
28Literal
29ExprTuple45, 47
30Literal
31ExprTuple34, 35
32Literal
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operand: 48
36Literal
37ExprTuple46, 42, 43, 44, 45
38Literal
39ExprTuple46, 47
40Literal
41ExprTuple48
42Literal
43Literal
44Literal
45Variable
46Literal
47Literal
48Literal