logo

Expression of type ExprTuple

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, ExprTuple, IndexedVar, N, Variable, 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 = ExprTuple(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())
\left(\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}, \ldots, \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}, \ldots, \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}, \ldots\ldots, \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}, \ldots, \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}\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1ExprRangelambda_map: 2
start_index: 38
end_index: 37
2Lambdaparameter: 31
body: 3
3ExprRangelambda_map: 4
start_index: 5
end_index: 6
4Lambdaparameter: 23
body: 8
5Operationoperator: 25
operands: 9
6IndexedVarvariable: 29
index: 31
7ExprTuple23
8Operationoperator: 11
operands: 12
9ExprTuple13, 38
10ExprTuple31
11Literal
12NamedExprselement: 14
targets: 15
13IndexedVarvariable: 29
index: 21
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operands: 20
16ExprTuple21
17Literal
18NamedExprsstate: 22
part: 23
19Literal
20ExprTuple38, 24
21Operationoperator: 25
operands: 26
22Operationoperator: 27
operands: 28
23Variable
24IndexedVarvariable: 29
index: 37
25Literal
26ExprTuple31, 32
27Literal
28ExprTuple33
29Variable
30ExprTuple37
31Variable
32Operationoperator: 34
operand: 38
33ExprRangelambda_map: 36
start_index: 38
end_index: 37
34Literal
35ExprTuple38
36Lambdaparameter: 42
body: 39
37Variable
38Literal
39IndexedVarvariable: 40
index: 42
40Variable
41ExprTuple42
42Variable