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 B, ExprRange, Function, IndexedVar, S, Variable, VertExprArray, k, n, p
from proveit.logic import InvImage
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 = [Function(p, [sub_expr1]), sub_expr2]
expr = VertExprArray(ExprRange(sub_expr1, [ExprRange(sub_expr2, MultiQubitElem(element = IndexedVar(B, sub_expr3), targets = Function(InvImage(p), [IndexedVar(S, 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{B_{p\left(1\right), 1}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(1\right), 1}\right)} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{B_{p\left(2\right), 1}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), 1}\right)} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{B_{p\left(n\right), 1}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), 1}\right)} & \qw 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{B_{p\left(1\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(1\right), 2}\right)} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{B_{p\left(2\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), 2}\right)} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{B_{p\left(n\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), 2}\right)} & \qw 
} \end{array} \\
\vdots & \vdots & \ddots & \vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{B_{p\left(1\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(1\right), k}\right)} & \qw 
} \end{array} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{B_{p\left(2\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), k}\right)} & \qw 
} \end{array} & \cdots & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \gate{B_{p\left(n\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), k}\right)} & \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: 7
end_index: 3
2Lambdaparameter: 27
body: 4
3Variable
4ExprTuple5
5ExprRangelambda_map: 6
start_index: 7
end_index: 8
6Lambdaparameter: 24
body: 10
7Literal
8Variable
9ExprTuple24
10Operationoperator: 11
operands: 12
11Literal
12NamedExprselement: 13
targets: 14
13IndexedVarvariable: 15
indices: 22
14Operationoperator: 16
operand: 20
15Variable
16Operationoperator: 18
operand: 25
17ExprTuple20
18Literal
19ExprTuple25
20IndexedVarvariable: 21
indices: 22
21Variable
22ExprTuple23, 24
23Operationoperator: 25
operand: 27
24Variable
25Variable
26ExprTuple27
27Variable