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
from proveit.numbers import Add, Interval, one
from proveit.physics.quantum import I
from proveit.physics.quantum.QFT import InverseFourierTransform
from proveit.physics.quantum.QPE import _Psi_ket, _ket_u, _s, _t
from proveit.physics.quantum.circuits import Gate, MultiQubitElem, Output
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Interval(one, _t)
expr = ExprTuple([ExprRange(sub_expr1, MultiQubitElem(element = Gate(operation = InverseFourierTransform(_t), part = sub_expr1), targets = sub_expr2), one, _t), ExprRange(sub_expr1, Gate(operation = I).with_implicit_representation(), one, _s)], [ExprRange(sub_expr1, MultiQubitElem(element = Output(state = _Psi_ket, part = sub_expr1), targets = sub_expr2), one, _t), ExprRange(sub_expr1, MultiQubitElem(element = Output(state = _ket_u, part = sub_expr1), targets = Interval(Add(_t, one), Add(_t, _s))), one, _s)])
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(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{{\mathrm {FT}}^{\dag}_{t}~\mbox{part}~1~\mbox{on}~\{1~\ldotp \ldotp~t\}} & \qw 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{{\mathrm {FT}}^{\dag}_{t}~\mbox{part}~2~\mbox{on}~\{1~\ldotp \ldotp~t\}} & \qw 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{{\mathrm {FT}}^{\dag}_{t}~\mbox{part}~t~\mbox{on}~\{1~\ldotp \ldotp~t\}} & \qw 
} \end{array},\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qw & \qw 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qw & \qw 
} \end{array}, ..\left(s - 3\right) \times.., \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qw & \qw 
} \end{array}\right), \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert \Psi \rangle~\mbox{part}~1~\mbox{on}~\{1~\ldotp \ldotp~t\}} 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert \Psi \rangle~\mbox{part}~2~\mbox{on}~\{1~\ldotp \ldotp~t\}} 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert \Psi \rangle~\mbox{part}~t~\mbox{on}~\{1~\ldotp \ldotp~t\}} 
} \end{array},\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert u \rangle~\mbox{part}~1~\mbox{on}~\{t + 1~\ldotp \ldotp~t + s\}} 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert u \rangle~\mbox{part}~2~\mbox{on}~\{t + 1~\ldotp \ldotp~t + s\}} 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert u \rangle~\mbox{part}~s~\mbox{on}~\{t + 1~\ldotp \ldotp~t + s\}} 
} \end{array}\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
1ExprTuple3, 4
2ExprTuple5, 6
3ExprRangelambda_map: 7
start_index: 46
end_index: 47
4ExprRangelambda_map: 8
start_index: 46
end_index: 48
5ExprRangelambda_map: 9
start_index: 46
end_index: 47
6ExprRangelambda_map: 10
start_index: 46
end_index: 48
7Lambdaparameter: 38
body: 11
8Lambdaparameter: 38
body: 12
9Lambdaparameter: 38
body: 13
10Lambdaparameter: 38
body: 15
11Operationoperator: 19
operands: 16
12Operationoperator: 27
operands: 17
13Operationoperator: 19
operands: 18
14ExprTuple38
15Operationoperator: 19
operands: 20
16NamedExprselement: 21
targets: 24
17NamedExprsoperation: 22
18NamedExprselement: 23
targets: 24
19Literal
20NamedExprselement: 25
targets: 26
21Operationoperator: 27
operands: 28
22Literal
23Operationoperator: 31
operands: 29
24Operationoperator: 33
operands: 30
25Operationoperator: 31
operands: 32
26Operationoperator: 33
operands: 34
27Literal
28NamedExprsoperation: 35
part: 38
29NamedExprsstate: 36
part: 38
30ExprTuple46, 47
31Literal
32NamedExprsstate: 37
part: 38
33Literal
34ExprTuple39, 40
35Operationoperator: 41
operand: 47
36Literal
37Literal
38Variable
39Operationoperator: 44
operands: 43
40Operationoperator: 44
operands: 45
41Literal
42ExprTuple47
43ExprTuple47, 46
44Literal
45ExprTuple47, 48
46Literal
47Literal
48Literal