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, ExprRange, IndexedVar, Variable, VertExprArray, k, l
from proveit.numbers import Interval, one
from proveit.physics.quantum import var_ket_u, var_ket_v
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 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr3 = Interval(one, l)
expr = VertExprArray([ExprRange(sub_expr1, MultiQubitElem(element = Input(state = var_ket_u, part = sub_expr1), targets = sub_expr3), one, l)], ExprRange(sub_expr2, [ExprRange(sub_expr1, IndexedVar(A, [sub_expr2, sub_expr1]), one, l)], one, k), [ExprRange(sub_expr1, MultiQubitElem(element = Output(state = var_ket_v, part = sub_expr1), targets = sub_expr3), one, l)])
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{\lvert u \rangle~\mbox{part}~1~\mbox{on}~\{1~\ldotp \ldotp~l\}} & \qw 
} \end{array} & A_{1, 1} & A_{2, 1} & \cdots & A_{k, 1} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert v \rangle~\mbox{part}~1~\mbox{on}~\{1~\ldotp \ldotp~l\}} 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{\lvert u \rangle~\mbox{part}~2~\mbox{on}~\{1~\ldotp \ldotp~l\}} & \qw 
} \end{array} & A_{1, 2} & A_{2, 2} & \cdots & A_{k, 2} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert v \rangle~\mbox{part}~2~\mbox{on}~\{1~\ldotp \ldotp~l\}} 
} \end{array} \\
\vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{\lvert u \rangle~\mbox{part}~l~\mbox{on}~\{1~\ldotp \ldotp~l\}} & \qw 
} \end{array} & A_{1, l} & A_{2, l} & \cdots & A_{k, l} & \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert v \rangle~\mbox{part}~l~\mbox{on}~\{1~\ldotp \ldotp~l\}} 
} \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: 36
end_index: 6
3ExprTuple7
4ExprRangelambda_map: 8
start_index: 36
end_index: 37
5Lambdaparameter: 33
body: 10
6Variable
7ExprRangelambda_map: 11
start_index: 36
end_index: 37
8Lambdaparameter: 35
body: 12
9ExprTuple33
10ExprTuple13
11Lambdaparameter: 35
body: 14
12Operationoperator: 17
operands: 15
13ExprRangelambda_map: 16
start_index: 36
end_index: 37
14Operationoperator: 17
operands: 18
15NamedExprselement: 19
targets: 23
16Lambdaparameter: 35
body: 21
17Literal
18NamedExprselement: 22
targets: 23
19Operationoperator: 24
operands: 25
20ExprTuple35
21IndexedVarvariable: 26
indices: 27
22Operationoperator: 28
operands: 29
23Operationoperator: 30
operands: 31
24Literal
25NamedExprsstate: 32
part: 35
26Variable
27ExprTuple33, 35
28Literal
29NamedExprsstate: 34
part: 35
30Literal
31ExprTuple36, 37
32Variable
33Variable
34Variable
35Variable
36Literal
37Variable