Distributed computation with continual population growth

Computing via synthetically engineered bacteria is a vibrant and active field with numerous applications in bio-production, bio-sensing, and medicine. Motivated by the lack of robustness and by resource limitation inside single cells, distributed approaches with communication among bacteria have recently gained in interest. In this paper, we focus on the problem of population growth happening concurrently, and possibly interfering, with the desired bio-computation. Specifically, we present a fast protocol in systems with continuous population growth for the majority consensus problem and prove that it correctly identifies the initial majority among two inputs with high probability if the initial difference is Ω(nlogn)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varOmega (\sqrt{n\log n})$$\end{document} where n is the total initial population. We also present a fast protocol that correctly computes the Nand of two inputs with high probability. By combining Nand gates with the majority consensus protocol as an amplifier, it is possible to compute arbitrary Boolean functions. Finally, we extend the protocols to several biologically relevant settings. We simulate a plausible implementation of a noisy Nand gate with engineered bacteria. In the context of continuous cultures with a constant outflow and a constant inflow of fresh media, we demonstrate that majority consensus is achieved only if the flow is slower than the maximum growth rate. Simulations suggest that flow increases consensus time over a wide parameter range. The proposed protocols help set the stage for bio-engineered distributed computation that directly addresses continuous stochastic population growth.


Introduction
In the past few decades, synthetic biology has laid considerable focus on the re-programming of cells as computing machines. They have been engineered to sense a range of inputs (metabolites [49], light [53], oxygen [3], pH [47]) and process them to produce desired outputs according to defined processing codes (primarily digital [37], but occasionally analog [17]). Some potential applications of the cellular machines include production of metabolic compounds of interest [41], bio-remediation of toxic environments [55], sensing of disease bio-markers [49], and therapeutic intervention by targeted effector delivery [3]. Yet, the ability of single cells to reliably process multiple inputs is acutely constrained by their limited resources. 5 Université Paris-Saclay, INRAE, AgroParisTech, Micalis Institute, Jouy-en-Josas, France Adding too many processes into one cell leads to resourcestress and eventually the code is lost due to mutation, a baseline error mechanism present in all living systems. This has, in part, encouraged the notion of distributing the computational tasks across multiple cells [43,54], to reduce resource-stress and improve robustness. The value of the idea is corroborated by the success of the division of labor seen in multi-cellular organisms that have naturally evolved from their unicellular ancestors [30,42]. While task-distribution in cell populations solves some problems, it immediately leads to other challenges that must be tackled for the successful implementation of any complex distributed program. Some of these challenges include: the orthogonality/specificity of communication signals, the rate and bandwidth of communication channels, cellular growth and its effect on signal amplification or dissipation, and effect of cross-talk between different signals.
In this work we focus on signal amplification and Boolean function computation in distributed systems whose agents are duplicating bacteria. A central problem in this setting is to maintain a consistent state of circuit values among the bacteria. The problem of maintaining a consistent state among agents has been studied in distributed computing for decades in different contexts [33], e.g., for replicated state machines [48] and mobile networks [7]. Starting from a mathematical computing model, analysis of a system's behavior has led to correctness proofs and performance bounds of proposed solutions, also shedding light on how protocol parameters influence the quality of the outcome. In distributed systems with biological agents, the cellular behavior is usually expressed in the language of chemical reaction networks (CRNs). A CRN is defined by a set of reactions, each consuming members of one or several species and producing members of others at a given rate.
The two most commonly used kinetics for CRNs are deterministic and stochastic approaches. The deterministic approach models the kinetics of a CRN as systems of ordinary differential equations (ODEs) with continuous realvalued concentrations of each species, whereas the stochastic approach models the CRN as a continuous-time Markov chain with discrete integer-valued counts of each species. While ODE modeling can capture important behavioral characteristics, in particular expected-value large-population limits, some phenomena can only be explained by stochasticprocess kinetics. In particular, ODE kinetics cannot elucidate the probability of certain population-level events occurring in a system of two competing species, e.g., the extinction of one species due to a series of random events. The stochastic-process kinetics of CRNs are much more common in distributed computing, in particular in population protocols [5], where reactions are restricted to two reactants and two products with constant-size populations and identical reaction rate constants equal to 1. They are also used in computability results in general CRNs [50] where nonconstant population sizes are exploited. A model that allows non-constant population sizes via "split" and "die" reactions, but otherwise restricts reactions as in population protocols, was studied by Goldwasser et al. [24]. The presented algorithm with the goal to maintain a stable population size, however, uses leader election and synchronized phases via non-constant states per agent, rendering it impractical for implementations in bacterial cultures.
Computation of Boolean predicates has been extensively studied both in CRNs and population protocols. Early work on Boolean computation in CRNs is by Magnasco [34]. Signal values are encoded with low and high concentrations of corresponding species. Chen et al. [15] generalized computation in CRNs to functions on natural numbers. Arguments are given in terms of input species counts and the computed value is encoded in the number of output species counts. The output in population protocols is typically provided by all agents reaching consensus on a common output state [6]. These works cited above, however, do not include obligatory duplication reactions as we do. Consistent cell states by competition among cells. Birthdeath processes track species counts within a population with "birth" and "death" events over time. For each such population state there are transitions that move from one population state to the other with respect to "birth" and "death" events. Birth-death processes have been used to model competition, predation, or infection in evolutionary biology, ecology, genetics, and queueing theory [39,46].
Competition among species naturally lends itself to solving consensus-type problems. Angluin et al. [5]  The population protocol by Angluin et al. [4] alternates phases of state duplication and cancellation, separated by a clock signal generated by a dedicated leader species. These protocols, however, rely on non-varying populations sizes and the latter on a dedicated leader, and are thus impractical for implementations in bacteria. More recent works have developed leaderless phase clocks in population protocols (e.g., [1]), which can be used to solve the majority problem [8,10,11,19] in population protocols.
An early mention of problems requiring a stochastic analysis of two competing species is by Volterra [56] and Feller [21] although only the growth of a single species is analyzed therein. For an overview of single species birth-death Markov chains, see, e.g., [13]. Extensions for multiples species, with applications to genetic mutations, are found in the literature on competition and branching processes [12,29,44]. For example, Ridler-Rowe [45] considers a stochastic process between two competing species. However, the process in that work differs from ours in that death reactions therein are A + B −→ A and A + B −→ B, leaving a winner after an encounter between two competing individuals. The paper presents an approximation for long-term distributions and bounds the probability that starting from initial A, B sizes, species A goes extinct. However, the analysis is for initial population sizes approaching infinity, only, and assumes an initial gap between species counts that is linear in the population size. By contrast our analysis holds for finite population sizes n, and requires a gap of Ω( √ n log n), only. A complementary approach for the same asymmetric process proposed in [25] is to numerically solve a finite size cut-off of the infinite linear equation systems. Computation in birth systems. In this work, we introduce and study protocols for birth systems where all species inherently duplicate. To simplify our model, we do not consider death reactions as they occur at far lower rates than duplication reactions in typical bacterial colonies. Such protocols are thus different from population protocols, which have population sizes that remain constant over the course of an execution. Further, our protocols do not rely on exact species counts, they are not leader-based, and they require small and constant state space per cell, lending themselves readily for future biological implementation.
For simplicity we assume that all duplication reactions of our birth systems have the same rate. We leave the question of natural selection due to differing growth rates to future work. In particular, we study two protocols within birth systems.
(i) We introduce the Pairwise Annihilation protocol for two species A and B and show that it solves majority consensus with high probability: If the initial difference Δ between sizes A and B grows weakly with the population size n according to Δ = Ω( √ n log n), then the protocol identifies the initial majority with high probability. Since it amplifies the difference between the two species, we also refer to the Pairwise Annihilation protocol as an amplifier. Further, we will show that the protocol reaches consensus in expected constant time. The protocol's reactions are deceptively simple. Besides the obligatory birth reactions A −→ 2 A and B −→ 2B, it comprises a single death reaction A + B −→ ∅.
(ii) We demonstrate how to implement the components of feed-forward Boolean circuits. Each Boolean gate in our implementation is a Nand gate, followed by an amplifier. Note that while we focus on the universal Nand gate for the sake of a lighter notation, our construction and its analysis holds for any arbitrary two-input Boolean function. The latter will be important for optimization and follow-up with biological implementations. Signals between the Nand gates are encoded using two species each, the difference of which determines whether a signal is a logical 0, 1, or neither. A Nand gate is a protocol that maps two input signals X and Y to an output signal Z that is the logical Nand of X and Y .
While Nand gates are used to implement the circuit's Boolean behavior, the successive amplifiers regenerate the gate's output signal by amplifying the difference between the two output signal species. Repeated, successive invocation of the Nand protocol followed by the amplifier protocol for time O(log n), where n is the total initial population, can finally be used to compute the circuit's output values layer by layer.
Organization. The rest of the paper is organized as follows: In Sect. 2, we define the computational model. In Sect. 3, we introduce and analyze our protocol for majority consensus, both analytically and via simulations. In Sect. 4, we define and analyze the Nand gate protocol. In Sect. 5, we present simulations of a biologically plausible implementation of the Nand gate with amplifiers. In Sect. 6, we consider the context of continuous cultures and suggest that majority consensus can become slower in these cultures. Finally, Sect. 7 concludes the paper.

