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, N, Variable, VertExprArray, m, n
from proveit.numbers import Add, Interval, one, subtract
from proveit.physics.quantum.circuits import MultiQubitElem, Output
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}")
expr = VertExprArray([ExprRange(sub_expr1, ExprRange(sub_expr2, MultiQubitElem(element = Output(state = IndexedVar(A, sub_expr1), part = sub_expr2), targets = Interval(Add(IndexedVar(N, subtract(sub_expr1, one)), one), IndexedVar(N, sub_expr1))), 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}~\mbox{part}~1~\mbox{on}~\{N_{1 - 1} + 1~\ldotp \ldotp~N_{1}\}} 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{1}~\mbox{part}~2~\mbox{on}~\{N_{1 - 1} + 1~\ldotp \ldotp~N_{1}\}} 
} \end{array} \\
\vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{1}~\mbox{part}~n_{1}~\mbox{on}~\{N_{1 - 1} + 1~\ldotp \ldotp~N_{1}\}} 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{2}~\mbox{part}~1~\mbox{on}~\{N_{2 - 1} + 1~\ldotp \ldotp~N_{2}\}} 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{2}~\mbox{part}~2~\mbox{on}~\{N_{2 - 1} + 1~\ldotp \ldotp~N_{2}\}} 
} \end{array} \\
\vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{2}~\mbox{part}~n_{2}~\mbox{on}~\{N_{2 - 1} + 1~\ldotp \ldotp~N_{2}\}} 
} \end{array} \\
\begin{array}{c}\vdots\\ \vdots\end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{m}~\mbox{part}~1~\mbox{on}~\{N_{m - 1} + 1~\ldotp \ldotp~N_{m}\}} 
} \end{array} \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{m}~\mbox{part}~2~\mbox{on}~\{N_{m - 1} + 1~\ldotp \ldotp~N_{m}\}} 
} \end{array} \\
\vdots \\
\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A_{m}~\mbox{part}~n_{m}~\mbox{on}~\{N_{m - 1} + 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: 36
end_index: 4
3Lambdaparameter: 32
body: 5
4Variable
5ExprRangelambda_map: 6
start_index: 36
end_index: 7
6Lambdaparameter: 20
body: 9
7IndexedVarvariable: 10
index: 32
8ExprTuple20
9Operationoperator: 11
operands: 12
10Variable
11Literal
12NamedExprselement: 13
targets: 14
13Operationoperator: 15
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16NamedExprsstate: 19
part: 20
17Literal
18ExprTuple21, 22
19IndexedVarvariable: 23
index: 32
20Variable
21Operationoperator: 30
operands: 24
22IndexedVarvariable: 27
index: 32
23Variable
24ExprTuple26, 36
25ExprTuple32
26IndexedVarvariable: 27
index: 29
27Variable
28ExprTuple29
29Operationoperator: 30
operands: 31
30Literal
31ExprTuple32, 33
32Variable
33Operationoperator: 34
operand: 36
34Literal
35ExprTuple36
36Literal