Time and Space Optimal Counting in Population Protocols

Time and Space Optimal Counting in Population Protocols

James Aspnes The work of this author is supported in part by NSF grants CCF-1650596 and CCF-1637385. Yale University, USA
james.aspnes@gmail.com
Joffroy Beauquier Université Paris Sud, LRI, France
{joffroy.beauquier, janna.burman}@lri.fr
Janna Burman contact author Université Paris Sud, LRI, France
{joffroy.beauquier, janna.burman}@lri.fr
Devan Sohier Université de Versailles, LI-PaRAD, France
devan.sohier@uvsq.fr
Abstract

This work concerns the general issue of combined optimality in terms of time and space complexity. In this context, we study the problem of (exact) counting resource-limited and passively mobile nodes in the model of population protocols, in which the space complexity is crucial. The counted nodes are memory-limited anonymous devices (called agents) communicating asynchronously in pairs (according to a fairness condition). Moreover, we assume that these agents are prone to failures so that they cannot be correctly initialized.

This study considers two classical fairness conditions, and for each we investigate the issue of time optimality of counting given the optimal space per agent. In the case of randomly interacting agents (probabilistic fairness), as usual, the convergence time is measured in terms of parallel time (or parallel interactions), which is defined as the number of pairwise interactions until convergence, divided by (the number of agents). In case of weak fairness, where it is only required that every pair of agents interacts infinitely often, the convergence time is defined in terms of non-null transitions, i.e, the transitions that affect the states of the interacting agents.

First, assuming probabilistic fairness, we present a “non-guessing” time optimal protocol of expected time given an optimal space of only one bit, and we prove the time optimality of this protocol. Then, for weak fairness, we show that a space optimal (semi-uniform) solution cannot converge faster than in time (non-null transitions). This result, together with the time complexity analysis of an already known space optimal protocol, shows that it is also optimal in time (given the optimal space constrains).

networks of passively mobile agents/sensors, population protocols, counting, anonymous non-initialized agents, time and space complexity, lower bounds, probabilstic/weak fairness
\Copyright

James Aspnes, Joffroy Beauquier, Janna Burman and Devan Sohier\subjclassC.2.4 Distributed Systems, I.1.2 Algorithms

1 Introduction

In this paper we are interested in the determination of the exact number of nodes in a mobile sensor network. In the considered networks, sensors are typically attached to mobile supports (vehicles, animals, people, etc.) moving in an unpredictable way. Moreover, nodes may be deployed at large scale. Therefore they should be cheap and consequently can be prone to failures. One can think of sensors attached to zebras (ZebraNet [18]), pigeons (Pigeon Air Patrol [27]), or public transport vehicles (EMMA project [20]). In this context, counting can be part of the task being realized (How many animals have a temperature exceeding some bound?), or part of the managing of the network (Should some nodes be added or replaced?). In relation with the domain of application we are looking at, we consider that the nodes are anonymous, undistinguishable, have a bounded memory and poor communication capabilities (no broadcast; only a pairwise communication when two nodes come close enough to each other). A distributed computing model that fits this description is the model of population protocols (PP) [4].

In PP, mobile nodes, which are called agents, can be represented as finite state transition systems. One can imagine that, when two agents are close enough, they interact and the effect of the interaction is a transition with a possible change of states. In this work we study the case of symmetric protocols, where two agents in a transition are indistinguishable if their states are identical (thus, their states have to be identical also after the transition). This assumption makes the protocol design more difficult than in the asymmetric case (as it restrains the set of possible transition rules), but provides a more general solution (correct in both cases).

The mobility and the resulting interactions of agents are completely asynchronous and modeled in a very general way - by a fairness assumption. Here, we study the problem of counting considering two classical fairness assumptions. One ensures that each pair of agents is drawn uniformly at random for each interaction, and the other, weaker assumption (called here weak), ensures only that every pair of agents interact infinitely often. While the probabilistic fairness captures the randomization inherent to many real systems, weak fairness only ensures progress of system entities (see Sec. 2 for an illustrating example).

As the agents are likely to be cheap and prone to failures (memory corruption, crash failures, etc.), re-counting may be required frequently. Since the population of agents may be very large, re-initialization may be infeasible. Hence, it is natural to assume that the agents are not initialized (i.e., an agent can be initially in any possible state). However, it is easy to prove that, in this case, counting in PP is impossible [10]. The solution is to use only one initialized and distinguishable agent, called the base station (BST). In this work, for the first time, we also prove, the necessity of such an agent being distinguishable (in case of symmetric protocols; see Sec. 4). BST is also the agent that eventually obtains the correct count of the population. Thus the considered protocols are semi-uniform, in the sense that all the agents, except BST, are a priori undistinguishable and execute the same protocol, for any population size and upper bound on (see Sec. 2 for a formal definition).

In this context, previous works [10, 16, 8] and a companion paper [9] study the issue of space complexity (of the counted nodes), a factor that is particulary important in the considered large-scale and unreliable networks. For instance, [10] shows that under weak fairness, (or more) agents cannot be counted with strictly less than states per counted agent, by deterministic protocols (considered here as well). Here, as a by-product, we present an alternative proof of this result, for the case of symmetric protocols (see Proposition 4). However, as shown in [9], under probabilistic or global fairness111Global fairness can be viewed as simulating probabilistic one without introducing randomization explicitly. One can see probabilistic fairness as a quantitative version of the global one. Moreover, it allows to analyze protocols’ time complexity, what is impossible in general with global fairness (see Sec. 2)., counting can be performed with only two states (one bit) per counted agent. [9] presents two space optimal solutions to counting in PP, one under weak fairness and the other under global fairness (the latter is also correct under probabilistic fairness). The solution for global fairness uses a memory of only one bit per agent, while the solution for weak fairness needs bits ( states) per counted agent. In the latter case, as the number of states for a given counting protocol is fixed, it represents an upper bound on the size of populations to which the protocol applies, and is considered as an explicit parameter.

