Time-space trade-offs in population protocols for the majority problem

Population protocols are a model for distributed computing that is focused on simplicity and robustness. A system of n identical agents (finite state machines) performs a global task like electing a unique leader or determining the majority opinion when each agent has one of two opinions. Agents communicate in pairwise interactions with randomly assigned communication partners. Quality is measured in two ways: the number of interactions to complete the task and the number of states per agent. We present protocols for the majority problem that allow for a trade-off between these two measures. Compared to the only other trade-off result (Alistarh et al. in Proceedings of the 2015 ACM symposium on principles of distributed computing, Donostia-San Sebastián, 2015), we improve the number of interactions by almost a linear factor. Furthermore, our protocols can be made uniform (working correctly without any information on the population size n), yielding the first uniform majority protocols that stabilize in a subquadratic number of interactions.


Introduction
In this article we consider the majority problem in the probabilistic population model. Majority is a fundamental problem in distributed computing. There are n different agents, each with one of two opinions, say A and B and the goal is to agree on the opinion with the larger support. This problem occurs when all elements of a distributed system have to reach consensus on the value of some parameter which reflects the prevailing opinion what this value should be. Because of its importance, the majority problem is frequently used as a case study in analysis and comparison of strengths and limitations of various models of distributed computing.
The population model was introduced by Angluin et al. [4,5] as a model to explore the computational power of resource-limited, mobile agents. Agents are modeled as finite-state machines. In every step, a pair of agents is chosen uniformly at random, observe each other's state, and perform a deterministic state transition. This is called an interaction.
States are mapped to outputs by a problem-specific output function. In the case of the majority problem, one can think of an agent's output as being A or B, indicating which opinion the agent believes to be the majority.
The quality of a population protocol is measured in terms of the number of interactions (the runtime) and the number of states per agent required to "successfully compute" the desired output. The number of interactions is sometimes expressed in parallel time, which divides the number of interactions by n to account for the inherent parallelism of the system. In order to avoid confusion, we stick to the actual number of interactions throughout the article.
There are several definitions for what is conceived as a "successful computation". A typical requirement is that the system must, eventually, reach a state with correct output and which is stable-i.e., no possible future transition can change the agents' output. However, runtime notions differ in when this strict guarantee must be achieved. A natural definition is to measure the number t of interactions after which the system is in such a stable state with correct output. This notion is used in most recent publications, especially for lower bounds (cf. Sect. 1.2). Another definition considers the number of interactions t after which the current execution always gives the correct output. The former runtime notion is typically referred to as stabilization and the latter as convergence (see Sect. 2).
One may wonder what the advantage in measuring the convergence time instead of the stabilization time may be. In [9] the authors introduce a hybrid protocol that combines a "fast" protocol that might never converge to the correct answer with a "slow" one that stabilizes at the correct answer. The hybrid protocol switches its output from the fast protocol, which might be incorrect, to that of the slow but always correct protocol when it is likely that the slow protocol has finished. And therein lies the crux: without further safeguards, it is possible, although with only negligible probability, that a correct output reached by the fast protocol at time t is later temporarily overwritten by a currently still wrong output of the slow protocol. Hence, while the system has converged at time t, it is not yet stable. It will stabilize only when the slow protocol does so. The convergence (to the correct output) always happens by the time when the computation stabilizes (on the correct output). The stabilization may, however, be reached later, sometimes much later, than convergence.
A desirable feature of population protocols is uniformity, in the sense that a single algorithm should be designed to work for populations of any size. Due to the simplicity of transition-based algorithms and the uniformity, uniform population protocols are well suited to model real-world systems that consist of many but comparatively simple agents, like a flock of birds or large sensor networks aggregating information (count, sum, average, extrema, median, or histogram). In both scenarios the agents' computational power is bounded and the algorithms should not depend on the number of agents.
The underlying theme of this article is to exhibit tradeoffs in population protocols between the running time and the required number of states, highlighting methods which help achieving fast stability (in addition to convergence) and uniformity of protocols.

Our contribution
Our protocols for the majority problem in the population model provide an integer parameter s ≥ 2 that enables a trade-off between the number of states and the runtime. Our results also depend on the absolute bias α, which is the initial absolute difference between the number of agents supporting opinion A and B, respectively. In the following we state the results for the tightest case when α = 1; see the corresponding theorems for the full statements.
Our first result is a comparatively simple protocol that, with high probability 1 , determines the exact majority in O n · (log n) 2 /log s interactions and uses (s + log log n) states (Theorem 3). While this high-probability guarantee is comparatively weak with respect to the typical requirement of stabilization or even just convergence (since high-probability correctness allows for some low but positive probability of a permanent error), this protocol is an important building block for the following main results of this article.
1. We present two hybrid exact majority protocols, both having a runtime of T = O n · (log n) 2 /log s . One converges with high probability in T interactions and uses (s + log log n) states (Theorem 5). The other stabilizes with high probability in T interactions but uses s · log s n states (Theorem 4). 2. For a constant s, we provide a uniform version of the second of the above two majority protocols. This protocol has essentially the same guarantee for the stabilization time. However, with high probability it uses O s · log s n · log log n states (Theorem 6).
All protocols above except for the uniform one need knowledge of log log n . Note that the state space of the uniform protocol is bounded only with high probability; with negligible probability, an agent might need arbitrarily many states. Since this is not covered in the original population model (where agents are finite-state machines), for this protocol we adopt a generalized model [14] in which agents are modeled as Turing machines (see Sect. 7).
We highlight a few implications of the above results. For a constant s, our majority results underline an important difference between stabilization and convergence. While the (log n) number of states in our stable protocol (Theorem 4) is asymptotically tight for any protocol that stabilizes with high probability in a subquadratic number of interactions 2 [3], our protocol with (log log n) states (Theorem 5) shows that the (log n) lower bound can be bypassed if one considers convergence instead of stabilization.
When choosing s = log log n, our majority protocols converge and stabilize with high probability in O n · (log n) 2 /log log log n interactions. These and the protocols presented in [11] are the first majority protocols with O (polylog n) states that work in o n · (log n) 2

interactions.
When choosing s = n , where > 0 is an arbitrary positive constant, we obtain a majority protocol that stabilizes within asymptotically optimal O (n log n) interactions using (n ) states. Before our work, achieving this optimal time required n 3/2 states [21]. For a constant parameter s, our uniform protocol that stabilizes in O n · (log n) 2 interactions and uses O(log n · log log n) states (Theorem 6) is the first uniform majority protocol that stabilizes in a subquadratic number of interactions, regardless of the required number of states.
An import ingredient for our results is an improvement to the phase clock from [18]-a distributed synchronization mechanism for population protocols. Although this phase clock itself requires just a constant number of states, it is driven by a junta of n agents (for a constant ∈ [0, 1)), and selecting such a junta requires (log log n) states. By careful changes to the internals of the junta selection protocol and the interplay between the junta and the phase clocks, we not only simplify the phase clock protocol but also allow agents to "forget" some of the values required to select the junta. This enables us to reduce the number of states required by our majority protocols from a factor of (log log n) to an additive term of the same order. See Sect. 3.2 for detailed explanations.

Related literature
The original population model was introduced by Angluin et al. [4,5], assuming that the number of states per agent is constant. Together with Angluin et al. [6,7], their results show that semilinear predicates (which include, e.g., parity and majority) are stably computable in this model. Subsequent results focused on quantifying the runtime and state requirements for specific problems, in particular for the majority and the leader election problems, and on generalizing the model. In the following overview we concentrate on results in the population model for the majority problem. Bear in mind that, as mentioned above, we state any runtime results in terms of the required number of interactions, even when original sources state bounds in parallel time only. For a broader overview of the extent of research and results on protocols for the population model the reader is referred to the survey papers [10] and [17].
Angluin et al. [8] present a protocol with three states and show that, with high probability, the agents agree on the majority after O (n log n) interactions if the initial difference between both opinions (the absolute bias α) is ω √ n log n . Mertzios et al. [20] show that, if agents are required to succeed with probability 1, at least four states are necessary. They also provide a four state protocol that stabilizes with high probability in O n 2 log n interactions. The same four state protocol was independently (and earlier) studied by Draief and Vojnovic [16], who proved similar results. Alistarh et al. [1] show a lower bound of n 2 /α on the expected interactions for any four state protocol. For any number of states, they show a lower bound of (n log n) expected interactions.
To achieve fast runtime, Mocquard et al. [21] consider the population model allowing a super-constant number of states per agent. They present a protocol that calculates the signed difference between the two opinions' support with high probability in asymptotically optimal O (n log n) interactions but uses polynomial n 3/2 number of states. The constant-state but slow quadratic-time protocols [16,20] on the one hand and the fast but polynomial-state protocol [21] on the other, posed the quite natural question of designing fast O (n polylog n)-time majority protocols which use a relatively small O (polylog n) number of states.
Alistarh et al. [2] show a lower bound on the required number of interactions for population protocols with a small number of states. For majority, their bound states that protocols with less than (log log n)/2 states require n 2 / polylog(n) interactions in expectation in order to stabilize. Alistarh et al. [3] further improve this lower bound, by showing that any protocol that solves majority and stabilizes in n 2− (1) expected interactions requires (log n) states. Both these lower bounds require certain natural monotonic-ity assumptions which are satisfied by all known majority protocols.
A recent series of papers [1][2][3]11,13] showed upper bounds. Alistarh et al. [3] present a protocol that stabilizes with high probability in O n · (log n) 2 interactions and requires O (log n) states. In a recently published result [11], we present a population protocol for majority that reduces the number of interactions to O n · (log n) 5/3 , both in expectation and with high probability.
The subquadratic-time protocols for majority presented in [1][2][3]11,13,21] are not uniform. To work correctly, they need an estimate of the size of the population; more precisely, they need a value which is (log n). They also, with exception of protocols proposed in [1], provide no means to trade runtime for the number of states required per agent, as our protocols do. Alistarh et al. [1] is the only paper we know of which presents majority protocols with a trade-off of similar nature. For a parameter m ≤ n, their algorithm uses O (m + log n · log m) states and stabilizes with high probability in O n 2 · (log n)/(α · m) + n · (log n) 2 interactions.
In parallel to our work, Kosowski and Uznanski [19] recently designed population protocols, including two majority protocols that converge in O n(log n) 3 and O n 1+ interactions and use O (log log n) and constant f ( ) number of states, respectively. Here, is an arbitrarily chosen positive constant.
With the only exception of [8], all majority protocols mentioned above solve exact majority. That is, they eventually output the correct majority opinion with probability 1. This holds even if the initial bias towards one opinion is as small as only 1.

