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 A, C, ExprRange, IndexedVar, R, T, Variable, VertExprArray, k, l, m
from proveit.numbers import one
from proveit.physics.quantum.circuits import MultiQubitElem
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr3 = [sub_expr1, sub_expr2]
expr = VertExprArray(ExprRange(sub_expr1, [ExprRange(sub_expr2, MultiQubitElem(element = IndexedVar(A, sub_expr3), targets = IndexedVar(R, sub_expr3)), one, k), ExprRange(sub_expr2, MultiQubitElem(element = IndexedVar(C, sub_expr3), targets = IndexedVar(T, sub_expr3)), one, l)], one, m))
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}{cccc} 
 \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{A_{1, 1}~\mbox{on}~R_{1, 1}} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{A_{2, 1}~\mbox{on}~R_{2, 1}} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{A_{m, 1}~\mbox{on}~R_{m, 1}} & \qw 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{A_{1, 2}~\mbox{on}~R_{1, 2}} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{A_{2, 2}~\mbox{on}~R_{2, 2}} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{A_{m, 2}~\mbox{on}~R_{m, 2}} & \qw 
} \end{array} \\
\vdots & \vdots & \ddots & \vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{A_{1, k}~\mbox{on}~R_{1, k}} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{A_{2, k}~\mbox{on}~R_{2, k}} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{A_{m, k}~\mbox{on}~R_{m, k}} & \qw 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{C_{1, 1}~\mbox{on}~T_{1, 1}} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{C_{2, 1}~\mbox{on}~T_{2, 1}} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{C_{m, 1}~\mbox{on}~T_{m, 1}} & \qw 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{C_{1, 2}~\mbox{on}~T_{1, 2}} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{C_{2, 2}~\mbox{on}~T_{2, 2}} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{C_{m, 2}~\mbox{on}~T_{m, 2}} & \qw 
} \end{array} \\
\vdots & \vdots & \ddots & \vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{C_{1, l}~\mbox{on}~T_{1, l}} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{C_{2, l}~\mbox{on}~T_{2, l}} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{C_{m, l}~\mbox{on}~T_{m, l}} & \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
1ExprRangelambda_map: 2
start_index: 11
end_index: 3
2Lambdaparameter: 28
body: 5
3Variable
4ExprTuple28
5ExprTuple6, 7
6ExprRangelambda_map: 8
start_index: 11
end_index: 9
7ExprRangelambda_map: 10
start_index: 11
end_index: 12
8Lambdaparameter: 29
body: 13
9Variable
10Lambdaparameter: 29
body: 15
11Literal
12Variable
13Operationoperator: 17
operands: 16
14ExprTuple29
15Operationoperator: 17
operands: 18
16NamedExprselement: 19
targets: 20
17Literal
18NamedExprselement: 21
targets: 22
19IndexedVarvariable: 23
indices: 27
20IndexedVarvariable: 24
indices: 27
21IndexedVarvariable: 25
indices: 27
22IndexedVarvariable: 26
indices: 27
23Variable
24Variable
25Variable
26Variable
27ExprTuple28, 29
28Variable
29Variable