In addition to the state space optimality, this paper raises the issue of the convergence time. Our objective is to determine the best guarantees on the convergence times given the established necessary minimum on the memory. To obtain this goal, we show, in particular, that the convergence times of the two previous space optimal solutions (in [9]) are exponential. In Sec. 3, for reasons explained there, we restrict our attention to so called “non-guessing” counting protocols. We prove that any such state optimal counting protocol, correct under probabilistic fairness, converges in expected parallel interactions (Sec. 3.1). In Sec. 3.2, we propose a new state optimal protocol fitting this complexity.

In the case of weak fairness, in Sec. 4, we show that a space optimal solution requires an exponential convergence time (in terms of non-null transitions). In particular, this result shows that the space optimal protocol under weak fairness in [9] is time optimal among the space optimal semi-uniform protocols.

Related Work.

We provide here the most relevant and recent works. Please, refer to [9] for additional related literature on the subject.

Considering PP, [10, 16, 8] proposed efficient counting protocols in terms of exact state space that were improved in [9] by space optimal solutions. For weak fairness, the protocol proposed in [16] uses states per agent (only 1 bit more than the optimal) and converges in only asynchronous rounds (a round being a shortest fragment of execution where each agent interacts with each other). This presents an interesting trade-off for counting in PP. A recent work [26] studies a problem related to counting in random PP, where agents should determine the difference between the number of agents started in state and the number of those started in state . In contrast with the current work, [26] assumes initialized agents, but similarly to the current work, it investigates the efficiency in terms of both time and space. It presents an -state population protocol that allows each agent to converge to the exact solution by interacting no more than times. Additional very recent works (as [1, 13, 2, 3]) jointly contribute to the time and space trade-offs study of fundamental tasks, as majority and leader election, in random PP. For example, [13] shows that it is impossible to achieve sub-linear leader election with only constant state space per agent, but due to [2] this problem can be solved in time with states. For majority, sub-linear time is impossible for protocols with at most four states per node, while there exists a poly-logarithmic time protocol which requires a linear in state space [3]. [1] presents additional upper and lower bounds for these tasks that highlight a time complexity separation between and state space for both majority and leader election. The present work contributes to the general study of time-space trade-offs in the case of counting.

In the context of dynamic networks with anonymous nodes, recent works [24, 23, 22, 25, 21], study the counting problem in the synchronous model of dynamic graphs. PP can be also represented by dynamic graphs, but is a completely asynchronous model. Moreover, in contrast with the current study, protocols in these works require that all nodes are initialized. These essential differences make the techniques (e.g., termination detection), extensively used there, inappropriate in our case. Note however that their protocols determining the exact count have exponential convergence time, except the results of [21] considering more restricted networks. In some sense this supports the results presented here for weak fairness. [21] presents interesting time complexity lower bounds for counting, but considers networks where anonymous nodes can communicate (by broadcast) any amount of data and diffuse it to all other nodes in a constant time w.r.t. , what is of course impossible in our context.

Due to the difficulty of the problem, a lot of work has been devoted to design protocols counting approximately the number of network nodes (see, e.g., [15, 19, 14, 28, 7, 30, 6]). These protocols use gossiping and probabilistic methods, like probabilistic polling, random walks, epidemic-based approaches, and also exploit classical results on order statistics to infer an estimated number of the nodes. Here, we consider only deterministic protocols for exact counting.

2 Model and Notations

A system consists of a collection of pairwise interacting agents, also called a population. Each agent represents a finite state sensing and communicating mobile device. Among the agents, there is a distinguishable agent called the base station (BST), which can be as powerful as needed, in contrast with the resource-limited non-BST agents. The non-BST agents are also called mobile, interchangeably. The size of the population is the number of mobile agents, denoted by , and is unknown (a priori) to the agents.

A (population) protocol can be modeled as a finite transition system whose states are called configurations. A configuration is a vector of states of all the agents. Each agent has a state taken from a finite set of states, the same for all mobile agents (denoted ), but generally different for BST.

In this transition system, every transition between two configurations and is modeled by a single transition between two agents happening during an interaction. That is, when two agents , in state , and , in state , in , interact (meet), they execute a transition rule . As a result, in , changes its state from to and from to . If and , the corresponding transition is called null (such transitions are specified by default), and non-null otherwise.222For simplicity, in some cases, we do not present protocols under the form of transition rules, but under the equivalent form of a pseudo-code.
If there is a sequence of configurations , such that for all , we say that is reachable from , denoted .

The transition rules of a protocol are deterministic, if for every pair of states , there is exactly one such that . We consider only deterministic transitions and thus, only deterministic protocols. Transitions and protocols can be symmetric or asymmetric. Symmetric means that, if is a transition rule, then is also a transition rule. In particular, if is symmetric, . Asymmetric is the contrary of symmetric.

Let , , , , be the transition rules of a protocol. Then, we shortly write to denote a possible sequence of these transition rules, which can be applied (in the same order) on two agents in states and , making them interact repeatedly until their states change to and , respectively. We sometimes call an agent in state a -state agent, or just agent.

An execution of a protocol is an infinite sequence of configurations such that is the starting configuration and for each , . In a real distributed execution, interactions of distinct agents are independent and could take place simultaneously (in parallel), but when writing down an execution we can order those simultaneous interactions arbitrarily.