Model & notation
Population protocols are a computational model for a distributed system consisting of n agents, in the following also referred to as nodes. Nodes are assumed to be identical finite-state machines. 3 In each time step, an ordered pair of nodes (u, v) is chosen independently and uniformly at random. Node u is called the initiator and node v is called the responder. Let s u be the state of u and s v be the state of v at the beginning of such an interaction. Both nodes observe each other's state and update themselves according to a fixed, deterministic transition function of the form (s u , s v ) → (s u , s v ). At any time, the global state of the system can be fully described by a function c that maps each node to its current state. This function c is called the configuration of the system at that time.
Nodes try to reach and stay in a set of target configurations, whose definition depends on the considered problem. It is not required, indeed not possible in this model, that nodes realize when a target configuration has been reached. Target configurations are specified via an output function of the form s → o that maps a state s to a (problem specific) output value o.
We are interested in population protocols for the majority problem, where nodes start in one of two different states (also called opinions). We seek a configuration in which all nodes agree on the opinion with the initially larger support. The absolute bias α is the absolute difference between the initial number of supporters for each opinion. We assume α ≥ 1. The output function maps each state s to an output o ∈ {+1, −1}, representing one of the two opinions. The target configurations are all configurations in which node states map all to +1, if +1 represents the initial majority opinion, or map all to −1, if −1 represents the initial majority.
The quality of a protocol is measured in terms of the number of interactions and the number of states per node required to reach and stay in target configurations. There are two common ways to formalize what exactly is meant by "reach and stay": stabilization time and convergence time. 4 Convergence Time: The convergence time T C of a protocol is the random variable that measures the number of interactions until the protocol has reached and remains in the set of target configurations. Stabilization Time: We say a configuration c is stable, if in any configuration c that is reachable from c by a sequence of interactions, each node has the same output as in c.
The stabilization time T ST of a protocol is the random variable that measures the number of interactions until the protocol has reached a stable target configuration.
Clearly, T C ≤ T ST , since reaching a stable target configuration implies that, whatever future interactions may be, the system will always remain in a target configuration. The stabilization time T ST can, however, be strictly larger than the convergence time T C .
As bounds on the convergence and stabilization time are given in probabilistic terms, one often additionally emphasizes whether a protocol is guaranteed to, eventually, reach a stable target configuration (i.e., whether T ST < ∞ holds with probability 1). Such protocols are called exact or always correct.
The newer results on population protocols, for example [3,18], tend to consider the stabilization time for exact protocols. However, from a practical point of view, con-vergence may provide similarly strong runtime guarantees while enabling more efficient protocols. Indeed, our Theorem 5 shows that the lower bound on the number of states required by any majority protocol that stabilizes in n 2− (1) expected interactions does not apply if one considers convergence instead.
In the remainder of this article, we define N as the set of natural numbers without zero and N 0 := N ∪ {0}.

Auxiliary population protocols
In this section we introduce a few auxiliary population protocols that we use as subroutines. These protocols, or variants of them, are well known and have been used in other work on population protocols, as indicated below.
We start with two comparatively simple primitives: Oneway Epidemic and Load Balancing. Afterward we proceed to describe two more involved protocols, one for the creation of a junta (Sect. 3.1) and one for the creation of a phase clock (Sect. 3.2), both of which require slight adaptions and rephrasing to fit into our setting.
One-way Epidemic A one-way epidemic for n nodes is a population protocol with state space {0, 1} and transition function (x, y) → (x, max{x, y}). Nodes with value 0 are referred to as susceptible and nodes with value 1 as infected.
We define the infection time T INF as the number of interactions required by a one-way epidemic starting with a single infected node to infect the whole population. The following upper and lower high-probability bounds on T INF have been shown in [9]. Load balancing We define a simple population protocol for load balancing over n nodes. The state space is {−Λ, −(Λ − 1), . . . , Λ − 1, Λ}, where Λ ∈ N is a positive integer (which may depend on n). We say a node in state x has load x. The transition function is (x, y) → x+y 2 , x+y 2 . Let Δ(t) denote the discrepancy after t interactions, which is the difference between the maximum and minimum load among all nodes, and set Δ := Δ(0). We define the load balancing time T LB as the number of interactions required to reduce the initial discrepancy to at most 2. The following upper high-probability bound on T LB has been shown in [12].

Junta
The next protocol rapidly elects a non-empty junta of size at most n 1− (1) . It is a variant of a protocol from [18], where each node calculates a level from a range of (log log n) values and all nodes with the highest level form the junta. The original protocol is modified such that we can not only provide an upper bound on the highest level reached by any node (as in [18]) but also a lower bound. This change also simplifies the protocol and allows the nodes to realize when the junta selection has finished. Thus, in contrast to [18], nodes are not required to store their level ad infinitum. This is important when using the junta selection as a subprotocol, as storing the level would then increase the number of states per node by a factor of (log log n).
We first describe in Sect. 3.1.1 how the levels are calculated. Then we continue to describe how this level calculation can be used to calculate a junta with the desired properties and state the main result for the junta election process in Sect. 3.1.2. The protocol's analysis is given in Sects. 3.1.3 and 3.1.4.

Level calculation
For the level calculation, the state of a node is a tuple of the form (l, a), where the level l ∈ N 0 is a counter and the activity bit a ∈ {0, 1} indicates whether a node is active or not. Initially, all nodes have state (l, a) = (0, 1). That is, they are at level 0 and active.
To describe the transition function, we distinguish between a node's first interaction and any of its subsequent interactions. During its first interaction, a node u adopts state (1,1) if it is the initiator and state (0, 0) if it is the responder. Since the interacting nodes are chosen randomly, this simulates a fair coin toss to decide whether the node should remain active and move up to level 1, or whether it should become inactive.
During any following interaction, u changes its state only if it is still active (a = 1) and if it is the initiator of the interaction. In this case, when interacting with a responder in state (l , a ), node u updates its state as follows: In words, a node remains active and increases its level as long as it does not encounter a node with a lower level. The only difference to the protocol from [18] is how nodes behave in their first interaction, which allows us to provide a lower bound on the maximum level reached by any node (Lemma 4). We use the random variable L * to denote this maximum level. Moreover, for l ∈ N 0 we define B l as the number of nodes that reach level at least l before becoming inactive.

Junta calculation
We now describe how the above level calculation can be used to calculate a suitable junta. In addition to the level l and activity bit a, each node stores a marker bit b ∈ {0, 1} that indicates whether the node is a member of the junta (b = 1) or not (b = 0) and a finished bit f ∈ {0, 1} that indicates whether a node knows that there is at least one marked node ( f = 1) or not ( f = 0). Initially, all nodes have b = 0 and f = 0. If two nodes with finished bit 0 interact, they update their levels as described in Sect. 3.1.1. Any node that reaches level l max := log log n − 3 sets its marker bit b = 1 and its finished bit f = 1. If two nodes interact and at least one of them has its finished bit set to 1, both nodes set their finished bit to 1; no further state updates happen in this case. We refer to this protocol as FormJunta. An important difference to the junta protocol from [18] is under which circumstances a node is assumed to be part of the junta. While our protocol starts with an empty junta and marks a node as part of the junta when it reaches level l max , the protocol from [18] assumes that a node is in the junta as long as it has not encountered a node with a higher level. In particular, initially the junta from [18] has linear size and decreases gradually over time. Protocols using a junta typically rely on a junta of size at most n 1− (1) . Dealing with the initially oversize junta requires some care, a difficulty avoided by our protocol. Another benefit of our protocol is that once a node sets its finished bit, its level value (and activity bit) are no longer of any relevance and need not be stored any longer. These benefits come with the caveat that our protocol may not finish with a non-zero (but, as we will show, negligible) probability. That is, it is possible that no node is ever marked/finished.
The remainder of this section proves the following theorem.
Theorem 1 Fix any constant a > 0 and let n be sufficiently large with respect to a. With probability at least 1 − n −a , protocol FormJunta calculates a non-empty junta (with all nodes being finished) of size at most n 0.98 within O (n log n) interactions. It uses 2 · (l max + 1) = (log log n) states per node. Finished nodes are in one of exactly two states, indicating whether the node is in the junta or not.
Note that our analysis of Theorem 1 is not designed to keep the involved constants small but instead to make the asymptotic analysis as clear as possible. For example, the current, simple asymptotic analysis wold require an exorbitant large value for n (≥ e 800 ). These numbers arise simply out of convenient choices and it is not difficult (if tedious) to improve them to more realistic values. In fact, simple experimental simulations show that these protocols work already well in practice for values of n ≥ 10 6 .

