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 D, ExprRange, IndexedVar, U, Variable, VertExprArray, k, n
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(D, sub_expr3), targets = IndexedVar(U, sub_expr3)), one, k)], one, n))
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{D_{1, 1}~\mbox{on}~U_{1, 1}} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{D_{2, 1}~\mbox{on}~U_{2, 1}} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{D_{n, 1}~\mbox{on}~U_{n, 1}} & \qw 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{D_{1, 2}~\mbox{on}~U_{1, 2}} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{D_{2, 2}~\mbox{on}~U_{2, 2}} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{D_{n, 2}~\mbox{on}~U_{n, 2}} & \qw 
} \end{array} \\
\vdots & \vdots & \ddots & \vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{D_{1, k}~\mbox{on}~U_{1, k}} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{D_{2, k}~\mbox{on}~U_{2, k}} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{D_{n, k}~\mbox{on}~U_{n, k}} & \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: 8
end_index: 3
2Lambdaparameter: 19
body: 5
3Variable
4ExprTuple19
5ExprTuple6
6ExprRangelambda_map: 7
start_index: 8
end_index: 9
7Lambdaparameter: 20
body: 11
8Literal
9Variable
10ExprTuple20
11Operationoperator: 12
operands: 13
12Literal
13NamedExprselement: 14
targets: 15
14IndexedVarvariable: 16
indices: 18
15IndexedVarvariable: 17
indices: 18
16Variable
17Variable
18ExprTuple19, 20
19Variable
20Variable