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 QPE1, _U, _s, _t
from proveit.physics.quantum.circuits import Gate, MultiQubitElem
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Add(_t, _s)
sub_expr3 = MultiQubitElem(element = Gate(operation = QPE1(_U, _t), part = sub_expr1), targets = Interval(one, sub_expr2))
expr = ExprTuple([ExprRange(sub_expr1, sub_expr3, one, _t), ExprRange(sub_expr1, sub_expr3, Add(_t, one), sub_expr2)], [ExprRange(sub_expr1, MultiQubitElem(element = Gate(operation = InverseFourierTransform(_t), part = sub_expr1), targets = Interval(one, _t)), one, _t), ExprRange(sub_expr1, Gate(operation = I).with_implicit_representation(), 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{\textrm{QPE}_1\left(U, t\right)~\mbox{part}~1~\mbox{on}~\{1~\ldotp \ldotp~t + s\}} & \qw 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{\textrm{QPE}_1\left(U, t\right)~\mbox{part}~2~\mbox{on}~\{1~\ldotp \ldotp~t + s\}} & \qw 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{\textrm{QPE}_1\left(U, t\right)~\mbox{part}~t~\mbox{on}~\{1~\ldotp \ldotp~t + s\}} & \qw 
} \end{array},\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{\textrm{QPE}_1\left(U, t\right)~\mbox{part}~t + 1~\mbox{on}~\{1~\ldotp \ldotp~t + s\}} & \qw 
} \end{array}, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{\textrm{QPE}_1\left(U, t\right)~\mbox{part}~t + 2~\mbox{on}~\{1~\ldotp \ldotp~t + s\}} & \qw 
} \end{array}, \ldots, \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{\textrm{QPE}_1\left(U, t\right)~\mbox{part}~t + s~\mbox{on}~\{1~\ldotp \ldotp~t + s\}} & \qw 
} \end{array}\right), \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)\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: 35
end_index: 44
4ExprRangelambda_map: 7
start_index: 8
end_index: 32
5ExprRangelambda_map: 9
start_index: 35
end_index: 44
6ExprRangelambda_map: 10
start_index: 35
end_index: 43
7Lambdaparameter: 34
body: 11
8Operationoperator: 38
operands: 12
9Lambdaparameter: 34
body: 13
10Lambdaparameter: 34
body: 15
11Operationoperator: 17
operands: 16
12ExprTuple44, 35
13Operationoperator: 17
operands: 18
14ExprTuple34
15Operationoperator: 27
operands: 19
16NamedExprselement: 20
targets: 21
17Literal
18NamedExprselement: 22
targets: 23
19NamedExprsoperation: 24
20Operationoperator: 27
operands: 25
21Operationoperator: 29
operands: 26
22Operationoperator: 27
operands: 28
23Operationoperator: 29
operands: 30
24Literal
25NamedExprsoperation: 31
part: 34
26ExprTuple35, 32
27Literal
28NamedExprsoperation: 33
part: 34
29Literal
30ExprTuple35, 44
31Operationoperator: 36
operands: 37
32Operationoperator: 38
operands: 39
33Operationoperator: 40
operand: 44
34Variable
35Literal
36Literal
37ExprTuple42, 44
38Literal
39ExprTuple44, 43
40Literal
41ExprTuple44
42Literal
43Literal
44Literal