An execution is said weakly fair, if every pair of agents in interacts infinitely often. An execution is said probabilistically fair, if, for each interaction in the execution, a pair of agents in is chosen uniformly at random. An execution is said globally fair, if for every two configurations and such that , if occurs infinitely often in the execution, then also occurs infinitely often in the execution. This also implies that, if in an execution there is an infinitely often reachable configuration, then it is infinitely often reached [5]. Global fairness can be viewed as simulating randomized systems without introducing randomization explicitly (any probabilistically fair execution is globally fair with probability 1 [17]).

A simple example allows to understand better the difference between weak and global (or probabilistic) fairness. Consider a population of 3 agents. Each agent can be white or black, and initially one agent is black and the two others are white. Consider also the protocol in which, when two white agents interact, they become both black and when two agents of different colors interact, they exchange their colors. It is easy to see that there is an infinite weakly fair execution in which there is always one black and two white agents (the black color “jump” indefinitely from agent to agent). At the contrary, every globally fair execution terminates in a configuration in which the 3 agents are black, because otherwise there would be infinitely many configurations during an execution from which the “all black” configuration could be reached, without ever being reached (contradicting global fairness).

A problem is defined by a predicate on executions. A population protocol is said to solve a problem , if and only if every execution of satisfies the conditions defining . The problem of counting is defined by the following condition: eventually, in any execution, there is at least one agent (BST, in our case) obtaining a value of in some (estimate) variable (called in the following) and this value does not change. Note that the counting predicate has to be satisfied only eventually (and forever after). When it happens, we say that the protocol has converged. A protocol is called silent, if in any execution, eventually, no state of an agent changes [11].

In the case of probabilistic fairness, the convergence time of a protocol is measured in terms of parallel time or parallel interactions, i.e., the independent interactions (of distinct agents) occurring in parallel. It is customary to define one unit of parallel time as consecutive interactions in a probabilistically fair execution. Then, in this case, the convergence time of a protocol is defined by the expected number of parallel time units in a fair execution till convergence. Moreover, under probabilistic fairness, it appears that technically (in the context of this specific work), we can perform the convergence time analysis in terms of transitions involving BST. It is easy to see that this corresponds to the (asymptotic) expected convergence time in terms of parallel time units.

In the case of weak fairness, the convergence time of a protocol is defined as the maximum number of non-null transitions in a fair execution till convergence.

We consider only semi-uniform protocols (cf. [12, 29]) in the sense that all agents, except BST (whence semi-), are a priori indistinguishable and interact according to the same transition rules. Moreover, the protocol functions similarly for any and any upper bound on . More formally, we can define a semi-uniform protocol so: {definition} A protocol is called semi-uniform if for any upper bound and any execution prefix in which only agents from a subset (including BST) interact, the (standard) projection333The projection of a configuration on a set of agents is a restriction of the vector representing the configuration to the elements corresponding to the agents of . Naturally, the projection of an execution on a set of agents () is obtained from by projecting every configuration of on , representing an execution where the agents of (the complement of ) do not interact. of on the agents of is an execution prefix of for any bound such that .

{remark}

Similarly, if is an execution prefix of a semi-uniform protocol for , it is also an execution prefix of for s.t. and , if we consider as an execution prefix for , and then extend the configurations of with agents (missing in and performing no interactions in the extended prefix).

3 Time and Space Optimal Counting under Probabilistic Fairness

3.1 Time Lower Bound for a Space Optimal Protocol

Defining time optimality for a counting protocol asks to be cautious. Indeed, a protocol could be efficient for counting some set of agents and slow for counting others. Think of a protocol that “guesses” initially a count and checks afterwards whether this count is correct or not. On the right set of agents, this counting protocol would converge in zero time. For other sets it is certainly less efficient than the protocols which estimate the count gradually, starting from 0. We would like to avoid such behavior and thus restrict our attention to protocols having always a “proof” that the estimate they have corresponds to a lower bound on the actual population size (i.e., they have observed a sequence of interactions that justifies this count). For such protocols, called here “non-guessing”, the estimate of the size (in the variable ) is a non-decreasing function along an execution (and so is always a lower bound on the number of agents in the population). In the sequel of the section, we consider an arbitrary state-optimal protocol and we prove that it converges in expected interactions with BST, or equivalently interactions between agents, or parallel time. uses (optimally) only two states per mobile agent (with one state, counting is impossible [9]). Note also that the result in this section does not assume that is symmetric.

We call trace of an execution prefix the sequence of transitions of BST in this prefix. Thus, a trace is a sequence of transitions of the form , where and are states of BST, and and are states of a mobile agent in the corresponding interaction. Note that this sequence captures all the information that BST has, and completely determines its state. Let us denote by the minimal population size for which there exists at least one execution prefix with trace . Thus, since the estimate counter is non-decreasing, we have : if it was not the case, by definition of , the protocol could run with agents and estimate, at some point of the execution, that ; then, to converge, the protocol would be required to decrease , which is impossible by the assumption above. We denote by the minimal number of mobile agents in state (w.l.o.g., ) in a configuration at the end of any possible execution prefix corresponding to trace (and with agents). Obviously, for all execution prefixes with agents and a trace , we have .

The idea behind Lemma 3.1 is that, if there is such a transition rule of mobile agents that can decrease the number of agents in state , then when several such agents are present in the population, making them interact and execute this transition will decrease their number to the minimum. The proof appears in the appendix.

{lemma}

If the considered protocol has a transition rule that allows to decrease the number of agents in state through interactions between mobile agents (rules , or ), then for any trace , we have .

