logo

Expression of type VertExprArray

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, U, Variable, VertExprArray, s, t
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
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 = VertExprArray([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())
\begin{array}{cc} 
 \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{{\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{\textrm{QPE}_1\left(U, t\right)~\mbox{part}~2~\mbox{on}~\{1~\ldotp \ldotp~t + s\}} & \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} \\
\vdots & \vdots \\
\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{{\mathrm {FT}}^{\dag}_{t}~\mbox{part}~t~\mbox{on}~\{1~\ldotp \ldotp~t\}} & \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{
& & \qw & \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} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qw & \qw 
} \end{array} \\
\vdots & \begin{array}{c}:\\ \left(s - 3\right) \times \\:\end{array} \\
\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} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qw & \qw 
} \end{array} \\
\end{array}

In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenterwith_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
42Variable
43Variable
44Variable