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 Conditional, Function, Lambda, Literal, k, m, n, p
from proveit.core_expr_types.expr_arrays import A11_to_Akm, B11_to_Bkn, R11_to_Rkm, S11_to_Skn
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Interval, NaturalPos, one
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([k, m, n], Conditional(Forall(instance_param_or_params = [p], instance_expr = Forall(instance_param_or_params = [A11_to_Akm, R11_to_Rkm, B11_to_Bkn, S11_to_Skn], instance_expr = Equals(QcircuitEquiv(circuit_Akm, circuit_Bkn), QcircuitEquiv(circuit_permuted_Akm, circuit_permuted_Bkn)).with_wrapping_at(2)).with_wrapping(), domain = Function(Literal("Perm", latex_format = r"\textrm{Perm}", theory = "proveit.physics.quantum.circuits"), [Interval(one, k)])), And(InSet(k, NaturalPos), InSet(m, NaturalPos), InSet(n, NaturalPos))))
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(k, m, n\right) \mapsto \left\{\forall_{p \in \textrm{Perm}\left(\{1~\ldotp \ldotp~k\}\right)}~\left[\begin{array}{l}\forall_{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}}~\\
\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)\end{array}\right] \textrm{ if } k \in \mathbb{N}^+ ,  m \in \mathbb{N}^+ ,  n \in \mathbb{N}^+\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
1ExprTuple87, 71, 73
2Conditionalvalue: 3
condition: 4
3Operationoperator: 19
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9, 10, 11
8Lambdaparameter: 121
body: 12
9Operationoperator: 21
operands: 13
10Operationoperator: 21
operands: 14
11Operationoperator: 21
operands: 15
12Conditionalvalue: 16
condition: 17
13ExprTuple87, 18
14ExprTuple71, 18
15ExprTuple73, 18
16Operationoperator: 19
operand: 23
17Operationoperator: 21
operands: 22
18Literal
19Literal
20ExprTuple23
21Literal
22ExprTuple121, 24
23Lambdaparameters: 25
body: 26
24Operationoperator: 27
operand: 35
25ExprTuple29, 30, 31, 32
26Operationoperator: 33
operands: 34
27Literal
28ExprTuple35
29ExprRangelambda_map: 36
start_index: 86
end_index: 87
30ExprRangelambda_map: 37
start_index: 86
end_index: 87
31ExprRangelambda_map: 38
start_index: 86
end_index: 87
32ExprRangelambda_map: 39
start_index: 86
end_index: 87
33Literal
34ExprTuple40, 41
35Operationoperator: 42
operands: 43
36Lambdaparameter: 123
body: 44
37Lambdaparameter: 123
body: 45
38Lambdaparameter: 123
body: 46
39Lambdaparameter: 123
body: 47
40Operationoperator: 49
operands: 48
41Operationoperator: 49
operands: 50
42Literal
43ExprTuple86, 87
44ExprRangelambda_map: 51
start_index: 86
end_index: 71
45ExprRangelambda_map: 52
start_index: 86
end_index: 71
46ExprRangelambda_map: 53
start_index: 86
end_index: 73
47ExprRangelambda_map: 54
start_index: 86
end_index: 73
48ExprTuple55, 56
49Literal
50ExprTuple57, 58
51Lambdaparameter: 120
body: 98
52Lambdaparameter: 120
body: 99
53Lambdaparameter: 120
body: 100
54Lambdaparameter: 120
body: 101
55Operationoperator: 62
operands: 59
56Operationoperator: 62
operands: 60
57Operationoperator: 62
operands: 61
58Operationoperator: 62
operands: 63
59ExprTuple64
60ExprTuple65
61ExprTuple66
62Literal
63ExprTuple67
64ExprRangelambda_map: 68
start_index: 86
end_index: 71
65ExprRangelambda_map: 69
start_index: 86
end_index: 73
66ExprRangelambda_map: 70
start_index: 86
end_index: 71
67ExprRangelambda_map: 72
start_index: 86
end_index: 73
68Lambdaparameter: 123
body: 74
69Lambdaparameter: 123
body: 75
70Lambdaparameter: 123
body: 76
71Variable
72Lambdaparameter: 123
body: 77
73Variable
74ExprTuple78
75ExprTuple79
76ExprTuple80
77ExprTuple81
78ExprRangelambda_map: 82
start_index: 86
end_index: 87
79ExprRangelambda_map: 83
start_index: 86
end_index: 87
80ExprRangelambda_map: 84
start_index: 86
end_index: 87
81ExprRangelambda_map: 85
start_index: 86
end_index: 87
82Lambdaparameter: 120
body: 88
83Lambdaparameter: 120
body: 89
84Lambdaparameter: 120
body: 90
85Lambdaparameter: 120
body: 92
86Literal
87Variable
88Operationoperator: 96
operands: 93
89Operationoperator: 96
operands: 94
90Operationoperator: 96
operands: 95
91ExprTuple120
92Operationoperator: 96
operands: 97
93NamedExprselement: 98
targets: 99
94NamedExprselement: 100
targets: 101
95NamedExprselement: 102
targets: 103
96Literal
97NamedExprselement: 104
targets: 105
98IndexedVarvariable: 107
indices: 106
99IndexedVarvariable: 116
indices: 106
100IndexedVarvariable: 109
indices: 106
101IndexedVarvariable: 117
indices: 106
102IndexedVarvariable: 107
indices: 118
103Operationoperator: 110
operand: 112
104IndexedVarvariable: 109
indices: 118
105Operationoperator: 110
operand: 115
106ExprTuple123, 120
107Variable
108ExprTuple112
109Variable
110Operationoperator: 113
operand: 121
111ExprTuple115
112IndexedVarvariable: 116
indices: 118
113Literal
114ExprTuple121
115IndexedVarvariable: 117
indices: 118
116Variable
117Variable
118ExprTuple119, 120
119Operationoperator: 121
operand: 123
120Variable
121Variable
122ExprTuple123
123Variable