{lemma}

Let be a trace obtained from a trace by adding a transition between BST and a mobile agent. If , then and .

Proof.

We show the contrapositive: if , then ; if , then .

Let the added interaction in be :

  • If , some executions with trace and agents lead to a configuration with agents in state . These agents may interact with BST, so that there still exist executions with trace and with agents, and with the same number of agents in both states. Thus , , and ;

  • If (which implies that ), all executions with trace and agents contain no agent in state . Thus, (it cannot be higher, since one can build an execution with agents interacting in pattern resulting in trace , and an extra agent in state that does not interact, then released for this last interaction). Since, as a result of this interaction, an agent in state remains, if no rule can remove it, , else . In addition, , because the execution described above with agents results in a configuration with agents in state . Finally, we have: , , and .

Now, let the added interaction in be :

  • If , some executions with trace and agents contain agents in state . These agents may interact with BST, so that there still exist executions with trace and with agents, and with an agent in state that has changed its state. Thus , , and .

  • If (which implies that ), all executions with trace and agents contain no agent in state . Thus, trace cannot be achieved with agents, and . can be achieved by adding an extra agent in state during trace and releasing it to realize the last interaction, so that . An agent in state has its state changed to , so that , and .

Thus, can increase only as the result of an interaction of BST with an agent in state such that . After this interaction, to increment again, BST must increment , which it can do only by switching an agent state to .∎

In particular, this implies that, if interactions between mobile agents can decrease the number of agents in both states 0 and 1, for , and , i.e., any trace can be obtained with two agents only, and is incorrect.

{theorem}

A two-state non-guessing counting protocol (correct under probabilistic fairness) converges in expected interactions with BST (equivalently, in expected parallel time).

Proof.

Consider a converging execution of this protocol with mobile agents. Denote by the trace of this execution until (which occurs, since the protocol converges), and by the trace obtained from by removing its last interaction. Denote by the mobile agents state such that (this state exists by Lemma 3.1).

Thus, must increase from 0 to . Now, increases only when BST meets an agent in state and changes its state to , and the number of mobile agents in state can only increase in an interaction with BST (from Lemma 3.1, as , no interaction between mobile agents can increase the number of agents in state ). Thus, in the last configuration before convergence with , all agents are in state (because eventually reaches , and can increase only when a mobile agent state is switched from to ).

Thus, in any converging execution, there is a configuration in which all agents are in state , and then all agents are switched to state in interactions with BST (except possibly one, that has been counted by BST, and will be switched to state by it only in a further interaction). Now, if agents are in state , the probability for BST to meet an agent in state in its next interaction is , and the expected number of interactions (involving BST) before meeting an agent in state and incrementing is .

So, the expected length of an execution before convergence is , with the th harmonic number. It is known that , hence the result.

Given that there are agents in the system, one interaction out of involves BST in average. Hence, the expected interactions with BST are equivalent to expected interactions between agents, and to the expected parallel time. ∎

3.2 Time and Space Optimal Protocol (Prot. 1)

The one bit space optimal protocol of [9] is recalled in the appendix (Prot. 2) together with its time complexity analysis that gives the average convergence time of interactions. In this section, we modify Prot. 2 to obtain an (asymptotically) time optimal protocol, Prot. 1, converging in time, and still optimally using only one bit of memory per mobile agent. We present and prove this protocol and its convergence time below.

In Prot. 1, each mobile agent can be in one of two states or , and respectively called or agent. We write and for the protocol’s count of and agents resp., and and for the actual number of and agents in the population. The total number of agents is then and the base station’s estimate of is . The values and are both initialized to . They may be seen as the implementations of the and used in the lower bound proof in the previous subsection.

The modified protocol proceeds in alternating phases. In a zero phase, BST only converts zeros to ones. Whenever it does so, it decrements if it is positive and increments . In a one phase, it does the reverse. We start the protocol in a zero phase.

The same argument as for the original protocol shows that holds as an invariant and that is non-decreasing over time (Lemma 1 in [9]). If, in addition, we can stay in two phases long enough that every agent is converted from to in the first phase, and then every agent is converted from to in the second phase, at the end of the second phase we will have , giving convergence.

Let us now specify when BST switches between phases. Suppose that BST is going to start in a phase. We adopt the following procedure (in two stages):

  1. (pre-phase) Flip any agents we encounter to as long as .

  2. (the phase itself) Continuing flipping any agents BST encounters to until it sees agents marked in a row without seeing an agent marked . If this event occurs, flip the phase (switch to the phase).

The first rule (the pre-phase) guarantees that whenever we start a phase, is always zero. This in turn guarantees that is never lower at the start of a phase than it is at the start of any previous phase.

  
  Variables at BST:
     : non-negative integer, initialized to ; eventually holds
     : non-negative integer, initialized to ; eventually holds
     c: non-negative integer initialized to ; eventually holds
     cnt: non-negative integer initialized to
     phase , initialized to
  Variable at a mobile agent :
      , initialized arbitrarily
  
1:  when a mobile agent with mark interacts with BST do
2:     if  then
3:        
4:        if  then
5:           
6:        
7:        
8:     else if  then
9:        
10:        
11:     else if  then
12:        
13:     
Protocol 1 – Time and Space Optimal Counting under Probabilistic Fairness

For the convergence bound, begin by bounding the likely length of a phase: {lemma} Each phase requires parallel interactions with high probability.

Proof.

Suppose we are in a phase. Using standard bounds on the Coupon Collector Problem it holds with high probability that BST has interacted with every agent after interactions. So either the phase has already ended, or every agent now carries . In the latter case, the phase can run for at most interactions before ending. ∎