Model
We write N = {0, 1, . . . }, N + = N \ {0}, and R + 0 = [0, ∞). When analyzing our protocols, we employ the term "with high probability" relative to the total initial population. That is, event E happens with high probability if there exists some c > 0 such that P(E) = 1 − O (1/n c ), where n is the total initial population.

Chemical reaction networks
We use the standard stochastic kinetics for chemical reaction networks. A reader familiar with the model can safely skip this subsection.
A chemical reaction network is described by a set S of species and a set of reactions. A reaction is a triple (r, p, α) where r, p ∈ N S and α ∈ R + 0 . The species with positive count in r are called the reaction's reactants and this with positive count in p are called its products. The parameter α is called the reaction's rate constant. A configuration of a CRN is simply an element of N S . A reaction (r, p, α) is applicable to configuration c if r(S) ≤ c(S) for all S ∈ S. We write r α −→ p to denote a reaction (r, p, α). For instance, the reaction ({A, B}, {2B, C}, α) will simply be denoted A + B α −→ 2B + C. Here, we used the shorthand notations {A, B} and {2B, C} for functions S → N. For instance, the notation {2B, C} represents the function p : S → N defined by p(B) = 2, p(C) = 1, and p(S) = 0 for all other species S / ∈ {B, C}. The stochastic kinetics of a CRN are a continuous-time Markov chain (see a textbook [13] for auxiliary definitions). Given some volume v ∈ R + 0 , which we will normalize to v = 1 for most of the paper, the propensity of a reaction (r, p, α) in configuration c is equal to The new configuration after an applicable reaction is equal to c = c − r + p.
We will use the notation Q(x, y) for the propensity of the transition from state x to state y in a continuous-time Markov chain. To each continuous-time Markov chain corresponds a discrete-time Markov chain that only keeps track of the sequence of state changes, but not of their timing. We use P(x, y) for the transition probability from state x to state y in the discrete-time chain. We have the formula P(x, y) = Q(x, y)/ z Q(x, z) .

Birth systems
A protocol for a birth system, or protocol, with input species I and output species O, for finite, not necessarily disjoint, sets I and O is a CRN specified as follows. Its set of species S comprises input/output species I ∪ O and a finite set of internal species L. Further, the protocol defines the initial species counts X 0 for internal and output species X ∈ L ∪ O and a finite set of reactions R on the species in S. For each species X ∈ S, there is a duplication reaction of the form X γ −→ 2X . All duplication reactions have the same rate constant γ > 0.
Given a protocol and an initial species count for its inputs, an execution of the protocol is given by the stochastic process of the CRN with species S, reactions R, and respective initial species counts.

