logo

Expression of type VertExprArray

from the theory of proveit.physics.quantum.circuits

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, Variable, VertExprArray, a, b, k
from proveit.core_expr_types import U_1_to_m
from proveit.numbers import Interval, one
from proveit.physics.quantum.circuits import Input, MultiQubitElem, Output
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Interval(one, k)
expr = VertExprArray([ExprRange(sub_expr1, MultiQubitElem(element = Input(state = a, part = sub_expr1), targets = sub_expr2), one, k)], U_1_to_m, [ExprRange(sub_expr1, MultiQubitElem(element = Output(state = b, part = sub_expr1), targets = sub_expr2), one, k)])
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}{cccccc} 
 \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{a~\mbox{part}~1~\mbox{on}~\{1~\ldotp \ldotp~k\}} & \qw 
} \end{array} & \multirow{4}{*}{$\begin{array}{c} \uparrow \\ U_{1} \\ \downarrow \end{array}$} & \multirow{4}{*}{$\begin{array}{c} \uparrow \\ U_{2} \\ \downarrow \end{array}$} & \multirow{4}{*}{$\begin{array}{c} \uparrow \\ \cdots \\ \downarrow \end{array}$} & \multirow{4}{*}{$\begin{array}{c} \uparrow \\ U_{m} \\ \downarrow \end{array}$} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{b~\mbox{part}~1~\mbox{on}~\{1~\ldotp \ldotp~k\}} 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{a~\mbox{part}~2~\mbox{on}~\{1~\ldotp \ldotp~k\}} & \qw 
} \end{array} &  &  &  &  & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{b~\mbox{part}~2~\mbox{on}~\{1~\ldotp \ldotp~k\}} 
} \end{array} \\
\vdots &  &  &  &  & \vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{a~\mbox{part}~k~\mbox{on}~\{1~\ldotp \ldotp~k\}} & \qw 
} \end{array} &  &  &  &  & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{b~\mbox{part}~k~\mbox{on}~\{1~\ldotp \ldotp~k\}} 
} \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, 3
1ExprTuple4
2ExprRangelambda_map: 5
start_index: 30
end_index: 6
3ExprTuple7
4ExprRangelambda_map: 8
start_index: 30
end_index: 31
5Lambdaparameter: 29
body: 9
6Variable
7ExprRangelambda_map: 10
start_index: 30
end_index: 31
8Lambdaparameter: 29
body: 11
9IndexedVarvariable: 12
index: 29
10Lambdaparameter: 29
body: 14
11Operationoperator: 16
operands: 15
12Variable
13ExprTuple29
14Operationoperator: 16
operands: 17
15NamedExprselement: 18
targets: 20
16Literal
17NamedExprselement: 19
targets: 20
18Operationoperator: 21
operands: 22
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operands: 26
21Literal
22NamedExprsstate: 27
part: 29
23Literal
24NamedExprsstate: 28
part: 29
25Literal
26ExprTuple30, 31
27Variable
28Variable
29Variable
30Literal
31Variable