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.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)])
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}{c} 
 \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} \\
\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{\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} \\
\vdots \\
\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} \\
\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
1ExprTuple2, 3
2ExprRangelambda_map: 4
start_index: 19
end_index: 26
3ExprRangelambda_map: 4
start_index: 5
end_index: 20
4Lambdaparameter: 18
body: 7
5Operationoperator: 23
operands: 8
6ExprTuple18
7Operationoperator: 9
operands: 10
8ExprTuple26, 19
9Literal
10NamedExprselement: 11
targets: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14NamedExprsoperation: 17
part: 18
15Literal
16ExprTuple19, 20
17Operationoperator: 21
operands: 22
18Variable
19Literal
20Operationoperator: 23
operands: 24
21Literal
22ExprTuple25, 26
23Literal
24ExprTuple26, 27
25Variable
26Variable
27Variable