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 ExprTuple, Lambda
from proveit.core_expr_types.expr_arrays import A11_to_Akm, B11_to_Bkn, R11_to_Rkm, S11_to_Skn
from proveit.logic import Equals
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_Akm, circuit_Bkn, circuit_permuted_Akm, circuit_permuted_Bkn
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([A11_to_Akm, R11_to_Rkm, B11_to_Bkn, S11_to_Skn], Equals(QcircuitEquiv(circuit_Akm, circuit_Bkn), QcircuitEquiv(circuit_permuted_Akm, circuit_permuted_Bkn)).with_wrapping_at(2)))
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(\left(A_{1, 1}, A_{1, 2}, \ldots, A_{1, m}, A_{2, 1}, A_{2, 2}, \ldots, A_{2, m}, \ldots\ldots, A_{k, 1}, A_{k, 2}, \ldots, A_{k, m}, R_{1, 1}, R_{1, 2}, \ldots, R_{1, m}, R_{2, 1}, R_{2, 2}, \ldots, R_{2, m}, \ldots\ldots, R_{k, 1}, R_{k, 2}, \ldots, R_{k, m}, B_{1, 1}, B_{1, 2}, \ldots, B_{1, n}, B_{2, 1}, B_{2, 2}, \ldots, B_{2, n}, \ldots\ldots, B_{k, 1}, B_{k, 2}, \ldots, B_{k, n}, S_{1, 1}, S_{1, 2}, \ldots, S_{1, n}, S_{2, 1}, S_{2, 2}, \ldots, S_{2, n}, \ldots\ldots, S_{k, 1}, S_{k, 2}, \ldots, S_{k, n}\right) \mapsto \left(\begin{array}{c} \begin{array}{l} \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{A_{1, 1}~\mbox{on}~R_{1, 1}} \qwx[1] & \gate{A_{2, 1}~\mbox{on}~R_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{m, 1}~\mbox{on}~R_{m, 1}} \qwx[1] & \qw \\
& \gate{A_{1, 2}~\mbox{on}~R_{1, 2}} \qwx[1] & \gate{A_{2, 2}~\mbox{on}~R_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{m, 2}~\mbox{on}~R_{m, 2}} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{A_{1, k}~\mbox{on}~R_{1, k}} & \gate{A_{2, k}~\mbox{on}~R_{2, k}} & \gate{\cdots} & \gate{A_{m, k}~\mbox{on}~R_{m, k}} & \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{B_{1, 1}~\mbox{on}~S_{1, 1}} \qwx[1] & \gate{B_{2, 1}~\mbox{on}~S_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{n, 1}~\mbox{on}~S_{n, 1}} \qwx[1] & \qw \\
& \gate{B_{1, 2}~\mbox{on}~S_{1, 2}} \qwx[1] & \gate{B_{2, 2}~\mbox{on}~S_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{n, 2}~\mbox{on}~S_{n, 2}} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{B_{1, k}~\mbox{on}~S_{1, k}} & \gate{B_{2, k}~\mbox{on}~S_{2, k}} & \gate{\cdots} & \gate{B_{n, k}~\mbox{on}~S_{n, k}} & \qw
} \end{array}\right)\right) =  \\ \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{A_{p\left(1\right), 1}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(1\right), 1}\right)} \qwx[1] & \gate{A_{p\left(2\right), 1}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(2\right), 1}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{p\left(m\right), 1}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(m\right), 1}\right)} \qwx[1] & \qw \\
& \gate{A_{p\left(1\right), 2}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(1\right), 2}\right)} \qwx[1] & \gate{A_{p\left(2\right), 2}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(2\right), 2}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{p\left(m\right), 2}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(m\right), 2}\right)} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{A_{p\left(1\right), k}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(1\right), k}\right)} & \gate{A_{p\left(2\right), k}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(2\right), k}\right)} & \gate{\cdots} & \gate{A_{p\left(m\right), k}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(m\right), k}\right)} & \qw
} \end{array}\right) \cong \left(\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)} \qwx[1] & \gate{B_{p\left(2\right), 1}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), 1}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{p\left(n\right), 1}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), 1}\right)} \qwx[1] & \qw \\
& \gate{B_{p\left(1\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(1\right), 2}\right)} \qwx[1] & \gate{B_{p\left(2\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), 2}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{p\left(n\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), 2}\right)} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{B_{p\left(1\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(1\right), k}\right)} & \gate{B_{p\left(2\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), k}\right)} & \gate{\cdots} & \gate{B_{p\left(n\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), k}\right)} & \qw
} \end{array}\right)\right) \end{array} \end{array}\right)\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple4, 5, 6, 7
3Operationoperator: 8
operands: 9
4ExprRangelambda_map: 10
start_index: 58
end_index: 59
5ExprRangelambda_map: 11
start_index: 58
end_index: 59
6ExprRangelambda_map: 12
start_index: 58
end_index: 59
7ExprRangelambda_map: 13
start_index: 58
end_index: 59
8Literal
9ExprTuple14, 15
10Lambdaparameter: 95
body: 16
11Lambdaparameter: 95
body: 17
12Lambdaparameter: 95
body: 18
13Lambdaparameter: 95
body: 19
14Operationoperator: 21
operands: 20
15Operationoperator: 21
operands: 22
16ExprRangelambda_map: 23
start_index: 58
end_index: 43
17ExprRangelambda_map: 24
start_index: 58
end_index: 43
18ExprRangelambda_map: 25
start_index: 58
end_index: 45
19ExprRangelambda_map: 26
start_index: 58
end_index: 45
20ExprTuple27, 28
21Literal
22ExprTuple29, 30
23Lambdaparameter: 92
body: 70
24Lambdaparameter: 92
body: 71
25Lambdaparameter: 92
body: 72
26Lambdaparameter: 92
body: 73
27Operationoperator: 34
operands: 31
28Operationoperator: 34
operands: 32
29Operationoperator: 34
operands: 33
30Operationoperator: 34
operands: 35
31ExprTuple36
32ExprTuple37
33ExprTuple38
34Literal
35ExprTuple39
36ExprRangelambda_map: 40
start_index: 58
end_index: 43
37ExprRangelambda_map: 41
start_index: 58
end_index: 45
38ExprRangelambda_map: 42
start_index: 58
end_index: 43
39ExprRangelambda_map: 44
start_index: 58
end_index: 45
40Lambdaparameter: 95
body: 46
41Lambdaparameter: 95
body: 47
42Lambdaparameter: 95
body: 48
43Variable
44Lambdaparameter: 95
body: 49
45Variable
46ExprTuple50
47ExprTuple51
48ExprTuple52
49ExprTuple53
50ExprRangelambda_map: 54
start_index: 58
end_index: 59
51ExprRangelambda_map: 55
start_index: 58
end_index: 59
52ExprRangelambda_map: 56
start_index: 58
end_index: 59
53ExprRangelambda_map: 57
start_index: 58
end_index: 59
54Lambdaparameter: 92
body: 60
55Lambdaparameter: 92
body: 61
56Lambdaparameter: 92
body: 62
57Lambdaparameter: 92
body: 64
58Literal
59Variable
60Operationoperator: 68
operands: 65
61Operationoperator: 68
operands: 66
62Operationoperator: 68
operands: 67
63ExprTuple92
64Operationoperator: 68
operands: 69
65NamedExprselement: 70
targets: 71
66NamedExprselement: 72
targets: 73
67NamedExprselement: 74
targets: 75
68Literal
69NamedExprselement: 76
targets: 77
70IndexedVarvariable: 79
indices: 78
71IndexedVarvariable: 88
indices: 78
72IndexedVarvariable: 81
indices: 78
73IndexedVarvariable: 89
indices: 78
74IndexedVarvariable: 79
indices: 90
75Operationoperator: 82
operand: 84
76IndexedVarvariable: 81
indices: 90
77Operationoperator: 82
operand: 87
78ExprTuple95, 92
79Variable
80ExprTuple84
81Variable
82Operationoperator: 85
operand: 93
83ExprTuple87
84IndexedVarvariable: 88
indices: 90
85Literal
86ExprTuple93
87IndexedVarvariable: 89
indices: 90
88Variable
89Variable
90ExprTuple91, 92
91Operationoperator: 93
operand: 95
92Variable
93Variable
94ExprTuple95
95Variable