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 Equals, 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 = NumBra(m, _t)
sub_expr2 = InverseFourierTransform(_t)
sub_expr3 = NumKet(k, _t)
sub_expr4 = Exp(e, Mult(two, pi, i, _phase, k))
expr = ExprTuple(Lambda(k, Conditional(Equals(Qmult(sub_expr1, sub_expr2, ScalarMult(sub_expr4, sub_expr3)), Mult(sub_expr4, Qmult(sub_expr1, sub_expr2, sub_expr3))), 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\{\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) = \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) \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: 55
body: 3
2ExprTuple55
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple55, 12
10Operationoperator: 23
operands: 13
11Operationoperator: 49
operands: 14
12Operationoperator: 15
operands: 16
13ExprTuple28, 29, 17
14ExprTuple27, 18
15Literal
16ExprTuple19, 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operands: 24
19Literal
20Operationoperator: 25
operands: 26
21Literal
22ExprTuple27, 30
23Literal
24ExprTuple28, 29, 30
25Literal
26ExprTuple31, 32
27Operationoperator: 40
operands: 33
28Operationoperator: 34
operands: 35
29Operationoperator: 36
operand: 47
30Operationoperator: 38
operands: 39
31Operationoperator: 40
operands: 41
32Operationoperator: 42
operand: 48
33ExprTuple44, 45
34Literal
35ExprTuple46, 47
36Literal
37ExprTuple47
38Literal
39ExprTuple55, 47
40Literal
41ExprTuple51, 47
42Literal
43ExprTuple48
44Literal
45Operationoperator: 49
operands: 50
46Variable
47Literal
48Literal
49Literal
50ExprTuple51, 52, 53, 54, 55
51Literal
52Literal
53Literal
54Literal
55Variable