Majority consensus
The Pairwise Annihilation protocol is defined for two species, A and B, both of which are inputs and outputs. It contains, apart from the obligatory duplication reactions, the single reaction of A and B eliminating each other with rate constant δ > 0. The complete list of reactions of the Pairwise Annihilation protocol is thus: We say that consensus is reached if one of the two species becomes extinct. If the initial population counts differ, we say that majority consensus is reached if consensus is reached and the species that was initially in majority is not extinct. If the initial counts of both species are equal, then majority consensus is reached when one species is extinct and the other is not.
We show that the Pairwise Annihilation protocol reaches consensus in constant time and majority consensus with high probability. From Theorem 1 we immediately obtain a bound on the initial gap sufficient for majority consensus with high probability.

Corollary 2
For an initial population n and an initial gap Δ, if Δ = Ω √ n log n , then the Pairwise Annihilation protocol reaches majority consensus with high probability.
Without duplication reactions, it is obvious that the Pairwise Annihilation protocol reaches consensus and that majority consensus is always reached if the two species have different initial population counts. We are thus not only able to show that we can achieve majority consensus in spite of continual population growth via duplication reactions of all species, but also that a sub-linear gap in the initial population counts suffices. The required initial gap of Ω( √ n log n) matches that of the best protocols without obligatory duplications [2,5,16]. The time complexity of our protocol is different to population protocols, however: in the O(n) expected transitions that it takes the Pairwise Annihilation protocol to achieve consensus, asymptotically almost surely, there are agents that never interacted once in a population protocol of the same size. This is not a contradiction: In contrast to population protocols, the population size decreases during the initial stages of the Pairwise Annihilation protocol.
We will prove Theorem 1 in the following sections; first the time upper bound, then correctness with high probability.

Markov-Chain model
The evolution of the Pairwise Annihilation protocol is described by a continuous-time Markov chain with state space S = N 2 . Its state-transition rates are: are absorbing, and so is the state (A, B) = (0, 0). This chain is regular, i.e., its sequence of transition times is unbounded with probability 1. Indeed, as we will show, the discrete-time chain reaches consensus with probability 1, from which time on the chain is equal to a linear pure-birth process, which is regular.
The corresponding discrete-time jump chain has the same state space S = N 2 and the state-transition probabilities The axes as well as state (A, B) = (0, 0) is absorbing, as in the continuous-time chain.
As a convention, we will write X (t) for the state of the continuous-time process X at time t, and X k for the state of the discrete-time jump process after k state transitions. The time to reach consensus is the earliest time T such that A(T ) = 0 or B(T ) = 0.

Time to reach consensus
In this section we prove the first part of Theorem 1, i.e., the bounds on the time to reach consensus, both in expected time and with high probability. For that, we will employ a coupling of the Pairwise Annihilation protocol Markov chain with a single-species birth-death process. We show that the Pairwise Annihilation protocol reaches consensus when the singlespecies process reaches its extinction state and then bound this time in the single-species process. Figure 1 visualizes the idea.
We denote the single-species process by M(t). It is a birthdeath chain with state space S = N and transition rates Q(M, M + 1) = γ M and Q(M, M − 1) = δ M 2 . State 0 is absorbing. Note that the death rate δ M 2 depends quadratically on the current population M, and not linearly like the birth rate γ M. The reason is that we want M(t) to bound the minimum of the populations A(t) and B(t) and that the death transition in the Pairwise Annihilation protocol is quadratic in this minimum.
We will crucially use the fact that P M(t) = 0 ≤ P A(t) = 0 ∨ B(t) = 0 for all times t. This, together with a bound on the time until M(t) = 0, then gives a bound on the time until consensus in the Pairwise Annihilation protocol chain.
Continuous-time coupling. The coupling is defined as follows. For sequences (ξ k ) k≥1 of i.i.d. (independent and identically distributed) uniform random variables in the unit interval [0, 1) and (η k ) k≥1 of i.i.d. exponential random variables with normalized rate 1, we define the coupled If A k > B k then the roles of A k and B k in (1) are exchanged. The update rule for M k+1 is: Analysis for time until consensus. Note that in the coupling "stuttering steps" for (A k , B k ) or M k are possible in the definition of the coupled process, making the underlying discrete-time jump chains of, e.g., chain (A(t), B(t)) and the Pairwise Annihilation protocol, potentially differ.
The following Lemma 3, however, shows that the continuous-time chain (A(t), B(t)) and the Pairwise Annihilation protocol chain have identical transition rates, and are thus identically distributed. Its proof is folklore and given in the appendix.
. be a sequence of i.i.d. exponential random variables with rate parameter λ and let k be an independent geometric random variable with success probability p. Then T = T 1 + · · · + T k is exponentially distributed with rate parameter pλ.
By construction of the coupled process, the single-species birth-death process M(t) indeed dominates the minimum of the population counts A(t) and B(t) in the following way: Proof Let K be the step number of the discrete-time coupled process such that t K ≤ t < t K +1 , where t k is the time of the k th step. We show by induction that min{A k , B k } ≤ M k for all k ∈ N. The inequality holds initially, for k = 0, by definition of the coupled process. Now assume that min{A k , B k } ≤ M k . Without loss of generality, by symmetry, assume that

. We distinguish the two cases
Thus, as easily verified by the alignment of the intervals in Fig. 3 Hence, combined with the above implication which remains true, we have A k+1 ≤ M k+1 in all possible cases for ξ k+1 .
Lemma 4 allows to compare the probabilities of extinction in the single-species chain and of consensus in the Pairwise Annihilation protocol chain: It thus suffices to prove bounds on the time until the population goes extinct in the single-species M chain. For that, The dotted relation between intervals is shown in the proof we leverage known results on birth-death processes, which are not applicable to the two-species Pairwise Annihilation protocol chain.

