Access the full text.
Sign up today, get DeepDyve free for 14 days.
O. Michail, P. Spirakis (2012)
Terminating population protocols via some minimal global knowledge assumptions
P. Rothemund, E. Winfree (2000)
The program-size complexity of self-assembled squares (extended abstract)
J. Schiff (2007)
Cellular Automata: A Discrete View of the World (Wiley Series in Discrete Mathematics & Optimization)
(2014)
In Proceedings of the 33rd ACM Symposium on Principles of Distributed Computing (PODC)
H. Attiya, J. Welch (2004)
Distributed computing - fundamentals, simulations, and advanced topics (2. ed.)
JL Schiff (2011)
Cellular Automata: A Discrete View of the World
O. Michail, George Skretas, P. Spirakis (2017)
On the Transformation Capability of Feasible Mechanisms for Programmable Matter
Michael Rubenstein, Alejandro Cornejo, R. Nagpal (2014)
Programmable self-assembly in a thousand-robot swarmScience, 345
I. Chatzigiannakis, O. Michail, P. Spirakis (2009)
Mediated Population ProtocolsTheor. Comput. Sci., 412
W. McCarthy (2000)
Programmable matterNature, 407
(1907)
¨Uber zwei bekannte einw¨ande gegen das boltzmannsche h-theorem
Cameron Chalk, E. Demaine, M. Demaine, Eric Martinez, R. Schweller, Luis Vega, Tim Wylie (2016)
Universal Shape Replicators via Self-Assembly with Attractive and Repulsive Forces
D. Angluin, J. Aspnes, Zoë Diamadi, M. Fischer, R. Peralta (2004)
Computation in networks of passively mobile finite-state sensorsDistributed Computing, 18
(2015)
Terminating Distributed Construction of Shapes and Patterns in a Fair Solution of Automata
R. Guerraoui, E. Ruppert (2009)
Names Trump Malice: Tiny Mobile Agents Can Tolerate Byzantine Failures
Nilesh Vaidya, Michael Manapat, I. Chen, R. Xulvi-Brunet, Eric Hayden, N. Lehman (2012)
Spontaneous network formation among cooperative RNA replicatorsNature, 491
S. Das, P. Flocchini, N. Santoro, M. Yamashita (2015)
Forming sequences of geometric patterns with oblivious mobile robotsDistributed Computing, 28
Zahra Derakhshandeh, S. Dolev, R. Gmyr, A. Richa, C. Scheideler, Thim Strothmann (2014)
Amoebot - a new model for programmable matterProceedings of the 26th ACM symposium on Parallelism in algorithms and architectures
P. Rothemund (2006)
Folding DNA to create nanoscale shapes and patternsNature, 440
S. Dolev, R. Gmyr, A. Richa, C. Scheideler (2013)
Ameba-inspired Self-organizing Particle SystemsArXiv, abs/1307.4259
E. Hall (1988)
The nature of biotechnology.Journal of biomedical engineering, 10 1
(2006)
pages 235–253
(2015)
Simple and efficient local codes for distributed stable network construction
SC Goldstein (2005)
10.1109/MC.2005.198Computer, 38
I Suzuki (1999)
10.1137/S009753979628292XSIAM J. Comput., 28
D. Angluin, J. Aspnes, David Eisenstat (2006)
Fast computation by population protocols with a leaderDistributed Computing, 21
Matthew Berbée, Katharine Schlinger (1958)
California Institute of TechnologyNature, 182
H. Ko (1967)
An introduction to probability theory and its applications, Vol. II: by William Feller. 626 pages, 6 × 9 inches, New York, John Wiley and Sons, Inc., 1966. Price $12.00Journal of The Franklin Institute-engineering and Applied Mathematics, 283
D. Angluin (1980)
Local and global properties in networks of processors (Extended Abstract)
M. Paprzycki (2001)
Distributed Computing: Fundamentals, Simulations and Advanced TopicsScalable Comput. Pract. Exp., 4
J Aspnes, E Ruppert (2009)
Middleware for Network Eccentric and Mobile Applications
L. Adleman (1994)
Molecular computation of solutions to combinatorial problems.Science, 266 5187
J. Welch, H. Attiya (1998)
Distributed Computing: Fundamentals, Simulations and Advanced Topics
Zahra Derakhshandeh, R. Gmyr, A. Richa, C. Scheideler, Thim Strothmann (2016)
Universal Shape Formation for Programmable MatterProceedings of the 28th ACM Symposium on Parallelism in Algorithms and Architectures
Shuguang Zhang (2003)
Fabrication of novel biomaterials through molecular self-assemblyNature Biotechnology, 21
W. Feller (1959)
An Introduction to Probability Theory and Its Applications
Giuseppe Luna, P. Flocchini, N. Santoro, G. Viglietta, Yukiko Yamauchi (2017)
Shape formation by programmable particlesDistributed Computing, 33
S. Das, P. Flocchini, N. Santoro, M. Yamashita (2010)
On the computational power of oblivious robots: forming a series of geometric patternsProceedings of the 29th ACM SIGACT-SIGOPS symposium on Principles of distributed computing
J. Kingman, W. Feller (1958)
An Introduction to Probability Theory and its ApplicationsBiometrika, 130
Shawn Douglas, I. Bachelet, G. Church (2012)
A Logic-Gated Nanorobot for Targeted Transport of Molecular PayloadsScience, 335
I. Suzuki, M. Yamashita (2006)
Erratum: Distributed Anonymous Mobile Robots: Formation of Geometric PatternsSIAM J. Comput., 36
I Suzuki, M Yamashita (1999)
Distributed anonymous mobile robots: formation of geometric patternsSIAM J. Comput., 28
David Doty (2012)
Theory of algorithmic self-assemblyCommun. ACM, 55
Moya Chen, Doris Xin, D. Woods (2013)
Parallel computation using active self-assemblyNatural Computing, 14
D. Angluin, J. Aspnes, David Eisenstat, E. Ruppert (2006)
The computational power of population protocolsDistributed Computing, 20
D. Freedman, W. Feller (1967)
An Introduction to Probability Theory and Its ApplicationsEconometrica, 35
Alexandra Keenan, R. Schweller, Xingsi Zhong (2013)
Exponential replication of patterns in the signal tile assembly modelNatural Computing, 14
J. Beauquier, J. Burman, J. Clément, S. Kutten (2010)
On utilizing speed in networks of mobile agentsProceedings of the 29th ACM SIGACT-SIGOPS symposium on Principles of distributed computing
(2007)
The next revolution in materials
I. Chatzigiannakis, O. Michail, Stavros Nikolaou, Andreas Pavlogiannis, P. Spirakis (2010)
Passively mobile communicating machines that use restricted spaceTheor. Comput. Sci., 412
I Chatzigiannakis (2011)
10.1016/j.tcs.2011.07.001Theor. Comput. Sci., 412
M. Niazi (2014)
Technical Problems With "Programmable self-assembly in a thousand-robot swarm"ArXiv, abs/1708.03341
Jennifer Padilla, Matthew Patitz, R. Schweller, N. Seeman, Scott Summers, Xingsi Zhong (2012)
Asynchronous signal Passing for Tile Self-assembly: Fuel Efficient Computation and Efficient assembly of ShapesInt. J. Found. Comput. Sci., 25
D. Soloveichik, Matthew Cook, E. Winfree, Jehoshua Bruck (2008)
Computation with finite stochastic chemical reaction networksNatural Computing, 7
O. Michail, I. Chatzigiannakis, P. Spirakis (2011)
New Models for Population Protocols
H Attiya (2004)
10.1002/0471478210
M. Kac (1947)
Random Walk and the Theory of Brownian MotionAmerican Mathematical Monthly, 54
O Michail (2016)
10.1007/s00446-015-0257-4vDist. Comput., 29
Ho-Lin Chen, David Doty, D. Soloveichik (2012)
Deterministic function computation with chemical reaction networksNatural Computing, 13
A. Bandyopadhyay, R. Pati, S. Sahu, F. Peper, D. Fujita (2010)
Massively parallel computing on an organic molecular layerArXiv, abs/1110.5844
O Michail, I Chatzigiannakis, PG Spirakis (2011)
Synthesis Lectures on Distributed Computing Theory
J. Aspnes, E. Ruppert (2007)
An Introduction to Population Protocols
M Kac (1947)
10.2307/2304386Am. Math. Mon., 54
O. Michail, P. Spirakis (2018)
Elements of the theory of dynamic networksCommunications of the ACM, 61
N. Lynch (1994)
Distributed Algorithms, 857
David Doty (2013)
Timing in chemical reaction networks
G. Aloupis, Nadia Benbernou, Mirela Damian, E. Demaine, Robin Flatland, J. Iacono, S. Wuhrer (2013)
Efficient Reconfiguration of Lattice-Based Modular RobotsComput. Geom., 46
E. Winfree (2006)
Algorithmic Self-Assembly of DNA
J. Kingman, P. Moran (1968)
An introduction to probability theory
O. Michail, P. Spirakis (2013)
Simple and efficient local codes for distributed stable network constructionDistributed Computing, 29
Zachary Abel, Nadia Benbernou, Mirela Damian, E. Demaine, M. Demaine, Robin Flatland, S. Kominers, R. Schweller (2010)
Shape replication through self-assembly and RNase enzymes
(2007)
DARPA's 25th Systems and Technology Symposium (DARPATech)
D. Woods, Ho-Lin Chen, Scott Goodfriend, Nadine Dabby, E. Winfree, P. Yin (2013)
Active self-assembly of algorithmic shapes and patterns in polylogarithmic time
O Michail (2011)
10.1016/j.tcs.2011.02.003Theor. Comput. Sci., 412
Distrib. Comput. (2018) 31:343–365 https://doi.org/10.1007/s00446-017-0309-z Terminating distributed construction of shapes and patterns in a fair solution of automata Othon Michail Received: 2 April 2016 / Accepted: 7 August 2017 / Published online: 23 August 2017 © The Author(s) 2017. This article is an open access publication Abstract In this work, we consider a solution of automata terminating subroutines that can be sequentially composed (or nodes) that move passively in a well-mixed solution with- to form larger modular protocols. One of our main results is out being capable of controlling their movement. Nodes can a terminating protocol counting the size n of the system with cooperate by interacting in pairs and every such interaction high probability. We then use this protocol as a subroutine may result in an update of their local states. Additionally, in order to develop our universal constructors, establishing the nodes may also choose to connect to each other in order that it is possible for the nodes to become self-organized with to start forming some required structure. Such nodes can be high probability into arbitrarily complex shapes while still thought of as small programmable pieces of matter, like tiny detecting termination of the construction. nanorobots or programmable molecules. The model that we introduce here is a more applied version of network con- Keywords Distributed network construction · Pro- structors, imposing physical (or geometric) constraints on grammable matter · Shape formation · Well-mixed solution · the connections that the nodes are allowed to form. Each node Homogeneous population · Distributed protocol · Inter- can connect to other nodes only via a very limited number acting automata · Fairness · Random schedule · Structure of local ports. Connections are always made at unit distance formation · Self-organization · Self-replication and are perpendicular to connections of neighboring ports, which makes the model capable of forming 2D or 3D shapes. We provide direct constructors for some basic shape con- 1 Introduction struction problems, like spanning line, spanning square, and self-replication. We then develop new techniques for deter- Recent research in distributed computing theory and practice mining the computational and constructive capabilities of our is taking its first timid steps on the pioneering endeavor of model. One of the main novelties of our approach is that of investigating the possible relationships of distributed com- exploiting the assumptions that the system is well-mixed and puting systems to physical and biological systems. The first has a unique leader, in order to give terminating protocols that main motivation for this is the fact that a wide range of phys- are correct with high probability. This allows us to develop ical and biological systems are governed by underlying laws that are essentially algorithmic. The second is that the higher- level physical or behavioral properties of such systems are Supported in part by the project “Foundations of Dynamic Distributed Computing Systems” (FOCUS) which is implemented under the usually the outcome of the coexistence, which may include “ARISTEIA” Action of the Operational Programme “Education and both cooperation and competition, and constant interaction Lifelong Learning” and is co-funded by the European Union of very large numbers of relatively simple distributed entities (European Social Fund) and Greek National Resources. A preliminary respecting such laws. This effort, to the extent that its per- version of the results in this paper has appeared in [32]. spective allows, is expected to promote our understanding of B Othon Michail the algorithmic aspects of our (distributed) natural world and Othon.Michail@liverpool.ac.uk to develop innovative artificial systems inspired by them. Ulam’s and von Neuman’s Cellular Automata (cf., e.g., Department of Computer Science, University of Liverpool, Ashton Street, Liverpool L69 3BX, UK [40]), essentially a distributed grid network of automata, 123 344 O. Michail have been used as models for self-replication, for model- when a thousand of them work together, their global dynam- ing several physical systems (e.g., neural activity, bacterial ics may resemble the complex collective behavior of some growth, pattern formation in nature), and for understanding living organisms. From our perspective, cooperation involves emergence, complexity, and self-organization issues. In the the capability of the nodes to communicate by interacting in young area of DNA self-assembly and DNA computation pairs and to bind to each other in an algorithmically controlled (starting with the works of Adleman [6] and Winfree [44]), way. In particular, during an interaction, the nodes can update it has been already demonstrated that it is possible to (algo- their local states according to a small common program that rithmically) self-assemble DNA strands so that they carry is stored in their memories and may also choose to connect to out computations as they grow some structures. Recently, an each other in order to start forming some required structure. interesting theoretical model was proposed, the Nubot model, Later on, if needed, they may choose to drop their connec- for studying the complexity of self-assembled structures with tion, e.g., for rearrangement purposes. We may think of such active molecular components [43]. This model is “inspired nodes as small programmable pieces of matter. For example, by biology’s fantastic ability to assemble biomolecules that they could be tiny nanorobots or programmable molecules form systems with complicated structure and dynamics, from (e.g., DNA strands). Naturally, such elementary entities are molecular motors that walk on rigid tracks and proteins that not (yet) expected to be equipped with some internal mobility dynamically alter the structure of the cell during mitosis, mechanism. Still, it is reasonable to expect that they could to embryonic development where large-scale complicated be part of some dynamic environment, like a boiling liquid organisms efficiently grow from a single cell”. Population or the human circulatory system, providing an external (to Protocols of Angluin et al. [1] were originally motivated by the nodes) interaction mechanism, which motivates the idea highly dynamic networks of simple sensor nodes that cannot of regarding such systems as a solution of programmable control their mobility. It was soon realized that their proba- entities. We model such an environment by imagining an bilistic version is formally equivalent to a restricted version of adversary scheduler operating in discrete steps and select- stochastic chemical reaction networks (CRNs), which model ing in every step a pair of nodes to interact with each other. chemistry in a well-mixed solution (see, e.g., [41]). Moreover, Our main focus in this work, building upon the findings the Network Constructors extension of population protocols of [33], is to further investigate the cooperative structure for- [33], showed that a population of finite-automata that inter- mation capabilities of such systems. Our first main goal is act randomly like molecules in a well-mixed solution and to introduce a more realistic and more applicable version that can establish bonds with each other according to the of network constructors by adjusting some of the abstract rules of a common small protocol, can construct arbitrarily parameters of the model of [33]. In particular, we introduce complex stable networks [33] (but without any physical geo- some physical (or geometric) constraints on the connec- metric considerations). Also recently a system was reported tions that the processes are allowed to form. In the network that demonstrates programmable self-assembly of complex constructors model of [33], there were no such imposed 2-dimensional shapes with a thousand-robot swarm, called restrictions, in the sense that, at any given step, any two pro- the Kilobot [38]. This was enabled by creating small, cheap, cesses were candidates for an interaction, independently of and simple “autonomous robots designed to operate in large their relative positioning in the existing structure/network. groups and to cooperate through local interactions and by For example, even two nodes hidden in the middle of distinct developing a collective algorithm for shape formation that dense components could interact and, additionally, there was is highly robust to the variability and error characteristic of no constraint on the number of active connections that a node large-scale decentralized systems”. could form (could be up to the order of the system). This was very convenient for studying the capability of such systems to 1.1 Our approach self-organize into abstract networks and it helped show that arbitrarily complex networks are in principle constructible. We imagine here a “solution” of automata (also called nodes On the other hand, this is not expected to be the actual or processes throughout the paper), a setting similar to that of mechanism of at least the first potential implementations. Population Protocols and Network Constructors. Due to its First implementations will most probably be characterized highly restricted computational nature and its very local per- by physical and geometric constraints. To capture this in spective, each individual automaton can practically achieve our model, we assume that each device can connect to other nothing on its own. However, when many of them cooper- devices only via a very limited (finite and independent of the size of the system) number of ports, usually four or six, ate, each contributing its meager computational capabilities, impressive global outcomes become feasible. This is, for which implies that, at any given time, a device has only a bounded number of neighbors. Moreover, we further restrict example, the case in the Kilobot system, where each individ- ual robot is a remarkably simple artifact that can perform only the connections to be always made at unit distance and to be primitive locomotion via a simple vibration mechanism. Still, perpendicular to connections of neighboring ports. Though 123 Terminating distributed construction of shapes and patterns in a fair solution of automata 345 such a model can no longer form abstract networks, it may together all definitions and basic facts that are used through- still be capable of forming 2-dimensional or 3-dimensional out the paper. In Sect. 4, we provide direct (stabilizing) shapes. This is also in agreement with natural systems, where constructors for some basic shape construction problems. the complexity and physical properties of a system are rarely Section 5 introduces our technique for counting the size n the result of an unrestricted interconnection between entities. of the system with high probability. The result of that section It can be immediately observed that the universal con- (i.e., Theorem 1) is of particular importance as it underlies all structors of [33] do not apply in this case. In particular, those sequential composition arguments that follow in the paper. In constructors cannot be adopted in order to characterize the particular, the protocol of Sect. 5 is then used as a subroutine constructive power of the model considered here. The reason in our universal constructors, establishing that it is possible is that they work by arranging the nodes in a long line and to construct with high probability arbitrarily complex shapes then exploiting the fact that connections are elastic, allowing (and patterns) by terminating protocols. These universality any pair of nodes of the line to interact independently of the results are discussed in Sect. 6. Finally, in Sect. 7 we con- distance between them. In contrast, no elasticity is allowed in clude and give further research directions that are opened by the more local model considered here, where a long line can our work. still be formed but only adjacent nodes of the line are allowed to interact with each other. As a result, we have to develop new techniques for determining the computational and con- 2 Further related work structive capabilities of our model. The other main novelty of our approach concerns our attempt to overcome the inabil- Population protocols Our model for shape construction is ity of such systems to detect termination due to their limited strongly inspired by the Population Protocol model [1] and global knowledge and their limited computational resources. the Mediated Population Protocol model [30]. In the former, For example, it can be easily shown that deterministic termi- connections do not have states. States on the connections nation of population protocols can fail even in determining were first introduced in the latter. The main difference to our whether there is a single a in an input assignment, mainly model is that in those models the focus was on the compu- because the nodes do not know and cannot store in their tation of functions of some input values and not on network memories neither the size of the network nor some upper construction. Another important difference is that we allow bound on the time it takes to meet (or to influence or to be the edges to choose between only two possible states which influenced by) every other node. To overcome the storage was not the case in [30]. Interestingly, when operating under issue, we exploit the ability of nodes to self-assemble into a uniform random scheduler, population protocols are for- larger structures that can then be used as distributed memo- mally equivalent to a restricted version of stochastic chemical ries of any desired length. Moreover, we exploit the common reaction networks (CRNs) which model chemistry in a well- (and natural in several cases) assumption that the system is mixed solution (see, e.g., [41]). “CRNs are widely used to well-mixed, meaning that, at any given time, all permissi- describe information processing occurring in natural cel- ble pairs of node-ports have an equal probability to interact, lular regulatory networks, and with upcoming advances in in order to give terminating protocols that are correct with synthetic biology, CRNs are a promising programming lan- high probability. This is crucial not only because it enables guage for the design of artificial molecular control circuitry” us to improve eventual stabilization to eventual termination [12,21]. However, CRNs and population protocols can only but, most importantly, because it enables us to develop ter- capture the dynamics of molecular counts and not of structure minating subroutines that can be sequentially composed to formation. Our model then may also be viewed as an exten- form larger modular protocols. Such protocols are more effi- sion of population protocols and CRNs aiming to capture the cient, more natural, and more amenable to clear proofs of stable structures that may occur in a well-mixed solution. correctness, compared to existing protocols that are based on From this perspective, our goal is to determine what stable composing all subroutines in parallel and “sequentializing” structures can result in such systems (natural or artificial), them eventually by perpetual reinitializations. To the best of how fast, and under what conditions (e.g., by what underly- our knowledge, [34] is the only work that has considered ing codes/reaction-rules). Most computability issues in the this issue but with totally different and more determinis- area of population protocols have now been resolved. Finite- tic assumptions. Several other papers [1,2,33] have already state processes on a complete interaction network, i.e., one in exploited a uniform random interaction model, but in all cases which every pair of processes may interact, (and several vari- it has been used to analyze the expected time to convergence ations) compute the semilinear predicates [3]. Semilinearity of stabilizing protocols and not for maximizing the correct- persists up to o(log log n) local space but not more than this ness probability of terminating protocols, as we do here. [13]. If, additionally, the connections between processes can In Sect. 2, we discuss further related literature. Section 3 hold a state from a finite domain (note that this is a stronger formally defines the model under consideration and brings requirement than the on/off that the present work assumes) 123 346 O. Michail then the computational power dramatically increases to the and any global parameter of the target configuration, such as commutative subclass of NSPACE(n ) [30]. Other important its size n, must be somehow explicitly encoded in advance works include [25] which equipped the nodes of population (as input), e.g., by assigning to each tile a number of glues protocols with unique identifiers (abbreviated “uids” or “ids” that depends on n or, as in [14], by starting from an initial throughout) and [10] which introduced a (weak) notion of line of length log n. In contrast, in our model n is always speed of the nodes that allowed the design of fast converg- the number of nodes in the system, their number remaining ing protocols with only weak requirements. For introductory unmodified throughout the execution, and, additionally, the texts see [8,31]. nodes do not know n in advance and have to coordinate in Algorithmic self-assembly There are already several mod- order to compute it and become capable of constructing a els trying to capture the self-assembly capability of natural sufficiently large shape (i.e., one that depends on the size of processes with the purpose of engineering systems and devel- the system). Other important differences are the existence oping algorithms inspired by such processes. The research of various types of glues in signal-passing tile assembly and area of “algorithmic self-assembly” belongs to the field of also temperature and strength parameters that determine sta- “molecular computing”. The latter was initiated by Adleman bility of a configuration, whereas in our model stability only [6], who designed interacting DNA molecules to solve an depends on the local states of nodes and their position in the instance of the Hamiltonian path problem. The model that has configuration. See [20] for an introductory text to algorithmic guided the study in algorithmic self-assembly is the Abstract self-assembly. Tile Assembly Model (aTAM) [39,44] and variations. Distributed network construction To the best of our knowl- Recently, the Nubot model was proposed [43], which edge, classical distributed computing has not considered the was another important influence for our work. That model problem of constructing an actual communication network aims at “motivating engineering of molecular structures from scratch. From the seminal work of Angluin [7] that ini- that have complicated active dynamics of the kind seen tiated the theoretical study of distributed computing systems in living biomolecular systems”. It tries to “capture the up to now, the focus has been more on assuming a given interplay between molecular structure and dynamics”. “Sim- communication topology and constructing a virtual network ple molecular components form assemblies that can grow” over it, e.g., a spanning tree for the purpose of fast dis- (exponentially fast, by successive doublings) “and shrink, semination of information. Moreover, these models assume and individual components undergo state changes and move most of the time unique identities, unbounded memories, relative to each other”. The main result of [43] was that any and message-passing communication. Additionally, a pro- computable shape of size ≤ n × n can be built in time poly- cess always communicates with its neighboring processes logarithmic in n, plus roughly the time needed to simulate a (see [9,29] for all the details). An exception is the area of TM that computes whether or not a given pixel is in the final geometric pattern formation by mobile robots (cf. [16,42] shape. One of the main differences between the Nubot model and references therein). A great difference, though, to our and our model is that in the former the nodes are equipped model is that in mobile robotics the computational entities with an active actuation mechanism (see also [14] for another have complete control over their mobility and thus over their study of active self-assembly). This means that nodes (repre- future interactions. That is, the goal of a protocol is to result senting monomers there) are capable of firing transition rules in a desired interaction pattern while in our model the goal that apart from changing their state can also change their rel- of a protocol is to construct a structure while operating under ative position to neighboring nodes. This core characteristic a totally unpredictable interaction pattern. brings the Nubot model closer to reconfigurable robotics (see, Programmable matter Programmable matter refers to any e.g., [5]) and active programmable matter (see, e.g., [15,36]) type of matter that can algorithmically change its physical models. In contrast, reconfiguration in our model is passive, properties (see, e.g., [24,35]). There is a recent growing inter- meaning that all mobility is controlled by the environment est in the theory and algorithms for programmable matter and the nodes can only “decide” whether to connect or dis- systems. The network constructors model [33] and its geo- connect whenever they are given the opportunity to interact. metric variant studied in this paper, may be viewed as models Another type of self-assembly model that is close to the for programmable matter operating in a dynamic environ- model studied in this paper, is the model of signal passing ment. The Amoebot model, a programmable matter model tiles [26,37]. Their main similarities are that signal-passing inspired by the behavior of amoeba, was proposed in [15,18] tiles are also passive and they can control connection and (seealso[17,19] for some more recent studies). Another very disconnection (via glues) as in our model. Still there are recent study considered spherical programmable matter mod- some important differences that set our model apart from ules that can rotate or slide relative to neighboring modules the signal-passing tiles model. The most crucial one, is that [36], trying to capture transformation mechanisms that are in signal-passing tiles (and in the vast majority of algorithmic feasible by current technology. As already mentioned above, self-assembly models) there is an unlimited supply of tiles the core characteristic that distinguishes the present model is 123 Terminating distributed construction of shapes and patterns in a fair solution of automata 347 p p port of another node v and the distance between them is one y y unit. Then w and v interact and, apart from updating their p p x x local states, they can also activate the connection between p p −x −x their corresponding ports. In a future pairwise interaction, they can again deactivate the connection if required. p p −y −y 2D Definition 1 A 2D (or 3D) protocol is defined by a 4-tuple (Q, q , Q ,δ), where Q is a finite set of node-states, q ∈ 0 out 0 Q is the initial node-state, Q ⊆ Q is the set of output out p p p p z z node-states, and δ : (Q × P) × (Q × P) ×{0, 1}→ Q × p p Q ×{0, 1} is the transition function, where P ={u, r, d, l} x x p p (P ={ p , p , p , p , p , p }, respectively, for the 3D −x −x y z x −y −z −x case) is the set of ports and {0, 1} is the set of edge-states. p p −z −z When required, also a special initial leader-state L ∈ Q p p −y −y 0 3D may be defined. Fig. 1 The top figure depicts the 2D version of the model. Each node If δ((a, p ), (b, p ), c) = (a , b , c ), we call (a, p ), 1 2 1 has four ports and consecutive ports are perpendicular to each other. (b, p ), c → (a , b , c ) a transition (or rule). A transition Two nodes are interacting, the left one via its p port and the right one via its p port. The interaction can occur because the distance between (a, p ), (b, p ), c → (a , b , c ) is called effective if a = a −x 1 2 the nodes is unit and the corresponding ports are totally aligned (in a or b = b or c = c and ineffective otherwise. When we straight line). The bottom figure depicts the 3D version of the model. present the transition function of a protocol we only present The only difference is an extra z dimension the effective transitions. Let E ={{(v , p ), (v , p )}: v = v ∈ V and p , p ∈ 1 1 2 2 1 2 1 2 P} be the set of all unordered pairs of node-ports (cf. [33] the fact that all dynamicity is passive and the only actuation for more details on unordered interactions). A configura- controlled by the program is the activation/deactivation of tion C is a pair (C , C ), where C : V → Q specifies the connections whenever some adversarially controlled condi- V E V state of each node and C : E →{0, 1} specifies the state tions are met. of every possible pair of node-ports (i.e., of every edge). In particular, an edge in state 0 is called inactive and an edge in 3 The model state 1 is called active. The initial configuration is always the one in which all nodes are in state q (apart possibly from The system consists of a population V of n distributed pro- a unique leader in state L ) and all edges are inactive.Exe- cesses (finite-state machines), called nodes when clear from cution of the protocol proceeds in discrete steps. In every context. Every node has a bounded number of ports which step, a pair of node-ports (v , p )(v , p ) is selected by an 1 1 2 2 it uses to interact with other nodes. In the 2-dimensional adversary scheduler and these nodes interact via the corre- (2D) case, there are four ports p , p , p , and p , which y x −y −x sponding ports and update their states and the state of the for notational convenience are usually denoted u, r, d, and l, edge joining them according to the transition function δ. respectively (for up, right, down, and left, respectively). Sim- Every configuration C defines a set of shapes G[A(C )], −1 ilarly, in the 3-dimensional (3D) case there are 6 ports p , p , y z where A(C ) = C [1]; i.e., the network induced by the p , p , p , and p (see Fig. 1). Throughout this work, x −y −z −x active edges of C. Observe that not all possible A(C ) are we denote by j the port “opposite” to port j, that is, if j ≡ p valid given our geometric restrictions, that connections are then j ≡ p . Neighboring ports are perpendicular to each −i made at unit distance and are perpendicular whenever they other, forming local axes. For example, in the 2-dimensional correspond to consecutive ports of a node. For example, if case, u ⊥ r, r ⊥ d, d ⊥ l, and l ⊥ u. An important remark (v , r )(v , l) ∈ A(C ) then (v , l)(v , r)/ ∈ A(C ). In gen- 1 2 1 2 is that the above coordinates are only for local purposes and eral, A(C ) is valid if any connected component defined by do not necessarily represent the actual orientation of a node it (when arranged according to the geometric constraints) is in the system. A node may be arbitrarily rotated so that, for a subnetwork of the 2D grid network with unit distances. example, its x local coordinate is aligned with the y global A valid A(C ) also restricts the possible selections of the t −1 coordinate of the system or it is not aligned with any global scheduler at step t ≥ 1. In particular, (v , p )(v , p ) ∈ E 1 1 2 2 coordinate. Nodes may interact in pairs, whenever a port of can be selected for interaction (or is permitted)atstep t iff one node w is at unit distance and in straight line (w.r.t. to A(C ) ∪{(v , p )(v , p )} is valid. Observe that any edge t −1 1 1 2 2 the local axes) from the port of another node v. For example, it could be the case that, at some point during execution, the To simplify notation, an unordered pair {a, b} will typically be axis of the u port of w becomes aligned with the axis of the l denoted by ab. 123 348 O. Michail that is active before step t is trivially permitted at step t.From can be extended by max_dim − min_dim extra rows or G G now on, we call a 2D (3D) shape any connected subnetwork columns, depending on which of its dimensions is smaller, of the 2D (3D) grid network with unit distances. to yield a max_dim × max_dim square S enclosing G G G Throughout the paper we restrict attention to configura- G (we mean here a {0, 1}-node-labeled square, as above, in tions C in which A(C ) is valid. We write C → C if C is which G can be identified). Observe, that such a square is reachable in one step from C (meaning via a single interac- not unique. For example, if G is a horizontal line of length tion that is permitted on C). We say that C is reachable from d (i.e., h = d and v = 1) then it is already equal to R G G G C and write C C , if there is a sequence of configurations and has to be extended by d − 1 rows to become S . These C = C , C ,..., C = C , such that C → C for all i, rows can be placed in d distinct ways relative to G, but all 0 1 t i i +1 0 ≤ i < t.An execution is a finite or infinite sequence of these squares have the same size max_dim × max_dim G G configurations C , C , C ,..., where C is the initial con- denoted by |S |. 0 1 2 0 G figuration and C → C , for all i ≥ 0. We only consider A2D(3D) shape language L is a subset of the set of i i +1 fair executions, so we require that for every pair of configura- all possible 2D (3D) shapes. We restrict our attention here to tions C and C such that C → C ,if C occurs infinitely often shape languages that contain a unique shape for each possible in the execution then so does C . In most cases, we assume maximum dimension of the shape. In this case, it is equiv- that interactions are chosen by a uniform random scheduler alent, and more convenient, to translate L to a language of which in every step selects independently and uniformly at labeled squares. In particular, we define in this work a shape random one of the permitted interactions. The uniform ran- language L by providing for every d ≥ 1asingle d ×d square dom scheduler is fair with probability 1. In this work, with with its nodes labeled from {0, 1}. Such a square may also high probability (abbreviated “w.h.p.” throughout) means be defined by a d -sequence S = (s , s ,..., s ) of bits d 0 1 d −1 with probability at least 1 − 1/n for some constant c ≥ 1. or pixels, where s ∈{0, 1} corresponds to the j-th node as We define the output of a configuration C as the set of follows: We assume that the pixels are indexed in a “zig-zag” shapes G (C ) = (V , E ) where V ={u ∈ V : C (u) ∈ fashion, beginning from the bottom left corner of the square, out s s s V Q } and E = A(C ) ∩{(v , p )(v , p ) : v = v ∈ V moving to the right until the bottom right corner is encoun- out s 1 1 2 2 1 2 s and p , p ∈ P}. In words, the output shapes of a config- tered, then one step up, then to the left until the node above 1 2 uration consist of those nodes that are in output states and the bottom left corner is encountered, then one step up again, those edges between them that are active. Throughout this then right, and so on (see the directed path in Fig. 7b on page work, we are interested in obtaining a single shape as the 21). The shape G defined by S , called the shape of S ,is d d d final output of the protocol (see, for an example, the black the one induced by the nodes of the square that are labeled 1 nodes and the connections between them in Fig. 7d on page and throughout this work we assume that max_dim = d. 21). As already mentioned, our main focus will be on ter- For simulation purposes, we also need to introduce appro- minating protocols. In this case, we assume a set Q such priate shape-constructing Turing Machines (TMs). We now halt that Q ⊆ Q ⊆ Q and, for all q ∈ Q ,every rule describe such a TM M: M’s goal is to construct a shape on out halt halt halt √ √ containing q is ineffective. In contrast, in stabilizing pro- the pixels of a n × n square, which are indexed in the halt tocols there is no Q and states in Q may have effective zig-zag way described above. M takes as input an integer halt out interactions which we guarantee (by design) to cease even- i ∈{0, 1,..., n − 1} and the size n or the dimension n of tually resulting in the stabilization of the final shape. the square (all in binary) and decides whether pixel i should belong or not to the final shape, i.e., if it should be on or off, Definition 2 We say that an execution of a protocol on n respectively. Moreover, in accordance to our definition of a processes constructs (stably constructs) a shape G,ifitter- minates (stabilizes, resp.) with output G. Observe that we have intentionally restricted attention to unary lan- Every 2D shape G has a unique minimum 2D rectan- guages as we want to focus on deterministic construction, in the sense gle R enclosing it. R is a shape with its nodes labeled G G that for any given “input-size” (here d) we want the population to always from {0, 1}. The nodes of G are labeled 1, the nodes in produce the same output shape. V (R ) \ V (G) are labeled 0, and all edges are active. It If the TM is not provided with the size of the square, then it can only compute uniform/symmetric shapes that are independent of n.Sucha is like filling G with additional nodes and edges to make shape could for example be one that has every even pixel on and every it a rectangle (in fact, this process can be carried out by odd pixel off. But such shapes rarely satisfy the connectivity condition. a protocol). The dimensions of R are defined by h , G G For example, it is not clear how to activate all the leftmost pixels of the which is the horizontal distance between a leftmost node square by a uniform TM, because such a TM should somehow guess that pixel 2 n −1 should be accepted without knowing n and given that and a rightmost node of the shape (x-dimension), and v , all pixels in [1, 2 n − 2] must be rejected. So, it seems more natural to which is the vertical distance between a highest and a lowest consider TMs that apart from the pixel index are also provided with n or node of the shape (y-dimension). Let also max_dim := n (if the latter is more convenient) in binary. Now, it is straightforward max{h ,v } and min_dim := min{h ,v }. Then R how to resolve the acceptance of only the leftmost pixels of the square. G G G G G G 123 Terminating distributed construction of shapes and patterns in a fair solution of automata 349 shape, the construction of the TM, consisting of the pixels that allows for terminating constructions will be introduced that M accepts (as on) and the active connections between in Sect. 5. them, should be connected (i.e., it should be a single shape). 4.1 Global line Definition 3 We say that a shape language L = (S , S , 1 2 S ,...) is TM-computable or TM-constructible in space We begin by presenting a protocol for the spanning line prob- f (d), if there exists a TM M (as defined above) such that, lem. Assume that there is initially a unique leader in state L for every d ≥ 1, when M is executed on the pixels of a (we typically use capital ‘L’ for the states of a leader to dis- d × d square results in S (in particular, on input (i, d), tinguish from the left port ‘l’) and all other nodes are in state where 0 ≤ i ≤ d −1, M gives output S [i ]), by using space q . A protocol that constructs a spanning line is described O( f (d)) in every execution. by the effective rules (L , i ), (q , j ), 0 → (q , L , 1) for all i 0 1 ¯ i, j ∈{u, r, d, l}, where j denotes the port opposite to port j. Definition 4 We say that a protocol A constructs a shape In words, initially the leader (i.e., L ) waits to meet a q via language L with useful space g(n) ≤ n,if g(n) is the greatest r 0 function for which: (i) for all n, every execution of A on n its right port. Assume that it meets port j of a q . Then the 5 6 connection between them becomes activated and the leader processes constructs a shape G ∈ L of order at least g(n) (provided that such a G exists) and, additionally, (ii) for all takes the place of the q , leaving behind a q . Moreover, the 0 1 new leader is now in state L indicating that it is now waiting G ∈ L there is an execution of A on n processes, for some n satisfying |V (G)|≥ g(n), that constructs G. Also, we say to expand the line towards the port that is opposite to the one that is already active, which guarantees that a straight line that A constructs L with waste n − g(n). will be formed. We could even have a simplified version of the form (L , r ), (q , l), 0 → (q , L , 1). This is a little slower, because 4 Some basic constructions 0 1 now an effective interaction, and a resulting expansion of the line, only occurs when the r port of the leader meets the l We give in this section protocols for two very basic shape port of a q . construction problems, the spanning line problem and the √ √ spanning square (or n × n square) problem. In both prob- √ √ lems, for any number of nodes n,the n nodes must end up 4.2 n × n Square organized in a desired shape from a given shape-language. In the spanning line problem, the nodes must end up with an We now give two protocols for the spanning square problem. active line that is spanning and straight and in the spanning We assume for simplicity that the square root of n is integer. square problem the nodes must end up with an active square- We again assume that there is a pre-elected unique leader, grid spanning the population. These constructions not only which is initially in state L and all other nodes are in state serve as first expositions of the model in action, but are also q . The code of our first protocol for the spanning square very useful because they organize the nodes in a way that problem is given in Protocol 1. is convenient for TM simulations that exploit the whole dis- We now describe the idea that Protocol 1 implements. tributed memory as a tape. Keep in mind that the protocols The protocol first constructs a 2 × 2 square. When it is of this section are stabilizing (that is, eventually the output done, the leader is at the bottom right corner and is in state shape stops changing) and not terminating. Our technique L . This can only cause the attachment of a free q from d 0 below, via rule (L , d), (q , u), 0 → (q , L , 1). When this d 0 1 l Footnote 3 continued occurs, the leader moves on the new node, updates its state The TM every time accepts the input-pixel i iff i = 2k n −1, for some √ √ to L , and tries to move to the left. This will occur by the k ≥ 1, or i = 2k n, for some k ≥ 0. Observe that 2k n can always attachment of another free node from the left this time, via be computed because the TM is also provided with n in its input. rule (L , l), (q , r ), 0 → (q , L , 1). When this occurs, the l 0 1 u We should mention that part of the ideas related to the pixel-encoding leader moves on the new node, updates its state to L , and and the TM operating on pixels have been inspired by similar construc- u tions of Woods et al. [43]. tries to move up. But this time the up movement cannot suc- G is the shape of a labeled square S ∈ L in case L is defined in terms ceed because the leader is below the bottom left corner of the of such squares. square. Instead, the leader activates the connection with that By “order” of a shape, we mean the number of nodes of the shape. corner, via rule (L , u), (q , d), 0 → (L , q , 1), and tries to u 1 l 1 By “greatest function” g(n), we mean that for all functions f (n) move another step left. When it succeeds, it tries to move up that satisfy the above properties and all n, it holds that g(n) ≥ f (n). again, which can now occur, via rule (L , u), (q , d), 0 → u 0 Intuitively, g(n) is a complete description of the guaranteed size of the (q , L , 1), because the leader has moved outside the left 1 r shapes that A constructs; in practice, it is often sufficient to characterize g(n) asymptotically. boundary of the 2 ×2 square. In general, whenever the leader 123 350 O. Michail Protocol 1 Square Protocol 2 Square2 1 2 3 4 1 Q ={L , L , L , L , q , q }, L = L (i.e., the initial leader-state u r d l 0 1 0 u Q = ({L , L , L , L , L : i ∈{u, r, d, l}} \ {L }) ∪{L , q , q }, i end 0 1 i i i i l is in this case L ) 2 L = L δ: δ: // an L -leader will move one step in the i direction, // adding the turning marks of the 2 × 2 square // adding one node to the perimeter of the square; 2 1 (L , d), (q , u), 0 → (L , q , 1) 0 1 d u // then it will try to change direction, clockwise 2 1 (L , l), (q , r ), 0 → (L , q , 1) 0 1 l r (L , u), (q , d), 0 → (q , L , 1) u 0 1 r 2 1 (L , u), (q , d), 0 → (L , q , 1) 0 1 u d (L , r ), (q , l), 0 → (q , L , 1) r 0 1 d (L , r ), (q , l), 0 → (L , q , 1) 0 end 1 (L , d), (q , u), 0 → (q , L , 1) r d 0 1 l // constructing the 2 × 2 square (L , l), (q , r ), 0 → (q , L , 1) l 0 1 u 1 2 (L , u), (q , d), 0 → (q , L , 1) // changing of direction cannot succeed as long as the 0 1 u l 1 2 // leader has not managed to go beyond the boundary (L , r ), (q , l), 0 → (q , L , 1) 0 1 r u 1 2 // of the square; the leader restores its previous direction (L , d), (q , u), 0 → (q , L , 1) 0 1 d r (L , u), (q , d), 0 → (L , q , 1) u 1 l 1 // end of the present phase at the bottom right corner (L , r ), (q , l), 0 → (L , q , 1) r 1 u 1 (L , d), (q , u), 0 → (q , L , 1) end 0 1 l (L , d), (q , u), 0 → (L , q , 1) d 1 r 1 // trying to grow the square perimetrically, L either (L , l), (q , r ), 0 → (L , q , 1) l 1 d 1 // suceeds and continues to be L or meets a turning // mark and becomes L // All transitions that do not appear have no effect (L , l), (q , r ), 0 → (q , L , 1) l 0 1 l (L , l), (q , r ), 0 → (q , L , 1) l 1 1 (L , u), (q , d), 0 → (q , L , 1) u 0 1 u is at the left (the up, right, and down cases are symmetric) (L , u), (q , d), 0 → (q , L , 1) u 1 1 of the already constructed square it tries to move to the right u (L , r ), (q , l), 0 → (q , L , 1) in order to walk above the square. If it does not succeed, it r 0 1 r is because it has not yet moved over the upper boundary, so (L , r ), (q , l), 0 → (q , L , 1) r 1 1 it activates the edge to the right, takes another step up and (L , d), (q , u), 0 → (q , L , 1) d 0 1 d then tries again to move to the right. In this way, the leader 3 (L , d), (q , u), 0 → (q , L , 1) d 1 1 always grows the square perimetrically and in the clockwise // adding a new turning mark to the present corner direction, i.e., following a spiral trajectory in the grid. 3 4 (L , l), (q , r ), 0 → (q , L , 1) 0 1 l d We next use turning marks to simplify and speed up 3 4 (L , u), (q , d), 0 → (q , L , 1) 0 1 u l the turning process. The unique leader begins in state L . 3 4 (L , r ), (q , l), 0 → (q , L , 1) 0 1 Now, instead of always trying to turn, the leader turns only r u 3 4 when it meets special marks left by the previous phase near (L , d), (q , u), 0 → (q , L , 1) 0 1 d r the corners of the square. When it meets such a mark, the leader introduces the new corner and a new mark adjacent 4 (L , d), (q , u), 0 → (L , q , 1) 0 u 1 to that corner to be found during the next phase, and then (L , l), (q , r ), 0 → (L , q , 1) 0 r 1 makes a turn (see Fig. 2). A difference to the previous proto- (L , u), (q , d), 0 → (L , q , 1) 0 d 1 col is that now several of the nodes of the new perimeter (L , r ), (q , l), 0 → (L , q , 1) 0 end 1 may remain disconnected for a while from their internal r // activating missing internal edges of the square neighbors (i.e., those belonging to the internal perimeter constructed in the previous phase). However, rules of the (q , i ), (q , i ), 0 → (q , q , 1), for all i ∈{u, r, d, l}, 1 1 1 1 form (q , i ), (q , i ), 0 → (q , q , 1) guarantee that these 1 1 1 1 where i denotes the opposite port of i nodes eventually become connected. A disadvantage of this (L , r ), (q , l), 0 → (L , q , 1) u 1 u 1 approach is that the structure may be less “rigid” than the pre- (L , d), (q , u), 0 → (L , q , 1) r 1 r 1 vious one as long as several (q , q ) connections are not yet 1 1 (L , l), (q , r ), 0 → (L , q , 1) d 1 d 1 established. The protocol is formally presented in Protocol (L , u), (q , d), 0 → (L , q , 1) l 1 l 1 A drawback of Protocol 2 is that the construction is never a true square but rather a square with four protruding turning marks (so, we here need n − 4 to be integer for a complete following. The leader constructs the perimeter of the present such construction). An alternative that circumvents this is the phase by walking on the perimeter drawn by the previous 123 Terminating distributed construction of shapes and patterns in a fair solution of automata 351 s the leader must again terminate and output n even though n = n. The main reason is that |s | is finite and independent 15 16 17 18 of n; it only depends on the maximum “depth” of a chain of rules of the protocol leading to termination. This implies that in s the leader terminates before interacting with all other nodes. In Sect. 5.1, we present a population protocol with a pre- end 1 12 8 elected unique leader, that solves w.h.p. the counting problem and always terminates. To the best of our knowledge, this 10 9 end is the first protocol of this sort in the relevant literature. All probabilistic protocols that have appeared so far, like 1st Phase 2nd Phase those in [1,2], are not terminating but stabilizing and the Fig. 2 The first two phases of Protocol 2. Gray nodes indicate the high probability arguments concern their time to conver- starting point of each phase. Edge labels indicate the order by which gence. Additionally, this protocol is crucial because all of the square grew during the phase. The nodes labeled L are the points end at which each of the phases ends. The unlabeled solid edges of Phase our generic constructors, that are developed in Sect. 6,are 2 indicate the shape that pre-existed from Phase 1. The nodes attached terminating by assuming knowledge of n (stored distribut- at “times” 1, 3, 5, 7 of Phase 1 and 11, 15, 19, 23 of Phase 2 are the edly on a line of length log n). They obtain access to this turning marks that will be exploited for easier turning by the leader in knowledge w.h.p. by executing the counting protocol as a the subsequent phase. Dotted edges are edges that have not be activated yet but will for sure be activated eventually resulting in a more “rigid” subroutine. Finally, knowing n w.h.p. enables us to develop structure protocols that exploit sequential composition of (terminat- ing) subroutines, which makes them much more natural and easy to describe than the protocols in which all subroutines phase. For example, while walking up the left border of the are executed in parallel and perpetual reinitializations is the square it attaches nodes to the left of the border, thus con- only means of guaranteeing eventual correctness (the latter structing a new left border. In this way, the leader just needs is the case, e.g., in [25,30,33], but not in [34] which was the to find a special state on the corner of the previous phase (or first extension to allow for sequential composition based on the absence of the corner) in order to determine that turning some non-probabilistic assumptions). Then in Sect. 5.2 we is required. comment on the possibility of dropping the unique leader Finally, though the constructions in this section were based assumption and leave this as an interesting open problem. on a pre-elected unique leader, we should mention that this Finally, in Sect. 5.3 we establish that if the nodes have unique assumption is not necessary for solving the above problems. ids then it is possible to solve the problem without a unique However, the protocols that do not require a leader are more leader. complicated and do not serve as good first expositions of the model. 5.1 Fast probabilistic counting with a leader Keep in mind that in order to simplify the discussion, a sort 5 Probabilistic counting of population protocol is presented here. So, there are no ports, no geometry, and no activations/deactivations of con- In this section, we consider the problem of counting n.In nections. In every step, a uniform random scheduler selects particular, we assume a uniform random scheduler and we equiprobably one of the n(n − 1)/2 possible node pairs, and want to give protocols that always terminate but still w.h.p. the selected nodes interact and update their states according count n correctly. The importance of such protocols is fur- to the transition function. The only difference from the clas- ther supported by the fact that we cannot guarantee anything sical population protocols is that a distinguished pre-elected much better than this. In particular, observe that if we require leader node has unbounded local memory (of the order of n). a population protocol to always terminate and additionally to In Sect. 6.1, we will adjust the protocol to make it work in always be correct, then we immediately obtain an impossibil- our model, using constant memory on every node, including ity result. It is easy to see this by imagining a system in which the leader. a unique leader interacts with the other nodes (there are no interactions between non-leaders and no connections are ever Counting-Upper-Bound protocol There is initially a unique activated). Any fair execution s of a protocol in a population leader l and all other nodes are in state q . Assume that l 1 0 of size n in which the leader outputs n and terminates can has two n-counters in its memory, initially both set to 0. So, appear as an “unfair” prefix of a fair execution s = s s on a the state of l is denoted as l(r , r ), where r is the value 1 2 0 1 0 population of size n > n. This is a contradiction because in of the first counter and r the value of the second counter, 123 352 O. Michail q q q q 0 2 q 2 q q 1 q 0 1 i 0 Fig. 3 A configuration of the system (excluding the leader). The num- number of q s introduced. The value of the counter r is equal to the 2 0 ber of q s remaining is denoted by i. The number of q s introduced so number of q s encountered, which is equal to the number of q sand 0 1 0 1 far is denoted by j. The value of the counter r is equal to the number q s introduced 1 2 of q s encountered so far by the leader, which is in turn equal to the 0 ≤ r , r ≤ n. The rules that capture the core operations of random one of the n(n − 1)/2 possible interactions. Recall 0 1 the protocol are of the form also that the random variable i denotes the number of q s and j denotes the number of q s in the current configuration, (l(r , r ), q ) → (l(r + 1, r ), q ), if r < r where initially i = n − b − 1 and j = b. Observe also that 0 1 0 0 1 1 1 0 all the following hold: j = r − r , r ≥ r , because every 0 1 0 1 (l(r , r ), q ) → (l(r , r + 1), q ), if r < r and 0 1 1 0 1 2 1 0 conversion of a q to q must have been first counted by r 1 2 0 (l(r , r ), ·) → (halt, ·) if r = r . 0 1 0 1 as a conversion of a q to q , r = (n − 1) − (i + j ), and 0 1 1 r + r is equal to the number of effective interactions (see 0 1 It is worth reminding that, for the time being, we have dis- Fig. 3). regarded edge-states and, therefore, the rules of the protocol We focus only on the effective interactions (we also dis- only specify how the states of the nodes are updated. Observe regard the halting interaction), which are always interactions that r counts the number of q s in the population while r 0 0 1 between l and q or q . Given that we have an effective inter- 0 1 counts the number of q s. Initially, there are n − 1 q s and 1 0 action, the probability that it is an (l, q ) is p = i /(i + j ) and 0 ij no q s. Whenever l interacts with a q , r increases by 1 and 1 0 0 the probability that it is an (l, q ) is q = 1− p = j/(i + j ). 1 ij ij the q is converted to q . Whenever l interacts with a q , r 0 1 1 1 This random process may be viewed as a random walk (r.w.) increases by 1 and the q is converted to q . The process ter- 1 2 on a line with n + 1 positions 0, 1,..., n where a particle minates when r = r for the first time. We also give to r an 0 1 0 begins from position b and there is an absorbing barrier at initial head start of b, where b can be any desired constant. 0 and a reflecting barrier at n. The position of the particle So, initially we have r = b, r = 0 and i = #q = n −b −1, 0 1 0 corresponds to the difference r − r of the two counters 0 1 j = #q = b (this can be easily implemented in the protocol which is equal to j. Observe now that if j ≥ n/2 then by having the leader convert bq sto q s as a preprocessing 0 1 r − r ≥ n/2 ⇒ r ≥ n/2, so it suffices to consider a 0 1 0 step). second absorbing barrier at n/2. The particle moves forward So, in Counting-Upper-Bound we have two competing (i.e., to the right) with probability p and backward with ij processes, one counting q s and the other counting q s, the 0 1 probability q (see Fig. 4). This is a “difficult” random walk ij first one begins with an initial head start of b and the game because the transition probabilities not only depend on the ends when the second catches up the first. We now prove that position j butalsoonthesum i + j which decreases in time. In when this occurs the leader will almost surely have already particular, the sum decreases whenever an (l, q ) interaction counted at least half of the nodes. occurs, in which case a q becomes q . That is, whenever the 1 2 random walk returns to some position j of the line, its tran- Theorem 1 The above protocol halts in every execution after sition probabilities have changed (because every leaving and an expected number of O(n log n) interactions. Moreover, returning involves at least on step to the left, which decreases when this occurs, w.h.p. it holds that r ≥ n/2. the sum). Observe also that, in our case, the duration of the Proof Recall that the scheduler is a uniform random one, random walk can be at most n − b, in the sense that if the which, in every step, selects independently and uniformly at 123 Terminating distributed construction of shapes and patterns in a fair solution of automata 353 q =1 − p p ij ij ij We will reduce the Ehrenfest walk to one in which the probabilities do not depend on j. We first further restrict our n/2 walk, this time to the prefix [0, b] of the line. In this part, it 0 b j holds that j ≤ b which implies that p ≥ (n − b)/n and ij Fig. 4 A random walk modeling of the probabilistic process that the q ≤ b/n .Now we set p = p = (n − b)/n and q = ij ij ij Counting-Upper-Bound protocol implements. A particle begins from q = b/n . Observe that this may only increase the probability position b. The position j of the particle corresponds to the difference of failure, so the probability of failure of the new walk is an between r and r . Forward movement corresponds to an increment of r 0 1 0 and backward movement corresponds to an increment of r . Absorption upper bound on the probability of failure of our original walk. at 0 corresponds to r becoming equal to r and thus to termination 1 0 Recall that initially the particle is on position b. Imagine now (and to failure if this occurs before r ≥ n/2 holds). Absorption at n/2 an absorbing barrier at 0 and another one at b. Whenever the corresponds to r becoming at least n/2 (before being absorbed at 0) r.w. is on b − 1 it will either return to b before reaching 0 or and thus to success it will reach 0 (and fail) before returning to b. So, we now have a r.w. with b + 1 positions, where positions 0 and b are particle has not been absorbed after n − b steps then we have absorbing and due to symmetry it is equivalent to assume that success. The reason for this is that n −b effective interactions the particle begins from position 1, moves forward with prob- imply that r + r = n, but as r ≥ r ,wehave r ≥ n/2. In 0 1 0 1 0 = q, backward with probability q = p, and it fails ability p fact, r ≥ n/2 ⇔ j + r ≥ n/2. We are interested in upper 0 1 at b. Thus, it is equivalent to bound P[reach b before 0 (when bounding P[failure]= P[reach 0 before r ≥ n/2 holds], beginning from position 1)]. This is the probability of win- which is in turn upper bounded by the probability of reaching ning in the classical ruin problem analyzed, e.g., in [23] page 0 before reaching n/2 and before n − b effective interactions 345. If we set x = q /p = p/q = (n − b)/b we have that: have occurred (this is true because, in the latter event, we have disregarded some winning conditions like, for exam- x − x x − 1 P[reach b before 0]= 1 − = ple, guaranteed winning in (n/2) + r effective interactions, b b x − 1 x − 1 in which case we have winning in only (n/2) + r effective x 1 ≤ ≈ interactions and j having become at most (n/2) − r ). It suf- b b−1 x − 1 x fices to bound the probability of reaching 0 before n effective ≈ . interactions have occurred. b−1 Thus, we have r + r ≤ n but r ≤ r ⇒ 2r ≤ r + r , 0 1 1 0 1 0 1 Thus, whenever the original walk is on b −1, the probabil- thus 2r ≤ n ⇒ r ≤ n/2 ⇒ (n − 1) − (i + j ) ≤ n/2 ⇒ 1 1 b−1 ity of reaching 0 before reaching b again, is at most 1/n . i + j ≥ (n/2) − 1. And if we set n = (n/2) − 1wehave Now assume that we repeat the above walk n times, i.e., we i + j ≥ n . Moreover, observe that when r + r = n + 1 0 1 place the particle on b − 1, play the game, then if it returns to we have n + 1 = r + r ≤ 2r ⇒ r ≥ n/2. In summary, 0 1 0 0 b we put again the particle on b − 1 and play the game again, during the first n effective interactions, it holds that i + j ≥ and so on. From Boole-Bonferroni inequality, we have that: n = (n/2) − 1 and when interaction n + 1 occurs it holds that r ≥ n/2, that is, if the process is still alive after time n, then r has managed to count up to n/2 and the protocol has P[fail at least once]≤ P[fail at repetition m] succeeded. Now, i + j ≥ n implies that p ≥ (n − j )/n ij m=1 and q ≤ j/n so that now the probabilities only depend on ij n 1 n the position j. This new walk is the well-studied Ehrenfest ≤ = b−1 b−1 n n random walk coming from the theory of brownian motion m=1 [22] and by results in [27] it is immediate to obtain that its 1 = . recurrence time is exponential in n, thus, we do not expect b−2 the walk to return to 0 and fail in only n effective steps. Footnote 8 continued In the sequel, we turn this into the desired high probability physical model, known as the Ehrenfest model of diffusion, introduced argument. in [22] in the early days of statistical mechanics to study thermodynamic equilibrium. So, the probability of failure of our counting protocol is asymptotically equivalent to the probability that urn I becomes empty Imagine gas molecules that move about randomly in a container in the first n steps assuming that it initially contains b balls. This walk which is divided into two halves symmetrically by a partition. A hole has been studied by Kac in [27] who, among other things, proved that 2R is made in the partition to allow the exchange of molecules between the mean recurrence time is ((R + k)!(R − k)!/(2R)!)2 ([27], page the subcontainers. Suppose there are n molecules in the container. 386). If we set k =−R so that the initial position is R +k = 0, then this 2R n/2 Think of the partitions as two urns, I and II, containing balls labeled evaluates to 2 = 2 , because 2R is the total length of the line. This 1 through n. Molecular motion can be modeled by choosing a number shows that, even if we begin from position 0 instead of b, the recurrence between 1 and n at random and moving the corresponding ball from time is expected to be huge and we do not expect the walk to return to the urn it is presently in to the other. This is a historically important 0 and fail in only n effective steps. 123 354 O. Michail In summary, even if the protocol was restricted to disre- least) a constant probability that some node terminates hav- gard counter differences that are greater than b, still with ing interacted only a constant number of times. probability at least 1 −1/n (for constant c = b −2) the pro- First of all, observe that a protocol, apart from the usual tocol has not terminated after at least n effective interactions, transition function δ : Q × Q → Q × Q that updates the which in turn implies that the leader has counted at least half communicating states, has also a function γ : Q × S → S of the nodes. that updates the internal memory based on the encountered For the Counting-Upper-Bound protocol to terminate, it states. We focus on deterministic γ and, in this case, the suffices for the leader to meet every other node twice. This internal state from S after k interactions only depends on the takes twice the expected time of a meet everybody (cf. [33]), observed sequence Q of encountered states (because the thus the expected running time of Counting-Upper-Bound is initial state q is always the same for all nodes). Every proto- O(n log n) (interactions). col A that always terminates, essentially defines a property L ⊆ Q consisting of those observed sequences that make Remark 1 When the Counting-Upper-Bound protocol termi- a node terminate (the remaining sequences do not cause ter- nates, w.h.p. the leader knows an r which is between n/2 mination). Moreover, as the protocol does not know n,an and n. So any subsequent routine can use directly this esti- s ∈ L of minimum length has length that is independent 0 A mation and pay in an apriori waste which is at most half of of n (it could only be a function of |Q|). Observe that for the population. In practice, this estimation is expected to be every population size n,if s is observed by some node u as much closer to n than to n/2 (in all of our experiments for up a prefix of its interaction pattern (i.e., in its first |s | inter- to 1000 nodes, the estimation was always close to (9/10)n actions) then u terminates while having participated in only and usually higher). On the other hand, if we want to deter- |s | interactions, which is a constant number independent of mine the exact value of n and have no apriori waste then we n. So, for an impossibility of dropping the leader it suffices to can have the leader wait an additional large polynomial (in prove that, for every n n and every such fixed s , there is 0 0 r ) number of steps, to ensure that the leader has met every 0 (at least) a constant probability that some node observes s . other node w.h.p. (observe, e.g., that the last unvisited node This could be further broken down into proving the following requires an expected number of Θ(n ) steps to be visited). set of arguments, provided that n n : 5.2 On dropping the leader assumption 1. With constant probability a configuration is reached, in which every state q ∈ Q has multiplicity Θ(n) (that is, An immediate question is whether the unique leader assump- appears on Θ(n) distinct nodes). tion of Theorem 1 can be dropped. Though we have not yet 2. With constant probability the multiplicities of all states managed resolve this issue, we will describe a possible strat- remain Θ(n) for Θ(n) steps. egy for proving that this is not possible. In any case, we leave 3. While (2) holds, with constant probability one of the this as a challenging open problem. Θ(n) nodes, let it be u, whose state is q , interacts |s | 0 0 The strategy would aim at showing that any protocol in times. which all nodes begin from the same state, may have some node terminate with (at least) constant probability, having If the above were true, then it would follow that u may participated in only a constant number of interactions. This observe s with constant probability, in which case u will would then imply that with constant probability the protocol terminate having interacted only a constant (i.e., |s |) number terminates without having estimated any non-constant func- of times. The reason for this is that in its ith interaction, for tion of n. In the sequel, we describe this potential strategy in all 1 ≤ i ≤|s |, u observes the ith state of s , let it be q , 0 0 i more detail. with probability (#q in the population)/Θ(n). As, by (2), Nodes again have a set of states Q and we also assume that the numerator is also Θ(n), for all q ∈ Q, the resulting they have unbounded private local memories. These mem- probability is constant. ories are for internal purposes only and their contents are not communicated to other nodes. For example, a node u 5.3 Counting without a leader but with UIDs could maintain |Q| counters, each counting the number of times the corresponding state has been encountered so far We now assume that nodes have unique ids from a universe U by u. We focus on protocols that always terminate (i.e for and that initially they do not know the ids of other nodes nor every n ≥ n , for some finite n ) and we want them to com- 0 0 n. The goal is again to count n w.h.p.. All nodes execute the pute something w.h.p., e.g., the node that first terminates to same program and no node can initially act as a unique leader, know an upper bound on n w.h.p.. Let now A be a proto- col as above. To establish the aforementioned impossibility, This seems to already follow from a result in [21], and, actually, not it would be sufficient to prove that, as n grows, there is (at only with constant probability that we require here, but w.h.p.. 123 Terminating distributed construction of shapes and patterns in a fair solution of automata 355 because nodes do not know which ids from U are actually when it meets a node for the second time it marks it twice present in the system. Nodes have unbounded memory but (simulating a q to q conversion), and that no other node can 1 2 we try to minimize it, e.g., if possible, store only up to a con- ever alter the nodes marked by u . When u interacts max max stant number of other nodes’ ids. We show that under these with a node v for the first time, then either belongs =⊥ assumptions, the counting problem can be solved without the or ⊥ = belongs < max_id. So, in this case it marks v necessity of a unique leader. once by setting marked ← 1, belongs ← max_id, and v v The idea is to have the node u with the maximum id in records this by increasing count1 by one. From now on, max u max the system to perform the same process as the unique leader no other active node w = u can ever affect the state of max in the protocol with no ids of Theorem 1. However, as ini- v, because for every such w it holds that id < belongs = w v tially all nodes have to behave as if they were the maximum, max_id and the only effect in this case is the deactivation of we must also ensure that u is not affected and that no w. The second time that u interacts with v, it still holds max max other node ever terminates (with sufficiently large probabil- that belongs = id (= max_id) and marked = 1, and v u v max ity) early, giving as output a wrong count. u marks v for a second time by setting marked ← 2 max v Informal description Every node u has a unique id id and records this by incrementing count2 by one. Again, u u max and tries to simulate the behavior of the unique leader of v still belongs to max_id and no other node can ever affect its the protocol of Theorem 1. In particular, whenever it meets state. We conclude that if we were only interested in u ’s max another node for the first time it wants to mark it once and output then, by Theorem 1, this would w.h.p. be an upper the second time it meets that node it wants to mark it twice, bound on n. recording the number of first-meetings and second-meetings However, observe that not only u but also the other max in two local counters. The problem is that now many nodes nodes execute a similar process and it could be the case that may want to mark the same node. One idea, of course, could one of them terminates early (and before u )givingas max be to have a node remember all the nodes that have marked output a wrong count. We now show that this is not the case. it so far but we want to avoid this because it requires a lot Take any node w with id < max_id. Observe that if there of memory and communication. Instead, we allow a node were no nodes with id greater than id then w would sim- to only remember a single other node’s id at a time. Every ply execute the process described for u . However, in the max node tries initially to increase its first-meetings counter to b presence such nodes, some nodes may be marked by a greater so that it creates an initial b head start of this counter w.r.t. id before w counts them and others may be marked after w the other. Every node that succeeds starts executing its main has counted them once but before counting them twice. Still, process. The main idea is that whenever a node u interacts we shall show that none of these increases the probability of with another node whose id is greater than id or that has been early termination of w (where termination of w occurs when marked by an id greater than id , u becomes deactivated and count1 = count2 first becomes satisfied). Consider the u w w stops counting. This guarantees that only u will forever partition of V \{w} into the sets S , S , and S of max w,0 w,1 w,2 remain active. Moreover, every node u always remembers the nodes which w has not marked yet, has marked once, and maximum id that has marked it so far, so that the probabilistic has marked twice, respectively. The counting process of w counting process of a node u can only be affected by nodes can only be affected when a node v in any of these sets is with id greater than id and as a result no one can affect the marked by an id greater than id :(i) If v ∈ S then w has u w w,2 counting process of u . Protocol 3 puts all these together already counted v both in count1 and count2 , therefore max w w formally and Theorem 2 shows that this process correctly marking v does not affect w’s counting at all. (ii) If v ∈ S w,1 simulates the counting process of Theorem 1, thus providing then v is a node that has been counted in count1 but not w.h.p. an upper bound on n. yet in count2 . Marking v in this case does not speed up termination, as it only decreases the probability of count2 Theorem 2 When a node u in Protocol 3 halts, w.h.p. it holds to increase (and recall that count2 is always trying to catch that u = u and that 2 · count1 ≥ n. max u up count1 ). (iii) If v ∈ S then marking v indeed slows w w,0 Proof We first show that u simulates the probabilistic down the rate of grow of count1 b, because a node that max w process of the unique leader l of Theorem 1. Recall that in could contribute to count1 and has not been counted yet the protocol of Theorem 1, all other nodes are initially q is no longer available. However, notice that every such v and when l meets a q it makes it q and when it meets a will from now on forever satisfy belongs > id , because 0 1 v w q it makes it q , every time counting in the corresponding belongs can only increase, therefore every interaction of 1 2 w with such a v will result in the deactivation of w.This counter. First, observe that u is never deactivated, i.e., max acti ve = 1 forever, because it never interacts with a implies that the “success” events of w (those correspond- max ingtoa count1 increment) have now been partitioned into greater id nor with a node that belongs to a greater id than its own. It suffices to show that when u meets a node for the count1 increment events and w deactivation events. So, if max first time it marks it once (simulating a q to q conversion), w ever fails to increment count1 due to an interference of 0 1 w 123 356 O. Michail Protocol 3 Counting with UIDs Require: Every node u has a unique id id and maintains a (belongs, marked) pair, a (count1, count2) pair, and a variable acti ve,where belongs ∈ U ∪{⊥} initially ⊥, marked ∈{0, 1, 2} initially 0, count1, count2 ∈ N initially count1 = count2 = 0and acti ve ∈{0, 1} ≥0 initially 1. All nodes know a predetermined constant b > 0. The following is the code for every interaction of u,v with id > id . u v 1: if acti ve = 1 then 2: acti ve ← 0 3: end if 4: if acti ve = 1 then 5: if belongs =⊥ or ⊥ = belongs < id then v v u 6: belongs ← id v u 7: marked ← 1 8: count1 ← count1 + 1 u u 9: end if 10: if ⊥ = belongs > id then v u 11: acti ve ← 0 12: end if 13: if belongs = id and marked = 1and count1 ≥ b then v u v u 14: marked ← 2 15: count2 ← count2 + 1 u u 16: if count1 = count2 then u u 17: u halts and outputs 2 · count1 18: end if 19: end if 20: end if some u with id > id on some v ∈ S , the effect is the 6.1 Storing the count on a line u w w,0 deactivation of w, which prevents w from continuing with unfavorable probabilities. In other words, the only event that We begin by adapting the Counting-Upper-Bound protocol could negatively affect w’s counting, deactivates w and, in of Theorem 1 to work in our model. In particular, the obtained this case, w cannot terminate early any more. protocol does not require the leader to have large local mem- ory. Instead, it stores the r and r counters distributedly 0 1 throughout the execution and when the protocol terminates 6 Generic constructors the final correct count is stored in binary on an active line of length log n. In this section, we give a characterization for the class of con- Counting-on-a-Line protocol The probabilistic process that structible 2D shape languages. In particular, we establish that is being executed is essentially the same as that of the shape constructing TMs (defined in Sect. 3), can be simulated Counting-Upper-Bound protocol. Again the protocol assumes by our model and therefore we can realize their output-shape a unique leader that forever controls the process. A difference in the actual distributed system. To this end, we begin in now is that every node has four ports (in the 2D case). The Sect. 6.1 by adapting the Counting-Upper-Bound protocol leader operates as a TM that stores the r and r counters in 0 1 of Sect. 5 to work in our model. The result is, again w.h.p., a binary, in a distributed tape that it controls. The ith cell of the line of length Θ(log n) with a unique leader, containing n in tape has three components, one storing the ith bit of r ,the binary. Then, in Sect. 6.2 the leader exploits its knowledge of other storing the ith bit of r , and the third one storing the ith √ √ n to construct a n × n square. In the sequel (Sect. 6.3), it bit of an r counter that will be discussed in the sequel. We simulates the TM on the square n distinct times, one for each say that the tape is full, if the bits of all r components of the pixel of the square. Each time, the input provided to the TM tape are set to 1. The tape of the TM is the active line that the is the index of the pixel and n, both in binary. Each simula- leader has formed so far, each node in the line implementing tion decides whether the corresponding pixel should be on or one cell of the tape. Initially the tape consists of a single cell, off. When all simulations have completed, the leader releases stored in the memory of the unique leader node. in the solution, in a systematic way, the connected shape con- As in Counting-Upper-Bound, the leader first tries to sisting of the on pixels and the active edges between them. obtain an initial advantage of b for the r counter. To achieve The connections of all other (off ) pixels become deactivated the advantage, the leader does not count the q s that it inter- and the corresponding nodes become free (isolated) nodes in acts with until it holds that r ≥ b. Observe that the initial the solution. length of the tape is not sufficient for storing the binary 123 Terminating distributed construction of shapes and patterns in a fair solution of automata 357 representation of b. In the sequel, together with the other these new choices, if treated uniformly, result in the same operations of the protocol, we also describe how the leader multiplicative factor for both the “positive” (an (l, q ) inter- handles such overflows. action) and the “negative” (an (l, q ) interaction) events, so Whenever it meets the left port of a q from its right port, the probabilities of the process are not affected at all by this. if its tape is not full yet, it switches the q to q , leaving it free Moreover, neither the debt affects the process. The reason is 0 1 to move in the solution, and increases the r counter by one. that the only essential difference w.r.t. to the process is that To increase the counter, it freezes the probabilistic process the conversion of some counted q s to the corresponding q s 0 1 (that is, during freezing it ignores all interactions with free is delayed. But this only decreases the probability of early nodes), and starts moving on its tape, which is a distributed termination and thus of failure. line attached to its left port. After incrementing the counter, It remains to show that not even a single q remains forever the leader keeps track of whether the tape is now full and then as debt, because, otherwise, some executions of the protocol it moves back to the right endpoint of the line to unfreeze and would not terminate. The reason is that the protocol cannot continue the probabilistic process. terminate before converting all the q s plus the debt to q . 1 2 On the other hand, if the tape is full, it binds the encoun- To this end, observe that the line of the leader has always tered q to its right by activating the connection between length lg r + 1, thus r ≤lg r , because the debt is 0 0 2 0 them (thus increasing the length of the tape by one), then it always at most the length of the line excluding the initial reorganizes the tape, it again increases r by one, and finally leader. So, at least r −lg r nodes have been successfully 0 0 0 moves back to the right endpoint to continue the probabilistic converted from q to q which implies that there is an eventual 0 1 process. This time, the leader also records that it has bound deposit of at least r −lg r nodes in state q . These q s 0 0 2 2 a q that should have been converted to q .This debt is also are not immediately available, but they will for sure become 0 1 stored on the tape in another counter r . Whenever the leader available in the future, because every interaction of the leader meets a q ,if r ≥ 1, it converts q to q and decreases r by with a q results in a q . Finally, observe that r −lg r ≥ 2 2 2 1 2 1 2 0 0 one. So, q s may be viewed as a deposit that is used to pay lg r holds for all r ≥ 1 (to see this, simply rewrite it 2 0 0 back the debt. In this manner, the q s that are used to form as r /2 ≥lg r ). Thus, r −lg r ≥ r , which means 0 0 0 0 0 2 the tape of the leader are not immediately converted to q that the eventual deposit is not smaller than the debt, so the when first counted. Instead, the missing q s are introduced protocol eventually pays back its debt and terminates. at a later time, one after every interaction of the leader with √ √ a q , and all of them will be introduced eventually, when a 6.2 Constructing a n × n square sufficient number of q s will become available. Finally, whenever the leader interacts with the left port of We now show how to organize the nodes into a spanning √ √ a q from its right port, it freezes, increases the r counter square, i.e., a n × n one. As we did in Sect. 4.2,weagain 1 1 by one (observe that r ≥ r always holds, so the length of assume for simplicity that n is integer. Observe that now 0 1 the tape is always sufficient for r increments), and checks the leader has n stored in its line. The present construction whether r = r . If equality holds, the leader terminates, exploits this knowledge and this makes it essentially differ- 0 1 otherwise it moves back to the right endpoint and continues ent than the constructions of Sect. 4.2. Moreover, knowledge the process. of n allows the protocol to terminate after constructing the Correctness is captured by the following lemma. square and to know that the square has been successfully constructed, a fact that was not the case in the stabilizing con- Lemma 1 Counting-on-a-Line protocol terminates in every structions of Sect. 4.2. The following protocol assumes that execution. Moreover, when the leader terminates, w.h.p. it the guarantee of Lemma 1 is provided somehow and based has formed an active line of length log n containing n in on this assumption we will show that it works correctly in binary in the r components of the nodes of the line (each every execution (this is in contrast to the high probability node storing one bit). argument of Lemma 1). This means that given the guaran- tee, the protocol that constructs the square is always correct. Proof We begin by showing that the probabilistic process Of course, if we take the composition of Counting-on-a-Line of the Counting-Upper-Bound protocol is not negatively that provides the guarantee and the protocol that constructs affected in the Counting-on-a-Line protocol. This implies the square based on the guarantee, the resulting protocol is that the high probability argument of Theorem 1 holds also again correct w.h.p., however we still allow the possibility for Counting-on-a-Line (in fact it is improved). that some other deterministic (even centralized) preprocess- First of all, observe that the four ports of the nodes intro- ing provides the required guarantee. duce more choices for the scheduler in every step. However, Square-knowing-n protocol The initial leader L first com- putes n on its line by any plausible algorithm (observe that Of course, b is constant so, in principle, it could be stored on a single node, however we prefer to keep the description as uniform as possible. the available space for computing the square root is expo- 123 358 O. Michail original line nential in the binary representation of n, which is the input L ii i i i i i to the algorithm, because, if needed, the leader can expand its line up to length n). In principle, it is not necessary to use additional space, because the leader can execute one after the other the multiplications 1 · 1, 2 · 2, 3 · 3, ... in binary s i i i e until the result becomes equal to n. Each of these operations (a) can be executed in the initial log n space of the line of the i i i i i i leader. The time needed, though exponential in the binary representation of n, is still linear in the population size n. Now that the leader also knows n, it expands its line to the right by attaching free nodes to make its length n. Then e i i L i i i e (b) it exploits the down ports to create a replica of its line. The replica has also length n and has its own leader but in a t i i i i i e i i distinguished state L . This new line plays the role of a seed that starts creating other self-replicating lines of length n. In particular, the seed attaches free nodes to its down ports, until all positions below the line are filled by nodes and addi- i tionally all horizontal connections between those nodes are seed replica (c) activated. Then it introduces a leader L to one endpoint of the replica and starts deactivating the vertical connections to Fig. 5 a Several free nodes have already been attached to the original line. Some of them have already activated some horizontal connections release the new line of length n. These lines with L leaders forming some segments of the replica. b The leader (L ) of the original are totally self-replicating, meaning that their children also line remains blocked while the leader (L ) of the replica has detected begin in state L . The initial leader L waits until the up ports that the replica is ready for detachment. It has already detached the of a non-seed replica r become totally aligned with the down three rightmost nodes and keeps moving to the left until it reaches the left endpoint and detaches the whole replica. c The seed replica has ports of the square segment that has been constructed so far. been released in the solution. The leader (L ) of the original line has So, initially it waits until a replica becomes attached to the waken up and is restoring the nodes of its line to their original states. lower side of its own line. When this occurs, it activates all When it finishes (that is, when it will have traversed the whole line and intermediate vertical connections to make the construction have returned to the left endpoint), it will go to state L to start the start square formation process. Similarly, the leader (L ) of the seed replica rigid and increments a row-counter by one (initially 0) and s is setting the nodes of its line to their normal i and e states, so that they moves to the new lowest row. If at the time of attachment r start accepting the attachment of other nodes in order to create non-seed was in the middle of an incomplete replication, then there will replicas be nodes attached to the down ports of r. L releases all these nodes, by deactivating the active connections of r to them, and then waits for another non-seed replica to arrive. When L to accept the attachment of r to the square segment. When the row-counter becomes equal to n − 1, the leader for the this occurs, the free node will be released and eventually it first time accepts the attachment of the seed to its construc- will be attached to the last free position below the seed. tion and when the seed is successfully attached the leader We now give, in Protocol 4, one of the possible protocols √ √ terminates. This completes the construction of the n × n for the replication process of the original leader’s line that square. See Figs. 5 and 6 for illustrations. creates the seed. The other replication processes, i.e., of L to The reason for attaching the seed last, and in particular L and of L to L , are almost identical to this one. Without r r r when no further free nodes have remained, is that otherwise loss of generality we assume that the original leader’s line self-replication could possibly cease in some executions. has state L on its left endpoint, e on its right endpoint, and Observe also that we have allowed the L-leader to accept the every other internal node of the line is in state i. All other attachment of a replica to the square segment even though (free) nodes are in state q . the replica may be in the middle of an incomplete replication. We additionally show that, in principle, the lines do not This is important in order to avoid reaching a point at which need a leader in order to successfully self-replicate. We give some free lines are in the middle of incomplete replications such a protocol which is “more parallel” and has a much more but there are no further free nodes for any of them to com- concise description than the previous one. We now assume plete. For a simple example, consider the seed and a replica r that one line has e on both of its endpoints and i on the and n free nodes (all other nodes have been attached to the internal nodes, and every (free) node is in state q . The code is square segment). It is possible that n − 1 of the free nodes presented in Protocol 5. The protocol works as follows. Free become attached to the seed and the last free node becomes nodes are attached below the nodes of the original line. When attached to r. We have overcome this deadlock by allowing a node is attached below an internal node i both become i and 123 Terminating distributed construction of shapes and patterns in a fair solution of automata 359 seed replica L Protocol 4 Line-Replication t t t t t t Q ={L , L , L , L , L , L , L , L , L , L , i, i , e, e }, j ∈ s start s s s {1, 2,..., 7} replicas δ: r L free nodes L // attaching nodes below the original line L (L , d), (q , u), 0 → (L , L , 1) r 0 (i, d), (q , u), 0 → (i , i , 1) original line square segment (e, d), (q , u), 0 → (e , e , 1) // connecting attached nodes with each other // horizonally to form the replica line (i , r ), (i , l), 0 → (i , i , 1) (i , r ), (e , l), 0 → (i , e , 1) // the leader of the replica starts moving along its line // activating any missing connections on the way 1 2 (L , r ), (i , l), 0 → (e , L , 1) s s Fig. 6 The seed at the top has created another replica which has just 2 2 (L , r ), (i , l), ·→ (i , L , 1) s s been released in the solution. Below it, some additional replicas appear. // once it reaches the right endpoint it starts to detach One of them is in the middle of a replication that has not completed yet. There are also several nodes that are still free. At the bottom appears // the replica from the original line by dectivating one the square segment that has been constructed so far. The original line of // after the other all vertical connections while moving the L-leader is the one at the top of the rectangle. The other rows below // to the left it have been formed by replicas that have been attached to the segment 2 3 in previous steps. The L-leader keeps waiting at the bottom left corner (L , r ), (e , l), ·→ (i , L , 1) s s for new replicas to arrive. One such has just arrived and will be attached 3 4 (L , u), (e , d), 1 → (L , e , 0) s s to the segment 4 5 (i , r ), (L , l), 1 → (L , e , 1) s s 5 6 (L , u), (i , d), 1 → (L , i , 0) s s when a node is attached below an endpoint e, both become 6 5 (i , r ), (L , l), 1 → (L , i , 1) e . Moreover, adjacent nodes of the replica connect to each s s // once it reaches the left endpoint it deactivates the other and every such connection increases their index. In // last remaining vertical connection and the replica is fact, their index counts their degree. An internal node of the // separated from the original line replica can detach from the original line only when it has 6 7 degree 3, that is, when, apart from its vertical connection, (e , r ), (L , l), 1 → (L , i , 1) s s it has also already become connected to both a left and a 7 t t (L , u), (L , d), 1 → (L , L , 0) s s right neighbor on the replica. On the other hand, an endpoint // the leaders of the two lines restore the local states detaches when it has a single internal neighbor. It follows // of all nodes to their default values to enable further that the replica can only detach when its length (counted // replications in number of horizontal active connections) is equal to that t t (x , r ), (i , l), 1 → (e , x , 1), x ∈{L , L } of the original line. To see this, assume that a shorter line t t (x , r ), (i , l), 1 → (i , x , 1), x ∈{L , L } detaches at some point. Clearly, such a line must have at s t t least one endpoint that corresponds to an internal node i of (x , r ), (e , l), 1 → (x , e, 1), x ∈{L , L } the replica. But this node is an endpoint of the shorter line, t t (i , r ), (x , l), 1 → (x , i, 1), x ∈{L , L } so its degree is less than 3, i.e., j < 3, and we conclude that (e , r ), (L , l), 1 → (L , i, 1) it cannot have detached. (e , r ), (L , l), 1 → (L , i, 1) start Lemma 2 There is a protocol (described above) that when executed on n nodes (for all n with integer n) w.h.p. con- √ √ structs a n × n square and terminates. Proof From Lemma 1, when the leader in Counting-on-a- described in Protocol 4. The seed replica keeps creating new Line protocol terminates, w.h.p. it has formed an active line self-replicating replicas. All these replications are performed of length log n containing n in binary in the r components by a routine essentially equivalent to Protocol 4. Every replica √ √ of the nodes of the line. Then the leader computes n on is a line of length n and will be eventually attached to its line and expands its line to make its length n.Next the square-segment to form another row of the square. First the leader creates the seed replica by executing the routine observe that the seed may only be attached to the square, 123 360 O. Michail Protocol 5 No-Leader-Line-Replication moving to the right until the bottom right corner is encoun- tered, then one step up, then to the left until the node above the Q ={q , e, e , i, i , i , i } 0 1 1 2 3 bottom left corner is encountered, then one step up again, then δ: right, and so on. To simplify this process, we may assume that (i, d), (q , u), 0 → (i , i , 1) 0 1 1 a preprocessing has marked appropriately the turning points (e, d), (q , u), 0 → (e , e , 1) 0 1 1 (see Fig. 7b). The tape will be used to simulate a TM M of the (i , r ), (i , l), 0 → (i , i , 1) for all j, k ∈{1, 2} j k j +1 k+1 form described in the Sect. 3.The n pixels of the square are (i , r ), (e , l), 0 → (i , e , 1) 1 1 2 2 numbered according to the above zig-zag process beginning (i , r ), (e , l), 0 → (i , e , 1) 2 1 3 2 from the bottom left node, each node corresponding to one (e , r ), (i , l), 0 → (e , i , 1) 1 1 2 2 pixel. The space available to the TM is exponential in the (e , r ), (i , l), 0 → (e , i , 1) binary representation of the input (i, n) (or (i, n)), because 1 2 2 3 (i , u), (i , d), 1 → (i, i, 0) i ≤ n −1 and therefore the length of its binary representation 3 1 (e , u), (e , d), 1 → (e, e, 0) |i|= O(log n), thus |(i, n)|= O(log n), but the available 2 1 log n |(i,n)| space is Θ(n) = Θ(2 ) = Ω(2 ) (still it is linear in the size of the whole shape to be constructed). The protocol invokes n distinct simulations of M, one when the square has already obtained n − 1rows. This for each of the pixels i ∈{0, 1,..., n − 1} beginning from implies that replications do not cease before the square has i = 0 and every time incrementing i by one. The leader been successfully constructed. Additionally, any non-seed maintains the current value of i in binary, in a pixel-counter replica r can be attached to the square-segment (whenever 11 pi xel stored in the O(log n) leftmost cells of the tape. the l leader is in the state of waiting for new attachments) Recall that the leader knows n from the procedures of the independently of whether r is in the middle of an incomplete previous sections. So, we may assume that the tape also holds replication. The reason is that attachment occurs via the up in advance n and n in binary (again in the leftmost cells). ports of r while replication takes place via the down ports of Initially pi xel = 0 and the leader marks the 0th node, that r. If this occurs, then the nodes of the incomplete replication is, the bottom left corner of the square. Then it simulates are simply released as free nodes. So, assume that there are k M on input (pi xel, n). When M decides, if its decision is nodes that are either free or part of an incomplete replication. accept, the leader marks the node corresponding to pi xel as We only have to prove that as long as k ≥ n then eventually on, otherwise it marks it as off. Then the leader increments another replica has to be formed. If not, then for an infinite pi xel by one, marks the node corresponding to the new value number of steps it holds that k ≥ n. Moreover, every non- of pi xel (which is the next node on the tape), clears the tape seed replica in a finite number of steps becomes attached to from residues of the previous simulation, invokes another the square-segment and releases any nodes of an incomplete simulation of M on the new value of pi xel, and marks the replication. Thus, in a finite number of steps, every one of corresponding node as on or off according to M’s decision. the k ≥ n nodes is either free or part of an incomplete The process stops when pi xel = n, in which case no further replication of the seed. Clearly, given that the seed does not simulation is executed. Alternatively, the leader can detect cease self-replication and given that there are enough nodes termination by exploiting the fact that the last pixel to be to fill the n replication positions of the seed, in a finite examined is the one corresponding to the upper left or right number of steps (due to fairness) all these positions should corner of the square (depending on whether n is even or have been filled and a replica should have been created. Thus, odd), which can be detected. the assumption that no further replication occurs violates the When the above procedure ends, the leader starts walking fairness condition. the tape in the opposite direction until it reaches the bottom left corner. In the way, it passes a release signal to every 6.3 Simulating a TM node it goes through. A node enters the release phase exactly when the leader departs from that node, apart from the bottom We now assume as given (from the discussion of the previous left corner which enters the release phase when the leader √ √ section) a n × n square with a unique leader L at the bot- arrives. When two nodes that are both in the release phase tom left corner. However, keep in mind that, in principle, the interact, if at least one of them is off and their connection is simulation described here can begin before the construction √ √ of the n× n square is complete. The only difference in this When we refer to the tape, we mean the line produced by traversing the square in a zig-zag way beginning from the bottom left node, as case, is that the two processes are executed in parallel and if described above. So the “leftmost”, here, corresponds to the leftmost at some point the TM needs more space, it has to wait until it nodes of the line, e.g., the left part of the bottom row of the square, and becomes available. The square may be viewed as a TM-tape should not be confused with the nodes on the leftmost column of the of length n traversed by the leader in a “zig-zag” fashion, first square. 123 Terminating distributed construction of shapes and patterns in a fair solution of automata 361 L L (a) (b) (c) (d) √ √ Fig. 7 a The n × n square has just been constructed. b The virtual pixel 1,..., the last position of the tape to pixel n −1. c The shape, which tape on the square. The arrows show the direction in which the tape is looks like a star, has been formed on the square. It consists of the pixels traversed from left to right (opposite arrows for the opposite direction that the TM M decidedtobe on, which are colored black here. All other are not shown). The two endpoints of the tape are marked as black here white pixels are the off pixels. The simulations have completed and the and the turning points are marked as gray. These facilitate the leader leader has just reached the upper right corner and now it starts releas- to detect and choose the right action, e.g., turn left twice (equivalently, ing the shape. To improve visibility, the edges that will eventually be follow the up port and then the left port) when it arrives at the bottom deactivated appear as dotted here. d Releasing is almost complete. The right corner and wishes to continue on the second row. The indices of leader has reached the bottom left corner and has updated all nodes to the pixels that the procedure assumes follow the order of the tape, that the release phase. Any connection involving at least one off node (i.e., is, the first position of the tape corresponds to pixel 0, the second to a white one) will be eventually deactivated active, they deactivate the connection. Clearly, the only nodes The following theorem states the lower bound implied by that will remain connected in the solution are the on nodes the construction described in this section. forming the desired connected 2-dimensional shape that M Theorem 3 Let L = (S , S ,...) be a connected 2D shape 1 2 computes. If we additionally require the leader to know when language, such that L is TM-computable in space d . Then all deactivations have completed and terminate, then we can there is a protocol (described above) that w.h.p. constructs L. either (i) have the leader deactivate them itself while moving In particular, for all d ≥ 1, whenever the protocol is executed backwards, also ensuring that it does not remain on a node 2 on a population of size n = d , w.h.p. it constructs S and that will be released, or (ii) have the leader repeatedly explore terminates. In the worst case, when G (that is, the shape of the final connected shape until it detects that all potential 2 S ) is a line of length d, the waste is (d − 1)d = O(d ) = deactivations have occurred. O(n). 123 362 O. Michail Proof We have to show that for every n = d , when the pro- tocol is executed on d nodes constructs G . From Lemma 2, we have a subroutine that terminates having w.h.p. con- structed a d × d square with a unique leader on the bottom left node. Next, the leader can easily organize the square k z into a tape of length d that has d stored in binary in its leftmost cells. Moreover, L is computable, so, by Defini- tion 3, there is a TM M that when executed on the pixels of a d × d square constructs S . The protocol simulates Fig. 8 The constructed d × d square lies in dimensions x and y.We M on the pixels of such a d × d square thus the result is can think as its “bottom left” corner, its leftmost node in the figure. S , which is an on/off labeled d × d square the on pixels d Every internal intersection point of the square is also a node, but we have not drawn these nodes here to improve visibility. “Below” it, in of which form G . To perform the simulation, the protocol 2 dimension z,are the d lines of length k each. The protocol executes a just feeds M with (i, d) = (0, d), (1, d), . . . , (d − 1, d), distinct simulation of the TM on each of these lines. In particular, on the one at a time, simulates M on input (i, d) in space Θ(d ), line attached to pixel i,for all0 ≤ i ≤ d − 1, the protocol simulates marks the corresponding pixel as on or off according to M’s the TM on input (i, d) decision, and moves on to the next input. When i = d , the square contains G and the leader releases G by one d d TM is already such a (computed) 0/1 pattern. The generic of the terminating approaches described above and termi- idea to extend this is to keep the same constructor as above nates. Observe that, given the guarantees of Lemma 2,the and simulate TMs that for every pixel output a color from a set procedure described here is always correct. So, the proba- of colors C. Then the resulting square with its nodes labeled bility of failure of the whole protocol is just the probability from C is the desired computed pattern and no releasing is of failure of the initial counting subroutine, thus the pro- required in this case. tocol succeeds w.h.p.. Finally, the waste is always equal to the number of pixels of the d × d square that are not part 6.4 Parallelizing the simulations of G . Observe now that the waste can never be more than (d −1)d, because if it was at least (d −1)d +1 = d −d +1, We now present two approaches for parallelizing the simu- then the size of G (i.e., the useful space) would be at most 2 2 lations, instead of executing them sequentially one after the d − (d − d + 1) = d − 1. But then, connectivity of G other. implies that max_dim ≤ d − 1, which contradicts the assumption that max_dim = d. Thus, the worst possible 6.4.1 Approach 1 waste is indeed (d − 1)d = O(d ) = O(n). Notice that here the waste of the protocol is equal to the waste of the simulated One approach is to construct a 2D shape in 3D space, by using TM: the protocol just provides the maximum square that fits the 3D version of our model (that is, the one with 6 ports). in the population and the TM determines which nodes will The idea is to construct a square as before and have each node be part of the final shape and which will be thrown away as in the square to grow its own line in the third dimension to waste. carry out the TM simulation for that node (see Fig. 8). Remark 2 It is worth mentioning that if the system designer knew n in advance, then he/she could preprogram the nodes 6.4.2 Approach 2 to simulate a TM that constructs a specific shape of size n,for example the TM corresponding to the Kolmogorov complex- We now show how to achieve a similar parallelism while ity of the shape (which is in turn the Kolmogorov complexity avoiding the use of a third dimension. Now the unique leader of the desired binary pixel sequence (s , s ,..., s )). 0 1 n−1 that knows n, instead of constructing a square, constructs a However, in this work we consider systems in which nis spanning line of length d , say in the x dimension. This line not known in advance, so the natural approach is to pre- corresponds to a linear expansion of the pixels of the d × d program the nodes with a TM that can work for all n.The square of the previous construction. Moreover, the leader cre- protocol must first compute n (w.h.p.) and then simulate the ates a seed of length k −1 as before, to partition the rest of the TM on input n to construct a shape of the appropriate size. nodes into lines of length k − 1, this time in the y dimension. For example, it could be a TM constructing a star, as in Fig. Each such line will be attached below one of the nodes of the 7c, such that the size of the star grows as n grows. x-line. As before, when all y-lines have been attached, the Remark 3 The above results can be immediately modified to leader initializes their memories with (i, d), where i is the refer to patterns instead of shapes. In fact, observe that the index of the corresponding pixel (the index of each pixel is √ √ n × n square that has been labeled by off and on by the now its distance from the left endpoint of the x-line, begin- 123 Terminating distributed construction of shapes and patterns in a fair solution of automata 363 1 2 (a) (b) Fig. 9 a As in Fig. 8, d lines of length k−1 each, are hanging below the upper side attaches to the upper side of segment 1. Every segment has d pixels. The difference now is that the pixels have been arranged lin- been marked by a black and a gray node placed at an appropriate posi- early in dimension x. So, the whole construction is now 2-dimensional. tion. b The segments have been released in the solution, and now they The pixels have been partitioned into equal segments of length d each have to gather together in order to form the square. Each segment knows (see the black vertical delimiters). The numbers represent the indices the correct orientation, i.e., whether it should use its up or down ports, of the segments counted from left to right. The arrows leaving above and also it can detect its predecessor row by exploiting the marking. In or below the segments, indicate which side of the segment should look particular, it attaches to a row if its black mark is above the gray mark “downwards” in the square that will be constructed. For example, seg- of the other row when their orientation is correct and their endpoints ment 1 can remain as it is, while segment 2 has to be rotated so that its are totally aligned ning from 0 and ending at d − 1). Then all simulations they meet their counterpart, and when this occurs the two of M are executed in parallel and eventually each one of segments bind together. Eventually, the d × d square is con- them sets its x-pixel to either on or off. When all simula- structed and every pixel is in the correct position (the position tions have ended, the leader releases the auxiliary memories corresponding to its index counting in a zig zag fashion as in (i.e., the y-lines) and then partitions the x-line into consec- the previous sections). The leader periodically walks on its utive segments of length d by placing appropriate marks on component to detect when it has become equal to the desired the boundary nodes (see Fig. 9a). Each segment corresponds square. When this occurs, it initiates as before the releasing to a row of the d × d square to be constructed. In particu- phase to isolate the final connected shape consisting of the lar, segment i ≥ 1 counting from left corresponds to row i on pixels. (rows being counted bottom-up). Observe that, in the way Remark 4 In all the above constructions the unique leader the pixels have been indexed, segment 2 should match with assumption can be dropped in the price of sacrificing ter- its upper side the upper side of segment 1 (that is, segment 2 mination. In this case, the constructions become stabilizing should rotate 180 ), segment 3 should match with its lower by the reinitialization technique, as in [33], but should be side the lower side of segment 2, and so on. In general, if i is carefully rewritten. even, segment i should match with its upper side to the upper side of segment i −1 and, if i is odd, segment i should match with its lower side the lower side of segment i −1. The leader 7 Conclusions and further research marks appropriately the nodes of each segment to make them aware of the orientation that they should have in the square. There are several interesting open problems related to the Moreover, it assigns a unique key-marking to each segment findings of this work. A possible refinement of the model so that segment i can easily and locally detect segment i − 1. could be a distinction between the speed of the scheduler and In particular, if i is odd, it marks nodes i and i − 1 of the seg- the internal operation speed of a component. For example, ment counting from left to right (for segment 1 it only marks a connected component will operate in synchronous rounds, the leftmost node), and, if i is even, it marks nodes i and where in each round a node observes its neighborhood and its i − 1 of the segment counting from right to left. In this man- own state and updates its state based on what it sees. Nodes ner, given that segments respect the correct orientation and can of course update also the state of their local connections provided that attachment is only performed when their end- and we may assume that a connection is formed/dropped if points match, every segment i uniquely matches to segment both nodes agree on the decision (another possibility is to i − 1 because the first mark of i is uniquely aligned with the allow a link change state if at least one of the nodes say second mark of i − 1(seeFig. 9b). Then the leader releases so). This distinction between two different “times”, though all segments, one after the other, and it remains on the last ignored so far in the literature, is very natural because a con- segment. The segments are free to move in the solution until nected component should operate at a different speed than 123 364 O. Michail it takes for the scheduler to bring two nodes (e.g., of dif- still be able to have a construction that constantly exists in ferent components, or an isolated node and a node of some the population by evolving and self-replicating. component) into contact. In the same spirit, it would be interesting to develop rou- It would be also interesting to consider for the first time tines that can rapidly reconstruct broken parts. For example, a hybrid model combining active mobility (that is, mobil- imagine that a shape has stabilized but a part of it detaches, ity controlled by the protocol) and passive mobility (that is, all the connections of the part become deactivated, and all its mobility controlled by the environment as in this paper). For nodes become free. Can we detect and reconstruct the broken example, it could be a combination of the Nubot model and part efficiently (and without resetting the whole population the model presented in this work. Another very intriguing and repeating the construction from the beginning)? What problem is to give a proof, or strong experimental evidence, knowledge about the whole shape should the nodes have to of whether the unique leader assumption is necessary for be able to reconstruct missing parts of it? Finally, it would be solving counting w.h.p. (see Sect. 5.2). If true, it would imply interesting to study in depth the shape self-replication prob- that there is no analogue of Theorem 1 if all processes are lem in our model in 2 and 3 dimensions (possibly by adjusting identical. A possibility left open then would be to achieve known techniques on replication [4,11,26,28]). Some of our high probability counting with f (n) leaders. There is also preliminary results, show that replication of 2D shapes in work to be done w.r.t. analyzing the running times of our two dimensions is possible by “squaring” the original shape, protocols and our generic constructors and proposing more then copying one column at a time, and shifting the copy efficient solutions. Also it is not yet clear whether the pro- of the column to the right to create a replica to the right of tocol of Sect. 5.1 is the fastest possible nor that its success the original shape. It is worth mentioning that several related probability or the upper bound on n that it guarantees cannot problems have been studied in the literature of algorithmic be improved; a proof would be useful. Moreover, it is not self-assembly, so future work in distributed network/shape obvious what is the class of shapes and patterns that the TMs construction will greatly benefit from taking into account considered here compute. Of course, it was sufficient as a first those developments, trying to adjust them where not directly step to draw the analogy to such TMs because it helped us applicable, and from highlighting the differences and simi- establish that our model is quite powerful. However, still we larities between the various related models originating from would like to have a characterization that gives some more different research areas. insight to the actual shapes and patterns that the model can Acknowledgements The author would like to thank Dimitrios Amax- construct. ilatis and Marios Logaras for implementing (in Java) the probabilistic It would be also important to develop models (e.g., varia- counting protocol of Sect. 5.1 and experimentally verifying its correct- tions of the one proposed here) that take other real physical ness and also David Doty for a few fruitful discussions on the same considerations into account. In this work, we have restricted protocol at the very early stages of this work. Finally, the author would like to thank the anonymous reviewers of this article and of its prelim- attention on some geometric constraints. Other properties of inary version. Their thorough reading and comments have helped the interest could be weight, mass, strength of bonds, rigid and author to improve his work substantially. elastic structure, collisions, and the interplay of these with the interaction pattern and the protocol. Moreover, in real Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecomm applications mere shape construction will not be sufficient. ons.org/licenses/by/4.0/), which permits unrestricted use, distribution, Typically, we will desire to output a shape/structure that opti- and reproduction in any medium, provided you give appropriate credit mizes some global property, like energy and strength, or that to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. achieves a desired behavior in the given physical environ- ment. The latter also indicates that the construction and the environment that the construction inhabits cannot be studied in isolation. Instead, the two will constantly affect each other, the optimal output will highly depend on the optimality that References the environment allows and also the environment may highly and continuously affect the construction process. The capa- 1. Angluin, D., Aspnes, J., Diamadi, Z., Fischer, M.J., Peralta, R.: Computation in networks of passively mobile finite-state sensors. bility of the environment to affect the construction process Distrib. Comput. 18, 235–253 (2006) suggests many robustness issues. Imagine an environment 2. Angluin, D., Aspnes, J., Eisenstat, D.: Fast computation by popula- that can at any given time break an active link with some tion protocols with a leader. Distrib. Comput. 21, 183–199 (2008) (small) probability (a similar question was also posed to the 3. Angluin, D., Aspnes, J., Eisenstat, D., Ruppert, E.: The computa- tional power of population protocols. Distrib. Comput. 20, 279–304 author during his talk at PODC ’14 by some attendee, who (2007) the author would like to thank). Under such a perpetual set- 4. Abel, Z., Benbernou, N., Damian, M., Demaine, E.D., Demaine, back no construction can ever stabilize. However, we may M.L., Flatland, R., Kominers, S.D., Schweller, R.: Shape replica- tion through self-assembly and RNase enzymes. In: Proceedings 123 Terminating distributed construction of shapes and patterns in a fair solution of automata 365 of the Twenty-First Annual ACM-SIAM Symposium on Discrete loquium on Automata, Languages and Programming (ICALP), Algorithms, pp. 1045–1064. SIAM (2010) Volume 5556 of LNCS, pp. 484–495. Springer (2009) 5. Aloupis, G., Benbernou, N., Damian, M., Demaine, E.D., Flatland, 26. Hendricks, J., Patitz, M.J., Rogers, T.A.: Replication of arbi- R., Iacono, J., Wuhrer, S.: Efficient reconfiguration of lattice-based trary hole-free shapes via self-assembly with signal-passing tiles. modular robots. Comput. Geom. 46, 917–928 (2013) In: International Conference on Unconventional Computation and 6. Adleman, L.M.: Molecular computation of solutions to combina- Natural Computation, pp. 202–214. Springer (2015) torial problems. Science 266, 1021–1024 (1994) 27. Kac, M.: Random walk and the theory of brownian motion. Am. 7. Angluin, D.: Local and global properties in networks of processors. Math. Mon. 54(7), 369–391 (1947) In: Proceedings of the 12th Annual ACM Symposium on Theory 28. Keenan, A., Schweller, R., Zhong, X.: Exponential replication of of Computing (STOC), pp. 82–93. ACM (1980) patterns in the signal tile assembly model. Nat. Comput. 14, 265– 8. Aspnes, J., Ruppert, E.: An introduction to population protocols. 278 (2015) In: Garbinato, B., Miranda, H., Rodrigues, L. (eds.) Middleware for 29. Lynch, N.A.: Distributed Algorithms, 1st edn. Morgan Kaufmann Network Eccentric and Mobile Applications, pp. 97–120. Springer, Inc, San Francisco (1996) Berlin (2009) 30. Michail, O., Chatzigiannakis, I., Spirakis, P.G.: Mediated popula- 9. Attiya, H., Welch, J.: Distributed Computing: Fundamentals, Sim- tion protocols. Theor. Comput. Sci. 412, 2434–2450 (2011) ulations, and Advanced Topics, vol. 19. Wiley, New York (2004) 31. Michail, O., Chatzigiannakis, I., Spirakis, P.G.: New models for 10. Beauquier, J., Burman, J., Clement, J., Kutten, S.: On utilizing population protocols. In: Lynch, N.A. (ed.) Synthesis Lectures on speed in networks of mobile agents. In: Proceedings of the 29th Distributed Computing Theory. Morgan & Claypool, San Rafael ACM SIGACT-SIGOPS Symposium on Principles of Distributed (2011) Computing (PODC), pp. 305–314. ACM (2010) 32. Michail, O.: Terminating distributed construction of shapes and 11. Chalk, C., Demaine, E.D., Demaine, M.L., Martinez, E., Schweller, patterns in a fair solution of automata. In: Proceedings of the R., Vega, L., Wylie, T.: Universal shape replicators via self- 34th ACM Symposium on Principles of Distributed Computing assembly with attractive and repulsive forces. In: Proceedings of (PODC), pp. 37–46. ACM (2015) the 28th Annual ACM-SIAM Symposium on Discrete Algorithms 33. Michail, O., Spirakis, P.G.: Simple and efficient local codes for (SODA), pp. 225–238. SIAM (2017) distributed stable network construction. Dist. Comput. 29(3), 207– 12. Chen, H.-L., Doty, D., Soloveichik, D.: Deterministic function 237 (2016). doi:10.1007/s00446-015-0257-4v computation with chemical reaction networks. Nat. Comput. 13, 34. Michail, O., Spirakis, P.G.: Terminating population protocols via 517–534 (2014) some minimal global knowledge assumptions. J. Parallel Distrib. 13. Chatzigiannakis, I., Michail, O., Nikolaou, S., Pavlogiannis, A., Comput. (JPDC) 81, 1–10 (2015) Spirakis, P.G.: Passively mobile communicating machines that use 35. Michail, O., Spirakis, P.G.: Elements of the theory of dynamic restricted space. Theor. Comput. Sci. 412, 6469–6483 (2011) networks. Commun. ACM (2017). https://livrepository.liverpool. 14. Chen, M., Xin, D., Woods, D.: Parallel computation using active ac.uk/3006836/ (To appear) self-assembly. Nat. Comput. 14, 225–250 (2015) 36. Michail, O., Skretas, G., Spirakis, P.G.: On the transformation 15. Derakhshandeh, Z., Dolev, S., Gmyr, R., Richa, A.W., Scheideler, capability of feasible mechanisms for programmable matter. In: C., Strothmann, T.: Brief announcement: amoebot—a new model Proceedings of the 44th International Colloquium on Automata, for programmable matter. In: Proceedings of the 26th ACM Sym- Languages and Programming (ICALP), pp. 136:1–136:15 (2017) posium on Parallelism in Algorithms and Architectures (SPAA), 37. Padilla, J.E., Patitz, M.J., Schweller, R.T., Seeman, N.C., Sum- pp. 220–222. ACM (2014) mers, S.M., Zhong, X.: Asynchronous signal passing for tile 16. Das, S., Flocchini, P., Santoro, N., Yamashita, M.: Forming self-assembly: fuel efficient computation and efficient assembly sequences of geometric patterns with oblivious mobile robots. Dis- of shapes. Int. J. Found. Comput. Sci. 25, 459–488 (2014) trib. Comput. 28, 131–145 (2015) 38. Rubenstein, M., Cornejo, A., Nagpal, R.: Programmable self- 17. Derakhshandeh, Z., Gmyr, R., Richa, A.W., Scheideler, C., Stroth- assembly in a thousand-robot swarm. Science 345, 795–799 (2014) mann, T.: Universal shape formation for programmable matter. In: 39. Rothemund, P.W.K., Winfree, E.: The program-size complexity of Proceedings of the 28th ACM Symposium on Parallelism in Algo- self-assembled squares. In: Proceedings of the 32nd Annual ACM rithms and Architectures (SPAA), pp. 289–299. ACM (2016) Symposium on Theory of Computing (STOC), pp. 459–468 (2000) 18. Dolev, S., Gmyr, R., Richa, A.W., Scheideler, C.: Ameba-inspired 40. Schiff, J.L.: Cellular Automata: A Discrete View of the World, vol. self-organizing particle systems. arXiv preprint arXiv:1307.4259 45. Wiley, New York (2011) (2013) 41. Soloveichik, D., Cook, M., Winfree, E., Bruck, J.: Computation 19. Di Luna, G.A., Flocchini, P., Santoro, N., Viglietta, G., Yamauchi, with finite stochastic chemical reaction networks. Nat. Comput. 7, Y.: Shape formation by programmable particles. arXiv preprint 615–633 (2008) arXiv:1705.03538 (2017) 42. Suzuki, I., Yamashita, M.: Distributed anonymous mobile robots: 20. Doty, D.: Theory of algorithmic self-assembly. Commun. ACM 55, formation of geometric patterns. SIAM J. Comput. 28, 1347–1363 78–88 (2012) (1999) 21. Doty, D.: Timing in chemical reaction networks. In: Proceedings of 43. Woods, D., Chen, H.-L., Goodfriend, S., Dabby, N., Winfree, E., the 25th Annual ACM-SIAM Symposium on Discrete Algorithms Yin, P.: Active self-assembly of algorithmic shapes and patterns (SODA), pp. 772–784 (2014) in polylogarithmic time. In: Proceedings of the 4th Conference on 22. Ehrenfest, P., Ehrenfest-Afanassjewa, T.: Über zwei bekannte ein- Innovations in Theoretical Computer Science, pp. 353–354. ACM wände gegen das boltzmannsche h-theorem. Phys. Zeit. 8, 311–314 (2013). Full version: arXiv preprint arXiv:1301.2626 (1907) 44. Winfree, E.: Algorithmic self-assembly of DNA. PhD thesis, Cal- 23. Feller, W.: An Introduction to Probability Theory and Its Applica- ifornia Institute of Technology, June (1998) tions, vol. 1, 3rd edn. Wiley, New York (1968). (Revised Printing) 24. Goldstein, S.C., Campbell, J.D., Mowry, T.C.: Programmable mat- ter. Computer 38, 99–101 (2005) 25. Guerraoui, R., Ruppert, E.: Names trump malice: tiny mobile agents can tolerate byzantine failures. In: 36th International Col-
Distributed Computing – Springer Journals
Published: Aug 23, 2017
You can share this free article with as many people as you like with the url below! We hope you enjoy this feature!
Read and print from thousands of top scholarly journals.
Already have an account? Log in
Bookmark this article. You can see your Bookmarks on your DeepDyve Library.
To save an article, log in first, or sign up for a DeepDyve account if you don’t already have one.
Copy and paste the desired citation format or use the link below to download a file formatted for EndNote
Access the full text.
Sign up today, get DeepDyve free for 14 days.
All DeepDyve websites use cookies to improve your online experience. They were placed on your computer when you launched this website. You can change your cookie settings through your browser.