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 ExprRange, ExprTuple, Variable, VertExprArray
from proveit.numbers import Interval, one
from proveit.physics.quantum.QFT import InverseFourierTransform
from proveit.physics.quantum.QPE import _Psi_ket, _psi__t_ket, _t
from proveit.physics.quantum.circuits import Gate, Input, MultiQubitElem, Output, Qcircuit
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Interval(one, _t)
expr = ExprTuple(Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, MultiQubitElem(element = Input(state = _psi__t_ket, part = sub_expr1), targets = sub_expr2), one, _t)], [ExprRange(sub_expr1, MultiQubitElem(element = Gate(operation = InverseFourierTransform(_t), part = sub_expr1), targets = sub_expr2), one, _t)], [ExprRange(sub_expr1, MultiQubitElem(element = Output(state = _Psi_ket, part = sub_expr1), targets = sub_expr2), one, _t)])))
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(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi_{t} \rangle} & \gate{{\mathrm {FT}}^{\dag}_{t}} & \qout{\lvert \Psi \rangle}
} \end{array}\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Operationoperator: 2
operands: 3
2Literal
3ExprTuple4, 5, 6
4ExprTuple7
5ExprTuple8
6ExprTuple9
7ExprRangelambda_map: 10
start_index: 37
end_index: 41
8ExprRangelambda_map: 11
start_index: 37
end_index: 41
9ExprRangelambda_map: 12
start_index: 37
end_index: 41
10Lambdaparameter: 36
body: 13
11Lambdaparameter: 36
body: 14
12Lambdaparameter: 36
body: 16
13Operationoperator: 19
operands: 17
14Operationoperator: 19
operands: 18
15ExprTuple36
16Operationoperator: 19
operands: 20
17NamedExprselement: 21
targets: 24
18NamedExprselement: 22
targets: 24
19Literal
20NamedExprselement: 23
targets: 24
21Operationoperator: 25
operands: 26
22Operationoperator: 27
operands: 28
23Operationoperator: 29
operands: 30
24Operationoperator: 31
operands: 32
25Literal
26NamedExprsstate: 33
part: 36
27Literal
28NamedExprsoperation: 34
part: 36
29Literal
30NamedExprsstate: 35
part: 36
31Literal
32ExprTuple37, 41
33Operationoperator: 38
operand: 41
34Operationoperator: 39
operand: 41
35Literal
36Variable
37Literal
38Literal
39Literal
40ExprTuple41
41Literal