Lemma 6 If T denotes the time until extinction in the singlespecies process M(t), then E T = O(1).
Proof The birth rate in state M(t) = i is equal to α(i) = iγ and the death rate is equal to β(i) = i 2 δ. From known general results on birth-death process (Theorem 25 in the appendix) we obtain, when starting from initial population M(0) = M, that This concludes the proof.
Combining this with Lemma 6, shows that the expected time until consensus in the Pairwise Annihilation protocol is also O (1). For the high-probability result in the first part of Theorem 1, we simply make Θ(log n) consecutive tries to achieve extinction in an interval of constant time:

Lemma 7 If T denotes the time until extinction in the singlesspecies process M(t), then there exists a constant C such that
Proof Let C 1 be the O(1) constant from Lemma 6 and set C = max{2C 1 , 2}. Then, by Markov's inequality, we have P(T > C) ≤ C 1 /C ≤ 1/2. Thus, the probability of the event T > C log 2 n is dominated by the probability of failing log 2 n consecutive tries with a Bernoulli random variable with parameter p = 1/2. But this probability is 2 − log 2 n = 1/n.
A simple combination of Corollary 5 and 7 completes the proof of the first part of Theorem 1.

Probability of reaching majority consensus
We now turn to the proof of the second part of Theorem 1, i.e., the bound on the probability to achieve majority consensus. We use a coupling of the Pairwise Annihilation protocol chain with a different process than for the time bound. Namely we couple it with two parallel independent Yule processes. A Yule process, also known as a pure birth process, has this single state-transition rule X → X + 1 with linear transition rate γ X . Since we already showed the upper bound on the time until consensus, it suffices to look at the discrete-time jump process. In particular, the coupling we define is discretetime. Discrete-time coupling. For an i.i.d. sequence (ξ k ) k≥1 of uniformly distributed random variables in the unit interval [0, 1), we define the coupling as the process Otherwise the process remains constant. Figure 4 visualizes the construction. Analysis for probability of reaching majority consensus. We start with two simple technical lemmas that we will use for the comparison of the coupled processes. Proof Multiplying both sides by (a + b) · (x + y), we see that the first inequality is equivalent to bx + by ≤ ay + by, which is in turn equivalent to bx ≤ ay.
The crucial property of this coupling is that the initial minority in the Pairwise Annihilation process cannot overtake the initial majority before the initial minority overtakes the initial majority in the parallel Yule processes. We now prove that our construction indeed has this property.

Lemma 10
Proof We first show by induction on k that X k ≤ A k + m k and Y k ≥ B k +m k for all 0 ≤ k ≤ K , where m k is the number of death reactions up to step k. In the base case k = 0 we even have equality. For the induction step k → k + 1, we distinguish four cases; see Fig. 4.
by the induction hypothesis and Lemma 9. This implies the interval relation indicated in Fig. 4.
The lemma now follows via

Corollary 11 If
As defined in the coupling the parallel Yule processes (X k , Y k ) can have stuttering steps where However, this happens only finitely often almost surely. This allows us to analyze a version of the process (X k , Y k ) without stuttering steps in the rest of the proof.
Proof Lemma 6 implies that there are only finitely many deaths in the coupled chain almost surely. There are hence only finitely many stuttering steps in (X k , Y k ) almost surely.
Because of Lemma 12, by slight abuse of notation, we will use (X k , Y k ) to refer to the parallel Yule processes without any stuttering steps.
Two parallel independent Yule processes are known to be related to a beta distribution, which we will use below. The regularized incomplete beta function I z (α, β) is defined as Proof The sequence of ratios X k X k +Y k converges with probability 1 and the limit is distributed according to a beta distribution with parameters α = X 0 and β = Y 0 (Theorem 26 in the appendix). In particular, the probability that the limit is less than 1/2 is equal to the beta distribution's cumulative distribution function evaluated at 1/2, i.e., equal to I 1/2 (X 0 , Y 0 ). Because initially we have X 0 > Y 0 , the law of total probability gives: Now, if ∀k : X k > Y k , then lim k X k X k +Y k ≥ 1/2, which shows that the second term in the sum in (3) is zero. Further, under the condition ∃k : X k = Y k , it is equiprobable for the limit of X k X k +Y k to be larger or smaller than 1/2 by symmetry and the strong Markov property. This shows that the right-hand side of (3) is equal to 1 2 · P (∃k : X k = Y k ), which concludes the proof.
We define the event "B wins" as A eventually becoming extinct. Then, we have: Proof Similarly to the proof of Lemma 13, by the law of total probability, we have: If ∀k : A k > B k , then B cannot win, i.e., the second term in the right-hand side of (4) is zero. Also, by symmetry and the strong Markov property, it is P (B wins | ∃k : A k = B k ) = 1/2 . Combining the previous two lemmas with the coupling, we get an upper bound on the probability that the Pairwise Annihilation protocol fails to reach majority consensus. This upper bound is in terms of the regularized incomplete beta function.