We now show that, on average, the protocol executes phases. This requires the following technical lemma showing that BST finds all agents in a phase if there are enough to begin with. {lemma} If phase starts with , then it ends with with probability at least .

Proof.

For simplicity we will assume ; the case is symmetric. So we are looking at a zero phase that starts with . From the structure of the protocol, we know that at the start of this phase, , but might be larger. It happens that the worst case is when , but we will analyze the process for any initial value of .

In the analysis below we will fix , to their values at the start of the phase. To keep track of what happens, let be the number of zero values converted to ones so far during this phase; given the value of , this gives zeros and ones in the population, and the value of the register will be . We fail to convert all zeros to ones if we exit the phase while is less than .

For each particular value of , this occurs only if (a) is already , and (b) BST observes ones in a row. Whether or not , the latter event occurs with probability exactly

(1)

which by the union bound gives an upper bound on the probability that we leave the phase for any of

(2)

We will bound this sum by considering the terms with and separately. The detailed computations for each case appear in the appendix and give a bound of for the case , and for . The original sum is thus bounded by for all , giving the claimed bound. ∎

{theorem}

The modified protocol (Prot. 1) converges to in an expected interactions with BST (equivalently, in an expected parallel interactions).

Proof.

There are two cases, depending on the initial value of .

  1. If in the starting configuration, then at the start of each zero phase. From Lemma 3.2, BST converts all zeros to ones in any of these phases with probability at least . If this event occurs, the following one phase converts all ones to zeros with probability at least as well, giving a probability of at least for each pair of phases that we converge to the correct count. Thus the protocol converges in an expected phases.

  2. If , then the initial zero phase ends with at least ones (because any conversion during this phase can only increase the number of ones). So the first one phase starts with . Repeating the above analysis shows that the protocol converges after at most phases on average on top of the initial zero phase, giving an expected phases total.

Because each of these phases takes expected interactions (Lemma 3.2), this gives a total expected number of interactions of . ∎

4 Time Lower Bound for Space Optimal Counting under Weak Fairness

To obtain this lower bound we first prove properties that have to be satisfied by any space optimal symmetric counting protocol functioning under weak fairness. These properties are important by themselves, as they can be useful in future studies of counting under weak fairness in PP. For instance, Proposition 4, states that a counting protocol has to distinctly name all the agents in any population of size . Recall that is the upper bound on the size of the population.

Next, from Proposition 4 and Lemma 4, it easily follows that any symmetric counting protocol under weak fairness has to use at least states per mobile agent (to be able to count any population of at most agents). This gives a somewhat simpler proof than the original one in [10].

The next important property, given in Proposition 4, is that any space optimal symmetric counting protocol under weak fairness has a unique “sink” state s.t., for every possible state of a mobile agent, there is a transition sequence , with and cannot be one of the distinct names given by the protocol in case .

The results above show in particular that, for any considered space-optimal counting protocol, if mobile agents are not named yet, agents in state will continue to appear (for any and ).

Moreover, recall that we consider counting with non-initialized mobile agents. In this case, to overcome the known impossibility [10], we assume one initialized and distinguishable agent BST that eventually counts the other (mobile) agents. Note that having a distinguishable agent is necessary. To see this, consider a starting configuration where all agents start at the same state (which has to be equal to the state of the only initialized agent). If the size of the population is even, by Proposition 4, there is a weakly fair execution reaching and staying in the configuration where all agents are in the “sink” state , and by Proposition 4, no counting can be realized.

Using the above-mentioned properties and those of semi-uniform protocols (see Definition 2 in Sec. 2), we prove the lower bound given in Theorem 4. This is one of the main results of the paper. It shows that, under weak fairness, counting undistinguishable, state-optimal and non-initialized agents in symmetric PP is a costly task in terms of a convergence time. It takes non-null transitions.

Finally, we show (Proposition Appendix in the appendix) that the space optimal protocol for weak fairness presented in [9] converges in non-null transitions. This proves that this is a time optimal protocol among all the space optimal semi-uniform protocols, under weak fairness.

Proposition \thetheorem.

Let be a (silent or not) counting protocol correct under weak fairness (for any ). For any weakly fair execution of on a population of size , there is an integer such that, for any , no two mobile agents are in the same state in .

Proof.

Let us assume, by contradiction, that in , there are infinitely many configurations with two agents in the same state. Since the state space is finite and the number of agents too, two specific agents and from are necessarily simultaneously in some state in infinitely many configurations. Let be these configurations such that W.l.o.g., we choose these configurations such that, in every execution segment , every agent in interacts with every other (this is possible with weak fairness).

Now consider a population of size . To prove the proposition, we will construct a weakly fair execution of in population where no agent can distinguish from , and where consequently wrongly counts only agents instead of the existing .

We construct based on . First, we assume that in , is in state in the starting configuration, and such that each segment follows the same transition sequence as in , but where the agents or participating in the corresponding interactions can be replaced by in the appropriate state, as we explain below. We ensure also that in every , each of the three agents is in state .

More precisely, in segment (), agent does not interact with the rest of the agents, and all the others interact exactly as in (each agent is in state in ). In , agent does not interact with the rest of the agents, and replaces in all the interactions where interacts in , and all the others interact as in (but with instead of in the corresponding interactions). Each agent is in state in . In , agent does not interact with the rest of the agents, and replaces in all the interactions where interacts in , and all the others interact as in (but with instead of in the corresponding interactions). Each agent is in state in .

