logo

Expression of type Lambda

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 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 = 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(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)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple3, 4, 5, 6
2Operationoperator: 7
operands: 8
3ExprRangelambda_map: 9
start_index: 57
end_index: 58
4ExprRangelambda_map: 10
start_index: 57
end_index: 58
5ExprRangelambda_map: 11
start_index: 57
end_index: 58
6ExprRangelambda_map: 12
start_index: 57
end_index: 58
7Literal
8ExprTuple13, 14
9Lambdaparameter: 94
body: 15
10Lambdaparameter: 94
body: 16
11Lambdaparameter: 94
body: 17
12Lambdaparameter: 94
body: 18
13Operationoperator: 20
operands: 19
14Operationoperator: 20
operands: 21
15ExprRangelambda_map: 22
start_index: 57
end_index: 42
16ExprRangelambda_map: 23
start_index: 57
end_index: 42
17ExprRangelambda_map: 24
start_index: 57
end_index: 44
18ExprRangelambda_map: 25
start_index: 57
end_index: 44
19ExprTuple26, 27
20Literal
21ExprTuple28, 29
22Lambdaparameter: 91
body: 69
23Lambdaparameter: 91
body: 70
24Lambdaparameter: 91
body: 71
25Lambdaparameter: 91
body: 72
26Operationoperator: 33
operands: 30
27Operationoperator: 33
operands: 31
28Operationoperator: 33
operands: 32
29Operationoperator: 33
operands: 34
30ExprTuple35
31ExprTuple36
32ExprTuple37
33Literal
34ExprTuple38
35ExprRangelambda_map: 39
start_index: 57
end_index: 42
36ExprRangelambda_map: 40
start_index: 57
end_index: 44
37ExprRangelambda_map: 41
start_index: 57
end_index: 42
38ExprRangelambda_map: 43
start_index: 57
end_index: 44
39Lambdaparameter: 94
body: 45
40Lambdaparameter: 94
body: 46
41Lambdaparameter: 94
body: 47
42Variable
43Lambdaparameter: 94
body: 48
44Variable
45ExprTuple49
46ExprTuple50
47ExprTuple51
48ExprTuple52
49ExprRangelambda_map: 53
start_index: 57
end_index: 58
50ExprRangelambda_map: 54
start_index: 57
end_index: 58
51ExprRangelambda_map: 55
start_index: 57
end_index: 58
52ExprRangelambda_map: 56
start_index: 57
end_index: 58
53Lambdaparameter: 91
body: 59
54Lambdaparameter: 91
body: 60
55Lambdaparameter: 91
body: 61
56Lambdaparameter: 91
body: 63
57Literal
58Variable
59Operationoperator: 67
operands: 64
60Operationoperator: 67
operands: 65
61Operationoperator: 67
operands: 66
62ExprTuple91
63Operationoperator: 67
operands: 68
64NamedExprselement: 69
targets: 70
65NamedExprselement: 71
targets: 72
66NamedExprselement: 73
targets: 74
67Literal
68NamedExprselement: 75
targets: 76
69IndexedVarvariable: 78
indices: 77
70IndexedVarvariable: 87
indices: 77
71IndexedVarvariable: 80
indices: 77
72IndexedVarvariable: 88
indices: 77
73IndexedVarvariable: 78
indices: 89
74Operationoperator: 81
operand: 83
75IndexedVarvariable: 80
indices: 89
76Operationoperator: 81
operand: 86
77ExprTuple94, 91
78Variable
79ExprTuple83
80Variable
81Operationoperator: 84
operand: 92
82ExprTuple86
83IndexedVarvariable: 87
indices: 89
84Literal
85ExprTuple92
86IndexedVarvariable: 88
indices: 89
87Variable
88Variable
89ExprTuple90, 91
90Operationoperator: 92
operand: 94
91Variable
92Variable
93ExprTuple94
94Variable