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, IndexedVar, N, Variable, VertExprArray, m
from proveit.core_expr_types import A_1_to_m
from proveit.linear_algebra import TensorProd
from proveit.numbers import Add, Interval, one, subtract
from proveit.physics.quantum.circuits import MultiQubitElem, N_m, Output
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_c", latex_format = r"{_{-}c}")
sub_expr2 = Variable("_b", latex_format = r"{_{-}b}")
expr = VertExprArray([ExprRange(sub_expr1, ExprRange(sub_expr2, MultiQubitElem(element = Output(state = TensorProd(A_1_to_m), part = sub_expr2), targets = Interval(one, N_m)), Add(IndexedVar(N, subtract(sub_expr1, one)), one), IndexedVar(N, sub_expr1)).with_wrapping_at(2,6), 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}{c} 
 \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{1 - 1} + 1~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{1 - 1} + 2~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} 
} \end{array} \\
\vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{1}~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{2 - 1} + 1~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{2 - 1} + 2~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} 
} \end{array} \\
\vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{2}~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} 
} \end{array} \\
\begin{array}{c}\vdots\\ \vdots\end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{m - 1} + 1~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{m - 1} + 2~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} 
} \end{array} \\
\vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{1} {\otimes}  A_{2} {\otimes}  \ldots {\otimes}  A_{m}~\mbox{part}~N_{m}~\mbox{on}~\{1~\ldotp \ldotp~N_{m}\}} 
} \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
1ExprTuple2
2ExprRangelambda_map: 3
start_index: 39
end_index: 38
3Lambdaparameter: 32
body: 4
4ExprRangelambda_map: 5
start_index: 6
end_index: 7
5Lambdaparameter: 24
body: 9
6Operationoperator: 26
operands: 10
7IndexedVarvariable: 30
index: 32
8ExprTuple24
9Operationoperator: 12
operands: 13
10ExprTuple14, 39
11ExprTuple32
12Literal
13NamedExprselement: 15
targets: 16
14IndexedVarvariable: 30
index: 22
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17ExprTuple22
18Literal
19NamedExprsstate: 23
part: 24
20Literal
21ExprTuple39, 25
22Operationoperator: 26
operands: 27
23Operationoperator: 28
operands: 29
24Variable
25IndexedVarvariable: 30
index: 38
26Literal
27ExprTuple32, 33
28Literal
29ExprTuple34
30Variable
31ExprTuple38
32Variable
33Operationoperator: 35
operand: 39
34ExprRangelambda_map: 37
start_index: 39
end_index: 38
35Literal
36ExprTuple39
37Lambdaparameter: 43
body: 40
38Variable
39Literal
40IndexedVarvariable: 41
index: 43
41Variable
42ExprTuple43
43Variable