We emphasize again that is possible, because in every , each of the three agents is in state , so any of them can replace any other in the transition sequence of the next segment . Moreover, is weakly fair, because each agent interacts with all the other agents in the appropriate segments (and by the assumption on ), and other agents too, due to the weak fairness of . Finally, in , every agent from (including BST), executes exactly the same sequence of transition rules as it does in , so no agent can distinguish the fact that the population is actually with agents, and counts only agents as it does in . This is a contradiction to the assumption that is a correct counting protocol. ∎

The proof of Lemma 4 uses similar techniques as the proof of Proposition 4 and appears in the appendix.

{lemma}

Let be a symmetric (silent or not) counting protocol correct under weak fairness (for any ). Consider any weakly fair execution of on a population of size . There is an integer such that, for any , no mobile agent is in a state such that there is a possible sequence of transitions of .

The following two propositions follow from Proposition 4 and Lemma 4. A proof of Proposition 4 uses similar techniques as the proof of Proposition 4 and appears in the appendix.

Proposition \thetheorem.

Any symmetric counting protocol correct for any (undistinguishable and non-initialized) mobile agents, under weak fairness, has to use at least states per mobile agent.

Proposition \thetheorem.

Consider any symmetric (silent or not) counting protocol correct under weak fairness (for any ), and using at most states per mobile agent. For every state , there is a transition sequence , s.t. is unique and does not appear infinitely often in executions with . Moreover, .

Proof.

As is symmetric, any two agents, both in some state , in an interaction, have to execute a symmetric transition of the form . Thus there is a possible sequence of transitions As mobile agents are finite state, for some , , i.e. . By Lem. 4, s.t. does not appear infinitely often in executions with . As there are at least states appearing infinitely often in an execution with (by Proposition 4), there is at most one such possible state in a state protocol. Thus, the first part of the lemma holds.

Finally, by contradiction, if s.t. , then the previous part of the proof implies . When , and as uses only states, and never appears infinitely often in an execution, does appear infinitely often in configurations of an execution (by Proposition 4). This is a contradiction to Lem. 4. Thus, . ∎

To prove the lower bound (Theorem 4), in addition to the results above, we use the following definitions related to the considered counting protocols.

{definition}
  • We call homonyms, or homonymous agents, mobile agents in the population having the same state, but different from .

  • We say that two (or more) homonyms (in state ) are reduced (to ) whenever a sequence of transitions is applied to them.

  • We say that a mobile agent is named if it has a state different from (a name). A group of agents is named if each of them is named with a distinct name. Similarly, a configuration of agents is named, if all the agents in this configuration are named.

  • A reduced (from homonyms) configuration is a configuration without any homonym. Given a configuration , let be the set of names of mobile agents appearing an odd number of times in , i.e., the set of names appearing in the corresponding reduced configuration.

  • For any two sets , we denote by their symmetric difference. In particular, () is if , and if .

  • A stationary point (or state) of BST is a state of BST such that and is also stationary. (Note that this transition sequence can be broken, i.e., BST can change its state to a non-stationary one, after an interaction with an agent in a state .)

  • The naming sequence is a sequence of pairs , where is a BST state and is a mobile agent state. is defined inductively as follows: is the initial state of BST, and for any , is a transition rule of the protocol. Let be a prefix of s.t. .

To obtain the result of Theorem 4, we focus on the set of the longest execution prefixes where BST meets and names agents in state (according to the fixed naming sequence, defined in Def. 4). In such prefixes, we study the possibility of the occurrence of a stationary point (Def. 4). We show that, for a semi-uniform counting protocol (Definition 2, Sec. 2), for any , such a point does not exist (Lemma 4), before BST has named all the agents. That is, in the case of the considered executions, BST will continue giving names to -state agents that it meets (it won’t be “blocked” waiting for some named agent, for possibly deciding to change its strategy accordingly).

So, using Lemma 4, we prove that there exists an execution prefix in which BST continuously meets and names agents in state without entering a stationary state. Then, we show that the longest such prefix corresponds to the naming sequence of length . This is by observing that the number of starting unnamed (reduced) configurations is , for , and that after each step (transition) of the naming sequence, BST can accomplish naming of only one such starting configuration. To prove the result for any and , we use Definition 2 of semi-uniform protocols. Intuitively, for such a protocol, when only a subset of a population of agents interacts with BST, BST should behave like is possible, even if it is larger.

In the following lemma, we show that the naming sequence does not contain any stationary state.

{lemma}

Let be a symmetric (silent or not) semi-uniform counting protocol correct under weak fairness (for any ) and using states per mobile agent. The naming sequence (Def. 4) of does not contain any stationary state.

Proof.

Assume by contradiction that the first stationary state in is in the step (element), i.e., the state is stationary, for some . In the following, we assume that (we justify this assumption later) and for any , we construct an execution of for a population of agents. In , agents are initially in state , while the other agents are in states , , …, (these are the states appearing in ). Each is composed of two phases.

In the first phase, let -state agents interact one by one with BST, and at the end of this phase (by the definition of ) the states of these agents are , , …, . Notice that now among these agents (call it the first sub-population), those that have names have homonyms in the second sub-population (of other agents). Notice also that, by Definition 2 of semi-uniform protocols, this is also a prefix of an execution projected on a population of only agents. By the same property, this can be also a prefix of execution for a larger population and for an upper bound as large as we want. Thus, is a valid assumption.

In the second phase, let every named (let us say, by ) agent of the first sub-population interact with its homonym in the second sub-population, s.t. the sequence of transitions takes place for each such pair of homonyms (possible by Proposition 4). At the end of this second phase, all agents are thus in state (at most were homonyms at the end of the first phase, and were initially in state and never interacted).