Auxiliary claims about the level calculation
In this section we state and prove some auxiliary claims about the level calculation described in Sect. 3.1.1. We start with upper and lower bounds on the number B 1 of nodes that proceed from level 0 to level 1 (Claim 1). Afterward, we provide both upper and lower bounds on the number of nodes that proceed from level l to level l + 1 for l ∈ N (Claim 2). Finally, we bound how many levels nodes can proceed beyond any level that is reached by at most O n 1/3 nodes (Claim 3).

Claim 1
Fix any two constants a, > 0 and let n be sufficiently large with respect to a and . Then, Pr Proof For a node u let the first interaction t u of u denote the earliest interaction during which u was either initiator or responder. We say u is a singleton if t u = t v for all nodes v = u. Two nodes u = v with t u = t v are called twins. Let S denote the set of all singletons and T the set of all nodes that have a twin.
For each node u we define the binary random variable X u to be 1 if and only if u is the initiator of t u . Note that Pr[X u = 1] = 1/2 and that B 1 = u X u . We would like to treat B 1 as a binomial distribution Bin(n, 1/2). Unfortunately, the variables X u are not independent: for twins u and v, exactly one of X u and X v is 1. To fix this, define K ∈ {1, 2, . . . , n/2 } as the number of pairs u and v that are twins and let us condition on a fixed K = k. The n − 2k variables X u with u ∈ S are completely independent of the remaining process (a node becomes initiator or responder independently with probability 1/2). For the 2k variables corresponding to twins, note that their sum is exactly k. We pick an arbitrary subset T 1 ⊆ T of k twins and define X u := 1 for all u ∈ T 1 as well as X u := 0 for all u ∈ T \ T 1 . For u ∈ S, we define X u := X u . Obviously, we have B 1 = u X u = u X u and the set of all X u is mutually independent. Moreover, where δ := 6b · log(n)/n = o (1). Using the law of total probability to get rid of the conditioning yields the inequality Pr[|B 1 − n/2| ≤ · n/2] ≥ 1 − 2n −b , which implies the claim's statement by choosing the constant b = a + 1.

Claim 2
Fix any two constants a > 0 and ∈ (0, 1] and let n be sufficiently large with respect to a and . For all l ∈ N, ξ U ∈ [n −1/3 , 1), and ξ L ∈ [n −1/2 ln n, 1) we have Proof Fix an l ∈ N and consider a node u that just reached level l. Node u is still active and will either become inactive or proceed to level l + 1 during its next interaction. Let t be u's next interaction.
1. The probability for u to proceed to level l +1 during interaction t is at most B l /n. This holds for all B l nodes that reach level at least l. By a straightforward coupling argument 5 , we get that B l+1 is stochastically dominated by a binomially distributed random variable Bin(B l , B l /n). Conditioned on B l ≤ ξ · n we can apply Chernoff (Equation (17)) to get implying the desired statement. 2. If u is among the last B l /2 nodes that try to proceed from level l to level l +1, its probability to proceed to level l +1 is at least B l /(2n). By a straightforward coupling argument 6 shows that B l+1 stochastically dominates a binomially distributed random variable Bin(B l /2, B l /(2n)).
Conditioned on B l ≥ ξ · n we can apply Chernoff (Equation (16)) to get implying the desired statement.

Claim 3
Fix any integer constant a ≥ 1 and let n be sufficiently large. For all l ∈ N, we have Proof Note that B l < 2n 1/3 implies B l ≤ B l < 2n 1/3 for all l ≥ l. By Markov's inequality, we have 5 Run the original process and mark all nodes that reach level l. Then run the coupled process and use the same random choices. Proceeding from level l to l + 1 for l ∈ N 0 \ {l} works as in the original process. However, for a node to proceed from level l to l + 1 its interaction partner must have been marked in the original process. 6 Run the original process and let b denote the number of nodes that reach level l. Mark the first b/2 nodes that try to proceed from level l to level l + 1. Then run the coupled process and use the same random choices. Proceeding to the next level works as in the original process, except for the last b/2 nodes that try to proceed from level l to level l +1: such nodes proceed only if their interaction partner has been marked in the original process.
We apply Markov's inequality to the next 4a levels and get

Analysis of the junta calculation
Equipped with the auxiliary claims from Sect. 3.1.3, we continue with the analysis of the junta calculation. First, we bound the time it takes until all nodes become inactive (Lemma 3). Next, we give upper and lower bounds on the maximum level L * reached by the nodes (Lemma 4) as well as an upper bound on the number B l max of nodes that reach level l max (Lemma 5). Finally, the proof of Theorem 1 is given at the end of this section.

Lemma 3
Fix any constant a > 0 and let n be sufficiently large with respect to a. With probability at least 1 − n −a all nodes become inactive during the first (6a + 12) · n ln n interactions.
Proof The probability that a given node does not interact in a given interaction is 1 − 1/n. Thus, the probability that a given node does not interact at all during the first c · n ln n interactions is at most (1 − 1/n) c·n ln n ≤ n −c for any c > 0. By a union bound, we get that all nodes interacted at least once after the first c · n ln n interactions with probability at least 1 − n −c+1 . Together with Claim 1 and a union bound, we know that, with probability 1 − 2n −c+1 , there are at least n/3 nodes in state (0, 0) after c · n ln n interactions. From that point on, the probability for any fixed node to become inactive during a given interaction is at least 1 3n (the node is chosen as the initiator of the interaction and its communication partner is one of the n/3 nodes in state (0, 0)). Thus, the probability that any fixed node remains active during the next c · n ln n interactions is at most (1 − 1/(3n)) c·n ln n ≤ n −c/3 . By a union bound, all nodes become inactive during the next c · n ln n interactions with probability at least 1 − n −c/3+1 . Combining, we get that all nodes become inactive within 2c · n ln n interaction with probability at least 1−2n −c+1 −n −c/3+1 ≥ 1−3n −c/3+1 . We can make this probability to be at least 1 − n −a by choosing c = 3a + 6.

Lemma 4
Fix any constant a > 0 and let n be sufficiently large with respect to a. With probability at least 1 − n −a we have log log n − 3 ≤ L * ≤ log log n + 4 · (a + 1).
Proof Let δ := 1/10,ξ 0 =ξ 0 := 1, and define for l ∈ N Note thatξ l andξ l are monotonically decreasing in l and that for l ∈ N 0 we haveξ l+1 = (1 + δ) ·ξ 2 l andξ l+1 = (1 − δ) ·ξ 2 l /4. For the upper bound on L * , apply Claim 1 and Claim 2.1, to get that, for any l ∈ N withξ l−1 ≥ n −1/3 and for any constant a > 0, (Note that, sinceξ 0 = 1 and B 0 = n, the conditioning is void for l = 1.) Sinceξ l < n −1/3 for l ≥ log log n, we can apply Eq. (8) iteratively to see that there is an l ≤ log log n such that Pr[B l < n 2/3 ] ≥ 1 − l · n −a−1 . Together with another application of Claim 2.1, we get an l ≤ log log n + 1 such that For the lower bound on L * , similarly apply Claim 1 and Claim 2.2 to get that, for any l ∈ N withξ l−1 ≥ n −1/3 and for any constant a > 0, (As above, sinceξ 0 = 1 and B 0 = n, the conditioning is void for l = 1.) Sinceξ l ≥ n −1/3 for all l ≤ log log n − 3, we can apply Eq. (9) iteratively to see that, for l = log log n − 3, The lemma's statement follows via a union bound.

Lemma 5 Fix any constant a > 0 and let n be sufficiently large with respect to a. Then we have the bound Pr
Proof Define δ andξ l as in the proof of Lemma 4. By their definition and since l max = log log n − 3, we have for any Let := 1 − 0.02 = 0.98. Analogously to the proof of Lemma 4, we have for any l ∈ N withξ l−1 ≥ n −1 and for any constant a > 0 Sinceξ l < n −1 for l ≥ l max (by Eq. (10) and by the monotonicity ofξ l ), we can apply Eq. (11) iteratively to see that there is an l ≤ l max such that Pr[B l < n ] ≥ 1 − l · n −a−1 ≥ 1 − l · n −a . This implies the lemma's statement.

