Dynamic Neighbourhood Cellular Automata

We propose a deﬁ nition of Cellular Automaton in which links between cells can change during the computation. This is done locally by each cell, which can reach the neighbours of its neighbours in a single computational step. We suggest that Dynamic Neighbourhood Cellular Automata can serve as a theoretical model for studying Algorithmic and Computational Complexity issues in the are of Ubiquitous Computing. We illustrate this approach by giving an optimal logarithmic time solution of the Firing Squad Synchronisation problem in our model, which is an exponential speed-up over classical Cellular Automata

serious drawback, in our opinion, is that the authors did not recognise the importance of the potential speed-up of CA with dynamic links over classical ones.For instance, they presented a linear (in the number of cells) algorithm for converting a line into a balanced binary tree.In this paper, we show that this can be done in logarithmic time, which is optimal up to a constant factor.As a matter of fact, Rosenfeld and Wu used the FSSP as a subroutine in their construction.We have had different motivation and quite the opposite approach -we suggest the use of creating a balanced binary tree as a building block for faster computations, and in particular for solving the FSSP problem in logarithmic time.
More recently, Dubacq [2] reconsidered the dynamic neighbourhood in the context of CA and compared several different models.He also proved a quite general "synchronisation" theorem, which included solving the FSSP in logarithmic time.While Dubacq's dynamically reconfi gurable CA have been rigorously defi ned and the importance of the the speed-up (logarithmic versus linear) have been acknowledged, his model has a serious drawback in that it allows for a cell to be seen by an unbounded number of other cells.Firstly, this does not look reasonable from a practical point of view that a processor can send information to everyone else in a single computational step.Secondly, it allows for a straightforward solution of the FSSP by simply pointing everyone to the general -this can trivially be done in logarithmic time.In contrast to this, our defi nition bounds the number of connections, which a cell can have at any time, by a constant (the same holds in the model of Rosenfeld and Wu).
Finally, it is worth mentioning some related sequential computational models (related in that they have the notion of changing links in their memory) that are called pointer machines or storagemodifi cation machines (see the survey [1]).
Rest of the paper is organised as follows.In section 2, we give the formal defi nition of what we call Dynamic-Neighbourhood Cellular Automata (DNCA).We have tried to keep it as simple as possible yet general enough so that it can be easily extended in different ways, which we discuss in section 4. The proof of the main result, a solution of the FSSP in Θ (log n) time, is given in section 3. Finally, we discuss possible directions for further research in section 4.

DEFINITIONS
The formal defi nition of DNCA and some related concepts is as follows.

Defi nition 1
DNCA is a quadruple (Q, P, δ, C) where 1. Q is a fi nite set of states; 2. P is a fi nite sets of ports; 3. δ : The intuitive meaning of the defi nition is as follows.We have a set of identical Deterministic Finitestate Automata (DFAs) that we call cells.The cells are "named" by the elements of some set C. Usually, we take C to be some countable set, e.g. the natural numbers N. In the rest of the paper, however, we shall be mainly concerned with time complexity and, thus, we shall assume than only fi nitely many cells numbered from 1 to n are active -here n plays the role of "input size".We note that the cell names have no relevance to the actual computation of a DNCA as a cell is a DFA, which cannot hold log n bits required to memorise a name.All the cells have a common state set Q and the same transition function δ which depends on the cell's own state as well as on the states of up to |P | neighbouring cells which are available through the cell's ports named by elements of some fi nite set P .
The links are formally defi ned with the help of the interconnection function: if two cells C 1 and C 2 are connected through ports p 1 of C 1 and p 2 of C 2 , the interconnection function should consistently say so, i.e. η (C 1 , p 1 ) = C 2 , p 2 and η (C 2 , p 2 ) = C 1 , p 1 .A port p of a cell C may be left loose -this is refl ected by η (C, p) = ⊥ and may be used to defi ne external input/output to the DNCA (however, we ignore this issue throughout the paper).Note that the defi nition allows for loops, i.e. η (C, p) = C, p .
The transition function δ takes the current state of a cell C together with the current states of its (at most)|P | neighbours and then returns a new state plus |P | port changes, each of them being one of the following three types: ε (leave the port loose), p (connect to the cell which is currently connected to the port p of C) or p 1 , p 2 (connect to the cell which is currently connected to port p 2 of the cell which is connected to port p 1 of C -i.e.switch a connection from a neighbour to a neighbour of a neighbour).All these changes that produce a new global state from the current one happen synchronously in parallel.It could happen that the new interconnection function is inconsistent, i.e. η (C, p) = ⊥ and η (η (C, p)) = C, p for some C ∈ C and p ∈ P -we shall treat such a situation as run-time error, in which case the computation of the DNCA fails.