Now, no matter how the agents continue to interact, as all mobile agents are in state , and BST is in a stationary state , all mobile agents remain forever in state (Proposition 4) and BST remains in a stationary state (by definition of such a state). Thus, after the second phase, we make all pairs of agents interact infinitely often to obtain a weakly fair execution for any . In all these constructed executions, no agent can distinguish between the executions and the corresponding population sizes ( agents for any ), and thus a correct counting cannot be obtained.

By Definition 2 of a semi-uniform protocol, the projection of the first phase (of any ) on the first sub-population (a group of agents interacting with BST in this phase), is also a prefix of an execution of for a bound (). Thus, for any such and , there is no stationary point in . In other words, the lemma holds for any value of and , and thus also for any prefix of . ∎

{theorem}

Let be a symmetric (silent or not) semi-uniform counting protocol correct under weak fairness (for any ) and using states per mobile agent. The convergence time of is at least non-null transitions.

Proof.

We will build an execution of where the length of the corresponding naming sequence before convergence (and thus the convergence time of ) is at least .

Consider a population of agents. Consider a possible execution prefix where BST interacts only with -state agents as long as they are not distinctly named. If the agents are not distinctly named, by Proposition 4, there is always either at least one agent in state , or some homonyms that can be reduced to . So, assume that in , whenever the mobile agents are not distinctly named and there is no agent in state , a reduction of some homonyms is done. Then, an agent in state interacts with BST. By Lemma 4, in every such corresponding transition, the state of BST is not stationary, and thus eventually an -state mobile agent is “given” a name by BST. Let us repeat this scenario, until all the agents are named. This is an execution prefix (with ) that we consider below.

By Lemma 4, has to name mobile agents, starting from any unnamed configuration . For this specific case of , there is exactly one possible configuration (ignoring the state of BST and the permuted configurations444A permuted configuration obtained by permuting the elements in the configuration vector.) where all mobile agents are named. Notice that ( is defined in Def. 4). Consider a prefix of the unique naming sequence . Notice also that, by Def. 4, iff . This implies that, given , there is a unique such that . As , the length of is at least . Hence, the length of the longest execution is at least s.t. . By the Remark following Definition 2, is also an execution prefix for any bound , given the same population size. Thus, the theorem actually holds for any and any upper bound on . ∎

5 Conclusion and Perspectives

This work is a sequel to [9] and it answers the questions concerning time complexity of the symmetric space optimal protocols proposed there. What can be learned from the current work is that there exists a big difference, not only in terms of the required space, but also in terms of time complexity, between the case where the interactions between agents are random and the case where they are only weakly fair.

From a more practical point of view, it would be interesting to investigate if this difference still exists when more memory space is given to the agents. We already know that, concerning weak fairness, a supplementary bit ( states) allows to design protocols like in [16] with a logarithmic round complexity (a round being a shortest fragment of execution where each agent interacts with each other), while another additional bit allows to solve this problem in only constant number of rounds [10]. Concerning global or probabilistic fairness, there exist less studies about counting protocols and especially about their complexity analysis. For example, it would be certainly interesting to determine which size of memory is needed, for having an expected constant convergence time. More generally, studying formally the trade-offs between space and time complexities for counting algorithms in population protocols could be a valuable sequel to the present work.