Proof of Theorem 1
We first prove the bound on the runtime. Lemma 3 states that, with high probability, all nodes become inactive within O (n log n) interactions. Lemma 4 states that, with high probability, at least one node reaches level l max and, thus, sets its marked and finished bits. Lemma 5 states that, with high probability, at most n 0.98 nodes reach level l max . Finally, by Lemma 1 the finished bit (which spreads via a one-way epidemic) is, with high probability, set in all nodes after O (n log n) additional interactions. A union bound over all these results yields the desired runtime bound. The number of states per node required for FormJunta is Note that a node's activity bit and level counter become irrelevant once its finished bit is set (which happens at latest when reaching level l max ). Thus, when a node's finished bit is set, it leaves the 2l max states that store the activity bit and the levels 0, 1, . . . , l max − 1 and enters one of two states: one indicating that it has finished and has the marker bit not set, and one indicating that it has finished and has the marker bit set.

Phase clock
Distributed protocols often benefit from some form of synchronization. Phase clocks [9] are one way to synchronize nodes in a population protocol. The idea is to equip each node with a clock that measures time in (let's say) hours consisting of m ∈ N minutes. These clocks do not run at a consistent speed and are not fully synchronized (a node's clock might run faster during a period in which the node is activated uncharacteristically often). However, the clocks can be set up such that, with high probability, each of the first poly(n) hours 1. lasts (n log n) interactions for each node and 2. all nodes simultaneously spend (n log n) interactions in each such hour.
We adapt the phase clock implementation from [18] to our needs. Each node has a phase counter p ∈ N 0 that keeps track of the current time in minutes. The value m ∈ N represents the number of minutes per hour. Its exact value must be chosen carefully as specified by Lemma 6 and its proof. The time for a node with phase counter p can be expressed as p/m hours and p mod m minutes. To limit the number of states per node, we do arithmetic on the phase counter modulo h · m for a parameter h ∈ N. We use PhaseClock h to refer to the protocol that uses the parameter h 7 (which may be a constant or grow with n, depending on the protocol using the phase clock). We also allow h = ∞, which means that PhaseClock h uses exact phase counters that may become arbitrarily large.
We continue with a formal description of the phase clock implementation in Sect. 3.2.1. That section also states the key result (Lemma 6) regarding the synchronization properties of PhaseClock h . The protocol description is based on two simplifying assumptions. Section 3.2.2 explains how to get rid of these. To simplify the usage of the phase clock protocol in the description of other population protocols, Sect. 3.2.3 describes an interface and its guarantees (extracted from Lemma 6) to access the phase clock, resulting in this section's main result (Theorem 2).

Phase clock protocol & synchronization
The state of a node is a tuple of the form ( p, b). The phase counter p ∈ N 0 indicates the total number of minutes passed. Initially, all nodes have p = 0. The marker bit b ∈ {0, 1} indicates whether the node is marked (b = 1) or not (b = 0). We make two simplifying assumptions for the following description: 1. We assume h = ∞ (so we describe PhaseClock ∞ ). In particular, the phase counters are unbounded. 2. We assume that the number of marked nodes lies in the interval [1, n 1−ξ ] at the start of any interaction. Here, ξ ∈ (0, 1] is an arbitrary constant. Note that the identity as well as the number of marked nodes is allowed to change arbitrarily from interaction to interaction, as long as the number of marked nodes stays within the mentioned interval. Section 3.2.2 explains how to get rid of these assumptions. Consider an interaction between an initiator u with state ( p, b) and a responder in state ( p , b ). Protocol PhaseClock ∞ causes node u to update its state according to the following transition function (from [18]): The responder's state remains unchanged. 7 Technically, m could also appear as a parameter in the index. However, for all our applications m will be a constant with respect to n. Thus, we omit m in the index and always assume it is chosen suitably according to Lemma 6. Synchronization Properties. Remember that the m denotes the number of minutes in an hour. We define the hour H u (t) ∈ N 0 of node u with phase counter p(t) after t interactions as H u (t) := p(t)/m . We say a node reached hour i ∈ N 0 if its phase counter is at least i · m.
We now define the notion of rounds, which represents a period of interactions during which all nodes have the same hour. Let R Start (i) (start of round i) denote the interaction during which the last node reaches hour i. Similarly, let R End (i) (end of round i) denote the interaction during which the first node reaches hour i + 1. If R Start (i) ≤ R End (i) (which is not necessarily true), then R End (i)−R Start (i) equals the number of interactions t for which all nodes u have, simultaneously, the same hour H u (t) = i. Thus, for any i ∈ N 0 we define the length of round i as R Length (i) := max{0, R End (i) − R Start (i)}. We also define the stretch of round i as R Stretch (i) := R End (i) − R End (i − 1). In other words, the stretch of round i denotes the time it takes for the first node to reach hour i + 1 after the first node reached hour i. In particular, we always have R Length (i) ≤ R Stretch (i).
A key property of the above phase clock construction is captured by the following lemma. It states that, by carefully choosing the phase clock parameter m, we can ensure that both the round length and stretch of the first poly(n) many rounds are (n log n). It is a reformulation of [18, Theorem 3.1] to fit our setting and proofs. A brief proof based on a technical lemma from [18] is given in "Appendix B".

Lemma 6
Let a, c, d 1 > 0 be constants and assume n to be sufficiently large with respect to them. There is a constant parameter m ∈ N (from the definition of PhaseClock ∞ ) and a constant d 2 > 0 such that, with probability at least 1 − n −a , for all i ∈ {0, 1, . . . , n c } Note that in the above lemma, the constant parameter m depends on the involved constants a, c, and d 1 . In particular, it increases with the exponent a of the desired error probability.

Fixing the odds and ends
We briefly explain how the simplifying assumptions we made for the protocol description can be avoided.
Computing a junta on the fly Our protocol description in Sect. 3.2.1 assumes that the number of marked nodes lies in the interval [1, n 1−ξ ] at the start of any interaction, where ξ ∈ (0, 1] is an arbitrary constant. Instead of assuming a priori the existence of such a junta in each round, we can use protocol FormJunta from Sect. 3.1 to generate such a junta (with ξ = 0.02) with high probability within O (n log n) interactions using 2 · ( log log n − 2) states per node (see Theorem 1).
The state of a node is a tuple (l, a, b, f , p). The (sub-) tuple (l, a, b, f ) is used as the state for the junta protocol and consists of the level l ∈ {0, 1, . . . , log log n −3}, the activity bit a ∈ {0, 1}, the marker bit b ∈ {0, 1}, and the finished bit f ∈ {0, 1}. The (sub-) tuple ( p, b) is used for the phase clock protocol and consists of the phase counter p ∈ N 0 and the marker bit b ∈ {0, 1}. Note that the marker bit b is used by both protocols. All nodes start in state (0, 1, 0, 0, 0) (with only the activity bit set) and execute protocol FormJunta on the (sub-) tuple (l, a, b, f ). Once the finished bit f of a node is set it starts to execute the phase clock protocol from Sect. 3.2.1 on the (sub-) tuple ( p, b). We make two simple observations: 1. PhaseClock ∞ starts only when (if) the first node in FormJunta becomes marked (and, thus, finished). By Theorem 1, this happens with high probability within O (n log n) interactions. Additionally, since the finished bit spreads via a one-way epidemic, with high probability all nodes start to execute PhaseClock ∞ in O (n log n) interactions (by Lemma 1). 2. When PhaseClock h starts, it does so with a junta of size exactly 1. During its execution, the junta might grow (due to more nodes becoming marked in FormJunta). However, by Theorem 1, with high probability the junta does not grow beyond size n 0.98 .
It follows that Lemma 6 holds also if the junta is computed on the fly, with the only difference being that it takes O (n log n) interactions before the first node starts to increase its phase counter. This yields the following observation.

Observation 1
We can change PhaseClock ∞ such that, with high probability, it computes a non-empty junta (marked nodes) of size at most n 0.98 on the fly and Lemma 6 still holds.
Unbounded state space The population protocol as described in Sect. 3.2.1 requires an unbounded number of states, since a node's phase counter p is unbounded. We can avoid this by performing any arithmetic on the phase counter modulo h · m. Here, h ∈ N is a parameter that controls how many hours nodes can count exactly (a node reaching hour h cannot tell whether it has hour h or hour 0).
Note that Lemma 6 implies that during the first poly(n) many rounds all nodes are, with high probability, in neighboring hours (otherwise, if there was a time where one node is in hour i and another node is in hour i + 2, those nodes could never be simultaneously in hour i + 1). Thus, h = 3 is already enough to allow a node, with high probability, to distinguish whether its interaction partner is in an earlier, in the same, or in a later hour. We get the following observation.  (13)) during the first n c rounds, where c is the constant from Lemma 6. In particular, Lemma 6 holds also for PhaseClock h .

