boolean circuits
boolean circuits
boolean circuits
Abstract
Boolean circuits are used to represent programs on 3nite data. Reversible Boolean circuits and
quantum Boolean circuits have been introduced to modelize some physical aspects of compu-
tation. Those notions are essential in complexity theory, but we claim that a deep mathematical
theory is needed to make progress in this area. For that purpose, the recent developments of
knot theory is a major source of inspiration.
Following the ideas of Burroni, we consider logical gates as generators for some algebraic
structure with two compositions, and we are interested in the relations satis3ed by those gen-
erators. For that purpose, we introduce canonical forms and rewriting systems. Up to now, we
have mainly studied the basic case and the linear case, but we hope that our methods can be
used to get presentations by generators and relations for the (reversible) classical case and for
the (unitary) quantum case.
c 2003 Elsevier B.V. All rights reserved.
MSC: 15-XX
1. Introduction
We use diagrams to represent certain kinds of maps. If p and q are natural numbers,
: p → q stands for a diagram with p inputs and q outputs. It is pictured as follows:
p
}
···
···
}
The basic case corresponds to control <ow diagrams and the classical case to data
<ow diagrams.
Diagrams may be composed in two diCerent ways. For any : p → q and : q → r,
we have a diagram ◦ : p → r, which corresponds to the usual composition of maps,
and which is pictured as follows:
···
···
···
This vertical (or sequential) composition is associative, and we have an identity dia-
gram id p : p → p for each p, such that ◦ id p = = id q ◦ for any : p → q. This
id p is pictured as follows:
···
··· ···
··· ···
• in the basic case, g is the disjoint union (or coproduct) f f de3ned by g(i)=f(i)
for i = 1; : : : ; p and g(p + i) = q + f (i) for i = 1; : : : ; p ;
• in the classical case, g is the cartesian product f × f de3ned by g(x1 ; : : : ; xp+p ) =
(y1 ; : : : ; yq+q ) where (y1 ; : : : ; yq ) = f(x1 ; : : : ; xp ) and (yq+1 ; : : : ; yq+q ) = f (xp+1 ; : : : ;
xp+p );
• in the linear case, g is the direct sum f ⊕ f de3ned by g(u ⊕ u ) = f(u) ⊕ f (u )
for u ∈ K p and u ∈ K p . Note that g coincides with the cartesian product f × f ;
• in the quantum case, g is the tensor product f⊗f de3ned by g(u⊗u )=f(u)⊗f (u )
for u ∈ ⊗p V and u ∈ ⊗p V .
This horizontal (or parallel) composition is associative, and the void diagram id 0 : 0 →
0 is such that | id 0 = = id 0 | for any : p → q. Furthermore, we have id p | id p =
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 259
id p+p , and the two compositions are compatible in the following sense: for any :
p → q, : q → r, : p → q , and : q → r , we have ( ◦ ) | ( ◦ ) = ( | ) ◦
( | ). This diagram is pictured as follows:
··· ···
··· ···
··· ···
In particular, for any : p → q and : p → q , we get ( | id q ) ◦ (id p | ) = | =
(id q | ) ◦ ( | id p ). This corresponds to the following picture:
···
··· ···
···
It is easy to see that any diagram is a vertical composition of elementary diagrams
1 ◦ · · · ◦ n , but this decomposition is not unique. In fact, two decompositions de3ne
the same diagram if and only if they are equivalent modulo the following commutation
rule:
• sets with disjoint union (basic case) or with cartesian product (classical case);
• vector spaces with direct sum (linear case) or with tensor product (quantum case).
2.1. Permutations
Note that the transposition i of {1; : : : ; n} which exchanges i with i+1 is represented
by the elementary diagram id i−1 | | id n−i−1 :
··· ···
Obviously, satis3es the relations ◦=id 2 and ( | id 1 )◦(id 1 | )◦( | id 1 )=(id 1 | )◦
( | id 1 ) ◦ (id 1 | ), which are pictured as follows:
= =
Of course, those equalities hold between the interpretations, not between the dia-
grams.
Theorem 1. The generator and the above two relations form a presentation of S.
This means that generates S, and if two diagrams represent the same permutation,
they are equivalent modulo the above relations.
If we restrict this presentation of the monoidal category S to permutations of
{1; : : : ; n}, we get the usual presentation of the symmetric group Sn by the gener-
ators 1 ; : : : ; n−1 and the following relations:
2i = 1; i i+1 i = i+1 i i+1 ; i j = j i for j ¿ i + 1:
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 261
However, our approach has several advantages: we present all Sn at the same time;
we need one generator instead of n − 1, and two relations instead of n(n − 1)=2; the
relations i j = j i for j ¿ i + 1 are made implicit by the commutation rule. Fur-
thermore, we shall see that a monoidal category such as F, which is not a groupoid,
can also be presented in this way, even though it cannot be decomposed into
monoids.
To show Theorem 1, we introduce the notions of stairs and canonical forms, which
are de3ned by the following grammar:
···
···
··· ···
is or is void or ···
··· ···
··· ··· ···
• If n = 0, then f is the identity on the empty set, which is represented by the void
diagram.
• If n ¿ 1, we get a permutation of {1; : : : ; n − 1} by removing 1 from the domain of
f and f(1) from its codomain, and by renumbering both of them. In the canonical
form of f, the size of the stairs is f(1) − 1, and the remaining part is given by the
induction hypothesis.
• If m=0, then =id n , which is a canonical form. This is easily checked by induction
on n.
• If m ¿ 1, then = ◦ where is an elementary diagram and is a diagram of
size m − 1 which reduces to a canonical form ˆ by induction hypothesis. Therefore,
reduces to ◦ ˆ and there are four possible cases: see Fig. 1. In the 3rst case,
we use the 3rst rule and the induction hypothesis for n − 1; in the second case,
we use the second rule and we get a canonical form; in the third case, we get a
canonical form; in the fourth case, we use the induction hypothesis for n − 1. Note
that in the 3rst and in the last case, we also need the commutation rule, which is
implicit.
262 Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310
···
··· ···
··· ···
··· ···
··· ··· ···
··· ···
··· ···
= = =
Theorem 2. The generators , and the above three relations form a presentation
of M.
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 263
···
··· ···
is void or or
··· ··· ···
• If n = 0, then f is the identity on the empty set, which is represented by the void
diagram.
• If p ¿ 1 and f(1) = 1, we get a monotone map by removing 1 from the domain
of f, and by renumbering it. The canonical form is of the second type, and the
remaining part is given by the induction hypothesis.
• Otherwise, q ¿ 1 and 1 is not in the image of f: we get a monotone map by
removing 1 from the codomain of f, and by renumbering it. The canonical form is
of the third type, and the remaining part is given by the induction hypothesis.
• If m=0, then =id p , which reduces to a canonical form. This is proved by induction
on p, using the 3rst rule:
···
··· ···
···
··· ···
··· ···
···
··· ···
···
··· ···
is void or or
··· ··· ··· ···
···
is ···
···
··· ··· ··· ···
is void or or
··· ··· ···
2.3. Maps
= = = =
= = =
These generators satisfy the relations of Fig. 5, which consist of: the two relations
for S; the 3rst two relations for M; three extra relations ◦( | id 1 )=(id 1 | )◦( | id 1 )◦
(id 1 | ), ◦( | id 1 )=id 1 | , and ◦=. Note that the third relation for M is derivable:
see Fig. 7.
Theorem 3. The generators , , and the seven relations of Fig. 5 form a presen-
tation of F.
···
··· ···
is ··· or
···
··· ···
It is easy to see that any map is represented by a unique canonical form. Now
we introduce the rules of Fig. 6, which are derivable from the above relations: see
Fig. 7. To show that any identity diagram reduces to a canonical form, we need a
slightly more general result:
= = = = = = = =
= = = = =
···
···
··· ···
is void or ··· or
··· ···
··· ··· ···
··· ···
is ···
···
··· ··· ··· ···
is void or or
··· ··· ···
···
··· ···
··· ··· ··· ···
Theorem 3 follows from the fact that any diagram reduces to a canonical form by the
rules of Fig. 6. In fact, it is also possible to show that our presentation is minimal:
see [8].
Again, the rewrite system of Fig. 6 is not terminating, but we can adopt the alterna-
tive canonical form of Fig. 8, which consists in decomposing any map f : {1; : : : ; p} →
{1; : : : ; q} into a surjection g : {1; : : : ; p} → {1; : : : ; n} followed by a monotone injection
h : {1; : : : ; n}→{1; : : : ; q}, and the terminating rewrite system of Fig. 9: see Appendix A.
By the way, we get:
= = =
Theorem 4. The generator ! and the above three relations form a presentation of A.
Note that the second relation can be replaced by the following one:
!i !j = !j !i for j ¿ i + 2:
To show Theorem 4, we introduce the following notion of stairs:
···
···
is or
···
···
···
···
··· ···
is void or or ··· or
···
··· ···
···
We introduce the rules of Fig. 10, which are derivable from the above relations: see
Fig. 11.
Lemma 7. Using the ?rst rule of Fig. 10, we get the following reduction (for some
diagram ):
··· ···
···
··· ···
This is proved by induction on the size of the stairs. Using this, one proves:
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 269
= = = = = = =
= = = =
= = = =
= = = = =
We write e1 ; : : : ; en for the canonical basis of K n . There are two major symmetries of
L(K):
For any map f : {1; : : : ; p} → {1; : : : ; q} in F, we de3ne two dual linear maps:
So we get two natural embeddings of F into L(K): a covariant one and a contravariant
one.
We start with the 3eld K = Z2 = {0; 1} of integers modulo 2. It is indeed a 3rst step
towards an algebraic theory of Boolean circuits. We introduce 3ve generators : 2 → 2,
! : 1 → 2, " : 1 → 0, : 2 → 1, and : 0 → 1, which are pictured and interpreted as
follows:
x y x x x y
y x x x x+ y 0
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 271
transpose conjugate
transpose
conjugate conjugate
transpose
conjugate conjugate
= =
= =
= =
= = =
= = =
= = =
This means that the matrices for , !, and are the following:
0 1 1
(1 1)
1 0 1
Note that each generator is its own conjugate and the transpose of another
generator: see Fig. 12. These generators satisfy the relations of Fig. 13, which consist
of: the two relations for S, which are self-dual; the 3ve other relations for F, corres-
ponding to the covariant embedding of F into L(Z2 ); the 3ve dual relations,
corresponding to the contravariant embedding of F into L(Z2 ); the four relations
272 Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310
Theorem 5. The generators , !, ", , and the relations of Fig. 13 form a presen-
tation of L(Z2 ).
Let GL(K) be the monoidal subcategory of L(K) whose morphisms are linear per-
mutations. In this case, there is an extra symmetry, inversion, which reverts the order
of vertical composition.
Note that any : 2 → 2 de3nes elementary operations on matrices:
Again, we consider the case of Z2 . Apart from id 2 and , there are four linear permu-
tations of Z22 :
x y x y x y x y
x x+y x+ y y x+ y x y x+ y
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 273
conjugate
transpose inverse
conjugate
inverse inverse
transpose
conjugate
transpose transpose
inverse
= = =
= = =
= = = =
But ! and are not permutations. In fact, GL(Z2 ) is generated by and any of the
four above generators, for instance the third one, that we call $. The other ones are
indeed superMuous:
= = =
Theorem 6. The generators , $, and the six relations of Fig. 15 form a presentation
of GL(Z2 ).
274 Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310
··· ···
···
is or or
···
··· ···
··· ···
···
···
is void or
··· ···
···
1. Consider the last row of A, and let j be the last index for which the coeNcient is 1.
2. While j ¿ 1, apply or $−1 to columns j−1 and j, so that this index becomes j−1.
3. By construction, the last row is now (1 0 · · · 0). So, if we consider the 3rst column,
n is the last index i for which the coeNcient is 1.
4. While i ¿ 1, apply or $−1 to rows i − 1 and i, so that this index becomes i − 1,
and row i − 1 becomes (1 0 · · · 0).
1 1 1
1 0 0
1 0 1
0 1 1 1
0 0 1 0
1 0 0 1 1 1 1
1 0 1 0 1 0 0 0 1 1 0
1 1 0 1 0 0 1
0 1 1 1
0 1 0 0 1 0 1 1 0 1 1 0 0
1 0 0 1 0 1 0 1 0 0 0 0 1
1 1 0 0 1 0 0 0 1 0 0 1 0
1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0
1 1 0 0 1 1 0 0 1 0 0 0 0 1 1 1
0 1 0 1 1 0 0 0 0 1 0 0 0 1 0 0
1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1
···
···
···
is void or
···
···
··· ···
0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 1 1 1 1 0 0 0
0 0 1 0 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 0 0 0 1 1 1
1 0 0 1 0 0 0 1 0 1 1 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 1
1 0 1 0 1 1 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0
1 1 1 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0
0 0 1 1 1 1 0 1 0 1 0 0 1 0 0 0 0 1
0 1 0 1 0 1 0 1 1 0 0 1 0 1 0 0 1 0
0 1 0 1 0
1 0 1 0 1
The extra column on the right contains a1 ; : : : ; an . Again, we get a matrix of the form
1 ⊕ A . This A is obtained by removing the 3rst column and one row of the original
matrix. See Fig. 17 for an example.
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 277
= = = = = =
= = = = = = =
In Fig. 18, we introduce two groups of rules for the following transformations:
or
Those 14 rules are derivable from the six relations of Fig. 15. Indeed, 3ve rules are
already in the presentation, 3ve more are derived in Fig. 19, and we get three more
by duality. It remains to show that the last rule of Fig. 18 is derivable from the
presentation. This is done in Fig. 20, using the superMuous generator $2 , which is both
the inverse and the conjugate of $:
=
278 Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310
= = = = = = = = =
= = = = = = =
= = = = = = = = =
• If m=0, then =id n , which reduces to a canonical form. This is proved by induction
on n, using the 3rst rule:
··· ···
···
··· ···
···
··· ···
···
···
···
···
···
···
··· ···
··· ··· ···
···
···
···
···
··· ···
··· ···
reduces to ◦ ˆ and there are four possible cases (Fig. 21): in the 3rst case, we
use the second group of rules and the induction hypothesis for n − 1; in the second
case, we get a canonical form; in the third case, we use the crucial transformation of
Fig. 22, which itself uses Lemma 10 and the 3rst group of rules, and the induction
hypothesis for n − 1; in the fourth case, we use the second group of rules twice and
the induction hypothesis for n − 1.
···
··· ···
···
··· ··· ···
Fig. 22. Crucial transformation for the third case of Lemma 11.
In other words, there are invertible matrices of order 3 which are not of the form
(1 ⊕ A)(B ⊕ 1)(1 ⊕ C). Here is an example:
1 1 0
1 0 1
0 1 0
Finally, note that is almost a superMuous generator, since | id 1 and id 1 | are de3n-
able in terms of $:
= =
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 281
1 0 1 1
1 0 0 0
1 1 0 1
This means that is only necessary in dimension 2, but again, removing it would
seriously complicate the presentation.
In order to extend our presentation of GL(Z2 ) to L(Z2 ), the generators " and are
clearly needed, but ! and are superMuous, since they are de3nable in terms of $, ",
and :
= =
= = =
Theorem 7. The generators , $, ", , and the six relations of Fig. 15 together with
the above three ones form a presentation of L(Z2 ).
···
··· ···
is ··· or
···
···
= = = = = = = = =
= =
We introduce the rules of Fig. 24, which are derivable from our presentation: see
Fig. 25. To show that any identity diagram reduces to a canonical form, an analogue
of Lemma 5 is needed: see Fig. 26. Theorem 7 follows from the fact that any diagram
reduces to a canonical form by the rules of Fig. 24.
We get Theorem 5 as a corollary. Indeed, we have de3ned a translation F of dia-
grams built with , $, ", into diagrams built with , !, ", , , and a translation G
in the opposite direction. By applying F to the nine relations of Theorem 7, we get
relations which are derivable from those of Fig. 13. Furthermore, the following two
relations are also derivable from those of Fig. 13:
= =
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 283
··· ···
··· ···
···
··· ···
···
···
··· ··· ···
is void or ··· or or
··· ··· ···
··· ··· ···
··· ···
is ···
···
··· ··· ··· ···
is void or or
··· ··· ···
This implies that for any diagram built with , !, ", , , we have ≡ F(G())
modulo the relations of Fig. 13. Therefore, if and represent the same linear map, we
have G() ≡ G( ) modulo the nine relations of Theorem 7, so that ≡ F(G()) ≡
F(G( )) ≡ modulo the relations of Fig. 13.
Again, the rewrite system of Fig. 24 is not terminating, but we can adopt the
alternative canonical form of Fig. 27, which uses the two superMuous generators !
and , and the rewrite system of Fig. 28. We conjecture that this rewrite system
is terminating: see Appendix A. The upper part of this canonical form is obtained
by the following algorithm, which applies to any matrix A without zero
row:
1. If the 3rst column is zero, remove it. Otherwise, let i be the last index for which
the coeNcient of the 3rst column is 1.
2. If row i is not of the form (1 0 · · · 0), replace this 1 by 0 and insert the row
(1 0 · · · 0) between rows i − 1 and i.
3. While i ¿ 1, apply or $−1 to rows i − 1 and i, or in case row i − 1 is of the form
(1 0 · · · 0), remove it, so that in all cases, this index becomes i − 1 and row i − 1
becomes (1 0 · · · 0).
284 Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310
Instead, we can generalize the 3rst canonical form of linear permutations as follows:
··· ···
···
··· ···
is ··· or or
··· ··· ···
···
This canonical form is obtained by the same algorithm as in the case of linear per-
mutations, except that the last row may be zero, and one may end with a degenerate
matrix. See Fig. 23 for an example. This algorithm can also be used to compute the
rank of a matrix. Note the following points:
In particular, the monoidal subcategory Lsurj (Z2 ) of L(Z2 ) whose morphisms are linear
surjections is generated by , $, and ". We have already seen that these generators
satisfy the following relations:
= =
Theorem 8. The generators , $, ", and the six relations of Fig. 15 together with the
above two ones form a presentation of Lsurj (Z2 ).
1 0 1 1
1 0 0 0
1 1 0 1
···
···
···
··· ···
is void or or
···
··· ···
··· ···
It is obtained by the following algorithm, which applies to any matrix A with q inde-
pendent rows:
We get a canonical form of the second type if the rank is q − 1, or of the third type if
the rank is q, and in that case, the stairs corresponds to the 3rst column of the matrix.
See Fig. 29 for an example.
In Fig. 30, we introduce rules for the following transformations:
or
Those rules are derivable from the six relations of Fig. 15 together with the above two
ones: see Fig. 31.
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 287
= = = = = = = =
··· ···
···
··· ··· ··· ··· ··· ··· ··· ···
···
···
Theorem 8 follows from the fact that any diagram reduces to a canonical
form by the rules of Fig. 18 together with those of Fig. 30. To show this, we
proceed as in the case of linear permutations, using the crucial transformation of
Fig. 32.
The canonical form of linear surjections can be generalized to linear maps: see
Fig. 33. The bottom part of this canonical form is obtained by the following
algorithm, which takes any system u1 ; : : : ; uq and returns a free subsystem of the
288 Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310
···
···
···
··· ···
is void or or
···
···
··· ···
··· ··· ···
is ···
···
··· ···
··· ···
is void or or
··· ··· ···
···
same rank:
This algorithm is applied to the rows of the matrix. One gets a canonical form of the
second type if u1 is independent of v1 ; : : : ; vn , or of the third type if u1 =a1 v1 +· · ·+an vn ,
and in that case, the antistairs are given by the coeNcients a1 ; : : : ; an . In both cases, the
rest of the canonical form is given by step 1. Finally, the algorithm returns a matrix
with independent rows, corresponding to a linear surjection, from which one gets the
upper part of the canonical form. See Fig. 35 for an example.
The canonical form of Fig. 33 corresponds to the unique decomposition of any linear
map f : Zp2 → Zq2 into a linear surjection g : Zp2 → Zn2 followed by a monotone linear
injection h : Zn2 → Zq2 , where n is the rank of f. Here, we assume that Zn2 is equipped
with the following antilexicographical ordering:
(0; x2 ; : : : ; x n ) ¡ (1; x2 ; : : : ; x n );
It is indeed easy to see that the bottom part of a canonical form corresponds to a mono-
tone linear injection. The converse is proved by induction on q, using the following
lemma:
Lemma 12. Let A be the matrix of a monotone linear injection f : Zp2 → Zq2 and let
B be the matrix obtained by removing the ?rst row of A. Then B is the matrix of
a monotone linear injection or A is of the form 1 ⊕ C where C is the matrix of a
monotone linear injection.
···
···
Note also that if we apply the above decomposition to a linear injection, we get a
linear permutation followed by a monotone linear injection. This means that monotone
linear injections provide a canonical choice of basis for subspaces of Zn2 .
There is a dual notion of comonotone linear surjection. Any linear map can be
uniquely decomposed into a comonotone linear surjection followed by a linear injection.
Again, if we apply this decomposition to a linear surjection, we get a comonotone linear
surjection followed by a linear permutation. In fact, the comonotone linear surjections
coincide with the conjugate of linear surjections whose matrices are in row-reduced
echelon form. This row-reduced echelon form is just what we get when we apply the
Gauss algorithm to solve a linear system.
Finally, any linear map can be uniquely decomposed into a comonotone linear
surjection followed by a linear permutation followed by a monotone linear injection.
···
··· ··· ···
is void or or
··· ···
···
···
···
···
··· ··· ···
is is void or
··· ··· ···
···
···
··· ···
···
··· ···
is void or or
··· ··· ···
···
0 1 1 0
1 0 1 1
0 0 0 0
1 0 0 0
1 1 0 1
This decomposition corresponds to the canonical form of Fig. 34. See Fig. 35 for an
example.
The results of the previous sections can be generalized to an arbitrary 3eld K. First
we introduce a generator Ha : 1 → 1 for each a ∈ K. It is pictured and interpreted as
follows:
x
a
ax
_x
The presentation of L(K) is the one of Fig. 13, where the last relation is replaced by
the nine relations of Fig. 36. The last six relations correspond to the following axioms
for vector spaces:
Note that H0 and H1 are superMuous generators. Furthermore, in the case of a 3nite
3eld, it is well known that the multiplicative group of invertible elements is cyclic, so
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 291
a a
= =
a a
a
=
a
a a
= =
a a
a
= ab 1 = a+ b = a b 0 =
b
that the Ha for a = 0 are de3nable in terms of a single one. Note also that is always
de3nable in terms of !, , and +:
x y x y
y x x+ y x
Note that the Ka for a = 0 are de3nable in terms of $ and the Ha :
a 1/a
a = =
1/a a
292 Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310
a a b ab b
ab 1
b b ab b a
a a a+1 /b a c
b= 0
a+ b b b −1/b b b+ac
b c c+1 /b c a
Stairs and antistairs are built with the Ka , and the second canonical form is generalized
as follows:
···
···
···
is void or
···
···
··· ···
Any diagram built with the Ha for a = 0 and the Ka reduces to such a canonical form
by the rules of Fig. 37. From this, it is possible to get a presentation of GL(K) with
, $, and the Ha for a = 0 as generators. Again, a single Ha is needed in the case of
a 3nite 3eld.
3.4. Isometries
cos −sin
It stands for the rotation of angle , whose matrix is sin cos .
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 293
is is or
is or or or or or
Symmetries are de3nable in terms of the R and +. For instance, can be decom-
posed as follows:
=
/2
=
Therefore, we shall only use R for ∈ ]0; .[. Stairs are built with those R , and
there is a simple notion of canonical form which is similar to the canonical form of
permutations in the basic case:
··· ···
···
is void or ··· or ···
···
··· ··· ··· ···
1. Consider the 3rst column of A, and let i be the last index for which the coeNcient
is = 0.
2. While i ¿ 1, apply R−1
to rows i−1 and i, so that this index becomes i−1. For that
purpose, choose such that cot = ai−1 =ai , where aj stands for the 3rst coeNcient
of row j.
By the previous remark, we get a matrix of the form ±1⊕A where A is an orthogonal
matrix of order n−1. The type of the canonical form is given by the sign ±1, the stairs
by step 2, and the rest of the canonical form is obtained by applying the algorithm to
the matrix A .
In dimension 3, we get the canonical form of Fig. 38. The parameters ; /; 0 ∈ ]0; .[
which appear in the bottom part of this canonical form are called Euler angles. In the
294 Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310
+ <
= = = + =
− −
3rst case, where three angles are actually needed, we say that the decomposition is
generic.
Lemma 13. If ; /; 0 ∈ ]0; .[, there are ; / ; 0 ∈ ]0; .[ such that (R0 | id 1 ) ◦ (id 1 | R/ ) ◦
(R | id 1 ) is of the form (id 1 | R ) ◦ (R/ | id 1 ) ◦ (id 1 | R0 ).
=
The parameters ; / ; 0 are given by the above algorithm. In this case, it happens
that no + appears in the canonical form, and the decomposition is generic. Obviously,
the generators satisfy the extra relations of Fig. 39. Using the same argument as for
Theorem 1, one proves:
Theorem 9. The generators +, R for ∈ ]0; .[, and the relations of Lemma 13
together with those of Fig. 39 form a presentation of O.
We consider the monoidal category F[k] of 3nite sets Znk with cartesian product.
Again we start with the Boolean case k = 2. Since F[2] is an extension of L(Z2 ), we
have already , !, ", , and as generators. We introduce two new ones : 2 → 1
and : 0 → 1, which are pictured and interpreted as follows:
x y
xy 1
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 295
= = = =
= = =
= = =
It is well known that any map from Zn2 to Z2 is a polynomial, and any two polynomials
de3ne the same map if and only if they are equal modulo the axiom x2 = x. Following
[1,3], we get:
Theorem 10. The generators , !, ", , , , , and the relations of Fig. 13 together
with those of Fig. 40 form a presentation of F[2].
Diagrams built with those generators can be seen as Boolean circuits: The generators
stand respectively for exchange, duplication, erasing, xor gate, false, and gate, and
true. The last six relations of Fig. 40 correspond to the following axioms for Boolean
algebras:
Furthermore, four of the six relations involving can be removed modulo this de3ni-
tion.
Theorem 10 can also be proved directly by using a suitable notion of canonical
form. Moreover, we get:
···
···
···
is void or
···
···
···
··· ··· ···
is ···
···
···
··· ··· ···
is void or or
··· ··· ···
Now, we consider the monoidal subcategory GA(Z2 ) of F[2] whose morphisms are
aAne permutations. We introduce a generator 2 : 1 → 1 for negation, which is pictured
and interpreted as follows:
x +1
= = =
Theorem 11. The generators , $, 2, and the relations of Fig. 15 together with the
above three ones form a presentation of GA(Z2 ).
To show this, it suNces to notice that any aNne permutation f : Zn2 → Zn2 is of
the form h ◦ g where g is a linear permutation and h is the translation de3ned by
h(x1 ; : : : ; x n ) = (x1 + a1 ; : : : ; x n + an ), with (a1 ; : : : ; an ) = f(0; : : : ; 0). Therefore, we have
the canonical form of Fig. 41 for aNne permutations. Any diagram reduces to such a
canonical form by the rules of Fig. 18 and those of Fig. 42. The latter are derivable:
three of them are already in the presentation and the other two are derived in Fig. 43.
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 297
= = =
= = = = = = = = =
It is easy to see that, for n 6 2, any permutation of Zn2 is aNne, but it is not the
case for n = 3. So we introduce the 3-bit ToBoli gate T3 : 3 → 3, which is pictured
and interpreted as follows:
x y z
T3
x y z + xy
This T3 is an involution: It corresponds to the transposition of Z32 which exchanges
(1; 1; 0) with (1; 1; 1). More generally, we introduce the n-bit ToBoli gate Tn : n → n
for each n ¿ 1, corresponding to the transposition of Zn2 which exchanges (1; : : : ; 1; 0)
with (1; : : : ; 1; 1). For instance, T1 is the negation 2 and T2 is the linear involution ◦$.
It happens that the monoidal subcategory S[2] of F[2] whose morphisms are per-
mutations is not ?nitely generated. This follows from the following remark:
These generators represent transpositions, which are not in A[2], but we have the
following corollaries:
Indeed, there are 3nitely many even permutations of Zn2 with n 6 3, and by the
theorem, any even permutation of Zn2 with n ¿ 4 is de3nable in terms of | id 1 , id 1 | ,
Ti | id 1 , and id 1 | Ti for i = 1; 2; 3. In fact, three generators suNce: see [10].
T2
F3 = T3
T2
The proof is based on the fact that any even permutation can be decomposed into
3-cycles. It does not use any notion of canonical form for S[2] or A[2]. Therefore, it
is not very helpful for getting presentations of those monoidal categories. Of course,
some obvious commutations are satis3ed by the generators:
T3 T3 T3 T2 T3
= = = =
T3 T2 T3 T3 T3 T2
Acknowledgements
This paper is dedicated to Albert Burroni who inspired this theory. The author wish
also to thank Serge Burckel, Julien Cassaigne, and Peter Selinger for fruitful interac-
tions.
Appendix A. Rewriting
The theory of rewriting is well established in the case of words and in the case
of terms. Following [2], we explain how it can be generalized to diagrams. Detailed
proofs will not be given here.
A rewrite system is given by a set of cells and a set of rules. Each rule of the
system is of the form 3 → 3 where 3; 3 : p → q are two diagrams built with the cells
of the system:
··· ···
··· ···
If such a rule is given, and if : m → i + p + j and : i + q + j → n are any diagrams,
we write ◦ (id i | 3 | id j ) ◦ → ◦ (id i | 3 | id j ) ◦ . This is called an elementary
reduction:
··· ···
··· ···
··· ··· ··· ···
··· ···
··· ···
We write →∗ for the iterated reduction, which is the reMexive transitive closure of
→. Similarly, we write ↔∗ for the reMexive transitive closure of ↔, which is itself
the symmetric closure of →. Note that ↔∗ when and are equivalent modulo
the rules (considered as relations).
We say that a diagram is reduced if there is no such that → . We say that
is a reduced form of if →∗ and is reduced. Note that the commutation rule
does not count as a reduction. For the question of 3nding canonical decompositions,
independently of the rewrite rules, see [9].
A.2. Termination
x y x y
x+ y x 2x + y 1
This system is terminating because the 3rst rule moves one cell to the right and the
second rule removes two cells. To make this argument precise, we de3ne the natural
number for any diagram as follows:
This de3nition does not depend on the decomposition of because the number of inputs
of the generator + is the same as its number of outputs. Since we have ¿
whenever → , the length of any reduction starting from a diagram is bounded
by .
The rewrite system of Fig. 9 for F is also terminating, but the previous argument
cannot be extended. Instead, we interpret any diagram : p → q as a strictly monotonic
map [] : N∗p → N∗q , where N∗ is the set of strictly positive integers, and N∗n is
equipped with the following partial order (product order):
(x1 ; : : : ; x n ) 6 (y1 ; : : : ; yn ) whenever x1 6 y1 ; : : : ; x n 6 yn :
It suNces to give the interpretation of each generator: see Fig. 44. For any strictly
monotone maps f; g : N∗p → N∗q , we write f ¡ g if f(x1 ; : : : ; xp ) ¡ g(x1 ; : : : ; xp ) for
all (x1 ; : : : ; xp ) ∈ N∗p . This relation is compatible with horizontal and vertical compo-
sition, and we have [3] ¿ [3 ] for each rule 3 → 3 : see Fig. 45. Therefore, [] ¿ [ ]
whenever → . Finally, the length of any reduction starting from a diagram is
bounded by n1 + · · · + nq where (n1 ; : : : ; nq ) is [](1; : : : ; 1).
We conjecture that the rewrite system of Fig. 28 for L(Z2 ) is also terminating, but
another method is needed to show this, since there is no way of interpreting the cell
" : 1 → 0 as a strictly monotone map.
A.3. Con<uence
Termination ensures the existence of a reduced form for any diagram, but uniqueness
is also needed to decide whether two diagrams are equivalent. The following result is
standard in rewriting theory:
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 301
x x x x x y x y
x +1 1 x 1 x +1 x 1 x 2x + y x + y x y
x x x x x y x y
x +2 x 2x +1 x 3x+2y 2x + y
x y z x y z
x y z x y z x y z x y z
x x
x+ y y 2x + y 2x + y
x+ y x+ y
3x + y+ z 2x + y+ z 2x + y+ z x + y+ z
2x + y+ z x + y+ z
x y z x y z x y z x y z
x y z x y z
x x 4x+2y+z 2x +2y+z
4x+2y+z 2x+2y+z
3x+2y+z x+2y+z
Lemma 15. For a terminating rewrite system, the following properties are equivalent:
*
* * * *
* * * *
=
* * * *
Indeed, it is easy to show that each item implies the next one, and the last one implies
the 3rst one by noetherian induction. Such a rewrite system is called canonical. In the
302 Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310
··· ···
'
··· ···
*
··· ···
···
'
···
··· ···
*
··· ···
'
··· ···
case of words or terms, it suNces to check local conMuence for a 3nite number of
conMicts between rules called critical peaks.
In the rewrite system of Lemma 2 for S, there are four obvious conMicts:
Each of the above diagrams contains two instances of the left member of a rule, and
those instances have a common cell. However, this list is not complete, and indeed,
there was a gap in [2]. Because of the commutation rule, the general form of the last
conMict is the following:
···
···
We call this a global con<ict. Fortunately, its conMuence can be proved by noetherian
induction on the diagram : see Fig. 46. Hence, it suNces to consider the case where
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 303
is reduced. By induction on the size, it is easy to see that such a diagram is of one
of the following two types:
···
···
or ···
···
···
Finally, it suNces to consider one extra conMict, corresponding to the case where is
of the second type:
To sum up, there are 3ve critical peaks and all of them are conMuent: see Fig. 47.
Therefore, our system is canonical. In fact, the reduced forms are the canonical forms
of Section 2.1, so that conMuence also follows from Lemmas 1 and 2.
The rewrite system of Fig. 4 for M is also canonical. In this case, there is no global
conMict and the 3ve critical peaks are conMuent: see Fig. 48. In fact, this system can
be identi3ed with the well-know term rewrite system for the theory of monoids:
(xy)z → x(yz); 1x → x; x1 → x:
In the rewrite system of Fig. 9 for F, there are six global conMicts: see Fig. 49. Again,
it suNces to consider the case where is reduced, and such a diagram is of one of
the following four types:
···
···
··· ···
or ··· or or
··· ··· ···
···
Furthermore, if is of the fourth type, we get a reducible con<ict. This means that a
third rule applies, and the conMuence of this conMict can be deduced from the conMuence
of a smaller conMict: see Fig. 50. Finally, the global conMicts lead to 6 × 3 = 18 critical
peaks, and all together, there are 68 critical peaks: see Fig. 51. The conMuence can be
checked case by case, but it also follows from Section 2.3.
In our examples, the study of critical peaks is not the only way to prove conMuence,
but the notion is interesting anyway:
• In [7], the critical peaks of Fig. 48 are used to prove the coherence theorem for
(nonstrict) monoidal categories. Similarly, the canonical system for F can be used
to prove the coherence theorem for symmetric monoidal categories.
Any 3rst-order equational theory with n function symbols and r equations corre-
sponds to a presentation by n + 3 generators and r + 3n + 7 relations. This presentation
consists of:
• one generator : m → 1 for each function symbol of arity m, and the 3 generators
: 2 → 2, ! : 1 → 2, and " : 1 → 0;
• one relation for each equation, 3 relations for each function symbol (see Fig. 52),
and the dual of the 7 relations for F.
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 305
··· ···
···
··· ··· ···
··· ···
···
··· ··· ···
For instance, the theory of Boolean algebras with 4 function symbols and 10 equa-
tions corresponds to the presentation of Theorem 10 for F[2] with 7 generators and 29
relations. This idea comes from [1]. It is based on Lawvere’s interpretation of algebraic
theories by means of Cartesian categories: see [6].
There is a similar correspondence for rewrite systems: Any left linear canonical
term rewrite system with n function symbols, r rules, and p critical peaks corresponds
to a canonical diagram rewrite system with n + 3 generators, r + 4n + 12 rules, and
p + 4r + n2 + 14n + 68 critical peaks. In addition to the r original rules, we have
4 extra rules for each function symbol (see Fig. 53) and the dual of the 12 rules
for F.
Left linearity is a strong restriction: It means that variables occur once in the left
member of each rule. For instance, x(y + z) → xy + xz is left linear, but not x + x → 0.
Here is the crucial observation: the left member of such a rule corresponds to a diagram
306 Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310
(in fact a tree) with no , !, or ", and there is no critical peak between the original
rules and those coming from the rules for F. Furthermore, one can check that all new
global conMicts are reducible. Therefore, it suNces to consider the 5 types of critical
peaks between the 3 types of rules (see Fig. 54).
This proliferation of rules and critical peaks is the price to pay for a decomposition
of equational reasoning into more elementary steps. However, we may 3nd canonical
systems which are not of the above form:
• If our conjecture about the termination of the rewrite system of Fig. 28 holds, then
we get a canonical system for L(Z2 ), whereas there is no canonical term rewrite
system for the theory of vector spaces over Z2 , simply because the commutativity
x + y = y + x cannot be oriented. This problem is usually handled by introducing
rewriting modulo associativity and commutativity, but we claim that our approach
is less ad hoc.
• There are useful algebraic structures, such as braids, tangles, and Hopf algebras,
which are naturally expressed with diagrams, but not with terms. Unfortunately,
we have no interesting example of canonical system of this kind. For instance, the
existence of a 3nite canonical rewrite system for the monoidal category of braids is
an open question.
= = =
= = =
= = =
4r 14n
r 4n 12
p n2 68
Fig. 54. The 5 types of critical peaks between the 3 types of rules.
Consider the following canonical form for GL(K), which generalizes the 3rst canon-
ical form for GL(Z2 ):
··· ···
···
···
is void or
··· ···
···
Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310 309
It suggests a variant of the Gauss algorithm, which applies to any invertible matrix A
of order n over K:
1. Create a counter k with initial value 1, and two matrices P and Q with initial value
I (the identity matrix of order n).
2. Consider the last row of A, and let j be the last index for which the coeNcient a
is not 0.
3. Divide column j by a so that this coeNcient becomes 1, and apply the same oper-
ation to P.
4. While j ¿ k, apply an elementary operation to columns j − 1 and j, so that this
index becomes j − 1, and apply the same operation to P.
5. Now, if we consider column p, n is the last index i for which the coeNcient is not
0 (in fact, it is 1).
6. While i ¿ k, apply an elementary operation to rows i − 1 and i, so that this index
becomes i − 1, and apply the same operation to Q.
7. If k ¡ n, increment k and go back to step 2. Otherwise, return the product PQ.
Note that the 3nal value of A is I. To see that this algorithm computes the inverse,
we write A0 ; : : : ; An for the successive values of A, and similarly for P and Q. Since
P0 = Q0 = I, it is easy to see that Ai = Qi A0 Pi for each i. In particular, An = Qn A0 Pn = I,
so that A−1
0 = P n Qn .
In the case where the last coeNcient of the last row is not 0, it amounts to applying
the following formula:
−1
A u C −1 − 1b C −1 u
= where C = A − 1b uv:
1 −1 1 1 −1
v b − b vC b + b2 vC u
Consider now the second canonical form for GL(K), which generalizes the 3rst canon-
ical form for GL(Z2 ):
···
···
···
is void or
···
···
··· ···
Here the antistairs are obtained by solving a linear system, which means that we must
3rst compute the inverse of some submatrix. We shall not give the details here, but in
the case where the matrix obtained by forgetting the 3rst row and the 3rst column is
invertible, it amounts to applying the following formula:
−1
a u 1
c − 1c uB−1
= where c = a − uB−1 v:
v B − 1c B−1 v B−1 + 1c B−1 vuB−1
310 Y. Lafont / Journal of Pure and Applied Algebra 184 (2003) 257 – 310
Note that the above formulas are two instances of a more general one:
−1
A U C −1 −C −1 UB−1
=
V B −B−1 VC −1 B−1 + B−1 VC −1 UB−1
where C = A − UB−1 V:
References
[1] A. Burroni, Higher dimensional word problem, Theoret. Comput. Sci. 115 (1993) 43–62.
[2] Y. Lafont, Penrose diagrams and 2-dimensional rewriting, in: M.P. Fourman, P.T. Johnstone, A.M. Pitts
(Eds.), Applications of Categories in Computer Science, LMSLNS, Vol. 177, Cambridge University
Press, Cambridge, 1992, pp. 191–201.
[3] Y. Lafont, Equational reasoning with 2-dimensional diagrams, Term Rewriting, Lecture Notes in
Computer Science, Vol. 909, Springer, Berlin, 1995, pp. 170 –195.
[4] Y. Lafont, A new 3niteness condition for monoids presented by complete rewriting systems (after Craig
C. Squier), J. Pure Appl. Algebra 98 (1995) 229–244.
[5] Y. Lafont, A. ProutRe, Church–Rosser property and homology of monoids, Mathematical Structures in
Computer Science, Vol. 1 (3), Cambridge University Press, Cambridge, 1991, pp. 297–326.
[6] F.L. Lawvere, Functorial semantics of algebraic theories, Proceedings of the Natural Academy of
Science, USA, 1963.
[7] S. Mac Lane, Categories for the Working Mathematician, Vol. GTM 5, Springer, Berlin, 1971.
[8] A. Massol, Minimality of the system of seven equations for the category of 3nite sets, Theoret. Comput.
Sci. 176 (1997) 347–353.
[9] A. Massol, Calcul symbolique avec des diagrammes de Penrose, ThSese de doctorat, UniversitRe
d’Aix-Marseille II, 1997.
[10] J. Musset, GRenRerateurs et relations pour les circuits boolReens rReversibles, rapport de stage, Institut de
MathRematiques de Luminy, preprint 97-32.
[11] C.C. Squier, Word problems and a homological 3niteness condition for monoids, J. Pure Appl. Algebra
49 (1987) 201–217.
[12] C.C. Squier, F. Otto, Y. Kobayashi, A 3niteness condition for rewriting systems, Theoret. Comput. Sci.
131 (1994) 271–294.