FIRING SQUAD IN OPTIMAL LOGARITHMIC TIME
Firing Squad Synchronisation Problem is a synchronisation problem for a line of fi nite automata (i.e.one-dimensional CA) proposed by Myhill in 1957, fi rst solved by McCarthy and Minsky, and appeared in print in [6].The problem statement is as follows.The fi rst (leftmost) cell is a general and all the others are soldiers.At some point in time, the general is placed in a special state "fi re when ready".The task is to turn all soldiers into a "fi re" state simultaneously at some later time, and it must be the fi rst time that any of them has fi red.
The simple divide-and-conquer solution of Moore starts by the general sending two signals along the line: a fast signal and a slow one, which moves three times as slow.The fast signal bounces off the end of the line and meets the slow signal in the centre.The middle soldier declares himself a general and with the help of additional two signals, he agrees with the original general that they both give order to fi re at the same time, each for his half of the line.Thus, the process recursively continues, halving each subline until each division consists of a single soldier (who becomes general at that moment).Then every soldier fi res.It is easy to see that the time required is O (n).A number of other solutions have been found including an absolute optimal ones in terms of time, number of states, communication bits etc.The problem has been generalised to many different topologies (see the survey [5]).
In order to formalise the FSSP, we shall assume throughout the section that we are given a DNCA with n linearly ordered cells.That is, the cell names are the numbers from 1 to n, and there are we successor and predecessor ports defi ned by succ = ε.We also assume that, in the beginning, all the cells are in some idle state except for cell 1, which initiates the computation, and cell n, which is in an end state, i.e. knows that it is the last in the line.
Our idea is to convert the line into a balanced binary tree (BBT) and then run a classical FSSP algorithm (i.e.any one that solves the problem on a static-neighbourhood CA) simultaneously on all branches (paths from the root to a leaf).Since the depth of a BBT of n nodes is roughly log n, we will be done if we can create the tree in time O (log n).Recall that an algorithm for transforming a line into a BBT was given [9] but it uses a classical FSSP algorithm running on lines of length n initially, thus takes time O (n).
Creating the BBT is done at two stages.The fi rst one produces an almost balanced binary tree (ABBT), and the second one balances it by identifying the leaves that are a level higher than the other leaves.
Building the ABBT is done recursively, by setting the root to be cell 1 and then recursively constructing two disjoint almost balanced subtrees -one with a root 2 and containing all evennumbered cells, and the other with root 3 and containing all odd-numbered cell (except 1, of course).The recursive split is made in constant time, by simply linking any cell whose name is ≥ 4 to the neighbour of the neighbour in both directions.Special care is needed in the boundary cases, i.e. the cells that are neighbours of the end(s) or the root(s).
More formally, the fi rst stage is meant to leave any cell in a state of the form (vertex-type, parent-type).Here vertex-type is leaf (a leaf of the tree), lean (a vertex that has a single left child which is a leaf) or node (any other internal vertex, including the root).parent-type is lef t, right (the node is a left, respectively right, child) or none (for the only root of the tree).The process starts by cell 1 going to a state (root, none) .A root node links the next two nodes as the left and the right (only if it exists) children: The fi gure below is an example of how the fi rst stage works on a 8-element line.The doublecircled vertices show the recursive propagation of the root(s).In the end, 1, 2, 3 are nodes, 4 is a lean, and 5, 6, 7, 8 are leaves.One can easily prove, by induction on the number of nodes, the following.

