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, 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 Equals, Forall, InSet
from proveit.numbers import Interval, 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(p, Conditional(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(), InSet(p, Function(Literal("Perm", latex_format = r"\textrm{Perm}", theory = "proveit.physics.quantum.circuits"), [Interval(one, k)]))))
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())
p \mapsto \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} \textrm{ if } p \in \textrm{Perm}\left(\{1~\ldotp \ldotp~k\}\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 106
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 8
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8
6Literal
7ExprTuple106, 9
8Lambdaparameters: 10
body: 11
9Operationoperator: 12
operand: 20
10ExprTuple14, 15, 16, 17
11Operationoperator: 18
operands: 19
12Literal
13ExprTuple20
14ExprRangelambda_map: 21
start_index: 71
end_index: 72
15ExprRangelambda_map: 22
start_index: 71
end_index: 72
16ExprRangelambda_map: 23
start_index: 71
end_index: 72
17ExprRangelambda_map: 24
start_index: 71
end_index: 72
18Literal
19ExprTuple25, 26
20Operationoperator: 27
operands: 28
21Lambdaparameter: 108
body: 29
22Lambdaparameter: 108
body: 30
23Lambdaparameter: 108
body: 31
24Lambdaparameter: 108
body: 32
25Operationoperator: 34
operands: 33
26Operationoperator: 34
operands: 35
27Literal
28ExprTuple71, 72
29ExprRangelambda_map: 36
start_index: 71
end_index: 56
30ExprRangelambda_map: 37
start_index: 71
end_index: 56
31ExprRangelambda_map: 38
start_index: 71
end_index: 58
32ExprRangelambda_map: 39
start_index: 71
end_index: 58
33ExprTuple40, 41
34Literal
35ExprTuple42, 43
36Lambdaparameter: 105
body: 83
37Lambdaparameter: 105
body: 84
38Lambdaparameter: 105
body: 85
39Lambdaparameter: 105
body: 86
40Operationoperator: 47
operands: 44
41Operationoperator: 47
operands: 45
42Operationoperator: 47
operands: 46
43Operationoperator: 47
operands: 48
44ExprTuple49
45ExprTuple50
46ExprTuple51
47Literal
48ExprTuple52
49ExprRangelambda_map: 53
start_index: 71
end_index: 56
50ExprRangelambda_map: 54
start_index: 71
end_index: 58
51ExprRangelambda_map: 55
start_index: 71
end_index: 56
52ExprRangelambda_map: 57
start_index: 71
end_index: 58
53Lambdaparameter: 108
body: 59
54Lambdaparameter: 108
body: 60
55Lambdaparameter: 108
body: 61
56Variable
57Lambdaparameter: 108
body: 62
58Variable
59ExprTuple63
60ExprTuple64
61ExprTuple65
62ExprTuple66
63ExprRangelambda_map: 67
start_index: 71
end_index: 72
64ExprRangelambda_map: 68
start_index: 71
end_index: 72
65ExprRangelambda_map: 69
start_index: 71
end_index: 72
66ExprRangelambda_map: 70
start_index: 71
end_index: 72
67Lambdaparameter: 105
body: 73
68Lambdaparameter: 105
body: 74
69Lambdaparameter: 105
body: 75
70Lambdaparameter: 105
body: 77
71Literal
72Variable
73Operationoperator: 81
operands: 78
74Operationoperator: 81
operands: 79
75Operationoperator: 81
operands: 80
76ExprTuple105
77Operationoperator: 81
operands: 82
78NamedExprselement: 83
targets: 84
79NamedExprselement: 85
targets: 86
80NamedExprselement: 87
targets: 88
81Literal
82NamedExprselement: 89
targets: 90
83IndexedVarvariable: 92
indices: 91
84IndexedVarvariable: 101
indices: 91
85IndexedVarvariable: 94
indices: 91
86IndexedVarvariable: 102
indices: 91
87IndexedVarvariable: 92
indices: 103
88Operationoperator: 95
operand: 97
89IndexedVarvariable: 94
indices: 103
90Operationoperator: 95
operand: 100
91ExprTuple108, 105
92Variable
93ExprTuple97
94Variable
95Operationoperator: 98
operand: 106
96ExprTuple100
97IndexedVarvariable: 101
indices: 103
98Literal
99ExprTuple106
100IndexedVarvariable: 102
indices: 103
101Variable
102Variable
103ExprTuple104, 105
104Operationoperator: 106
operand: 108
105Variable
106Variable
107ExprTuple108
108Variable