Phase clock interface
To simplify the usage of the phase clock in our Majority protocols, we provide an interface to PhaseClock h , together with the guarantees implied by Lemma 6. The parameter h ∈ N ∪ {∞} is assumed to be at least 3. We group the guarantees of the different interface functions in three categories: (B) The following function calls to PhaseClock h are guaranteed to work as described for n c many rounds with probability 1 − n −a for any constants a, c > 0 (assuming m was chosen suitably and n is sufficiently large): -PCdifferentHour(u, v): Return true iff u is currently in a different hour as v. (C) Moreover, until the first node reaches hour h (i.e., for the first R End (h − 1) many interactions), all function calls work as described with probability 1.
Protocols using the phase clock should be aware that, with negligible probability, the phase clock might not run at all (no nodes were marked) or might run too fast (if n 1−o(1) nodes were marked).
We gather the above guarantees in Theorem 2, the main result of this section. In the following, remember that l max = log log n − 3 is the maximum junta level.

Theorem 2 Let a, c > 0 be constants and assume n to be sufficiently large with respect to them. Consider a parameter h ∈ {3, 4, . . . } ∪ {∞}. PhaseClock h supports the interface specified above with Guarantees (A) to (C) and uses
(h + log log n) states per node. A node whose phase clock is running (finished bit from junta creation is set) is in one of (h) many states.

Proof of Theorem 2 PHASECLOCK h (·), PCmarked(·), as well as
PCfinishedJunta(·) are simple state updates and lookups. As such, they are correct by definition. The function calls PCoverflowed(·), PCnewHour(·), and PCskippedHour(·) can be implemented by providing a bit for each of them, which is set to either true or false according to the respective function description (note that the corresponding conditions can be easily checked locally by a node). This implies Guarantee (A). The statements from Guarantee (B) (which cover the function calls PCdifferentHour(·), PCsameHour(·), PCsmallerHour(·), and PClargerHour(·)) are a consequence of the choice h ≥ 3 and Lemma 6 and Observation 2. These ensure that, with high probability, for poly(n) rounds, the hours of any pair of nodes differ by at most one.
Before the first node reaches hour h, nodes store their exact phase counter and, thus, know their exact hour. This implies Guarantee (C).
We now bound the number of states each node requires. By Theorem 1, the on the fly creation of the junta requires 2 · (l max + 1) states. Note that, as described in Sect. 3.2.2, the values of a node's phase clock state (marker bit, phase counter, bit for PCoverflowed(·), bit for PCnewHour(·), bit for PCskippedHour(·)) only become relevant once its finished bit from the junta creation is set. At that moment, nodes can forget the level from the junta calculation and only need to store whether they are finished and marked or finished and unmarked. Thus, for each of the two value of the marker bit when the node is finished, the maximum number of states that can occur is bounded by h · m × 2 3 . So in total, the number of states per node is Since we have l max = (log log n) and m = (1), this is (h + log log n).

Simple majority
In this section we present and analyze our first majority protocol, SimpleMajority s,h , which works correctly with high probability. It is parameterized by two integer values s and h (the latter value is used for the phase clocks). As many majority protocols, it is based on a variant of the cancellation and doubling approach (see, e.g., [9]). Here, the general idea is that nodes first perform cancellation (opposite opinions cancel each other out) for (n log n) consecutive interactions and then, for another (n log n) consecutive interactions, each node with an opinion finds a node whose opinion was canceled and copies its opinion onto that node. Cancellation boost the ratio between the support of majority and minority opinions, while duplication eliminates non-opinionated nodes created during cancellation.
Our protocol uses cancellation as described above. However, nodes do not simply create a single copy of their opinion but s ≥ 2 copies (load explosion). These copies are distributed among the nodes via a load balancing mechanism. This approach allows us to reduce the number of required phases. We will prove the following theorem: Consider the majority problem for n nodes with initial absolute bias α ∈ N. With high probability, protocol SimpleMajority s,h correctly identifies the majority for all interactions t = n log n · log s (n/α) . It uses (hs + log log n) states per node.
According to Theorem 3 there is no benefit by choosing h > 3. However, our stable protocol presented in Sect. 5 does rely on a larger value of h.
We now describe the protocol's state space and its transition function (see also Algorithm 1). Afterward, we give the proof of Theorem 3. State space The state of a node u consists of the states required for the PhaseClock h protocol (which subsumes the states of FormJunta, cf. Section 3.2) and a load value load u . The load value load u represents u's current opinion (sign) and its "magnitude" (absolute value). It is initialized with either +1 or −1, depending on u's initial opinion. The output function maps the state of a node to the sign of its load value. Thus, the majority guess of a node u is equal to sign(load u ). 8 For most of the analysis, we assume unbounded, integral load values. In the proof of Theorem 3, we will see that, with high probability, load values will be integers not exceeding 3s unless all nodes have already the same positive or negative sign. This allows us to cap the absolute load values at 3s (i.e., setting a node u's load via the assignment load u ← x to a value x with |x| ≥ 3s instead sets load u ← sign(x) · 3s) while still maintaining the high probability guarantee from Theorem 3.
Transition function Consider an interaction between two nodes u (initiator) and v (responder). The nodes' actions can be divided into three parts: synchronization, load explosion, and load balancing. During the synchronization, the PhaseClock h protocol is triggered with initiator u and responder v to update the states of u's phase clock. During the load explosion, u uses the PCnewHour(·) method to check whether this is its first interaction in its current hour. If yes, it multiplies its load by a factor of s. During the load balancing, the nodes use the phase clock's PCsameHour(·) method to check whether they are in the same hour and, if so, perform a simple load balancing step by balancing their respective loads as evenly as possible.
The following observation follows from the fact that all phase clock function calls work correctly with probability 1 until the first node reaches hour h (Guarantee (C) in Sect. 3.2.3). In particular, since nodes u and v balance their loads only if PCsameHour(u, v) returns true (Line 4 in Algorithm 1), we get: Observation 3 Whenever two nodes u and v balance their loads in SimpleMajority s,h before some node reached hour h, both u and v are guaranteed to be in the same hour. This observation will be of importance for our stable majority protocol presented in Sect. 5 (which is based on SimpleMajority s,h ).
Total & scaled total load Let load u (t) denote the load of node u after t interactions and expl u (t) the number of load explosions node u experienced after t interactions. Define the total load Φ(t) and the scaled total load Ψ (t) after t interactions as Observe that Ψ (0) = Φ(0) is the total initial load. Thus, sign(Ψ (0)) = sign(Φ(0)) reflects the initial majority and |Ψ (0)| = |Φ(0)| equals the initial absolute bias α.
The following lemma will be useful to show that, if SimpleMajority s,h works for O (log n) rounds as expected (the phase clock runs, is properly synchronized, and the loads balance out), all nodes forever agree on the correct initial majority.

Lemma 7
Let t ∈ N 0 and assume that whenever two nodes u and v balance their loads in an interaction t ≤ t, expl u (t ) = expl v (t ). Then Ψ (t) = Ψ (0). If, additionally, for all nodes u and v we have sign(load u (t)) = sign(load v (t)), then all nodes forever agree on the correct initial majority opinion after interaction t.

Proof
The invariant for Ψ (t) follows via a simple induction over t. For the second part, assume all nodes' load values have the same sign after t interactions. Note that no load balancing action can change this, afterward. Moreover, the total scaled load Ψ (t) also has the same sign as each single node. So every node's sign forever equals sign(Ψ (t)). Since the lemma's first part states sign(Ψ (t)) = sign(Ψ (0)) (the initial majority opinion), this implies that each node's sign forever equals the correct initial majority opinion after interaction t.
We are now ready to prove this section's main result.

Proof of Theorem 3
For i ∈ N 0 let T i denote the last interaction of round i (with T i = ∞ if R Length (i) = 0). Define i * := log s (2n/α) . Applying Lemmas 2 and 6, with d 1 from Lemma 6 equal to the constant c from Lemma 2, and using a union bound over the first i * + 1 = O (log n) rounds yields that, with high probability, the following properties hold: Note that Property (1) implies that no node skips any hour i ∈ {0, 1, . . . , i * }: If there were such a node, it had hour < i and met a node in hour > i when it skipped hour i. But then, by definition of a round's length, we have R Length (i) = 0. This contradicts Property (1). We now condition on the high probability event that the above properties hold and consider the first T i * interactions. Because nodes are properly synchronized, the calls to PCsameHour(·) (Line 4) correctly indicate whether two nodes are in the same hour or not. Also, since no node skipped an hour, any node in hour i experienced exactly i load explosions. This implies that, whenever two nodes balance their loads during the first T i * interactions, they experienced the same number of load explosions. Lemma 7 gives Ψ (T i * ) = Ψ (0), and the scaled total load definition gives Note that if |Φ(T i * )| ≥ 2n, the absolute value of the average load is at least 2. Hence, either all nodes have load exactly 2 (or −2), or there is at least one node with load ≥ 3 (≤ −3). In the later case it follows from Property (2) that all other nodes have load at least 1 (at most −1). In both cases, all loads have the same sign after interaction T i * . Thus, using again Lemma 7, all nodes forever agree on the correct initial majority opinion after interaction T i * . The runtime bound follows since, by Property (1), the first i * + 1 = O log s (n/α) rounds have stretch O (n log n).
To bound the number of states, observe that -conditioned on the high probability event that the above properties hold -no absolute load value exceeds 2s unless all nodes' loads have the same sign. Indeed, if not all loads have the same sign at the end of a round, the discrepancy bound (Property (2)) implies that all loads have absolute load at most 2. After the load explosion in the following round the load will be at most 2s. This allows us to cap the absolute load values at 3s as described at the beginning of this section and, with high probability, the protocol outcome will not change. 9 These load values are combined with the states from PhaseClock h . By Theorem 2, that protocol requires in total (h + log log n) states per node, but only (h) states per node once the node has finished the junta election process. From that time on, each node needs to store the current phase of the PhaseClock h protocol and the current load value. Thus, SimpleMajority s,h requires (hs + log log n) states per node.

