A Categorical Outlook on Cellular Automata
aa r X i v : . [ n li n . C G ] D ec Journ´ees Automates Cellulaires 2010 (Turku), pp. 88-99
A CATEGORICAL OUTLOOK ON CELLULAR AUTOMATA
SILVIO CAPOBIANCO AND TARMO UUSTALUInstitute of Cybernetics at Tallinn University of Technology, Akadeemia tee 21, 12618Tallinn, Estonia
E-mail address : {silvio,tarmo}@cs.ioc.ee Abstract.
In programming language semantics, it has proved to be fruitful toanalyze context-dependent notions of computation, e.g., dataflow computation andattribute grammars, using comonads. We explore the viability and value of similarmodeling of cellular automata. We identify local behaviors of cellular automatawith coKleisli maps of the exponent comonad on the category of uniform spacesand uniformly continuous functions and exploit this equivalence to conclude somestandard results about cellular automata as instances of basic category-theoreticgeneralities. In particular, we recover Ceccherini-Silberstein and Coornaert’s ver-sion of the Curtis-Hedlund theorem.
1. Introduction
Since the seminal work of Moggi [13], it has become standard in programminglanguage semantics to analyze functions producing effects such as exceptions, input,output, interactive input-output, nondeterminism, probabilistic choice, state, con-tinuations using monads. Specifically, effectful functions are identified with Kleislimaps of a suitable monad on the category of pure functions. Wadler [18] put thisview to further use in programming methodology by extracting from it a very usefulprogramming idiom for purely functional languages like Haskell.The dual view of context-dependent functions as coKleisli maps of a comonad isequally useful, but less well known. Brookes and Geva [2] explained the “intensional”aspect of denotational semantics in terms of the ω -chain comonad on the categoryof ω -cpos. More recently, Uustalu and Vene [15, 16, 17] employed comonads toanalyze dataflow computation and attribute grammars and Hasuo et al. [9] treatedtree transducers.Characteristic of many context-dependent notions of computation is shape-preserving transformation of some datastructure based on a value update rule whichis local in nature and applied uniformly to every node. This is the case with dataflowcomputation where such a transformation is applied to a list or to a stream with adistinguished position and with attribute grammars where computation happens ona tree or a tree with a distinguished position (a “zipper”). Cellular automata are This research was supported by the European Regional Development Fund (ERDF) throughthe Estonian Center of Excellence in Computer Science (EXCS) and by the Estonian ScienceFoundation under grant no. 6940.
88 CATEGORICAL OUTLOOK ON CELLULAR AUTOMATA 89 similar, the datastructure being the integer line or plane or, more generally, a group.It should therefore be worthwhile to test the slogan that context-dependent compu-tation is comonadic also on cellular automata. To a degree, this has already beendone, as Piponi [14] programmed cellular automata in Haskell using the comonadicinterface. However, he did not use his modeling of cellular automata to prove prop-erties about them and also dropped the classical requirement that cellular automatarely on a finite neighborhood only.In this paper, we study the comonadic aspect of cellular automata deeper. Weidentify cellular automata (more exactly their local behaviors) with coKleisli mapsof the exponent monad on
Unif , the category of uniform spaces and uniformlycontinuous functions, and explore whether this view can be useful. We see that itis: we can conclude some standard results about cellular automata as instances ofcategory-theoretic generalities. In particular, we recover the Curtis-Hedlund theo-rem [10]—a characterization of global behaviors of cellular automata—in the versionof Ceccherini-Silberstein and Coornaert [4] (this applies to general discrete alpha-bets rather than finite alphabets only). This theorem turns out to be an instance ofthe basic category-theoretic fact that the coKleisli category of a comonad is isomor-phic to the full subcategory of its co-Eilenberg-Moore category given by the cofreecoalgebras. We also show that the comonadic view allows one to see 2-dimensionalcellular automata as 1-dimensional and treat point-dependent cellular automata.The paper is organized as follows. Section 2 is a quick introduction to comonadswhile Section 3 reviews some preliminaries about topological and uniform spaces. InSection 4, we show that cellular automata local behaviors are the same as coKleislimaps of a certain comonad. In Section 5, we recover the Curtis-Hedlund theorem(in the version of Ceccherini-Silberstein and Coornaert). In Section 6, we reprovethe reversibility principle. In Sections 7, 8, we discuss some further applications ofthe comonadic view: 2-dimensional cellular automata as 1-dimensional and point-dependent cellular automata.The paper assumes knowledge of basic category theory (categories, functors,natural transformations, Cartesian closed categories), but is self-contained in re-gards to comonads. For background material on category theory and (co)monads inparticular, we refer the reader to Barr and Wells [1, Ch. 1, 3]. We also assume thebasics of ca as presented by Ceccherini-Silberstein and Coornaert [5, Ch. 1].
2. Comonads
Given two categories C , D and a functor L : D → C , a right adjoint to L is givenby a functor R : C → D and two natural transformations ε : LR → Id C (the counit )and η : Id D → RL (the unit ) such that the diagrams L Lη / / FFFFFFFFF FFFFFFFFF
LRL εL (cid:15) (cid:15) L R ηR (cid:15) (cid:15) GGGGGGGGG GGGGGGGGG
RLR Rε / / R commute. Equivalently, a right adjoint may be given by an object mapping R : |C| → |D| , for any object A ∈ |C| , a map ε A : LRA → A , and, for any objects A ∈ |D| , B ∈ |C| and map k : LA → B , a map k ‡ : A → RB (the right transpose )such that • for any objects A ∈ |D| , B ∈ |C| , and map k : LA → B , ε B ◦ Lk ‡ = k , • for any object A ∈ |C| , ( ε A ) ‡ = id RA , • for any objects A, B ∈ |D| , C ∈ |C| and maps f : A → B , k : LB → C ,( k ◦ Lf ) ‡ = k ‡ ◦ f .The morphism mapping part of R and unit η define the right transpose of k : LA → B by k ‡ = df Rk ◦ η A . The right transpose ( − ) ‡ determines the morphism mappingpart of R and unit η by Rf = df ( f ◦ ε A ) ‡ , for f : A → B , and η A = df (id LA ) ‡ .A comonad on a category C is given by a functor D : C → C and naturaltransformations ε : D → Id C (the counit ) and δ : D → DD (the comultiplication )making the diagrams D δ / / δ (cid:15) (cid:15) HHHHHHHHH HHHHHHHHH DD εD (cid:15) (cid:15) DD Dε / / D D δ / / δ (cid:15) (cid:15) DD δD (cid:15) (cid:15) DD Dδ / / DDD commute. Equivalently, a comonad can be given by an object mapping D : |C| → |C| ,for any object A ∈ |C| , a map ε A : DA → A , and, for any objects A, B ∈ |C| andmap k : DA → B , a map k † : DA → DB (the coKleisli extension ) such that • for any objects A, B ∈ |C| and map k : DA → B , ε B ◦ k † = k , • for any object A , ( ε A ) † = id DA , • for any objects A, B, C ∈ |C| and maps k : DA → B , ℓ : DB → C , ( ℓ ◦ k † ) † = ℓ † ◦ k † .The morphism mapping part of D and comultiplication δ define the coKleisli ex-tension ( − ) † by k † = df Dk ◦ δ A . Conversely, the ( − ) † determines the morphismmapping part of D and comultiplication δ by Df = df ( f ◦ ε A ) † , δ A = df (id DA ) † .A functor L : C → D with a right adjoint (
R, ε, η ), defines a comonad on C withcounit ε by D = df LR , δ = df LηR , alternatively by DA = df L ( RA ), k † = df Lk ‡ .In the converse direction, a comonad ( D, ε, δ ) on C induces a whole category ofadjunctions ( D , L, R, η ) that have ε as the counit and satisfy D = LR , δ = LηR ,called splittings of the comonad. This category has initial and final objects, whichare known as the coKleisli and coEilenberg-Moore splittings of the comonad.The coKleisli category coKl( D ) has as objects those of C and as maps from A to B those from DA to B of C . The identity jd A on object A is defined byjd A = df ε A . The composition ℓ • k of maps k : DA → B and ℓ : DB → C is ℓ • k = df ℓ ◦ Dk ◦ δ A = ℓ ◦ k † . The functor L : coKl( D ) → C in the coKleisli splittingis defined by LA = df DA , Lk = df k † . The right adjoint, unit and right transposeare defined by RA = df A , Rf = df f ◦ ε A , η A = df id DA , k ‡ = df k .The coEilenberg-Moore category coEM( D ) has as objects coalgebras of D andas maps coalgebra maps of D . A coalgebra of D is given by an object A ∈ |C| andmap u : A → DA (the coalgebra structure ) making the diagrams A u / / EEEEEEEE EEEEEEEE DA ε A (cid:15) (cid:15) A A u / / u (cid:15) (cid:15) DA δ A (cid:15) (cid:15) DA Du / / D ( DA ) CATEGORICAL OUTLOOK ON CELLULAR AUTOMATA 91 commute. A coalgebra map between (
A, u ) and (
B, v ) is a map f : A → B makingthe diagram A u / / f (cid:15) (cid:15) DA Df (cid:15) (cid:15) B v / / DB commute. The identity and composition are inherited from C . The functor L :coEM( D ) → C in the splitting of D through coEM( D ) is the coalgebra-structureforgetful functor: L ( A, u ) = df A , Lf = df f . The right adjoint R is defined by RA = df ( DA, δ A ), Rf = df Df . The unit and right transpose are defined by η ( A,u ) = df u and k ‡ = df Dk ◦ u (for k : L ( A, u ) → B ).The functor R being the right adjoint of the forgetful functor implies that, forany B , the coalgebra RB = ( DB, δ B ) is the cofree coalgebra on B , i.e., for anycoalgebra ( A, u ), object B and map k : A → B , there is a unique map f : A → DB ,namely k ‡ , such that the diagrams A k } } zzzzzzzz u / / f (cid:15) (cid:15) DA Df (cid:15) (cid:15) B DB ε B o o δ B / / D ( DB )commute.The unique splitting map between the coKleisli and coEilenberg-Moore splittingis the functor E : coKl( D ) → coEM( D ) defined by EA = df ( DA, δ A ), Ek = df Dk ◦ δ A = k † . This functor is a full embedding. The image of E is the full subcategoryof coEM( D ) given by the cofree coalgebras that is therefore isomorphic to coKl( D ).A simple and instructive example of a comonad and its coKleisli and coEilenberg-Moore splittings is given by the reader (or product ) comonad . It is defined on anycategory C with finite products, but let us choose C to be Set (or
Top or Unif ),so we can write pointwise definitions for intuitiveness. Given some fixed object C ∈ |C| , it is defined by DA = df A × C , Df ( x, c ) = df ( f ( x ) , c ), ε A ( x, c ) = df x , δ A ( x, c ) = df (( x, c ) , c ), k † ( x, c ) = df ( k ( x, c ) , c ).The coKleisli category has as objects those of C and as maps from A to B thosefrom A × C to B . The identities and composition are defined by jd( x, c ) = df x ,( ℓ • k )( x, c ) = df ℓ ( k ( x, c ) , c ).A coalgebra of D is given by an object A and a map u : A → A × C satisfyingthe laws of a coalgebra. Let us define ( u ( x ) , u ( x )) = df u ( x ). The laws impose that u ( x ) = x and (( u ( x ) , u ( x )) , u ( x )) = ( u ( u ( x )) , u ( x )). The first law defines u and the second becomes a tautology as soon as this definition is substituted intoit. Hence, a coalgebra is effectively the same as an object A with an unconstrainedmap u : A → C .A map between D -coalgebras ( A, u ), (
B, v ) is a map f : A → B such that( f ( u ( x )) , u ( x )) = ( v ( f ( x )) , v ( f ( x ))), which boils down to u ( x ) = v ( f ( x )).The coEilenberg-Moore category has thus as objects pairs of an object A andmap u : A → C and a map between ( A, u ), ( B, v ) is map f : A → B suchthat u ( x ) = v ( f ( x )). The cofree coalgebra on A is the pair ( A × C, δ A ) where δ A ( x, c ) = df c .The isomorphism between coKl( D ) and the category of cofree D -coalgebrasestablishes a 1-1 correspondence between maps k : A × C → B and maps f : A × C → B × C such that δ B ( f ( x, c )) = c .
3. Exponentials, topologies, and uniformities
Given an object C in a category C with finite products, it is said to be expo-nentiable if the functor ( − ) × C has a right adjoint. This amounts to the existence,for any object A , of an object A C (the exponential ) and map ev A : A C × A → C (the evaluation ) as well as, for any objects A , B and map k : A × C → B , a map cur ( k ) : A → B C (the currying of k ) satisfying appropriate conditions. If every ob-ject of C is exponentiable, it is called Cartesian closed . Intuitively, exponentials areinternalized homsets. In
Set , every object C is exponentiable and the exponential A C is the set of all functions from C to A .Things are somewhat more complicated in the category Top of topologicalspaces, as the exponential A C is to be the set of continuous functions from C to A ,but it must also be given a topology. Moreover, the evaluation ev A : A C × A → C must be continuous and the currying cur ( k ) : A → B C of a continuous functionmust be continuous.Not every topological space is exponentiable. Hausdorff spaces are exponentiableif and only if they are locally compact: in this case, the exponential topology on thespace of continuous functions from C to A is the compact-open topology generatedby the sets { f : C → A | f ( K ) ⊆ U } with K compact in C and U open in A [7, 8]. In particular, discrete spaces are exponentiable (which also follows fromthe discrete topology making every function from it continuous) and their compact-open topology is in fact the product topology.That not all objects can act as exponents is also true in the category Unif of uniform spaces whose constituents we now define. A uniform space is a set A endowed with a uniformity , i.e., a collection U of binary relations on A (called entourages ) satisfying the following properties:(1) ∆ ⊆ U for every U ∈ U , where ∆ = { ( x, x ) | x ∈ A } is the diagonal .(2) If U ⊆ V and U ∈ U then V ∈ U .(3) If U, V ∈ U then U ∩ V ∈ U .(4) If U ∈ U then U − ∈ U .(5) If U ∈ U then V = { ( x, y ) | ∃ z | ( x, z ) , ( z, y ) ∈ V } ⊆ U for some V ∈ U .The simplest non-trivial uniformity on A is the discrete uniformity , made of all thesupersets of the diagonal. A uniformity induces a topology as follows: Ω ⊆ A is openif and only if, for every x ∈ Ω, there exists U ∈ U such that { y ∈ A | ( x, y ) ∈ U } ⊆ Ω . Such topology is Hausdorff if and only if T U ∈U U = ∆ . The discrete uniformityinduces the discrete topology, but is not the only one that does (cf. [11, I-5]), i.e.,uniform spaces may be discrete without being uniformly discrete .A map f : A → B between uniform spaces is uniformly continuous (briefly, u.c.)if, for every entourage V on B , there is an entourage U on A such that ( f × f )( U ) ⊆ V . Any u.c. function is continuous in the topology induced by the uniformities:the converse is true if A is compact [11, II-24] but false in general even for metricspaces. The product uniformity is the coarsest uniformity that makes the projectionsuniformly continuous: the topology induced by the product uniformity is the producttopology. A product of discrete uniformities is called prodiscrete .In Unif , uniformly discrete objects are exponentiable [11, III.19 and III.21].Again, the reason is that every function from C is u.c. as soon as C is uniformlydiscrete. CATEGORICAL OUTLOOK ON CELLULAR AUTOMATA 93
4. Cellular automata as coKleisli maps
Classically, a cellular automaton on a monoid ( G, G , · ) (the universe ) and set A (the alphabet ) is given by a finite subset N of G (the support neighborhood ) andfunction d : A N → A (the transition rule ).Any cellular automaton induces a local behavior k : A G → A via k ( c ) = df d ( c | N ).One speaks of elements A N of finite subsets N ⊆ G as patterns and elementsof A G as configurations . Transition rules work on patterns, local behaviors on con-figurations. Cellular automata that induce the same local behavior are consideredequivalent. In this paper, we will not distinguish between equivalent cellular au-tomata, hence we can identify cellular automata with their local behaviors.If the alphabet A is finite, a function k : A G → A is a local behavior (i.e., thelocal behavior of some cellular automaton) if and only if it is continuous for thediscrete topology on A and the product topology on A G .In the general case (where A may be infinite), the above equivalence does notgenerally hold, but a refinement does. A function k : A G → A is then a localbehavior iff it is uniformly continuous for the discrete uniformity on A and productuniformity on A G . The finite case becomes an instance: if A is finite, then A G iscompact and therefore any continuous function k : A G → A is uniformly continuous.Based on these observations, we henceforth take it as a definition that a localbehavior on a set (the alphabet) A is a uniformly continuous function k : A G → A wrt. the prodiscrete uniformity on A G and forget about the definition of cellularautomata in terms of a support neighborhood and a transition rule.Any local behavior k induces a global behavior k † : A G → A G , a map betweenconfigurations, via k † ( c )( x ) = df k ( c ⊲ x ) where ⊲ : A G × G → A G (the translation of configurations) is defined by ( c ⊲ x )( y ) = df c ( x · y ) The translation is a uni-formly continuous function. It follows that the global behavior k † is also uniformlycontinuous.Local behaviors on a fixed universe G and fixed alphabet A form a monoid withunit jd given by jd( c ) = df c (1 G ) and multiplication • given by ℓ • k = df ℓ ◦ k † . Indeed,it is easy to see that jd is uniformly continuous and • preserves uniform continuity(because ( − ) † does) and the monoid laws turn out to hold too.We now make two small generalizations and make a richer category out of localbehaviors: after all, a monoid is a category with one object. First, we do not insistthat the alphabet be a discrete uniform space, it may be any uniform space. Andsecond, we give up the idea of a fixed alphabet: we let the local behavior change thealphabet.For a fixed monoid G (the universe), we redefine a local behavior between twogeneral uniform spaces (the source and target alphabets) A and B to be a uniformlycontinuous function k : A G → B where A G is given the product uniformity.Local behaviors now make a category that has as objects alphabets and asmaps local behaviors between them. The identity on A is jd A : A G → A given byjd A ( c ) = df c (1 G ) and the composition ℓ • k : A G → C of two maps k : A G → B Instead of the monoid, one usually takes a group in the cellular automata literature. But wedo not need inverses in this paper. The alphabet is often required to be finite. We make this assumption only where we need it. (Cf. [5, Th. 1.9.1]) Every entourage of the prodiscrete uniformity contains an entourage of theform V N = { ( c, e ) | c | N = e | N } with N ⊆ G finite. If k : A G → A is u.c. with A uniformly discrete,then ( k × k )( V N ) ⊆ ∆ for some finite N ⊆ G : thus, k ( c ) only depends on c | N . and ℓ : B G → C given by ℓ • k = df ℓ ◦ k † where k † : A G → B G is defined by k † ( c )( x ) = df k ( c ⊲ A x ) from ⊲ A : A G × G → A G defined by ( c ⊲ A x )( y ) = df c ( x · y ).Notice that these definitions coincide exactly with those we made for the monoid oflocal behaviors above, except that local behaviors can now mediate between differentalphabets that need not be uniformly discrete. The function jd A is still uniformlycontinuous for any A and the operation • preserves uniform continuity.While the generalized definition of local behaviors is more liberal than the clas-sical one, it is conservative over it in the following sense: The local behaviors fromany uniformly discrete space A back to itself are exactly the classical local behaviorson A seen as a set.We will now recover our category of local behaviors from a categorical generality,by showing that it is a straightforward instance of the coKleisli construction for acomonad.Any fixed monoid ( G, G , · ) determines a comonad ( D, ε, δ ) on
Unif (in fact,on any category where the carrier G is exponentiable, so also, e.g., on Set and
Top ) (the cellular automata or exponent comonad ) as follows. The object mappingpart of D is defined by DA = df A G , where A G is the G -exponential of A , i.e., thespace of uniformly continuous functions from G to A equipped with the prodiscreteuniformity. The morphism mapping part is defined by Df = df f G , i.e., Df ( c ) = df f ◦ c . The components of the counit ε A : A G → A and comultiplication δ A : A G → ( A G ) G are defined by ε A ( c ) = df c (1 G ) and δ A ( c )( x ) = df c ⊲ A x (so that δ A ( c )( x )( y ) = c ( x · y )); these functions are uniformly continuous. The general definition of thecoKleisli extension ( − ) † via the morphism mapping part of D and comultiplication δ tells us that k † ( c )( x ) = Dk ( δ A ( c ))( x ) = k ( δ A ( c )( x )) = k ( c ⊲ A x ).The laws of a comonad are proved from the monoid laws for G by the followingcalculations (we omit the proofs of the naturality conditions of ε and δ ). ε DA ( δ A ( c ))( x ) = δ A ( c )(1 G )( x ) = c (1 G · x ) = c ( x ) c ( x ) = c ( x · G ) = δ A ( c )( x )(1 G ) = ε A ( δ A ( c )( x )) = Dε A ( δ A ( c ))( x ) δ DA ( δ A ( c ))( x )( y )( z ) = δ A ( c )( x · y )( z ) = c (( x · y ) · z )= c ( x · ( y · z )) = δ A ( c )( x )( y · z ) = δ A ( δ A ( c )( x ))( y )( z ) = Dδ A ( δ A ( c ))( x )( y )( z )As we have seen, a comonad on a category always defines two canonical splittingsof its underlying functor into two adjoint functors. The coKleisli splitting of ourcomonad D on Unif goes via the coKleisli category which has as objects those of
Unif and as maps from A to B those from DA to B in Unif . The identity on A is jd A = df ε A and the composition of k and ℓ is ℓ • k = df ℓ ◦ k † . Note that theseare exactly the data of the category of local behaviors that we introduced above.But this time we do not have to prove that the unital and associativity laws of thecategory hold. Our proof obligations went into establishing that the comonad dataare well defined and the comonad laws hold.
5. Retrieving the Curtis-Hedlund theorem
Let (
D, ε, δ ) be the G -exponential comonad on Unif for a given monoid ( G, G , · ),with G endowed with the discrete uniformity, as introduced in the previous section.As we know from Section 2, coKl( D ) is equivalent to the category of cofree D -coalgebras under a comparison functor E that sends a coKleisli map (local behavior) k : DA → B to the cofree coalgebra map k † : ( DA, δ A ) → ( DB, δ B ), which, as a CATEGORICAL OUTLOOK ON CELLULAR AUTOMATA 95 map of
Unif , we know to be the corresponding global behavior. Hence, a map f : DA → DB would be a global behavior if and only if f is a cofree coalgebra map.Now, given an arbitrary comonad, it is usually of interest to study its generalcoalgebras and not only the cofree ones. We too follow this thumb rule.By definition, objects in coEM( D ) are pairs of objects A and maps u : A → DA in Unif satisfying A u / / IIIIIII IIIIIII A Gε A (cid:15) (cid:15) A A u / / u (cid:15) (cid:15) A Gδ A (cid:15) (cid:15) A G u G / / ( A G ) G In our case, the first equation simply means u ( a )(1 G ) = a while the second onesimplifies to u ( a )( x · y ) = u ( u ( a )( x ))( y ) . This writing, however, is cumbersome andunexplicative.To see more, we uncurry u : A → A G to ⊗ : A × G → A, so that a ⊗ x = u ( a )( x ) . Then the two equations become a ⊗ G = a, and a ⊗ ( x · y ) = ( a ⊗ x ) ⊗ y. Diagrammatically, this is to require commutation of A ρ A / / VVVVVVVVVVVVVVVVVVVVV VVVVVVVVVVVVVVVVVVVVV A × A × G / / A × G ⊗ (cid:15) (cid:15) A ( A × G ) × G α A,G,G / / ⊗× G (cid:15) (cid:15) A × ( G × G ) A × ( · ) / / A × G ⊗ (cid:15) (cid:15) A × G ⊗ / / A where ρ and α are the right unital and associative laws of the product monoidalstructure. But these are precisely the laws of a (right) action of G on A (where A is a uniform space, so we expect an action to also be uniformly continuous).Let us now consider coalgebra maps. A map f : ( A, u ) → ( B, v ) in coEM( D )is a map in Unif that commutes with u and v or (which is equivalent) with theiruncurried forms ⊗ and ⊘ as shown on the left and right diagrams below, respectively: A u / / f (cid:15) (cid:15) A Gf G (cid:15) (cid:15) B v / / B G A × G ⊗ / / f × G (cid:15) (cid:15) A f (cid:15) (cid:15) B × G ⊘ / / B Clearly, coalgebra maps are just action maps.We are now ready to consider maps of cofree D -coalgebras. The uncurriedform of δ A : A G → ( A G ) G is ⊲ A : A G × G → A G . By what we have shown,a map f : A G → B G in Unif is a map between ( A G , δ A ) and ( B G , δ B ) if andonly if f ( c ⊲ A x ) = ( f ( c ) ⊲ B x ). We see that maps between the cofree coalgebras( A G , δ A ) and ( B G , δ B ) are precisely those maps f : A G → B G that commute withthe translation!With our reasoning, we have reproved the version of Curtis-Hedlund theoremgiven by Ceccherini-Silberstein and Coornaert ([4, Th. 1.1], [5, Th. 1.9.1]): globalbehaviors between uniform spaces A and B are those uniformly continuous functionsbetween the product uniformities on A G and B G that commute with the transla-tion. Keep in mind that we are allowing arbitrary uniform spaces as alphabets, andspeaking of global behaviors in the sense of Section 4. It is, however, immediate tospecialize to the statement of C.-S. and C. by requiring A and B to be uniformlydiscrete. Then local behaviors are precisely the finitary functions from A G to B .The original Curtis-Hedlund theorem ([10], [5, Th. 1.8.1]) corresponds to thespecial case where A is finite and discrete. In this case, A G is compact and anycontinuous function between A G and B G is then uniformly continuous. We conclude, in this case, that global behaviors between A to B are those continuous functionsbetween the product topologies on A G and B G that commute with the translation.We have seen that the cofree coalgebra ( B G , δ B : B G → ( B G ) G ) on B is thecurrying of the translation action ( B G , ⊲ B : B G × G → B G ). Because of thecofreeness on B of this coalgebra, the action must also be the cofree.In basic terms, this means that for any action ( A, ⊗ : A × G → A ) and map p : A → B , there is a unique action morphism f to the translation action such that ε B ◦ f = p , i.e., a map f : A → B G such that the following diagrams commute: A × G ⊗ / / f × G (cid:15) (cid:15) A p $ $ HHHHHHH f (cid:15) (cid:15) B G × G ⊲ B / / B G ε B / / B This fact can of course be proved from first principles, but we learned it for free!
6. Retrieving the reversibility principle
We will now recover the reversibility principle. Let again ( G, G , · ) be a monoidand ( D, ε, δ ) be the G -exponential comonad on Unif as introduced in Section 4.Suppose we have a cofree coalgebra map f : ( DA, δ A ) → ( DB, δ B ) so that f hasan inverse f − as a map of Unif .A very simple diagram chase (not specific to our particular comonad; we onlyuse that D is a functor!) shows that f − is also a cofree coalgebra map, i.e., aninverse of f in coEM( D ): DA δ A / / f (cid:15) (cid:15) D ( DA ) Df (cid:15) (cid:15) D ( DA ) DB f − : : ttttttt DB δ B / / D ( DB ) Df − nnnnnnn We have thus reproved the reversibility principle [5, Th. 1.10.1]: A global behav-ior f : A G → B G (a uniformly continuous function commuting with the translation)between uniform spaces A , B is reversible if f has a uniformly continuous inverse.If both A and B are finite and discrete, an inverse f − of f is necessarily uni-formly continuous, because, in this case, A G and B G are compact Hausdorff and f − is continuous. So we obtain a special case [5, Th. 1.10.2]: A global behavior f : A G → B G (a continuous function commuting with the translation) betweenuniform spaces A , B is reversible if f has an inverse.In general, an inverse of a uniformly continuous function is not necessarily uni-formly continuous. For a counterexample, see [5, Example 1.10.3].For reversibility, it is useful, if the monoid G is actually a group. In particular,for reversibility of δ A : DA → D ( DA ), G must be a group.
7. Distributive laws and 2-dimensional cellular automata
We will now proceed to two variations on the theme of cellular automata as co-Kleisli maps—2-dimensional (classical) cellular automata and point-dependent cellu-lar automata. In both cases we first introduce some further comonad theory relevantfor our cause.
CATEGORICAL OUTLOOK ON CELLULAR AUTOMATA 97
Sometimes, but not always, the composition D D of two comonads D and D on the same category C is a comonad. It is the case, if there is a distributive law of D over D . A distributive law of a comonad ( D , ε , δ ) over a comonad ( D , ε , δ )is a natural transformation κ : D D → D D making the diagrams D D κ / / D ε GGGGG D D ε D { { D D D κ / / D δ (cid:15) (cid:15) D D δ D (cid:15) (cid:15) D D D κD / / D D D D κ / / D D D D D κ / / ε D GGGGG D D D ε { { D D D κ / / δ D (cid:15) (cid:15) D D D δ (cid:15) (cid:15) D D D D κ / / D D D κD / / D D D commute. A distributive law induces a comonad ( D, ε, δ ) defined by D = df D D , ε = df ε ε , δ = df D κD ◦ δ δ .A distributive law also induces comonad liftings. For the lack of space, weconcentrate on the coKleisli side of the picture. Given a distributive law κ of D over D , the comonad D on C lifts to coKl( D ), i.e., induces a comonad ¯ D on coKl( D ).This comonad is defined by: ¯ D A = df D A , ¯ D k = df D k ◦ κ A : D D A → D B (for k : D A → B ), ε A = df ε A ◦ ε D A , δ A = df δ A ◦ ε D A .Via this lifting, the coKleisli category of the composite comonad D and theother ingredients of the coKleisli splitting of D can be obtained by a double coKleisliconstruction: We have coKl( D ) = coKl( ¯ D ) (equal strictly, not just isomorphic).A simple example of a distributive law is obtained by taking D to be anycomonad and D the product comonad defined by D A = df A × C for a fixed object C ∈ |C| . The distributive law κ of D over D is given by κ A = df h D π , ε ◦ D π i : D ( A × C ) → D A × C . It follows that the functor D defined by DA = df D ( A × C )is a comonad.Given now two monoids G , G , we can think of a map k : ( A G ) G → B in Unif as a “2-dimensional” (2D) cellular automaton on the universes G , G betweenalphabets A and B (relying on the isomorphism A G × G ∼ = ( A G ) G ).Such a cellular automaton is by definition the same thing as a “1-dimensional”(1D) cellular automaton on the universe G between alphabets A G and B . Notethat we can only see 2D cellular automata as 1D in this way, if we allow source andtarget alphabets of a cellular automaton to differ and if we do not require them tobe uniformly discrete (notice that A G carries the prodiscrete uniformity). But thisview of 2D cellular automata as 1D, although nice, suffers from a serious drawback.Since the 1D views do not have the same source alphabets as the 2D originals, theydo not compose the same way.Distributive laws come to help. Let D A = df A G and D A = df A G . Thereis a distributive law κ : D D → D D defined by κ A ( c )( x )( x ) = c ( x )( x ) :( A G ) G → ( A G ) G . Hence, the functor DA = df ( A G ) G is a comonad, which ishardly a surprise. But there is more: We know that coKl( D ) = coKl( ¯ D ). Hence,a good view of k : ( A G ) G → B as a 1D cellular automaton is not as a Unif -cellular automaton on the universe G between the alphabets A G and B , but on asa coKl( D )-cellular automaton on the universe G between the alphabets A and B .Then 1D views compose exactly as their 2D originals. We see that it makes senseto consider maps of categories other than Unif !1D views of 2D cellular automata were of interest to Dennuzio et al. [6]
8. Comonad maps and point-dependent cellular automata
To make a category out of comonads over a fixed category C one needs a suitablenotion of comonad maps. A comonad map between two comonads ( D, ε, δ ) and( D ′ , ε ′ , δ ′ ) on C is a natural transformation τ : D → D ′ making the diagrams D ε ( ( QQQQQQ τ (cid:15) (cid:15) Id C D ′ ε ′ nnnnnn D δ / / τ (cid:15) (cid:15) DD ττ (cid:15) (cid:15) D ′ δ ′ / / D ′ D ′ commute. Comonads and comonad maps on C form a category. The identity andcomposition of comonad maps is inherited from the category of natural transforma-tions between endofunctors on C .A comonad map τ between ( D, ε, δ ) and ( D ′ , ε ′ , δ ′ ) relates the coKleisli andcoEilenberg-Moore categories between the two comonads. It defines a functor fromcoKl( D ′ ) to coKl( D ) and a functor from coEM( D ) to coEM( D ′ ).We now introduce point-dependent cellular automata (studied under the nameof non-uniform cellular automata by Cattaneo et al. [3]). For a set G , the localbehavior of a point-dependent cellular automaton between uniform spaces A , B isa uniformly continuous function k : A G × G → B . Note the added second argumentcompared to the definition of a classical local behavior.It turns out that local and global behaviors of point-dependent cellular automatacan be analyzed in the same way as those of classical cellular automata. In particular,their local behaviors are the same thing as coKleisli maps of a suitable comonad( D, ε, δ ) on
Unif and global behaviors are the corresponding cofree coalgebra maps!Let us review the data of the comonad. The object mapping of D is defined by DA = df A G × G and the morphism mapping by Df = df f G × G , i.e., Df ( c, x ) = df ( λy.f ( c ( y )) , x ). The components of the counit and comultiplication ε A : A G × G → A and δ A : A G × G → ( A G × G ) G × G are defined by ε A ( c, x ) = df c ( x ), δ A ( c, x ) =( λy. ( c, y ) , x ). Accordingly, the coKleisli extension k † : A G × G → B G × G of a map k : A G × G → B is forced to satisfy k † ( c, x ) = Dk ( δ ( c, x )) = Dk ( λy. ( c, y ) , x ) =( λy.k ( c, y ) , x ).When is a map f : A G × G → B G × G a global behavior? It is a global behavioriff it is a cofree coalgebra map. Not surprisingly at all, the conditions for f beinga cofree coalgebra map reduce to the condition that f ( c, x ) = ( g ( c ) , x ) for some g : A G → B G .Assume G is endowed with a monoid structure (1 G , · ). Let ( D ′ , ε ′ , δ ′ ) be thecomonad of classical cellular automata. The translation ⊲ is a comonad map from D to D ′ . Accordingly, any classical local behavior is also a point-dependent localbehavior that simply makes no use the point information that is available.
9. Conclusions
It was not the purpose of this paper to prove deep or difficult theorems. Rather,we set out to experiment with definitions. We deem that this experiment succeeded.We were pleased to learn that, from the category-theoretic point-of-view, cellularautomata are a “natural” construction with “natural” properties. Crucially, clas-sical cellular automata are coKleisli maps of the exponential comonad on
Unif ,and it is harmless to accept alphabets with nondiscrete uniformities and variation
CATEGORICAL OUTLOOK ON CELLULAR AUTOMATA 99 of alphabets, once it has been decided that local behaviors are uniformly contin-uous functions. But other base categories can be useful too, as the example of2-dimensional cellular automata as 1-dimensional shows.We hope to be able to extend this work to cover more results of cellular automatatheory, in particular results toward the Garden of Eden theorem.
Acknowledgments.
We are grateful to Jarkko Kari and Pierre Guillon for comments.
References [1] Barr, M. and Wells, C. (1983)
Toposes, Triples and Theories . Grundlehren der math. Wis-senschaften . Springer. // Revised and corrected electronic version (2005).
Reprints inTheory and Appl. of Categ. , 1–287.[2] Brookes, S. and Geva, S. (1992) Computational comonads and intensional semantics. In Four-man, M. P., Johnstone, P. T., and Pitts, A. M., eds., Applications of Categories in ComputerScience , London Math. Society Lect. Note Series , 1-44. Cambridge Univ. Press.[3] Cattaneo, G., Dennunzio, A. Formenti, E., and Provillard, J. (2009) Non-uniform cellularautomata. In Dediu, A. H., Ionescu, A.-M., and Mart´ın-Vide, C., eds.,
Proc. of 3rd Int. Conf.on Languages and Automata Theory and Applications, LATA 2009 (Tarragona, Apr. 2009) , Lect. Notes in Comput. Sci. , 302–313. Springer.[4] Ceccherini-Silberstein, T. and Coornaert, M. (2008) A generalization of the Curtis-Hedlundtheorem.
Theor. Comput. Sci. (1–3), 225–229.[5] Ceccherini-Silberstein, T. and Coornaert, M. (2010)
Cellular Automata and Groups , SpringerMonographs in Mathematics . Springer.[6] Dennunzio, A. and Formenti, E. Decidable properties of 2D cellular automata. (2008) In Ito,M. and Toyama, M., eds.,
Proc. of 12th Int. Conf. on Developments in Language Theory, DLT2008 (Kyoto, Sept. 2008) , Lect. Notes in Comput. Sci. , 264–275. Springer.[7] Escard´o, M. and Heckmann, R. (2001) Topologies on spaces of continuous functions.
Topol.Proc. (2), 545–564.[8] Geroch, R. (1985) Mathematical Physics . University of Chicago Press.[9] Hasuo, I., Jacobs, B., and Uustalu, T. (2007) Categorical views on computations on trees.In Arge, L., Cachin, C., Jurdzinski, T., and Tarlecki, A., eds.,
Proc. of 34th Int. Coll. onAutomata, Languages and Programming, ICALP 2007 (Wroc law, July 2007) , Lect. Notes inComput. Sci. , 619–630. Springer.[10] Hedlund, G. A. (1969) Endomorphisms and automorphisms of the shift dynamical system.
Math. Syst. Theory (4), 320–375.[11] Isbell, J.R. (1964) Uniform Spaces . Am. Math. Soc.[12] Mac Lane, S. (1997)
Categories for the Working Mathematician . Graduate Texts in Mathe-matics . 2nd edition. Springer.[13] Moggi, E. (1991) Notions of computation and monads. Inform. and Comput. (1), 55-92.[14] Piponi, D. “sigfpe” (2006) Evaluation of cellular automata iscomonadic. Entry on the author’s blog, A Neighborhood of Infinity . http://blog.sigfpe.com/2006/12/evaluating-cellular-automata-is.html [15] Uustalu, T. and Vene, V. The essence of dataflow programming. (2006) In Horv´ath, Z., ed., Revised Selected Lectures from 1st Central European Functional Programming School, CEFP2005 (Budapest, July 2005) , Lect. Notes in Comput. Sci. , 135–167. Springer.[16] Uustalu, T. and Vene, V. Comonadic evaluation of attribute grammars. (2006) In van Eekelen,M., ed.,
Trends in Functional Programming 6 , 145–162. Intellect.[17] Uustalu, T. and Vene, V. (2008) Comonadic notions of computation.
Electron. Notes in Theor.Comput. Sci. (5), 263–284.[18] Wadler, P. (1992) The essence of functional programming. In
Conf. Record of 19th Ann. ACMSIGPLAN-SIGACT on Principles of Programming Languages, POPL ’92 , 1–14. ACM Press.
This work is licensed under the Creative Commons Attribution-NoDerivs License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/3.0/http://creativecommons.org/licenses/by-nd/3.0/