References

  • [1] D. Alistarh, J. Aspnes, D. Eisenstat, R. Gelashvili, and R. L. Rivest. Time-space trade-offs in population protocols. CoRR, abs/1602.08032, 2016.
  • [2] D. Alistarh and R. Gelashvili. Polylogarithmic-time leader election in population protocols. In ICALP, pages 479–491, 2015.
  • [3] D. Alistarh, R. Gelashvili, and M. Vojnovic. Fast and exact majority in population protocols. In PODC, pages 47–56, 2015.
  • [4] D. Angluin, J. Aspnes, Z. Diamadi, M. J. Fischer, and R. Peralta. Computation in networks of passively mobile finite-state sensors. Dist. Comp., 18(4):235–253, 2006.
  • [5] D. Angluin, J. Aspnes, D. Eisenstat, and E. Ruppert. The computational power of population protocols. Dist. Comp., 20(4):279–304, 2007.
  • [6] A. F. Anta, M. A. Mosteiro, and C. Thraves. An early-stopping protocol for computing aggregate functions in sensor networks. J. Parallel Distrib. Comput., 73(2):111–121, 2013.
  • [7] C. Baquero, P. S. Almeida, R. Menezes, and P. Jesus. Extrema propagation: Fast distributed estimation of sums and network sizes. IEEE Trans. Parallel Distrib. Syst., 23(4):668–675, 2012.
  • [8] J. Beauquier, J. Burman, and S. Clavière. Comptage et nommage simples et efficaces dans les protocoles de populations symétriques. In ALGOTEL 2014, pages 1–4, June 2014.
  • [9] J. Beauquier, J. Burman, S. Clavière, and D. Sohier. Space-optimal counting in population protocols. In DISC, pages 631–646, 2015.
  • [10] J. Beauquier, J. Clement, S. Messika, L. Rosaz, and B. Rozoy. Self-stabilizing counting in mobile sensor networks with a base station. In DISC, pages 63–76, 2007.
  • [11] S. Dolev, M. G. Gouda, and M. Schneider. Memory requirements for silent stabilization. Acta Inf., 36(6):447–462, 1999.
  • [12] S. Dolev, A. Israeli, and S. Moran. Self-stabilization of dynamic systems assuming only read/write atomicity. Dist. Comp., 7(1):3–16, 1993.
  • [13] D. Doty and D. Soloveichik. Stable leader election in population protocols requires linear time. In DISC, pages 602–616, 2015.
  • [14] A. J. Ganesh, A.-M. Kermarrec, E. Le Merrer, and L. Massoulié. Peer counting and sampling in overlay networks based on random walks. Dist. Comp., 20(4):267–278, 2007.
  • [15] C. Gkantsidis, M. Mihail, and A. Saberi. Random walks in peer-to-peer networks: Algorithms and evaluation. Perform. Eval., 63(3):241–263, 2006.
  • [16] T. Izumi, K. Kinpara, T. Izumi, and K. Wada. Space-efficient self-stabilizing counting population protocols on mobile sensor networks. Theor. Comput. Sci., 552:99–108, 2014.
  • [17] H. Jiang. Distributed Systems of Simple Interacting Agents. PhD thesis, Yale University, 2007.
  • [18] P. Juang, H. Oki, Y. Wang, M. Martonosi, L. Peh, and D. Rubenstein. Energy-efficient computing for wildlife tracking: design tradeoffs and early experiences with zebranet. In ASPLOS, pages 96–107, 2002.
  • [19] D. Kostoulas, D. Psaltoulis, I. Gupta, K. P. Birman, and A. J. Demers. Active and passive techniques for group size estimation in large-scale and dynamic distributed systems. Journal of Systems and Software, 80(10):1639–1658, 2007.
  • [20] S. Lahde, M. Doering, W. Pöttner, G. Lammert, and L. C. Wolf. A practical analysis of communication characteristics for mobile and distributed pollution measurements on the road. Wirel. Comm. and Mob. Comput., 7(10):1209–1218, 2007.
  • [21] G. A. Di Luna and R. Baldoni. Brief announcement: Investigating the cost of anonymity on dynamic networks. In PODC, pages 339–341, 2015.
  • [22] G. Di Luna, R. Baldoni, S. Bonomi, and I. Chatzigiannakis. Conscious and unconscious counting on anonymous dynamic networks. In ICDCN, pages 257–271, 2014.
  • [23] G. Di Luna, R. Baldoni, S. Bonomi, and I. Chatzigiannakis. Counting in anonymous dynamic networks under worst-case adversary. In ICDCS, pages 338–347, 2014.
  • [24] O. Michail, I. Chatzigiannakis, and P. G. Spirakis. Naming and counting in anonymous unknown dynamic networks. In SSS, pages 281–295, 2013.
  • [25] A. Milani and M. A. Mosteiro. A faster counting protocol for anonymous dynamic networks. In OPODIS, pages 28:1–28:13, 2015.
  • [26] Y. Mocquard, E. Anceaume, J. Aspnes, Y. Busnel, and B. Sericola. Counting with population protocols. In NCA, pages 35–42, 2015.
  • [27] Pigeon Air Patrol project. 2016. http://www.pigeonairpatrol.com/.
  • [28] B. F. Ribeiro and D. F. Towsley. Estimating and sampling graphs with multidimensional random walks. In ACM SIGCOMM, pages 390–403, 2010.
  • [29] G. Tel. Introduction to Distributed Algorithms (2nd ed.). Cambridge University Press, 2000.
  • [30] D. Varagnolo, G. Pillonetto, and L. Schenato. Distributed statistical estimation of the number of nodes in sensor networks. In CDC, pages 1498–1503, 2010.

Appendix

 Lemma 3.1. If the considered protocol has a transition rule that allows to decrease the number of agents in state through interactions between mobile agents (rules , or ), then for any trace , we have .

Proof.

Consider such a protocol, with a rule or . Consider a trace . This trace can be obtained by an execution prefix , such that in configuration , there are agents in state , and agents in state . Now, we can expand this execution prefix by making agents in state interact, until they all are in state , except one in the case of the interaction . This new execution prefix contains the same interactions with BST, and thus, has the same trace. The last configuration of this execution prefix contains at most one agent in state . So, .

Now, if is the only rule allowing the number of agents in state to decrease, to use the same kind of reasoning, one must first show that there can always be an agent in state in the configuration, to allow this rule to be executed. So let us show that a situation with cannot be reached. Indeed, consider a trace such that . At least one execution with this trace can lead to a configuration with a single agent in state . In this configuration, transition is always possible, so that either transition or must eventually occur for to increase. When the transition takes place, all executions with this trace contain at least one agent in state in the configuration before, and this agent can interact with any agent in state , so that . If an interaction occurs, then . In any case, the trace is such that , so that any traces built upon corresponds to some execution ending with some agent in state and one or zero agent in state . Thus, any trace can be expanded with interactions until at most one agent in state remains, and .∎

 Lemma 3.2. If phase starts with , then it ends with with probability at least .

Proof.

For simplicity we will assume ; the case is symmetric. So we are looking at a zero phase that starts with . From the structure of the protocol, we know that at the start of this phase, , but might be larger. It happens that the worst case is when , but we will analyze the process for any initial value of .

In the analysis below we will fix , to their values at the start of the phase. To keep track of what happens, let be the number of zero values converted to ones so far during this phase; given the value of , this gives zeros and ones in the population, and the value of the register will be . We fail to convert all zeros to ones if we exit the phase while is less than .

For each particular value of , this occurs only if (a) is already , and (b) BST observes ones in a row. Whether or not , the latter event occurs with probability exactly

(3)

which by the union bound gives an upper bound on the probability that we leave the phase for any of

(4)

We will bound this sum by considering the terms with and separately.

For , we have

For , we have

The original sum is thus bounded by for all , giving the claimed bound. ∎

 Lemma 4. Let be a symmetric (silent or not) counting protocol correct under weak fairness (for any ). Consider any weakly fair execution of