Stable majority
In this section, we present and analyze the protocol StableMajority s , a hybrid majority protocol which stabilizes efficiently. We prove the following theorem: Theorem 4 Let s ∈ {2, 3, . . . , n}. Consider the majority problem for n nodes with initial absolute bias α ∈ N. Protocol StableMajority s is exact and stabilizes with high probability and in expectation in O(n log n ·log s (n/α)) interactions. It uses s · log s n states per node.
We now describe the protocol's state space and its transition function (see also Algorithm 2). Afterward, we give the proof of Theorem 4.

Algorithm 2:
Pseudocode for transition function of StableMajority s (initiator u and responder v). It calls SimpleMajority s,h with h := log s (4n) + 2 Each node u executes a slow but exact protocol Backup-Majority 10 (Line 1) as well as up to h rounds of our fast but possibly incorrect SimpleMajority s,h (Lines 4 to 5), with h := log s (4n) + 2. As output, we use the output of the backup protocol if the phase clock is not yet running (u's phase counter is zero and PCoverflowed(u) = false) or if u thinks that protocol SimpleMajority s,h failed (an error bit is set). Otherwise, we use the output of SimpleMajority s,h .
Node u stops SimpleMajority s,h via a finished bit finished u and checks whether SimpleMajority s,h failed via an error bit error u . Both bits are initially false and are spread via a one-way epidemic (Lines 2 to 3). SimpleMajority s,h is executed only while both bits are false (Lines 4 to 5).
The (first) finished bit is set for one of two reasons (Lines 6 to 7): (i) u reached hour h (i.e., its phase counter overflowed). This marks the end of the first h rounds. Stopping at this point ensures that any load balancing operation happens between two nodes in the same hour (Observation 3). (ii) u has absolute load at least 3s after its first 11 interaction in an hour i. Then it had absolute load at least 3 at the end of round i − 1. If SimpleMajority s,h managed to balance the loads during round i − 1, the load of any other node differs by at most 2. Thus, all nodes have the same sign, which we will show to be correct if no node sets its error bit.
The (first) error bit is also set for one of two reasons (Lines 8 to 9): (i) Two finished nodes whose loads have different signs interact with each other, in which case SimpleMajority s,h obviously failed. (ii) A node skipped an hour. Then it is no longer true that a node in hour i experienced exactly i load explosions. This might cause SimpleMajority s,h to fail, since two nodes that experienced a different number of load explosions might balance their loads.
Since the backup protocol is exact, our protocol is exact if the error bit is set. A major part of the analysis is to show that it is also exact if none of the error bits is set. Moreover, we have to show that, with high probability, no error bit is set and the protocol stabilizes fast.

Proof of Theorem 4
Let us first bound the number of states per node. By Theorem 3, SimpleMajority s,h requires (hs + log log n) = s · log s n states. This is increased by a constant factor from the 4 states for BackupMajority and the 4 combinations of the bits finished u and error u , yielding the desired bound.
Next, we prove that StableMajority s is exact. That is, if T ST denotes the stabilization time of protocol StableMajority s , we show that T ST < ∞ with probability 1. We distinguish three cases: (i) The phase clock does not start: That is, in FormJunta all nodes set their activity bit to 0 before reaching level l max . No node is marked, such that the phase counters cannot increase and PCoverflowed(u) always returns false. Then all nodes forever use the output of the backup protocol, which has finite stabilization time. Thus, T ST < ∞ in this case. (ii) The phase clock starts and some node sets its error bit: The error bit is spread via a one-way epidemic (Line 3). Thus, with probability 1 eventually all nodes set their error bit. From then on, they use the output of the backup protocol, yielding again T ST < ∞. (iii) The phase clock starts and no node ever sets its error bit: If the phase clock runs, FormJunta marks at least one node and, eventually, all nodes u set their finished bit finished u : Indeed, nodes with an unset finished bit execute the phase clock (via SimpleMajority s,h ), such that they have a non-zero probability to increase their phase counter (since there is a marked node, see Sect. 3.2.1). Thus, eventually the phase counter overflows and the finished bit is set (Lines 6 to 7). Let T < ∞ denote the interaction after which all finished bits are set. Since no error bit is ever set, no node ever skips an hour (Lines 8 to 9). Thus, any two nodes that balance their loads are not only in the same hour i < h (as checked by SimpleMajority s,h ) but also experienced both exactly i load explosions. Moreover, after interaction T the loads no longer change and all nodes have the same load signs (otherwise, eventually two finished nodes of different sign meet and an error bit is set, contradicting the case assumption). Thus, by Lemma 7, all nodes forever agree on the correct initial majority after interaction T , such that T ST ≤ T < ∞.
It remains to prove the theorem's runtime bounds. We first show that T ST = O n log n · log s (n/α) with high probability.
To this end, let H * ∈ N denote the maximal hour ever reached by any node and for i ∈ {0, 1, . . . , H * − 1} let T i be the last interaction of round i. Define T * as the first interaction during which some node sets its finished or error bit. By Lines 6 to 9, the first finish or error bit is set because of three possible reasons: (i) a node had load at least 3s after its first interaction in an hour (finished bit), (ii) a node's phase counter overflowed (finished bit), or (iii) a node skipped an hour (error bit).
In a similar way to the proof of Theorem 3, we first show that, with high probability, Reason (i) applies and that all nodes agree on the correct initial majority after T * interactions without setting the error bit. At that moment, we might not yet have stabilized, since there's still a non-zero probability for a node to set the error bit because of Reason (iii). But with high probability that won't happen before all nodes set their finished bit by the one-way epidemic (Line 2), after which the error bit cannot be set anymore. We formalize this idea below.
Note that the finished bit is set when a node reaches hour h (its phase counter overflows), so H * ≤ h. As in Theorem 3's proof, we apply Lemmas 6 and 2 via a union bound to the first H * ≤ h = O (log n) rounds to get, with high probability, the following properties: (1) T * < ∞ (the phase clock runs and some node sets its error bit or, eventually, its phase counter overflows). As in the proof of Theorem 3, Property (2) implies that no node ever skips an hour.
In the remainder we condition on the high probability event that the above properties hold. Since no node ever skips an hour, whenever two nodes in hour i ∈ {0, 1, . . . , H * − 1} balance their loads, both of them experienced exactly i load explosions. Thus, Lemma 7 gives Ψ (T i ) = Ψ (0) for all i ∈ {0, 1, . . . , H * −1}. With this, we can show that H * −1 ≤ log s (4n/α) =: i * : Indeed, otherwise all nodes go through round i * and a similar calculation as in Theorem 3's proof yields |Φ(T i * )| = |Ψ (T i * )|·s i * = |Ψ (0)|·s i * = α ·s i * ≥ 4n. By an average argument as in Theorem 3's proof, all nodes have absolute load ≥ 3 after interaction T i * . This implies that any node reaching hour i * + 1 < H * has absolute load ≥ 3s after the load explosion and sets its finished bit, contradicting H * 's choice (i * + 1 would be the maximal hour).
Let u * denote the initiator of interaction T * and remember the three possible reasons why u * could have set its finished or error bit (Reasons (i) to (iii)). Reason (iii) does not apply since no node skipped any hour. Reason (ii) does not apply since the maximal hour is H * ≤ i * + 1 ≤ h − 1, so no node's phase counter overflows. Thus, u * set its finished bit because of Reason (i): it had absolute load at least 3s after its first interaction in hour H * . Then u * had absolute load at least 3 after T H * −1 interactions (the end of round H * − 1). Together with Property (3)" either all nodes had load at least 1 or all nodes had load at most −1 after T H * −1 interactions. In particular, all nodes have the same sign, which cannot change subsequently. Since we already saw that load balancing happens only between nodes that experienced the same number of load explosions, Lemma 7 implies that the nodes' sign is also the initial majority.
In summary, with high probability, after T H * −1 interactions, no error bit is set and all nodes forever have the correct load sign. This is still the case after interaction T * . Note that this does not imply T ST ≤ T * , since so far only one node finished and there is still a non-zero probability that some node skips an hour and, thus, sets the error bit after interaction T * . However, with high probability, the finished bit spreads to all nodes within T INF = O (n log n) interactions (the infection time, see Lemma 1). Thus, by using Lemma 6 with a large enough constant d 1 , we can ensure that, with high probability, R Length (H * ) ≥ T INF , such that no node skips an hour before all finished bits are set. Once all nodes are finished, the error bit cannot be set anymore, since all nodes have the same sign.
Combining everything above via a union bound, this yields that, with high probability, T ST ≤ T * + T INF = H * · O (n log n) + T INF = O n log n · log s (n/α) , yielding the desired high-probability bound on the stabilization time.
Finally, we show that the stabilization time T ST of StableMajority s is O n log n · log s (n/α) in expectation. To this end, observe that we know that, with high probability, the stabilization time T ST is O(n log n · log s (n/α)). That is, for any constant a > 0, there is a constant C > 0 and appropriate values of the constant protocol parameters such that To show that T ST is O n log n · log s (n/α) in expectation, we show the following statement: For some fixed η (independent of the constant parameters of protocol StableMajority s ), for each sufficiently large n, and for each configuration C reachable from the initial configuration, the protocol stabilizes from C within n η interactions in expectation. Once this is shown, we can calculate ≤ C · n log n · log s (n/α) + n −a · C · n log n · log s (n/α) + n η ≤ 2C · n log n · log s (n/α).
The first inequality above follows from Equation (15). The second inequality follows from the bound n η on the expected stabilization time from the configuration C reached after the first C · n log n · log s (n/α) interactions. Finally, the last inequality holds by taking a = η.
We use the following facts about the expected running time of some basic protocols: 1. Protocol BackupMajority stabilizes within O(n 2 · log n) ≤ n 3 (for sufficiently large n) interactions in expectation [20]. 2. The one-way epidemic completes within O (n log n) interactions in expectation. 3. For each K ≥ 1, the number of interactions required so that each node is the initiator of at least K interactions is O (K n log n) in expectation (a simple consequence from the expected completion time O (n log n) of the coupon collector problem).
Let C be any non-stable configuration of the protocol StableMajority s that is reachable from the initial configuration. We distinguish several configuration types with respect to C: 1. The phase clocks of all nodes have reached their limit of h · m, viewing the clocks (for the purpose of this analysis but without actually altering anything in the protocol) as if there were kept running until reaching the limit: Configuration C is not stable, so either there is a node with the error flag raised, or all nodes have their finished flag raised but not all nodes have the same signs of their load. Otherwise the configuration is stable. In the former case (when there is a node with an error), one instance of one-way epidemic raises the error flag in all nodes in expected O (n log n) interactions, and then protocol StableMajority s stabilizes within additional expected n 3 interactions by completing BackupMajority.
Similarly, in the latter case, two consecutive one-way epidemics (the first one to make two nodes with different load signs meet and the second one to spread out the information about the error) and then the completion of the BackupMajority protocol are sufficient to stabilize StableMajority s . In both cases, the protocol StableMajority s stabilizes within additional O n 3 interactions in expectation. 2. There is at least one marked node (by protocol For-mJunta), but there is still at least one node whose clock has not yet reached the limit of h · m (as above, we view the clocks as if running until the limit): The marked node with the largest clock value increases its clock within one instance of one-way epidemics. Thus within at most h · m consecutive instances of one-way epidemics, one marked node reaches the clock limit. One additional oneway epidemic makes all clocks reach the limit. This takes (h · m + 1) · O(n log n) = O(n log n · log s (n)) interactions in expectation and takes us to a configuration of Type 1. 3. No node is marked (by protocol FormJunta): We consider two sub-cases: (a) All nodes in FormJunta are inactive: No node is ever marked and the phase clock never starts. Thus, StableMajority s stabilizes in n 3 additional interactions in expectation (via BackupMajority). (b) There is at least one active node in FormJunta: If an active node is the initiator of an interaction, then it either increases its junta level or becomes inactive. Thus, when this node initiated l max interactions, either it reached level l max and got marked, or it has become inactive. So within l max · O(n log n) = O(n log n · log log n) interactions in expectation (after each node initiated at least l max interactions) we either reach a configuration with the first marked node (Type 2) or a configuration with no marked node but only inactive nodes (Type 3a).
In summary, we see that StableMajority s stabilizes from any configuration C reachable from the initial configuration within O n 3 ≤ n 4 (for sufficiently large n) interactions in expectation.

Convergent majority
In this section, we present and analyze the protocol ConvergentMajority s , a hybrid majority protocol which converges efficiently. The main idea of the protocol is that all nodes execute SimpleMajority s,3 , which converges quickly. However, there is a positive probability that it returns the wrong answer without detecting the error. Therefore, every node switches its output to the backup protocol after a (polynomially) long time. To determine that this time has passed, we use a simple approach based on counting the number of consecutive interactions with junta nodes. Formally, we prove the following theorem: Theorem 5 Let s ∈ {2, 3, . . . , n}. Consider the majority problem for n nodes with initial absolute bias α ∈ N. Protocol ConvergentMajority s is exact and converges with high probability and in expectation in O(n log n · log s (n/α)) interactions. The protocol uses (s + log log n) states per node.
We now describe the protocol's state space and its transition function (see also Algorithm 3). Afterward, we give the proof of Theorem 5.
Nodes first execute a backup protocol BackupMajority . 12 Additionally, each node u executes protocol SimpleMajority s,3 as long as it did not encounter 600 marked nodes in a row. The number of such encounters is It remains to prove the convergence time bound for the ConvergentMajority s protocol. Assuming a non-empty junta (which, by Theorem 1, holds with high probability after O (n log n) interactions), we can derive the desired bound from the following observations.
(i) Once the junta is established, the output of protocol ConvergentMajority s during the next poly 1 (n) interactions equals, with high probability, that of SimpleMajority s, 3 . That protocol converges with high probability in at most O n log n · log s (n/α) interactions. (ii) After poly 1 (n) interactions, the nodes' outputs start switching gradually to the output of BackupMajority, which stabilizes in O n 2 log n interactions. After poly 2 (n) > poly 1 (n) interactions, with high probability all nodes have switched their output to BackupMajority.
By choosing parameters such that poly 1 (n) = n 3 , the switch to the backup protocol happens only when it has, with high probability, stabilized. Thus, with high probability, the subprotocol SimpleMajority s,3 converges to the correct outcome within O n log n · log s (n/α) interactions and, when the nodes start switching their output to BackupMajority, that subprotocol also has the correct output. Together, this implies the desired bound on the convergence time.
To see Observation (i), note that, once there is a nonempty junta of size at most n 0.98 (which happens with high probability in O (n log n) interactions by Theorem 1), the probability that a node samples a junta node 600 times in a row is at most (n 0.98 /n) 600 = n −12 . Using a union bound, with high probability no node reaches counter value 600 (and switches to the backup protocol) before n 3 interactions. Observation (ii) follows by a simple Markov bound applied to the expected number of interactions a node requires to switch its output back to the backup protocol (which is upper bounded by O n 600 ) together with a union bound over all nodes.
It remains to prove the bound on the expected convergence time T C of ConvergentMajority s . For this, using the same argument as in the proof of Theorem 4, it is sufficient to show the following statement: For some fixed η, for each sufficiently large n, and for each configuration C reachable from the initial configuration, the protocol stabilizes from C within n η interactions in expectation. Once this is shown, the same calculation as for Theorem 4 yields E[T C ] ≤ 2C · n log n · log s (n/α). To this end, we proceed as in the proof of Theorem 4 and distinguish the following configuration types:

All nodes have switched to the backup protocol: Then
ConvergentMajority s stabilizes in n 3 additional interactions in expectation (via BackupMajority).

Some node has not yet switched to the backup protocol:
The time until all nodes switch to the backup protocol is dominated by the sum of n geometrically distributed random variables with parameter ≥ 1/n 1200 (see the exactness proof above). Thus, there is a constant η such that all nodes switch their output to BackupMajority after at most n η−1 many interactions in expectation. This takes us to a configurations of Type 1.
In summary, wee see that ConvergentMajority s converges from any configuration C reachable from the initial configuration within n η−1 + n 3 ≤ n η (for sufficiently large n) interactions in expectation.

A note on uniformity
Uniformity in population protocols means that a single algorithm is designed to work for populations of any size. In particular, nodes have no information on the population size n. Protocols where nodes are restricted to a constant number of states are always uniform. But most of the newer protocols allow for a super-constant number of states and use some upper bounds on n, so they are not uniform. In particular, protocols that stop their computation once a counter reaches a value of polylog(n) fall into this category of non-uniform protocols. This section presents a uniform population protocol for majority.
Uniform population model For studying uniform population protocols whose state requirements increase with the population size n, the original model-which considers nodes as finite-state machines (FSM), see Sect. 2 -turns out to be inadequate. Indeed, if each node is an FSM with a state space of size f (n) for a non-trivial function f , then the nodes and, thus, the protocol inherently depend on n and cannot be simply "deployed" in a population of different size.
Doty and Eftekhari [14] introduce a generalized population model that is better suited for this scenario and which we adopt in the remainder of this section . In their model, each node is represented by a 2-tape deterministic Turing machine (TM). We assume that both tapes are infinite to the left and right and that the origin is marked by a special origin symbol. Tape 1 (read-only) is called the input tape and tape 2 (read-write) the working tape. One two-way infinite working tape is sufficient for us since it allows maintaining two unbounded variables, as required in our protocol. For protocols with more unbounded variables, similarly to [15] one can use a TM with as many (one-sided infinite) input/working tapes as there are unbounded variables (whose number must not depend on n).
At the beginning of any interaction, a node's working tape is identical to its working tape at the end of the previous interaction. Whenever two nodes interact, they copy each other's working tape onto their own input tape and restart their TM by entering a start TM-state (which then computes a new state, updates the node's working tape, and halts). We define the number of states used during a protocol execution as | | s , where is the (binary) tape alphabet and s is the maximum number of tape cells written by any node during the execution.
Having the above formal model in mind, our description sticks with the standard population protocol terminology. In particular, we assume a suitable encoding of the nodes' states using the alphabet and simply identify the content of a node's working tape with its state. An important implication of the model is that nodes might now use an unbounded number of states (write an unbounded number of cells on the working tape). However, in our uniform majority protocol, the number of used states is finite with probability 1 and O(log n · log log n) in the population size n with high probability.
Uniform majority One of the rare examples of a uniform protocol whose state requirements increase with n is the junta protocol from [18]; we refer to it as FormJuntaUniform.
Observe that our protocol FormJunta is not uniform, as nodes need to know l max = log log n − 3 in order to mark themselves (see Sect. 3.1). See below for a brief description of FormJuntaUniform.
Since our majority protocols from the previous sections use the non-uniform junta FormJunta, none of them is uniform. In fact, to the best of our knowledge, until now there was no exact, uniform majority protocol that would stabilize with high probability in n 2− (1) interactions. The following theorem shows that we get such a uniform majority protocol by applying slight modifications to protocol StableMajority s . Theorem 6 Let s ∈ N \ {1} be a constant. Consider the majority problem for n nodes with initial absolute bias α ∈ N. Protocol UniformMajority s is an exact and uniform variant of StableMajority s . With high probability and in expectation, it stabilizes in O(n log n·log s (n/α)) interactions. While the number of used states can be arbitrarily high with non-zero probability, with high probability it uses only s · O(log s (n/α) · log log n) states per node.
Note that, in order for UniformMajority s to be uniform, the parameter s must be constant (i.e., s may not depend on n).
Protocol UniformMajority s is identical to protocol StableMajority s with the following changes: 1. It uses subprotocol SimpleMajority s,∞ instead of SimpleMajority s, log s (4n) +2 . In particular, the phase clock PhaseClock ∞ is used, which cannot overflow. Thus, nodes always know their exact hour.
2. The phase clock uses FormJuntaUniform instead of FormJunta.
Using the original junta instead of ours has the drawback that nodes must remember their level from the junta calculation indefinitely. However, since protocol FormJunta is inherently non-uniform, this seems unavoidable when aiming for a uniform protocol. For the sake of completeness, we give a brief description of FormJuntaUniform, using slightly different wording and notation than in [18], in order to fit it into our framework. 13 We also describe how the phase clock is adapted to the changed junta protocol. Afterward, we give the proof of Theorem 6.
Description of UniformMajority s . As our junta protocol FormJunta, protocol FormJuntaUniform is based on the level calculation described in Sect. 3.1.1. Recall that the level calculation uses a level l, an activity bit a, and the transition function described by Equation (1). In addition to the level l and activity bit a, each node stores a marker bit b ∈ {0, 1} (indicating whether the node assumes to be in the junta or not) and a defeated bit d ∈ {0, 1}. Initially, all nodes have b = 0 and d = 0. A node that just became inactive at a level l ≥ 1 sets b to 1. If an inactive node at level l ≥ 1 encounters a node on a higher level, it becomes defeated: it sets d to 1, b to 0, and will from now on simply adopt the larger level during any interaction (not changing any of its other state values related to the junta). If encountered by another node in the level calculation, a defeated node is treated as if it were in state (0, 0), independent of its actual level counter l.
Phase Clocks on different Levels & Reset. Compared to FormJunta, any (inactive) node starts with the belief of being in the junta until it becomes defeated by a node from a higher level. This ensures that the junta is never empty. However, when used in the phase clock protocol, there will be a large number of nodes in the junta for the first few interactions (until lower-level nodes become defeated), causing the phase clock to run too fast.
To avoid problems in the protocol relying on the synchronization of the phase clock, nodes now also use the level (from the junta protocol) in the phase clock protocol. This basically results in multiple phase clocks running on different levels. When a node running a phase clock on level l encounters a node running a phase clock on a higher level l , it resets its phase counter to zero (and -by the junta protocol -updates its level to l ). This reset also triggers a reset of the protocol using the phase clock. In our case this is the majority protocol StableMajority s . For a node u this entails a reset of the bits finished u and error u to 0, and a reset of the load value from SimpleMajority s,∞ to ±1, depending on the original opinion of u. This idea of phase clocks running on different levels and a corresponding reset was first proposed and used in [18] for the case of leader election.

Proof of Theorem 6
First note that the protocol requires no knowledge of n, meaning that it is uniform. The remaining proof is similar to that of Theorem 4. In fact, having unbounded phase counters (which avoid overflows in the phase clock) and the guarantee from FormJuntaUniform that the junta is never empty simplify the argumentation considerably. Also note that the exact phase counters guarantee that any load balancing action is always guaranteed to be done only between nodes in the same hour.
Let T ST denote the stabilization time of protocol UniformMajority s . To proof exactness, remember the three cases from the exactness proof of Theorem 4. The first two cases are trivial: Case (i) (phase clock does not start) cannot occur, since we use FormJuntaUniform. Case (ii) (phase clock starts and some error bit is set) is identical, since with probability 1 eventually all nodes set their error bit and use the output of the backup protocol. For Case (iii) (phase clock starts and no error bits are ever set) we again first show that all nodes finish with probability 1. However, in Theorem 4 this was proven via the overflowing phase counters, which cannot happen for h = ∞. Thus, we use a different argument: For the sake of a contradiction assume no node finishes (if one node finishes, all nodes finish eventually). Since the phase clock runs and no error ever occurs, all nodes reach any hour i ∈ N. Consider an interaction t when all nodes are in hour at least ι := log s (s · 3n/α) . Since load balancing is only performed between nodes in the same hour and no node ever skips an hour (or an error would occur), Lemma 7 gives Ψ (t) = Ψ (0). But then, similar to previous arguments, our choice of ι ensures that |Φ(t)| ≥ s · 3n. So there would be a node u with absolute load at least 3s. This yields the desired contradiction, since u would have set its finished bit at the beginning of its current hour. Once we know that all node finish with probability 1 in this case, the exactness follows again as in Case (iii) in the exactness proof of Theorem 4.
To prove that, with high probability, we have T ST = O(n log n · log s (n/α)), we use the same argumentation as for the corresponding part in the proof of Theorem 4, just slightly simplified since nodes now store their exact phase counters. Basically, we again take a union bound over the first i * := log s (4n/α) rounds and get the same three properties as in the proof of Theorem 4: (1) T * < ∞ (as we have shown above for the exactness) for the interaction T * when the first finish or error bit is set. (2) The first i * rounds have length (n log n) and stretch O (n log n). (3) The load discrepancy is at most 2 at the end of each of the first i * rounds.
With these properties, the remaining argumentation from Theorem 4's proof goes through.
The proof for the bound on the expected stabilization time is also identical, by noting that all nodes complete protocol FormJuntaUniform in expected O n log n interactions [18].
For the bound on the number of states, note that replacing the phase clock's junta algorithm FormJunta by FormJun-taUniform increases the required number of states by a factor of (log log n) (instead of an additive term), since we now need to store the level indefinitely. Now, above we saw that, with high probability, all nodes finish after at most O(log s (n/α)) rounds. Thus, with high probability, no phase counter is larger than O(log s (n/α)) in absolute value. Finally, there is a factor of (3s + 1) · (1) = s · (1) for the load values and the bits finished u and error u , yielding the desired bound.

Conclusions & future work
We analyzed three similar variants of a population protocol for the majority problem: SimpleMajority s,3 , ConvergentMajority s , and UniformMajority s . All of them based on the so-called doubling and cancellation approach. They feature a parameter s that allows for a tradeoff between runtime and memory per node.
A natural open question is to improve the bounds we provide. In particular, for s = log log n our protocol StableMajority s has stabilization time o(n · (log n) 2 ) while using O (polylog n) states. There is (to the best of our knowledge) one other result that also achieves this guarantee [11]. While it does not feature a trade-off capability, it comes with a better stabilization time. It seems non-trivial but also not impossible to combine our trade-off result with the improved stabilization time. Also, it would be interesting whether it is possible to derive parameterized lower bounds in which one can similarly see the effect on the running time of increasing or decreasing the number of states per node.
Another open research question for population protocols deals with the phase clock introduced in [18]. It is unclear whether one can derive a similar phase clock that requires only a constant number of states and still synchronizes the population for a polynomial number of interactions with high probability. If it exists, such a phase clock could be used to devise constant-state (majority) protocols that converge in polylogarithmic time with high probability.
Our results formally show that lower bounds for the stabilization time can be bypassed by considering the convergence time. Unfortunately, there are currently no strong lower bounds regarding the convergence time. As conver-gence time might be considered the more practical runtime notion, finding such lower bounds and tightening the corresponding upper bounds should be deemed a worthy but challenging task.