Achieving Universal Computations on One-dimensional Cellular Automata Jean-Baptiste Yun`es Laboratoire d’Informatique et Algorithmique, Fondements et Applications (LIAFA), Universit´e Paris Diderot & CNRS, Case 7014, 75205 Paris Cedex 13,
[email protected]
Abstract. We show how natural universal computations can be achieved on one-dimensional cellular automata. That model of computation is obviously Turing complete but how can we effectively program any given computation is far less known. In this paper we are interested in intrinsic universality; we want a CA in which any other CA can be represented and simulated with no intermediate coding relevant to another computation model. The first step is to abstract from the space-time diagram in favor of a more essential dependency graph. Then such dependency graph can be projected on grids. This work shows that grids put forward causality in place of space-time contingencies.
1
Introduction
In this paper, we first exhibit very simple computations on one-dimensional cellular automata, CA. We observe how usual algorithms are fundamentally parallel and can be easily implemented on CA. By observing how information flows during the process we are able to explain how the task of programming on such a model can be done by abstracting the contingencies of the machine — in particular space and time — to a more general concept of causality. This is how the space-time diagram is replaced by a grid. A grid is simply the universal basic dependency graph of any CA and can then realize any CA computation. A simulation is first achieved by the dynamical construction of a grid into the space-time diagram of a CA viewed as the hardware, and by the projection of the space-time diagram of a CA to be simulated into the grid. Universality is then built by injecting the coding of the transition rules of a CA into the whole process.
2 2.1
Examples of Computations Clocking and Subclocking
That first example is probably of no practical use, but will serve us as an illustration of a very simple but fundamental principle for CA programming.
2
Jean-Baptiste Yun`es The construction produces a family of clocks all derived from a main clock. Each successive subclock ticks one tick over two of the previous clock, so that if the main clock is periodic withf period p, on cell i the period will be 2i p. The behavior is quite simple and exactly reflects what one would have done in real life: if someone ticks you, you just have to wait two ticks before ticking yourself as in Fig. 1. In this figure, ticks are represented by black squares.
71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0123456789 (a) p=2
71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 (b) 0123456789 p=6
Fig. 1. Two clocks of period p and their subdivisions. (Time going downward.)
Let us emphasize the nature of the construction. In fact, whatever the first cell produces (regular clocking or not, even if not algorithmically produced), the algorithm produces for each cell a subclock (one tick over two) of the one produced by the previous cell. We distinguish here two important things: – the initial process (what is produced on the first cell); – the iterative process (what is produced from the flow of information transmitted by the previous process). This locality feature is the crux of programming, and the source of modularity.
1D-CA, Grids and Universality Processes are standing against one another: the previous providing inputs for the next. This geometrical construction is the main idea which underlies the concept of grids and leads to a very natural implementation of computation composition.
2.2 From Clocks to Firing Squad Synchronization Solutions In the previous example the construction tightly intermixes the machine and the algorithm realized by the machine. It may seem that the construction is tricky whereas explanations are quite simple. In fact, what really matters is the logic of the construction. The hardware contingencies may be a source of confusion if the logic has not been properly clarified. We now give a much more interesting example. The problem can be stated as the following: Whatever be the length of the line, from an “empty” initial configuration — empty except for the first cell — the transition rules should make all cells enter simultaneously in the same state for the first time. Among the numerous solutions, we focus on one that has interesting properties for our discussion. That solution is due to Mazoyer (see [7]) and is illustrated in Fig. 2.
63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 012345678910 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Fig. 2. Mazoyer’s solution on a line of length 32. (Time going downward.)
What can be observed is that the recursive process uses some kind of clock division process. One can see a kind of period made of three states
3
4
Jean-Baptiste Yun`es that fills the first main triangle, its first subdivision in the second triangle which stands against the first (the frontier is represented by the blank signal), etc. Except for technical details, one can see that the algorithm in this solution is based on a kind of clock division algorithm similar to the previous example. The main difference is that no clock is located on a single cell anymore: each clock has to be realized by some computation that takes place in a dedicated part of the space-time diagram. Each clock runs in a triangle delimited by blank signals. For each clock what exactly happens inside the dedicated zone of other clocks is of no importance, only the communication that takes place at blank signals is meaningful. If it seems odd to the reader that the quiescent state has been used as a signal, this is just a trick used by Mazoyer to optimize the total number of states of his solution. The reader may imagine that this could be another dedicated state. That “frontier” signal is the border of triangles one standing against another. So what makes the real difference in both examples is that in the second one the main direction of any clock (see Sablik [11]) is not vertical but a line with some slope. Further it moves in the space during the computation and uses more and more cells as time grows. These moves constraint the moves of the next subclock, thus producing related speeds of clock moves (they are related in the same way as are their periods).
2.3
Addition and Multiplication
In the previous examples, we started from implemented computations and abstracted them to kinds of blocks of computations together with their geometrical organization. Now we proceed in the converse way. We start with the two elementary arithmetical operations, plus and times, and use them to illustrate how we can organize computations in the space-time diagram of CA.
148 +274 422 (a) Addition
148 ×274 592 =148×4 1 0 36 . =148×70 2 9 6 . . =148×200 4 0 552 (b) Multiplication
Fig. 3. The usual addition and multiplication algorithms
What should be remarked is that in these two algorithms results are produced, on each line, digit by digit and from right to left. This is due to propagation of carries which induces dependencies between digits as illustrated in Fig. 4. A simple rotation of those graphs, as in Fig. 5, shows how these graphs are just space-time diagrams of treillis automata.
1D-CA, Grids and Universality
4
2
2
(a) Addition
5
9
2
1
0
3
6
.
2
9
6
.
.
0
5
5
2
4
(b) Multiplication
Fig. 4. Dependency graphs as treillis automata
. 5
6 4
4
2
0
2
1
9
5
2
0
2
.
6 .
3
5
9
2
Observe that we removed many unnecessary technical details of the algorithms like carry management, value bounding, etc. For more information about this, we refer to [1] for the multiplication and to [8] for these computations in the context of grids.
(a) Addition
(b) Multiplication
Fig. 5. Dependency graphs
One can remark that the dependency graphs we obtain can be projected in the space-time diagram of any CA. There were two approaches to this ˇ question which are due to Cole (see [3]) and Choffrut & Culik (see [2]). Whatever approach is taken, the result is the same and the general idea is the following (from section 5.1 in [8]): It is sufficient to have two independent communication channels to be able to simulate any one-dimensional CA whatever be its neighborhood. Every dependency graph of a CA computation is the Cayley graph of a monoid with two generators and every such Cayley graph can be embedded in a dependency graph. Thus, in a fundamental sense, this means that what really matters is the dependency graph, not the way it is embedded into a CA machine. The programmer must focus on the underlying dependency graph of the computation to be implemented. He/she must formalize it, and the compiler will embed it as needed. Observe that in a dependency graph there is no concept of space or time.
5
6
Jean-Baptiste Yun`es
3
Computing on grids
We previously stressed that what matters is the dependency graph: the implementation should not interfere with the logic. Of course to compute something, one needs to exhibit an adequate embedding of the dependency graph into the space-time diagram of the machine. So a question arises: how can we embed it? A first answer is provided by Cole (see [3]) ˇ and Choffrut & Culik (see [2]) embeddings. These embeddings are just as regular as the Cayley graph is. We want to overcome any physical contingency related to such a regularity: it should be an abstract regularity rather than a physical one given by neighborhoods {−1, +1}, ˇ {0, +1} or {−1, 0} as in Cole and Choffrut & Culik. This leads to the concept of grids: roughly, a grid is any representation — possibly quite irregular — of a treillis. The sole constraint is that any causality in the representation has to be a causality in the implementing machine (i.e. respects the dependency cones). We refer the reader to [10] for question on complexity relative to neighborhood equivalence.
(a) Rational
(b) Irregular
Fig. 6. Different embeddings of a treillis in classical CA. (Time going downward.)
Given a CA with neighborhood {−1, 0, +1} one can construct in this CA many different representations of the dependency graph of a given computation. What does mean construct? A possible informal answer is to draw such a graph in the space-time diagram of the given CA. The generators of the monoid of the dependency graph can be represented by CA signals (see [12]) that meet. Any meeting corresponds to an element of the monoid. Though it is easy to imagine a very regular embedding as shown in Fig. 6(a) (this is called a rational grid since slopes of signals are rationals and constant), it is possible to use more general embeddings as illustrated in Fig. 6(b). Note that any usable embedding must be constructible by a CA with neighborhood {−1, 0, +1} from a finite initial configuration.
1D-CA, Grids and Universality
3.1
Simulation
Suppose that on a given elementary initial configuration (a unique cell not quiescent), the CA G is able to construct a grid as defined in the previous section. Example of such a grid constructor are shown in figures 7(a) and 7(b). Given another CA S to be simulated on its initial configuration IS (an example is shown in Fig. 7(c), it is possible to construct a CA Sim, that is able to embed the space-time diagram of S on IS in the grid constructed by G. Fig. 8 shows how the whole process is done. Fig. 8(a) shows a rational embedding of the space-time diagram of CA of Fig. 7(c). Things are pretty clear when the grid is rational: it is easy to see that each column embeds the trace of the simulated CA. When the grid is irregular, as show in Fig. 8(b), it is much more difficult to see the original space-time diagram, but it is sufficient to remark that one can simply bend the rational embedding as needed.
Initial elementary configuration
(a) G1
(b) G2
Initial configuration
(c) Excerpt of some S computing a sum modulo 2
Fig. 7. Elements of a simulation. (Time going downward.)
In the illustrations, we omit many technical details concerning the relative positionning of the two initial configurations of G and S, we refer the interested reader to [8]. Let us stress that this construction is uniform.
3.2
Universality
To achieve universality it is necessary to be able to inject a coding of the transition rules of the machine to be simulated into the simulating
7
8
Jean-Baptiste Yun`es Initial configuration
Initial configuration
(a) S embedded in G1
(b) S embedded in G2
Fig. 8. Simulation. (Time going downward.)
machine so as to be able to execute any needed transition rule at each node of the grid. In previous embeddings, meeting points correspond to elementary cells of the underlying machine. This can be generalized: a meeting point can be a piece of the underlying space-time diagram. The idea is that in this piece of the space-time diagram any complex computation can be done. In particular, a computation that produces the result of the local transition function of the simulated CA. Such a computation can be, for example, the one by Martin (see [6]) or by Ollinger (see [9]). The injection of the transition rules to the nodes of the grid, can be made by a very similar construction of the injection of the initial configuration of the CA to be simulated.
4
Towards grids
Let us recall the notions of intrinsic universality. The one by Durand & R´ oka, see [5], requires that a single step of an automaton is simulated by a fixed number of steps of another automaton (up to some coding of configurations). The second one by Ollinger, see [9], introduces a grouping operation. These definitions preserve the strong regular nature of CA (either temporal or spatio-temporal regularity). In our work such a regularity can be kept or removed as wanted. In a grid, computations can
1D-CA, Grids and Universality be made asynchronously. This gives a powerful flexibility to implement interesting operations with grids. For example, a composition is easy to obtain. It is sufficient to distort two computations such that outputs of one of the computations correspond to inputs of the other. Moreover, as any treillis distortion is a suitable grid (remind that this means that the distortion respects causality of the machine), one can even imagine dynamic distortions, i.e. distortions driven by another computation or by the computation itself. A simple example of the latter could be obtained when output bits of a computation are located on some non regular frontier. Then, any computation can stand against it, thereof uses an irregular border as its inputs and thus computes on a dynamic grid. Thus, when programming some function, it is no more necessary to output bits of results along some regular frontier. Whatever way the output is generated, the computation can be injected on a grid as it is, and even combined into a composition. In some way, this leads to computations that synthesize their circuits during their runs. The general schema does not require any regularity. What is essential is to focus on causality. Afterall, this is the only unavoidable feature in computing: if you want a machine to execute a program, the causalities induced by the machine must be compatible with the causalities expressed by the program.
Acknowledgments The author would like to thank Pr. Jacques Mazoyer for all his helpful and constructive discussions on the topic and also Pr. Serge Grigorieff who generously reviewed the draft of this paper.
References 1. A. J. Atrubin. A one-dimensional real-time iterative multiplier. IEEE Transactions on Electronic Computers, Vol. 14, pp. 394–399, 1965. ˇ 2. Christian Choffrut and Karel Culik II. On real-time cellular automata and trellis automata. Acta Informatica, Vol. 21, pp. 393– 407, 1984. 3. Stephen N. Cole. Real-time computation by n-dimensional iterative arrays of finite-states machines. IEEE Transactions on Computers, Vol. C-18/4, pp. 349–365, 1969. 4. Marianne Delorme, Jacques Mazoyer. Cellular Automata: A Parallel Model. Mathematics and Its Applications, Vol. 460. Kluwer Academic Publishers, 1999. isbn 0-7923-5493-1. 5. Bruno Durand, Zsuzanna R´ oka. The Game of Life: universality revisited. Cellular automata, Saissac, 1996, Kluwer Acad. Publ., Dordrecht, 1999, pp. 51–74. 6. Bruno Martin. A universal cellular automaton in quasi-linear time and its S-m-n form. Theoretical Computer Science, Vol. 123, pp. 99–237, 1994.
9
10
Jean-Baptiste Yun`es 7. Jacques Mazoyer. A six states minimal time solution to the firing squad synchronization problem. Theoretical Computer Science, Vol. 50, pp. 183–328, 1987. 8. Jacques Mazoyer, Jean-Baptiste Yun`es. Computations on Cellular Automata. in Handbook of Natural Computing, G. Rozenberg, T. B¨ ack, J. Kok. (Eds.) Springer. To appear in 2010. isbn 978-3540-92911-6. 9. Nicolas Ollinger. The intrinsic universality problem of onedimensional cellular automata. Lecture Notes on Computer Science, Proceedings of STACS’2003. pp. 632–641. doi: 10.1007/3-54036494-3, 2003. 10. Victor Poupet. Cellular Automata: Real-Time Equivalence Between One-Dimensional Neighborhoods. STACS 2005, 22nd Annual Symposium on Theoretical Aspects of Computer Science, Stuttgart, Germany, February 24-26, 2005, Proceedings, pp. 133-144. 11. Mathieu Sablik. Directional dynamic for cellular automata: A sensitivity to initial condition approach. Theoretical Computer Science, Vol. 400/1-3, pp. 1-18, 2008. 12. Jacques Mazoyer and V´eronique Terrier. Signals in OneDimensional Cellular Automata. Theoretical Computer Science, Vol. 217/1, pp. 53–80, 1999. doi 10.1016/S0304-3975(98)00150-9. 13. Stephen Wolfram. A New Kind of Science. Wolfram Media, Inc., 2002.