Proposition 2
The ABBT, produced by the algorithm above, has the following properties.
1.The height of the tree is h = ⌊log 2 n⌋ + 1.
2. For every internal node v, the difference between the sizes (number of nodes) of the left subtree and the right subtree rooted at v is either zero or one.

The purpose of the second stage is
Balancing the ABBT This is done by fi nding all the leaves at the higher depth h−1 and advising them to pretend that they have a fake child (at level h) -we call such leaves extended.This could be easily achieved recursively.Given a node with left and right subtrees L and R, respectively, the height of L is greater than the height of R if only if R is perfectly balanced and L has a node more than R, i.e. |L| = |R| + 1 = 2 t for some t.In this case all leaves of R should be extended and L should be recursively balanced -this is the base case of the recursion.Otherwise, L and R have the same height, so they should be simultaneously balanced.
The implementation of this stage is better described in terms of message passing.It is initiated by the unique root of almost BBT who sends a message balance to both his children.This message is passed down by ordinary nodes until it reaches a lean or a leaf.A lean is a root of subtree of size two, so it replies back to its parent by a message power whose informal meaning is "my subtree is of size which is a perfect power of two".A leaf replies back to its parent by a message balanced whose meaning is "my subtree is of perfectly balanced", i.e. of size which is a perfect power of two minus one.Now every node awaits messages from both children.Whenever a node receives two balanced, it passes balanced to its parent.If a node gets power from the left and balanced from the right, every leaf of the right subtree should be extended.This is done by sending two message at the same time, an extend to the right child and a power to the parent, respectively (the latter message refl ects the fact that the size of the subtree is a perfect power of two 2 t+1 if and only if the left subtree is of size 2 t while the right one is of size 2 t − 1 and, thus, balanced).Any other combination of two messages from the children can simply be ignored as the subtree rooted at the current node is neither balanced nor is its size a perfect power of two.Any extend message is passed down until it reaches a leaf, which then gets to know that it should behave as it had a child.
An example with 18 nodes is given below.The black nodes are roots of balanced subtrees, while the grey ones are roots of subtrees whose size is a perfect power of two.The grey node vertices 3, 4, 5, 6 sent extend message to all leaves in their respective right subtrees.There is a fi nal bit, which is not actually needed for solving the FSSP, but may be needed in other applications that use the conversion to a BBT, so we briefl y describe it.This is letting the root know that the algorithm has fi nished, i.e. every leaf knows if it is extended or not and, thus, will behave accordingly in the future.At fi rst, it seems that this could be done by every leaf and lean sending a message ready back to their parents, and by every internal node sending awaiting for two ready messages (from both children) and the passing it up.This does not work as a some leaves may fi nd out at a later stage that they should be extended.The problem is easily fi xed by observing that any incorrect ready message (going up) will eventually meet an extend message going down -in such a case the ready message(s) is/are simply cancelled.A leaf, which is extended, then has to send a second ready message that will not be cancelled and thus every node will eventually get two correct ready messages.

As for
Solving the FSSP we point out that the two stages of creating the BBT can work in parallel (more precisely the second stage lags a step behind the fi rst one) -it is not hard to see that whenever a node needs to send or receive a message, the relevant links as well as the type of the node has already been established by the fi rst stage.In order to solve the FSSP, we can run any static-neighbourhood algorithm on all branches in parallel with a speed three times slower than normal -it is easy to see that every signal sent by such an algorithm will reach a soldier who has already established his position (i.e.knows he is the end of the line, or knows he has to simulate an additional fake soldier).The running time is clearly O (log n).The optimality follows from the fact that, the reach of any cell at time k is at most 2 k , so that the last in the line cannot even see the order to fi re in fewer than ⌈log n⌉ − 1 steps.To summarise it, we have shown the following.

Proposition 3
The FSSP can be solved in optimal time Θ (log n) on a DNCA which is a line of n cells.

CONCLUSION AND FUTURE WORK
We have given a basic defi nition of Dynamic Neighbourhood Cellular Automata and have shown that a DNCA can exhibit an exponential speed-up over a classical static neighbourhood CA.There are a number of ways to extend the model as well as many other algorithmic and complexity questions.One could consider:

Figure 2 :
Figure 2: Completing the tree