Lemma 15
If A 0 ≥ B 0 , then the Pairwise Annihilation protocol fails to reach majority consensus with probability at most I 1/2 (A 0 , B 0 ).
Proof Setting X 0 = A 0 and Y 0 = B 0 , and combining Corollary 11 and Lemmas 13 and 14 , we get P(B wins) = 1 2 · P(∃k : Due to Lemma 15, it only remains to upper-bound the term I 1/2 (α, β). Lemma 16 provides such a bound. Its proof is given in the appendix.

Lemma 16
For m, Δ ∈ N, it holds that Combining the above lemmas proves the second part of Theorem 1.

Simulation of the Pairwise Annihilation protocol
Stochastic simulations [22,26] of the Pairwise Annihilation protocol are shown in Fig. 5 for the probability that species A survives, while species B goes extinct. The birth and death rates, γ and δ, are both set to 1. The probability that the protocol converges on A surviving and B going extinct is primarily dependent on the difference in initial population size A 0 − B 0 . Larger populations are only slightly less sensitive to the difference: Fig. 5 demonstrates that the total population size across two orders of magnitude has a small effect compared to the difference between species. Indeed, this behavior qualitatively matches the bound in Theorem 1 with −Ω(Δ 2 /n) in the exponent.
The dependence of expected convergence time for the Pairwise Annihilation protocol is explored using stochastic simulation over its reaction rate constants and initial conditions in Fig. 6. Exponential changes in rate constants yield exponential changes in convergence time. As expected, the convergence time is more strongly dependent on the death rate constant δ than the birth rate constant γ . Convergence time sharply increases if the initial concentrations of the two species A and B are closer to each other. The off-diagonal initial concentrations converge faster for larger population sizes since the absolute difference in concentrations is larger.

Boolean gates
In terms of circuit design, the Pairwise Annihilation protocol can be viewed as a differential signal amplifier; see also the sharp S-shaped curve in Fig. 5 that is typical for an amplifier. Differential signaling has applications in systems that require high resilience to noise, and thus an application for our inherently growing systems is natural.
In this section we study a protocol for computing the logical Nand of two signals, despite a loss of signal quality at the output. The Pairwise Annihilation protocol is then applied to regenerate the signal, obtaining a clear 0 or 1 with high probability. Note that the Nand gate protocol is easily generalized to arbitrary two-input Boolean functions, and so is its analysis.

Dual-rail signals
We start with some notation. A signal is from a finite alphabet Σ = {X , Y , . . . }. At each time t ≥ 0, a signal X ∈ Σ has a value x(t) ∈ {0, 1, ⊥}. Following a technique from clockless circuit design [38,51] we encode the value of a signal as a dual-rail signal in the following way. For each signal X , there are two species X 0 and X 1 . Intuitively, for v ∈ {0, 1}, a large count of X v (t) and a low count of X ¬v (t) encodes for x(t) = v. In fact, we will ask for a minimum gap in species counts between X v (t) and X ¬v (t). If the signal is neither 0 nor 1, we will say that it has value ⊥. We will make the assumptions on the input signals precise and discuss guarantees on output signals when specifying the gate input/output behavior. Fig. 7 Dual-rail Nand gate with input signals A and B an output signal Y . Successive amplification of Y to signal Z shown in gray Let X 0 , X 1 be species of a dual-rail encoding of signal X . For convenience we write X (t) for X 0 (t) + X 1 (t). For n, Δ ∈ N, we say signal X is initially (n, Δ)-correct with value x ∈ {0, 1} if The initial gap X x (0) − X ¬x (0) of signal X is thus bounded by

Dual-rail NAND gate
A dual-rail implementation of a Nand gate with input signals A, B and output signal Y , the so called Nand gate protocol, is as a protocol with input species Further, for all a, b ∈ {0, 1} and y = ¬(a ∧ b), the protocol contains a reaction where α > 0 is the gate's rate constant. Since all species are permanently replicating, we further have the obligatory duplication reactions Figure 7 depicts the Nand gate with the subsequent amplification protocol.
In Sect. 4.3 we will show that the Nand gate ensures the following input-output specification:

Gate correctness and performance
To show the correct of the dual-rail two-input gate, we proceed as follows. Starting with technical lemmas, we first show that the initial value of a single dual-rail input signal is not lost due to growth of the input species (Lemma 20). Making use of independence of growth of the species encoding the rails of the two input signals, we then bound the probability that both input signals remain correct (Lemma 22). We finally show that the gate's dual-rail output is correct in two steps: We first assume a simplified model where gate output species are produced by the gate but cannot duplicate (Lemma 23). The lemma bounds the number of incorrect output species that are produced by the gate, showing that its output signal has the correct value. In a second step, we prove that duplication of the output species, as required by our model, does not invalidate the output correct value (Lemma 24).
We now turn to the proof of Theorem 17. For our analysis we need a bound on the regularized incomplete beta function I 3/4 . The proofs of the next two lemmas are given in the appendix.

Lemma 18 For X ≥ Y , it holds that I
The following lemma shows that for z = 3/4, the function (x, y) → I z (x, y) is non-decreasing in (x, y) along the discretized line with slope 1/3.

Lemma 19
If X ≥ 3Y ≥ 0, then We are now in the position to show a lower bound on the probability for a discrete time Yule process with two species X and Y , that lim k→∞ X k /(X k +Y k ) < 3/4, given that the initial values fulfill X 0 /(X 0 + Y 0 ) > 3/4 and that there is a step with X /(X + Y ) ≤ 3/4.

Lemma 20 Let X and Y be species from a Yule process.
Assume that X 0 /(X 0 + Y 0 ) > 3/4 for the initial values. Then where ω X 0 , Y 0 equals to Proof By assumption X 0 /(X 0 + Y 0 ) > 3/4. Let ≥ 1 be minimal such that X /(X + Y ) ≤ 3/4. By assumption such an exists. By minimality of , we have From the fact that X , Y follow a Yule process, this can only be the case if Y has increased from step − 1 to , i.e., Thus, X > 3Y − 3 from which X ≥ 3Y − 3 and further, For a Yule process with species X and Y , and arbitrary initial counts X 0 = x and Y 0 = y, we have The first inequality of the lemma now follows from (6), (7), (8), and (9). We next show the second inequality of the lemma. For that purpose, we remark that any (x, y) in where s 0 ∈ {(4, 2), (5, 2), (6, 2)} and m ∈ N. Assume x = 3y − Δ with Δ ∈ {0, 1, 2}. Choosing s 0 = (6 − Δ, 2) and m = y − 2 ≥ 0, and applying (10) yields from which the claim follows.

The lemma follows.
Making use of Lemma 20, we next prove an upper bound on the probability that the two-species discrete-time Yule process X , Y , with an initial large majority of X , eventually hits a step where its relative population size drops to 3 4 or below. We will later on use this result, instantiating it with species X 0 , X 1 of a dual-rail encoding of a signal X , to make sure both rails remain separated and the signal X maintains its initial value.

Lemma 21 Let X and Y be species from a Yule process.
Assume that X 0 X 0 +Y 0 > 3 4 . Then P ∃k : Proof By assumption X 0 > 3Y 0 . Further, we have The lemma follows.
While Lemma 20 dealt with the correctness of a single dual-rail signal, the following lemma provides a lower bound on the probability that the dual-rail encoding of signals A and B, that are both initially (n, Δ)-correct, for Δ > n/2, remains separated as their species grow. We will make use of this result in Boolean gates with two dual-rail inputs, making sure that the inputs of the gate remain their correct signal value. A 0 , A 1 as well as B 0 , B 1

be species of a dualrail encoding of signals A and B. Assume that each species follows a Yule processes. If signals A and B are initially
Proof By Independence of the two Yule processes, we have Further, since A is (n, Δ)-correct with Δ > n 2 , By analogous arguments, B b (0) B(0) > 3 4 . We may thus apply Lemma 21 twice to (12), obtaining We can now apply Lemma 18 twice: for X = A a (0) and Y = A ¬a (0), and for X = B b (0) and Y = B ¬b (0). For A a and A ¬a , we further have By analogous arguments for B b and B ¬b , the bound in (11) follows.
We next show in Lemma 23 that when the Nand gates has produced n output species Y 0 and Y 1 , a certain gap Δ > 0 is guaranteed with a probability that depends on n and Δ. However, instead of showing this for the original Nand gate, we first prove that the bound holds for an adapted version where Y 0 and Y 1 do not duplicate. We later extend the result to the original Nand gate in Lemma 24.

Lemma 23
Consider an adapted version of the Nand gate with dual-rail encoded input signals A, B and output signal Y . In the adapted version, species Y 0 and Y 1 do not duplicate.
Further, assume that for some a, b ∈ {0, 1}, Then, with y = ¬(a ∧ b) being the correct Boolean output of the gate, for any t ≥ 0 and Δ, n ∈ N with Δ ≤ n/8, Proof From the assumption on the inputs, we have that the probability of the Nand gate to chose species A a and B b when producing an output species, is at least p = 3 4 2 .
Likewise a wrong output is produced with probability at most 1 − p.
Consider the discrete random walk on Z, starting at position D 0 = 0, and at step i ≥ 1, incrementing D i−1 by one with probability p, and decrementing by one with probability 1 − p. It is easy to construct a coupling such that Let I i , i ≥ 1, be a sequence of i.i.d. Bernoulli trials with success probability p, and R n = n i=1 I i . Then R n follows a Binomial distribution and 2R n − n is identically distributed to D n . Thus, Applying Chernoff's inequality for sums of Bernoulli trials, we obtain for Δ ≤ (2 p − 1)n = n 8 , The lemma follows.

Lemma 24
Consider the Nand gate with dual-rail encoded input signals A, B and output signal Y . If for some a, b ∈ {0, 1}, A(0) ≥ n, and B(0) ≥ n then, letting y = ¬(a ∧ b) be the correct Boolean output of the gate, with high probability there exists a t = O(1) such that Y y (t) − Y ¬y (t) = Ω(n) and Y (t) = n.
Proof We first consider the variant of the Nand gate from Lemma 23 where Y 0 and Y 1 do not duplicate. Let T > 0 be the earliest time t when Y (t) = n.
By assumption, for all t ≥ 0, A(t ) ≥ n and B(t ) ≥ n. Thus the gate's production rate of Y species is at least n 2 α. It follows that with high probability T ≤ log n αn . We will next upper bound the count of species Y that would have been produced if duplication were in place during time [0, T ]. For that purpose, assume that all Y species generated by the gate during [0, T ] are already produced at time 0. Then, the count of species Y generated by duplication, let us call themŶ , follows a single species Yule process with initial countŶ (0) = n. Thus,Ŷ (T ) follows a negative binomial distribution with success probability p = 1 − e −γ T and r =Ŷ (0), i.e., Further, for the expected count of species generated by duplication, minus the initialŶ (0) that were generated by the gate, we have, We next show that, Setting g = γ /α, and letting C = ge g , Eq. (13) follows from the fact that for all n > 0, n e g log n n − 1 ≤ C log n ⇔ e g log n n ≤ C log n n + 1 .
Inequality (14), follows by observing that it holds for z = 0, and that, by taking the z-derivative on both sides, we obtain ge gz ≤ C which is true for z ∈ [0, 1] by choice of C = ge g ; Eq. (13) follows. Noting that the variance σ 2 = Var Ŷ (T ) −Ŷ (0) of a negative binomial distribution, with r and p as above, is and setting μ = E(Ŷ (T )−Ŷ (0)), we next apply Chebyshev's bound P (|X − μ| ≥ ) ≤ σ 2 2 . In particular, the fact that with high probability less than μ+ species of Y are generated by duplication, follows from Solving for ε gives, Applying Lemma 23 for Y (T ) = n, we obtain a bound on the gap Δ = Y y (T ) − Y ¬y (T ), excluding those generated by duplication, that holds with high probability. Choosing we apply Lemma 23 for n and Δ ≤ n 8 , and obtain By choice of Δ, Together with (17), we have Additionally accounting for the Y species that have been generated by duplication until time T , by using (16), we obtain that the gap Y y (T ) − Y ¬y (T ) between correct output species Y y and incorrect output species Y ¬y at time T in a gate with duplication, with high probability, fulfills The lemma follows.
We are now in the position to prove Theorem 17, showing the correctness of the Nand gate if each of the two dual-rail input signals has a sufficiently large gap between its rails.

Proof of Theorem 17
The theorem follows from Lemma 24 if its assumption holds with high probability. The latter, however, follows from Lemma 22 if the exponent 1 2 − Δ 2 (n−Δ) + max{A(0), B(0)} holds to be in Ω (− max{A(0), B(0)}). We next show that this is the case.
Let M = max{A(0), B(0)}. From Δ ≥ μM with μ = 0.62 we have, It thus remains to show that 1 − μ 2 (1−μ) < 0. By algebraic manipulation, this is the case if μ ∈ 1 2 ( √ 5 − 1), 1 , which is true by assumption. The theorem follows. biological species, and is readily adaptable for specific biological applications. If reactions are modified such that one of the two reactants does not change, the model could represent one-way messaging equivalent to a conjugation event between a sender and receiver bacterial cell [36]. Similarly, if the messages A and B are coded as free species diffusible between senders and receivers, it could represent communication between bacterial cells using bacteriophage particles as messages [40].
In this section, we discuss a plausible biological implementation with E. coli bacteria that use conjugation to communicate. Conjugation is a method of genetic communication in which circular DNA plasmids are transferred from a sender cell to a receiver cell. An F plasmid allows a cell to be a sender during conjugation. The receiver can be engineered to express a logical function using the received plasmid and its existing DNA, although the internal implementation is not detailed for this simulation. A conjugation reaction with a sender S and a receiver R is described by where δ is the conjugation rate constant, and f is a function to the species. Both, the amplifier and the Nand gate follow this scheme. For the amplifier, f (R, S) = ∅ and for the Nand gate f (R, S) = Y , where Y is the gate's corresponding output species. While with wildtype F plasmids, E. coli are either senders (with F plasmid) or receivers (without F plasmid), there exist engineered systems that allow the same cell (with F plasmid) to be both a sender and a receiver [18,36]. Note that a single cell still cannot act as both the sender and the receiver during a single reaction.
The growth of the E. coli is modeled by a logistic model with a carrying capacity of 10 9 cells. A limited resource is consumed when species duplicate and released when they die. Reaction rate constants for duplication γ = 0.016 and for conjugation δ = 10 −11 have been taken from Dimitriu et al. [18]. For our implementation, amplification of the gate's inputs and outputs was executed in parallel to the gate's protocol. The simulations discussed in the following suggest that sequential execution is not required for correctness and performance, greatly simplifying the biological design. If all possible gate reactions were used, inputs that lead to Y 1 would be more susceptible to noise since there are more possible input pairs leading to Y 1 than Y 0 in a Nand gate. This was alleviated by selecting a subset of all possible gate reactions in which three reactions lead to Y 1 (see 1-3 below) and two reactions lead to Y 0 (see 4-5 below).
Simulation of our system for the four possible input choices are shown in Fig. 8. For performance with many individuals, simulations are done using the τ -leaping approximation of stochastic simulation, in which multiple reactions occur during a dynamic time interval of τ , before updating reaction rates [23,26]. The initial population size is set to 5 × 10 8 , the carrying capacity to 1 × 10 9 , and the initial input error to 10% of wrong input species per input. Despite the low rate of communication from conjugation, the correct output species rapidly out-competes the incorrect output species for all input choices.

Pairwise annihilation in an open system
Many biological applications require growing cells for prolonged periods of time [20,27]. Continuous cultures, also known as chemostats, can be used to constantly supply fresh nutrients while maintaining a fixed volume via a respective outflow. This in-and outflow transforms the system into an open system. We examined the effect of this setting on the Pairwise Annihilation protocol. Since outflow contributes to the basal death rate of each species, we conjectured that it aids the annihilation process and accelerates consensus. Interestingly, this is not the case. We will show that flow tends to impede consensus.
The section is structured as follows: first, linear stability analysis of an ODE model is used to show that the system converges to majority consensus, assuming that both species do not die. In this range, the analysis suggests that flow impedes consensus, except in a narrow parameter range. Second, stochastic simulations demonstrate that flow increases the time until consensus across a wide range of parameters, including the questionable range isolated by linear analysis.

ODE model
In addition to the species A and B, we use a food species F to model logistic growth due to depletion of resources like nutrients. We use the common notation ofẊ for d dt X (t) and X instead of X (t) when no confusion can arise. Let γ > 0 be the growth rate constant within fresh medium, δ > 0 the annihilation rate constant, and φ > 0 the in-and outflow rate constant. The fresh medium supplied via the inflow is assumed to containF > 0 food per unit volume. As before, food is consumed by duplication and released by death. We then obtain the following ODE model for the Pairwise Annihilation protocol: A biologically plausible implementation of a Nand gate with amplifiers on inputs and outputs. Note that a subset of all possible gate reactions has been implemented to balance production of Y 0 and Y 1 . Initial population size is 5 × 10 8 , carrying capacity of 10 9 cells. Reaction rate constants were set to γ = 0.016 and δ = 10 −11 [18]. The output species is shown for each choice of inputs. The initial input error is 10%. All choices lead to correct, clearly separable outputs within half an hour. Confidence intervals from 30 sample simulations are smaller than the width of the lineṡ Letting X = A + B, Y = A − B, and Z = A + B + F and assuming that A(0) ≥ B(0), we have that Y (t) ≥ 0 for all t ≥ 0, and we may rewrite the system, obtaining: In the following we will analyze this transformed system.

Linearization at fixed points
Let (X * , Y * , Z * ) be a fixed point of the above system. The Jacobian J (X * , Y * , Z * ) at this point is a linear approximation for the ODEs in the neighborhood of that fixed point, and its eigenvalues determine the stability of the point [14,32,52]: if all real parts of eigenvalues are negative, the point is a stable sink, while a strictly positive real part shows instability along the corresponding eigenvector making it an unstable source or saddle point. The magnitude of the largest real component of an eigenvalue controls the rate of attraction to a stable point or rate of repulsion from an unstable point, so long as the point is not approached precisely along another eigenvector. In our case, the Jacobian J (X , Y , Z ) is equal to and there exist 3 fixed points: Only the last point will be referred to as majority consensus, since it is not desirable in practice to reach consensus if both species eventually die (as in washout). Next, we show that irrespective of the parameters, at least one of the fixed points is stable. In particular, we will show that the metastable point is always unstable, whereas the washout and majority consen-sus points exchange stability during a transcritical bifurcation at γ = φ. The system will always converge to the only stable point since the system is bounded without periodic or chaotic behavior. No periodic behavior occurs since the imaginary components of all eigenvalues are always zero, as shown below. The system is bounded since Z approaches a constant F independently of X and Y , and Y ≤ X ≤ Z by definition. Finally, chaos does not occur: since Z approachesF, the system is 2-dimensional and bounded in the limit, which cannot exhibit chaos [9,52]. We detail the stability of each point in the following. Washout point A = B = 0. At the fixed point where washout happens, we have 2γ +Fδ , and . Hence a larger flow rate constant φ decreases the repulsion rate when washout does not occur. By contrast, the birth and death rate constants γ and δ both increase the rate of repulsion.
Majority consensus point min(A, B) = 0, max(A, B) > 0. We have, All eigenvalues are negative if and only if γ > φ. In case the largest eigenvalue is −φ, higher φ increases the rate of attraction. In other words φ seems to accelerate majority consensus where φ < min γ 2 , δFγ γ +δF . The preceding linear analysis demonstrates that if washout does not occur, majority consensus is achieved, since the majority consensus point would be the only sink in a bounded system without periodic or chaotic behavior. This stability result holds in the nonlinear, deterministic case [14,32,52]. However, the implications of the linear analysis for the attraction and repulsion rates is an approximation for the overall system's behavior. This approximation suggests that γ and δ accelerate majority consensus by increasing the attraction rate near majority consensus and the repulsion rate near the other fixed points. Conversely, φ tends to impede majority consensus, except possibly where φ < min γ 2 , δFγ γ +δF .

Simulation of the open system
Next we ran stochastic simulations [22,26] to observe the overall behavior of the system. Two pairwise parameter sweeps are performed: δ with φ and γ with φ. The results in Fig. 9 are mostly in accordance with the observations from linearization: larger flow rate constants φ are seen to increase the times until majority consensus as φ approaches the birth rate constant γ in fresh medium. However, both parameter sweeps cross φ = min γ 2 , δFγ γ +δF without φ ever reducing majority consensus time, in contrast to the linear approximation around the majority consensus point.
The same two pairwise parameter sweeps are explored over a far wider parameter range in Fig. 10 in the appendix. The results reinforce that φ does not decrease the time until majority consensus. For all simulations, the measured probability for majority consensus is always 1 in the parameter ranges shown, which is consistent with the washout point being unstable for γ > φ. Note that high flow rate constants φ could occasionally help knock out the smaller species B for very small initial B(0). However, in a biological setting, we expect numbers of at least several thousand cells, as used in the simulation.
The linear analysis and stochastic simulations confirm that majority consensus is still reached within plausible biological parameter ranges and sufficiently slow in-and outflow, but suggest that consensus takes longer to reach.

Conclusions
We considered the majority consensus problem with continuous population growth in a stochastic setting, and established the Pairwise Annihilation protocol between two compet- ing species A and B with birth reactions A −→ 2 A and B −→ 2B, and death reaction A+B −→ ∅. In particular, the input of the Pairwise Annihilation protocol are two species A and B with an initial total population size n = A(0) + B(0) and an initial gap Δ = |A(0) − B(0)|. We showed that the Pairwise Annihilation protocol reaches majority consensus with high probability if the gap weakly grows with the population size according to Δ = Ω( √ n log n). Expected convergence time until consensus is constant and in O(log n) with high probability. Simulations show that the qualitative behavior of our protocols matches the behavior expected from these asymptotic bounds.
We further demonstrated how to use dual-rail gates to implement digital circuits computing two-input Boolean functions in the example of a Nand gate. As opposed to thresholds of a single species, dual-rail encoding is particularly useful in our birth systems as the Pairwise Annihilation protocol allows us to amplify and thus regenerate such signals.
As a dual-rail gate implementation, we presented the Nand gate protocol that takes two dual-rail encoded input signals and produces a corresponding dual-rail output signal. The protocol is simple, an important criterion for follow up in real-world biological implementations. We proved that, given a sufficiently large initial gap between the rails of the input signals, our gate produces the correct output with high probability in O(log n) time, where n is a lower bound on the initial input population size. In particular, our gate guarantees an output signal gap of Ω(n) if both inputs have a gap of at least 0.62 times their initial population size. By alternating execution of the Nand gate protocol and the Pairwise Annihilation protocol, layer by layer, we finally arrive at computing the circuit's outputs.
Finally, several biologically motivated extensions of the Pairwise Annihilation protocol were explored. First, we simulated a potential biological implementation that is based on communication by conjugation among engineered E. coli that computes a noisy Nand gate. Second, a continuous culture setting with in-and outflow was analyzed. We demonstrated that majority consensus is reached with sufficiently slow in-and outflow and our simulations suggest that it takes longer to do so in presence of flow. While the studied protocols are simplifications of biological implementations, we believe that our results give a signpost for future research to implement complex distributed systems such as indirect inter-cellular communication.

A Proof of Lemma 3
By the law of total probability, for every t ≥ 0, we have which is equal to the cumulative distribution function of an exponential random variable with parameter pλ.

C Urn draws and beta distribution
A Pólya-Eggenberger urn is an urn containing white and black balls. At each discrete time step, we draw a ball uniformly at random from the urn, independently from the other draws. The color of the drawn ball is observed and the ball, as well as an additional ball of the same color, is returned to the urn. We denote by W n and B n the number of white and black balls in the urn after n draws, respectively.

H Wider sweep of parameters for open systems
Convergence time in the open system is explored for an exponentially wider range of parameters than in Fig. 9 to emphasize that flow never decreases convergence time. This scale is not visually thrilling, but one can faintly discern that the flow rate constant φ even increases convergence time as φ approaches the growth rate constant γ .