The solvability of consensus in iterated models extended with safe-consensus

The safe-consensus task was introduced by Afek, Gafni and Lieber (DISC' 09) as a weakening of the classic consensus. When there is concurrency, the consensus output can be arbitrary, not even the input of any process. They showed that safe-consensus is equivalent to consensus, in a wait-free system. We study the solvability of consensus in three shared memory iterated models extended with the power of safe-consensus black boxes. In the first iterated model, for the $i$-th iteration, the processes write to memory, then they snapshot it and finally they invoke safe-consensus boxes. We prove that in this model, consensus cannot be implemented. In a second iterated model, processes first invoke safe-consensus, then they write to memory and finally they snapshot it. We show that this model is equivalent to the previous model and thus consensus cannot be implemented. In the last iterated model, processes write to the memory, invoke safe-consensus boxes and finally they snapshot the memory. We show that in this model, any wait-free implementation of consensus requires $\binom{n}{2}$ safe-consensus black-boxes and this bound is tight.


Introduction
Iterated models e.g. [6,16,17,18,19,20] facilitate impossibility results, and (although more restrictive) facilitate the analysis of protocols [21]. We follow in this paper the approach of [22] that used an iterated model to prove the separation result that set agreement can implement renaming but not vice-versa, and expect our result can be extended to a general model using simulations, as was done in [23] for that separation result. For an overview of the use of topology to study computability, including the use of iterated models and simulations see [24].
Afek, Gafni and Lieber [4] presented a wait-free protocol that implements consensus using n 2 safeconsensus black-boxes (and read/write registers). Since our implementation uses the iterated form of sharedmemory, it is easier to prove correct. Safe-consensus was used in [4] to show that the g-tight-group-renaming task 2 [25] is as powerful as g-consensus.
The idea of the classical consensus impossibility result [2,3] is (roughly speaking) that the executions of a protocol in such a system can be represented by a graph which is always connected. The connectivity invariance has been proved in many papers using the critical state argument introduced in [2], or sometimes using a layered analysis as in [26]. Connectivity can be used also to prove time lower bounds e.g. [26,27,28]. We extend here the layered analysis to prove the lower bound result on the number of safe-consensus objects needed to implement consensus. Also, our results show that when the basic shared memory iterated model is used with objects stronger than read/write memory, care has be taken in the way they are added to the model, as the resulting power of the model to solve tasks can vary.
In a previous work [29] we had already studied an iterated model extended with the power of safeconsensus. However, that model had the restriction that in each iteration, all processes invoke the same safeconsensus object. We showed that set agreement can be implemented, but not consensus. The impossibility proof uses much simpler connectivity arguments than those of this paper. Organization. The paper is organized as follows. Section 2 describes the basic concepts and previous results of the models of computation. This section can be skipped by readers familiar with standard distributed computing notions. Section 3 defines the three iterated models of computation that we investigate and also we present the main results for each model. Section 4 is dedicated to our first iterated model with safe-consensus. In this model, the processes first write to memory, then they snapshot the contents of the memory and after that, they invoke safe-consensus objects. We prove that in this model, consensus cannot be implemented. In Section 4.2, we develop our second iterated model extended with safe-consensus. In this model, the processes first invoke safe-consensus objects, then they write to the memory and finally, they snapshot the shared memory. We prove that this model is equivalent to the previous model (for task solvability), thus the consensus task cannot be implemented in this model. Section 5 is devoted to develop all the results obtained for our last iterated model, in it the processes write to memory, invoke the safe-consensus objects and then they snapshot the shared memory. For this model, our results are the following: • We construct a protocol that solves n-process consensus using n 2 safe-consensus boxes (Section 5.2). We give our consensus protocol using the new 2coalitions-consensus task, which is described in full detail in Section 5.1.
• We describe and prove the main result for this iterated model, which is also the main result of this paper, it is a lower bound on the number of safe-consensus objects needed to solve consensus in this iterated model (Section 5.3).
In Section 6 we give our final conclusions and some open problems.

Basic definitions
In this section, we introduce the model of computation and present many basic concepts used in this paper. We follow the usual definitions and extend some concepts from [30,31].

Distributed systems
Our formal model is an extension of the standard iterated version [16] of the usual read/write shared memory model e.g. [31]. A process is a deterministic state machine, which has a (possible infinite) set of local states, including a subset called the initial states and a subset called the output states. A one-shot snapshot object A is a shared memory array A [1, . . . , n] with one entry per process. That array is initialized to [⊥, . . . , ⊥], where ⊥ is a default value that cannot be written by a process. The snapshot object A provides two atomic operations that can be used by a process at most once: • A.update(v): when called by process p j , it writes the value v to the register A [ j].
• A.scan(): returns a copy of the whole shared memory array A.
It is also customary to make no assumptions about the size of the registers of the shared memory, and therefore we may assume that each process p i can write its entire local state in a single register. Notice that the snapshot operation can be implemented in read/write shared memory, according to [32,33].
A system consists of the following data: • A set of n 1 processes Π = {p 1 , . . . , p n }; • a shared memory SM [i] (i 0) structured as an infinite sequence of one-snapshot objects; • an infinite sequence S [ j] ( j 0) of shared objects.
A global state of a system is a vector P of the form P = s 1 , . . . , s n ; SM , where s i is the local state of process p i ∈ Π and SM is the shared memory of the system. An initial state is a state in which every local state is an initial local state and all registers in the shared memory are set to ⊥.
A decision state is a state in which all local states are output states. When referring to a global state P, we usually omit the word global and simply refer to P as a state.

Events and round schedules
An event in the system is performed by a single process p i ∈ Π, which applies only one of the following actions: a write (update) operation, denoted by W or a read (scan) operation, denoted by R, on the shared memory or an invocation to a shared object (S). Any of these operations may be preceded/followed by some local computation, formally a change of the process to its next local state. We will need to consider events performed concurrently by the processes. If E is any event and p i 1 , . . . , p i k ∈ Π are processes, then we denote the fact that p i 1 , . . . , p i k execute concurrently the event E by E(X), where X = {i 1 , . . . , i k }. We fix once and for all some notation. Let n = {1, . . . , n}, when convenient, we will denote E(X) by E(i 1 , . . . , i k ) and if i ∈ n is a process id, then E(n − {i}) is written simply as E(n − i).
A round schedule π is a finite sequence of events of the form π : E 1 (X 1 ), . . . , E r (X r ), that encodes the way in which the processes with ids in the set r j=1 X j perform the events E 1 , . . . , E r . For example, the round schedule given by W(1, 3), R(1, 3), W(2), R(2), S (1,2,3) means that processes p 1 , p 3 perform the write and read events concurrently; after that, p 2 executes solo its read and write events and finally all three processes invoke the shared objects concurrently. Similarly, the round schedule W(1, 2, 3), R(1, 2, 3), S(1, 2, 3) says that p 1 , p 2 and p 3 execute concurrently the write and read events in the shared memory and then they invoke the shared objects concurrently.

Protocols and executions
The state machine of each process p i ∈ Π is called a local protocol A i , that determines the steps taken by p i . We assume that all local protocols are identical; i.e. Processes have the same state machine. A protocol is a collection A of local protocols A 1 , . . . , A n .
For the sake of simplicity, we will give protocols specifications using pseudocode and we establish the following conventions: A lowercase variable denotes a local variable, with a subindex that indicates to which process it belongs; the shared memory (which is visible to all processes) is denoted with uppercase letters. Intuitively, the local state s i of process p i is composed of the contents of all the local variables of p i . Also, we identify two special components of each process' states: an input and an output. It is assumed that initial states differ only in the value of the input component; moreover, the input component never changes. The protocol cannot overwrite the output, it is initially ⊥; once a non-⊥ value is written to the output component of the state, it never changes; when this occurs, we say that the process decides. The output states are those with non-⊥ output values.
Let A be a protocol. An execution of A is a finite or infinite alternating sequence of states and round schedules S 0 , π 1 , . . . , S k , π k+1 , . . . , where S 0 is an initial state and for each k 1, S k is the resulting state of applying the sequence of events performed by the processes in the way described by the round schedule π k . An r-round partial execution of A is a finite execution of A of the form S 0 , π 1 , . . . , S r−1 , π r , S r . If P is a state, P is said to be reachable in A if there exists an r-round partial execution of A (r 0) that ends in the state P and when there is no confusion about which protocol we refer to, we just say that P is reachable.
Given the protocol A and two states S, R, we say that R is a successor of S in A , if there exists an execution α of A such that α = S 0 , π 1 , . . . , S r = S, π r+1 , . . . , π r+k , S r+k = R, . . . , i.e., starting from S, we can run the protocol A k rounds (for some k 0) such that the system enters state R. If π is any round schedule and S is a state, the successor of S in A obtained by running the protocol (starting in the state S) one round with the round schedule π is denoted by S · π.

Decision tasks
In distributed computing, a decision task is a problem that must be solved in a distributed system. Each process starts with a private input value, communicates with the others, and halts with a private output value. Formally, a decision task ∆ is a relation that has a domain I of input values and a domain O of output values; ∆ specifies for each assignment of the inputs to processes on which outputs processes can decide. A bounded decision task is a task whose number of input values is finite.
We also refer to decision task simply as tasks. Examples of tasks includes consensus [2], renaming [25,33] and the set agreement task [34].
A protocol A solves a decision task ∆ if any finite execution α of A can be extended to an execution α in which all processes decide on values which are allowable (according to ∆) for the inputs in α. Because the outputs cannot be overwritten, if a process has decided on a value in α, it must have the same output in α . This means that outputs already written by the processes can be completed to outputs for all processes that are permissible for the inputs in α.
A protocol A is wait-free if in any execution of A , a process either has a finite number of events or decides. This implies that if a process has an infinite number of events, it must decide after a finite number of events. Roughly speaking, A is wait-free if any process that continues to run will halt with an output value in a fixed number of steps, regardless of delays or failures by other processes. However, in our formal model, we do not require the processes to halt; they solve the decision task and decide by writing to the output component; processes can continue to participate. We typically consider the behaviour of a process until it decides, and therefore, the above distinction does not matter.
The study of wait-free shared memory protocols has been fundamental in distributed computing, some of the most powerful results have been constructed on top of wait-free protocols [9,8,6,10]. Also, other variants of distributed systems can be reduced to the wait-free case [7,9,35].
Definition of consensus and safe-consensus tasks.
The tasks of interest in this paper are the consensus and safe-consensus [4] tasks.
Consensus Every process starts with some initial input value taken from a set I and must output a value such that: • Termination: Each process must eventually output some value.
• Agreement: All processes output the same value.
• Validity: If some process outputs v, then v is the initial input of some process.
Safe-consensus Every process starts with some initial input value taken from a set I and must output a value such that Termination and Agreement are satisfied, and: • Safe-Validity: If a process p i starts executing the task and outputs before any other process starts executing the task, then its decision is its own proposed input value. Otherwise, if two or more processes access the safe-consensus task concurrently, then any decision value is valid.
The safe-consensus task was proposed first in [4] as a result of weakening the validity condition of consensus.

Iterated models extended with safe-consensus and results
Intuitively, a model of distributed computing describes a set of protocols that share some common properties and restrictions in the way the processes can access the shared objects and these conditions affect the way in which the protocols can be specified. In this paper, we are interested in protocols which can be written in a simple and structured way, such that the behaviour of the system in the ith-iteration, can be described by using the behaviour of the (i − 1)th-iteration, in an inductive way.
In this section, we introduce an extension of the basic iterated model of [16], adding the power of safeconsensus shared objects. We also present all the results of this paper.

The iterated model with shared objects
In the iterated model extended with shared objects, the processes can use two kinds of communication media. The first is the shared memory SM structured as an infinite array of snapshot objects; the second medium is the infinite array S of shared objects (SM and S are described in Section 2.1). The processes communicate between them through the snapshot objects and the shared objects of S, in an asynchronous and round-based pattern. In all the iterated models that we investigate, we make the assumption that the shared memory is composed of one-shot snapshot objects and the array S contains one-shot shared objets. Specifically, we assume that: • The operations update and scan of the snapshot objects in SM can be used by a process at most once.
• The exec operation of each shared object in S can be used at most once by each process that invokes it.
When we want to add the power of shared objects to the standard iterated model [16], we must consider two important questions. The first question is: In which order should we place the three basic operations (write, read and invoke a shared object)? We have three possibilities: • Write, read from the shared memory and invoke a shared object; • invoke a shared object, write and read the shared memory; • write to memory, invoke a shared object and read the contents of the shared memory.
The second question, which is very closely related to the previous one is: Does the order of the main operations affect the computational power of the new model (for task solvability)? In this paper, we address these two questions and show the differences of the models of distributed computing that we obtain when the shared objects invoked by the processes are safe-consensus objects.
A safe-consensus object is a shared object that can be invoked by any number of processes. The object receives an input value from each process that invokes it, and returns to all the processes an output value that satisfies the Agreement and Validity condition of the safe-consensus task. In other words, a safe-consensus object is like a "black box" that the processes can use to solve instances of the safe-consensus task. The method of using distributed tasks as black boxes inside protocols is a standard way to study the relative computational power of distributed tasks (i.e. if one task is weaker than another, see [4,22,36]). Notice that safe-consensus shared objects combined with shared memory registers, can implement consensus [4].
From now on, we work exclusively in iterated models, where the shared objects invoked by the processes are safe-consensus objects.

The WRO iterated model
We now define the first iterated model that we investigate; in it, processes write to shared memory, then they snapshot it and finally they invoke the safe-consensus objects. We say that a protocol is in the WRO (Write, Read and invoke Object) iterated model if it can be written in the form given in Figure 1.
end if (10) end loop Figure 1: The WRO iterated model An explanation of the pseudocode in Figure 1 follows. All the variables r, sm, val, input and dec are local to process p i and only when we analyse a protocol, we add a subindex i to a variable to specify it is local to p i . The symbol "id" contains the id if the executing process. Initially, r is zero and sm is assigned the contents of the read-only variable input, which contains the input value for process p i ; all other variables are initialized to ⊥. In each round, p i increments by one the loop counter r, accesses the current shared memory array SM [r], writing all the information it has stored in sm and val (full information) and taking a snapshot of the shared memory array and after these operations, p i decides which shared object it is going to invoke by executing a deterministic function h that returns an index l, which p i uses to invoke the shared object S [l] with some value v. Finally, p i checks if dec is equal to ⊥, if so, it executes a deterministic function δ to determine if it may decide a valid output value or ⊥. Notice that in each round of a protocol, each process invokes at most one safe-consensus object of the array S.
In Section 4, we argue that the consensus task cannot be implemented in the WRO iterated model using safe-consensus objects (Theorem 4.4), this is the main result for this iterated model.

The OWR iterated model
The second iterated model that we study is the OWR (invoke Object, Write and Read) iterated model. In this model, processes first invoke safe-consensus shared objects and then they write and snapshot the shared memory. We say that a protocol A is in the OWR iterated model if A can be written in the form specified in Figure 2.
This pseudocode is explained in a similar way to that used for the code in Figure 1, the only thing that changes is the place where we put the invocations to the safe-consensus shared objects, before the execution of the snapshot operations.
In Section 4.2, we argue that for task solvability, there is no real difference between the WRO and the OWR iterated models. Any protocol in the WRO iterated model can be simulated by a protocol in the OWR iterated model and the converse is also true, this is stated formally in Theorem 4.8. Combining this result with Theorem 4.4, we can conclude that it is impossible to solve consensus in the OWR iterated model (Corollary 4.9).

The WOR iterated model
The last iterated model that we introduce is constructed by placing the safe-consensus objects between the update and snapshot operations. A protocol A is in the WOR (Write, invoke Object and Read) iterated model if it can be written as specified in Figure 3.
if (dec = ⊥) then (8) dec ← δ (sm, val); (9) end if (10) end loop Figure 3: The WOR iterated model It turns out that the WOR iterated model is quite different from the two previous iterated models. This is true because of the following facts: • The consensus task for n processes can be solved in the WOR iterated model using only n 2 safeconsensus black boxes (Theorem 5.6).
• Any protocol in the WOR iterated model which implements consensus using safe-consensus objects must use at least n 2 safe-consensus objects.
The second fact, which is a consequence of Theorem 5.7, is the main result of this paper. It describes a matching lower bound on the number of safe-consensus objects needed to solve consensus by any protocol in the WOR iterated model which implements consensus. In Section 5, we give the detailed description of the WOR iterated protocol which implements consensus using safe-consensus objects, we prove its correctness and finally, we give the proof of the lower bound on the number of safe-consensus objects needed to solve consensus in the WOR iterated model. Our lower bound proof is based in the fact that, if for a protocol A there exists m 0 ∈ {2, . . . , n} such that there are not enough groups (of size m 0 ) of processes that can invoke safe-consensus shared objects, then A will fail to solve consensus. Specifically, A cannot solve consensus if the total number of groups of size m 0 is no more than n − m 0 . See Theorem 5.7 in Section 5.3 for the full details.

Shared objects represented as combinatorial sets
We now introduce some combinatorial definitions which will help us represent shared objects and the specific way in which the processes can invoke these shared objects. These definitions are useful in Sections 4 and 5.
For any n 1 and m ∈ n, let V n,m = {c ⊆ n | |c| = m}. Given a protocol A , we define for each m n the set Γ A (n, m) ⊆ V n,m as follows: b = {i 1 , . . . , i m } ∈ Γ A (n, m) if and only if in some execution of A , only the processes p i 1 , . . . , p i m invoke a safe-consensus object of the array S (see Figures 1, 2 and 3). Roughly speaking, each c ∈ Γ A (n, m) represents a set of processes which together can invoke safe-consensus shared objects in A .
For example, if m = 3 and c = {i, j, k} ∈ Γ A (n, 3), then in at least one round of A , processes p i , p j and p k invoke a safe-consensus object and if in another round or perhaps another execution of A , these processes invoke another safe-consensus object in the same way, then these two invocations are represented by the same set c ∈ Γ A (n, 3), that is, shared objects invoked by the same processes are considered as the same element of Γ A (n, 3) (repetitions do not count). On the other hand, if d = {i, j, l} / ∈ Γ A (n, 3), then there does not exist an execution of A in which only the three processes p i , p j and p l invoke a safe-consensus shared object.
A set b ∈ Γ A (n, m) is called a m-box or simply a box. An element d ∈ Γ A (n, 1) is called a trivial box, it represents a safe-consensus object invoked only by one process, we consider such objects as useless, because they do not give any additional information to the process. We model a process that does not invoke a safe-consensus object as a process that invokes a safe-consensus object and no other process invokes that object, i.e., this safe-consensus object is represented by a trivial box. A process p i participates in the box b if i ∈ b. Let the set Γ A (n) and the quantities ν A (n, m) and ν A (n) be defined as follows: From now on, for all our protocols, we consider global states only at the end of some iteration. Suppose that P is a reachable state in the protocol A . The set of shared objects o 1 , . . . , o q invoked by the processes to enter state P is represented by a set of boxes Inv(P) = {b 1 , . . . , b q } which is called the global invocation specification of P. We assume without loss of generality that in all rounds, each process invokes some shared object, that is, the set Inv(P) satisfies b∈Inv(P) b = n, (a process that does not invoke a safe-consensus object can be seen as a process that invokes a safe-consensus object and no other process invokes that object). Notice that since each process invokes only one safeconsensus object in each round, Inv(P) is a partition of n.
If b = {l 1 , . . . , l s } ∈ Inv(P) is a box representing a safe-consensus shared object invoked by the processes p l 1 , . . . , p l s , we define the safe-consensus value of b in P, denoted by scval(b, P) as the unique output value of the safe-consensus shared object represented by b.

Additional definitions on global states
We now introduce the notions of connectivity and paths between global states. These are well known concepts [2,8] and have become a fundamental tool to study distributed systems.

Paths of global states
Two states S, P are said to be adjacent if there exists a non-empty subset X ⊆ n such that all processes with ids in X have the same local state in both S and P. That is, for each i ∈ X, p i cannot distinguish between S and P. We denote this by S X ∼ P. States S and P are connected, if we can find a sequence of states (called a path) p : S = P 1 ∼ · · · ∼ P r = P, such that for all j with 1 j r − 1, P j and P j+1 are adjacent. Connectivity of global states are a key concept for many beautiful results in distributed systems, namely, impossibility proofs. The indistinguishability of states between processes is the building block to construct topological structures based on the executions of a given protocol and is fundamental in many papers [9,29,8,3,10]. In addition to the classic definitions of connectivity and paths, we also introduce the following concepts. Let q : Q 1 ∼ · · · ∼ Q l be a path of connected states, define the set of states States(q); the set of indistinguishability sets iSets(q); and the degree of indistinguishability deg q, of q as follows: The degree of indistinguishability of the path q guarantees that we can find for any pair of states Q i , Q j ∈ States(q) with Q i ∼ Q j , a set of processes P ⊂ Π that cannot distinguish between Q i and Q j such that |P| deg q. The degree of indistinguishability of a path is usually of non-importance in the standard and well known bivalency proofs of the impossibility of consensus in various systems [2,3], but in the impossibility proof of Section 4 and also the lower bound proof of Section 5, measuring the degree of indistinguishability will be a recurring action in all the proofs.
A path p of connected states of A is said to be C-regular if and only if Inv(S) = Inv(Q) for all S, Q ∈ States(p), that is, p is C-regular when all the states in the set States(p) have the same global invocation specification.
Lemma 3.1. Let A be an iterated protocol for n processes, A ⊆ n a non-empty set and S, Q two reachable states of A in round r, such that for all j ∈ A, p j cannot distinguish between S and Q. Then all processes with ids in A participate in the same boxes in S and Q.
Sketch. Intuitively, for each j ∈ A, p j has the same content in all its local variables, thus it inputs the same values for the function h that outputs the index of the shared object (box) p j is going to invoke in S and Q respectively. Therefore h outputs the same index in both states, gather that, p j invokes the same shared object in S and Q.

Consensus protocols
We need some extra definitions regarding consensus protocols: If v is a valid input value of consensus for processes and S is a state, we say that S is v-valent if in any possible execution starting from S, there exists a process that outputs v. S is univalent if in every execution starting from S, processes always output the same value. If S is not univalent, then S is bivalent 3 .
Lemma 3.2. Any two initial states of a protocol for consensus are connected.
Proof. Let S, P be two initial states. If S and P differ only in the initial value input i of a single process p i , then S and P are adjacent (Only p i can distinguish between the two states, the rest of the processes have the same initial values). In the case S and P differ in more that one initial value, they can be connected by a sequence of initial states S = S 1 ∼ · · · ∼ S q = P such that S j , S j+1 differ only in the initial value of some process (we obtain S j+1 from S j by changing the input value of some process p i , the result is a valid input of the consensus problem), hence they are adjacent. In summary, S and P are connected.
We need one last result about consensus protocols, we omit its easy proof. Lemma 3.3. Suppose that A is a protocol that solves the consensus task and that I, J are connected initial states of A , such that for all rounds r 1, I r , J r are connected successor states of I and J respectively. Also, assume that I is a v-valent state. Then J is v-valent.
Proof. Suppose that I is v-valent and J is v -valent (v = v ). By hypothesis, for all rounds r 1, I r and J r are connected successor states of I and J respectively. Thus, for any r 0, we can find r-round partial executions I = I 0 , π 1 , I 1 , . . . , π r , I r and J = J 0 , π 1 , J 1 , . . . , π r , J r , such that I r and J r are connected states for all r 0. Given that A solves consensus, there must exists k 1 such that I u and J u are decision states for all u k. Let p u be a path connecting I u and J u . For the rest of the proof, assume that States(p u ) = {I u , J u } (i.e., I u ∼ J u ), as the general case will follow easily from this case and induction on |States(p u )|.
Since I u is a successor state of I, which is a v-valent state, all processes decide v in I u ; similarly, as J u is a successor state of J (a v -valent state), processes decide v in J u . Let p be a process that cannot distinguish between I u and J u . Then the local state of p in I u and J u must be the same and this includes its output component. But this is a contradiction, because in I u , p decides v while in J u , p decides v . We conclude that J must be v-valent, such as I.

Impossibility of consensus in the WRO and OWR iterated models
In this section, we prove that the consensus task cannot be implemented in the WRO iterated model with safe-consensus objects and we extend this result to the OWR iterated model, by showing that the WRO and OWR iterated models are equivalent models in their computational power to solve tasks. Given that there exists a protocol in the standard model that solves consensus with registers and safe-consensus objects [4], it is a consequence of the results presented in this section that the WRO and OWR iterated models are not equivalent to the standard model extended with safe-consensus objects.

The impossibility of consensus in the WRO iterated model
We give a negative result concerning protocols in the WRO iterated model. Although there exist wait-free shared memory protocols that can solve consensus using safe-consensus objects [4], in this paper we show that there is no protocol in the WRO iterated model that solves consensus using safe-consensus objects. We first introduce some extra definitions and results that we will be using and after that, we prove that there is no protocol in the WRO iterated model which can solve the consensus task. For simplicity, we will refer to a protocol in the WRO iterated model simply as a WRO protocol.
Lemma 4.1. Let A be a WRO protocol for n processes, A i = n − i for some i ∈ n. Assume there exist S, Q two reachable states of A in round r, such that for all j ∈ A i , p j does not distinguish between S and Q. Then Proof. Let A be a WRO protocol, A i = n − i and S, Q such that every process p j with j ∈ A i cannot distinguish between S and Q. By Lemma 3 For the box c ∈ Inv(S) that contains the id i, we argue by cases: Case I. |c| = 1. All processes with ids in A i participate in the same boxes in both states S and Q and p i does not participate in those boxes, thus c = {i} ∈ Inv(Q).
Case II. |c| > 1. There exists a process p j with j ∈ c and j = i. Then j ∈ A i , so that by Lemma 3 We have prove that Inv(S) ⊆ Inv(Q). To show that the other inclusion holds, the argument is symmetric. Therefore Inv(S) = Inv(Q).
In order to prove the impossibility of consensus in the WRO iterated model (Theorem 4.4), we need various results that describe the structure of protocols in the WRO iterated model. These results tell us that for any given WRO protocol, the degree of indistinguishability of paths of connected states is high, even with the added power of safe-consensus objects, because we can make the safe-consensus values returned by the shared objects the same in all these reachable states, so that they cannot help the processes distinguish between these states. This is the main reason (of) why consensus cannot be implemented with safe-consensus in the WRO iterated model.
The following construction will be useful for the rest of this section. If A 1 , . . . , A q ⊂ n (q 1) is a collection of disjoin subsets of n, define the round schedule The key point of the round schedule η(A 1 , . . . , A q ,Y ) is that in a given one-round execution of a WRO protocol, it will allow us to choose the safe-consensus values of the safe-consensus shared objects invoked by at least two processes (using the Safe-Validity property of the safe-consensus task).
Our next Lemma is the first step to prove Theorem 4.4. Roughly speaking, it tells us that if a WRO protocol has entered any reachable state S, then we can find two one-round successor states of S, such that we can connect these states with a small path of very high indistinguishability degree. These two successor states of S are obtained when the processes execute the WRO protocol in such a way that only one process is delayed in the update and snapshot operations, but all processes execute the safe-consensus shared objects concurrently in every state of the resulting path, thus we can keep the safe-consensus values of every safeconsensus shared object the same in every state. Lemma 4.2. Let n 2, A a WRO protocol and i, j ∈ n. If S is a reachable state of A in round r 0 and the states Q i = S · η(n − i) and Q j = S · η(n − j) satisfy the conditions Then Q i and Q j are connected in round r + 1 of A with a C-regular path q with deg q n − 1.
Proof. If i = j, the result is immediate. Suppose that i = j and n − i = {l 1 , . . . , l n−1 } with l n−1 = j. We show that Q i and Q j can be connected with a C-regular sequence with indistinguishability degree n − 1 by building three subsequences q 1 , q 2 and q 3 .
We proceed to build the sequence q 1 . We claim that there exists a state Q of the form The first property holds because in any state of the form S · η(l 1 , n − {i, l 1 }, i), only process l 1 can distinguish between Q i and Q, thus by Lemma 4.1 we obtain that Inv(Q i ) = Inv(Q). Now, in both Q i and Q, all processes execute the safe-consensus shared objects concurrently and we can use the Safe-Validity property of the safe-consensus task to find a state of A in round r + 1 such that This proves the second property. Therefore, we have that and this sequence is a C-regular path. Repeating the same argument, we can connect Q with a state of the form P = S · η(l 1 , l 2 , n − {i, l 1 , l 2 }, i) and obtain the three state C-regular path Q i Continuing in this way, we can show that the path q 1 is given by which is clearly a C-regular path by repeated use of the previous argument. In the same way, we construct the sequence q 2 as and finally, in a very similar way, we build q 3 as follows, Both q 2 and q 3 are C-regular paths and for k = 1, 2, 3, deg q k = n − 1. Notice that the processes execute the safe-consensus objects in the same way in all the states of the previous sequences, and by construction, all the states have the same invocation specification. As j = l n−1 , S · η(n − l n−1 , l n−1 ) = S · η(n − j, j) = Q j , thus we can join q 1 , q 2 and q 3 to obtain a C-regular path q : Q i ∼ · · · ∼ Q j such that deg q = n − 1. This finishes the proof. Lemma 4.3 is the next step towards proving Theorem 4.4. Basically, it says that for any WRO protocol, if we already have a path of connected states with high indistinguishability degree for some round, then we can use this path to build a new sequence of connected states in the next round with a high degree of indistinguishability. Again, using the round schedules where the processes execute the safe-consensus shared objects concurrently, we can render useless the safe-consensus values, so that the number of processes that cannot distinguish between a pair of states of the path is as high as possible. Lemma 4.3. Let A be a WRO protocol and S, P be two reachable states of some round r 0 such that S and P are connected with a sequence s such that deg s n − 1; suppose also that the number of participating processes is n 2. Then there exist successor states S , P of S and P respectively, in round r + 1 of A , such that S and P are connected with a C-regular path q with deg q n − 1.
Proof. Suppose that S and P are connected with a sequence s : . . , p n be the set of participating processes. We now construct a sequence of connected states in such a way that each Q i is a successor state to some state S j and deg q n − 1. We use induction on m; for the basis, consider the adjacent states S 1 , S 2 and suppose that all processes with ids in the set X 1 (|X 1 | n − 1) cannot distinguish between S 1 and S 2 . By the Safe-Validity property of the safe-consensus task and Lemma 4.1, we can find states Q 1 , Q 2 such that • Q 1 = S 1 · η(X 1 ) and Q 2 = S 2 · η(X 1 ); • Q 1 and Q 2 are indistinguishable for all processes with ids in X 1 ; Combining these facts, we can see that the small sequence Q 1 X 1 ∼ Q 2 is C-regular and has indistinguishability degree at least n − 1. Assume now that we have build the sequence q : Q 1 ∼ · · · ∼ Q s , of connected successor states for S 1 ∼ · · · ∼ S q (1 q < m) such that q is C-regular , deg q n − 1 and Q s = S q · η(X) with |X| n − 1. Let X q with |X q | n − 1 be a set of processes' ids that cannot distinguish between S q and S q+1 . To connect Q s with a successor state for S q+1 , we first use Lemma 4.2 to connect Q s and Q = S q · η(X q ) by means of a C-regular sequence p such that deg p n − 1. Second, notice that we have the small C-regular path s : Q X q ∼ S q+1 · η(X q ) = Q s +1 . In the end, we use q , p and s to get a C-regular sequence q : Q 1 ∼ · · · ∼ Q s +1 , which fulfils the inequality deg q n − 1. By induction, the result follows.
Using Lemmas 4.2 and 4.3 and previous results regarding bivalency arguments, we can finally prove the impossibility of consensus in the WRO iterated model.

Theorem 4.4.
There is no protocol for consensus in the WRO iterated model using safe-consensus objects.
Proof. Suppose A is a WRO protocol that solves consensus with safe-consensus objects and without loss, assume that 0,1 are two valid input values. Let O,U be the initial states in which all processes have as initial values only 0 and 1 respectively. By Lemma 3.2, O and U are connected and it is easy to see that the sequence joining O and U, build in the proof on Lemma 3.2 has degree of indistinguishability n − 1. So that applying an easy induction, we can use Lemma 4.3 to show that there exist connected successor states O r ,U r of O and U respectively in each round r 1 of the protocol A . Clearly, O is a 0-valent state and by Lemma 3.3, U is 0-valent. But this is a contradiction, because U is a 1-valent state. Therefore no such protocol A can exists.
At this moment we remark that the key fact that allows us to prove this impossibility of consensus in the WRO model, is that in all our proofs, we are able to "neutralize" the safe-consensus objects by making all processes invoke their respective shared objects concurrently, this is the entry point for the Safe-Validity property of consensus to allow us to find the states of the executing protocol with the same safe-consensus values, so that the processes can only distinguish different states by their local view of the shared memory. In contrast to the protocols in the WOR model, it is not possible to apply this technique and neutralize the safe-consensus objects, because the shared objects operations are located between the update and snapshot operations, so that when the processes take the snapshot, they have already invoked the safe-consensus shared objects.

The equivalence of the WRO and OWR iterated models
In this section, we prove Theorem 4.8, which tells us that the WRO and the OWR iterated models have the same computational power. We show that given any protocol in the WRO iterated model, there is an OWR protocol that can simulate its behaviour and the converse is also true. To check the meaning of some definition or previous result, the reader may consult Sections 2, 3.2 and 3.3. For the sake of simplicity, we will refer to a protocol in the OWR iterated model, simply as an OWR protocol.

Transforming a WRO protocol into an OWR protocol
The algorithm of Figure 4 is a generic OWR protocol to simulate protocols in the WRO iterated model. Suppose that A is a WRO protocol that solves a task ∆ and assume that h A is the deterministic function to select safe-consensus objects in A and δ A is the decision map used in the protocol A . To obtain an OWR protocol B that simulates the behaviour of A , we use the generic protocol of Figure 4, replacing the functions h and δ with h A and δ A respectively. If the processes execute B with valid input values from ∆, then in the first round, the participating processes discard the output value of the safe-consensus object that they invoke, because the test at line (6) is successful and after that, each process goes on to execute the write-snapshot operations, with the same values that they would use to perform the same operations in round one of A . Later, at lines (13)-(15), they do some local computing to try to decide an output value. It is clear from the code of the generic protocol that none of the executing processes will write a non-⊥ value to the local variables dec, thus no process makes a decision in the first round and they finish the current round, only with two simulated operations from A : write and snapshot. In the second round, the processes invoke one or more safe-consensus objects at line (5), accordingly to the return values of the function h A , which is invoked with the values obtained from the snapshot operation of the previous round (from the round one write-read simulation of A ) and notice that instead of using the current value of the round counter r, the processes call h A with the parameter r − 1. Since r = 2, the processes invoke h A as if they were still executing the first round of the simulated protocol A . Finally, after using the safe-consensus objects, processes do local computations in lines (8)-(10), using the decision map δ A to simulate the decision phase of A , if for some process p j , it is time to take a decision in A , it stores the output value in the local variable dec j , which is used at the end of the round to write the output value in dec j and then p j has decided. If the map δ A returns ⊥, then p j goes on to do the next write-read operations (simulating the beginning of round two of A ) and proceeds to round three of B. The described behaviour is going to repeat in all subsequent rounds.
dec ← dec ; /* Decide when simulated protocol decides */ (15) end if (16) end loop Let π be a round schedule. Denote by π [W, R] the sequence of write and read events of π, these events appear in π [W, R] just in the same order they are specified in π. The symbol π [S] is defined for the event S in a similar way. For example, given the round schedule . For another example, suppose that the round schedule π is given by In this case, we have that π [W, R] = W(1, 2, 3), R(1, 2, 3) and π [S] = S(1), S(3), S(2).
Let A be a WRO protocol as given in Figure 1, h A the deterministic function to select safe-consensus objects and δ A the decision map used in the protocol A . An OWR protocol B that simulates the behaviour of A is obtained by using the generic protocol G of Figure 4. To construct B, we only replace the functions h and δ of G with h A and δ A respectively.
In order to show that B simulates A , we first notice that there is a correspondence between executions of A and B. For, if α is an execution of A such that α = S 0 , π 1 , S 1 , . . . π k , S k , π k+1 , . . .

Then there exists an execution
where s j=1 X j = n is an arbitrary partition of n. Conversely, for any execution β = R 0 , η 1 , R 1 , . . . η k , R k , η k+1 , . . . of the protocol B, we can find an execution Proof. The proof is based on induction on the round number r, the base case and the inductive case are obtained by an easy analysis of the programs given in Figures 1 and 4.
The converse of the previous lemma is also true. The final result that we need to prove that B simulates A for task solvability is an immediate consequence of Lemma 4.5. This shows that the protocol B simulates the behaviour of A for task solvability and therefore proves the first part of Theorem 4.8.
end if (15) end loop

Transforming an OWR protocol into a WRO protocol
Now we show that any OWR protocol can be simulated with a WRO protocol. We follow the same technique that we used in the previous section, we use the generic protocol of Figure 5. The intuitive argument of how it works is very much the same as in the WRO case, thus we omit the details.
Theorem 4.8. Let A be a protocol in the WRO iterated model which solves a task ∆. Then A can be simulated with a protocol B in the OWR iterated model. Conversely, for every protocol B in the OWR iterated model that solves a task ∆ , there is a protocol A in the WRO iterated model, which simulates B .
The equivalence of the WRO iterated model with the OWR iterated model can be combined with Theorem 4.4 to obtain the following Corollary 4.9. There is no protocol in the OWR iterated model for consensus using safe-consensus objects.
The results of this section about the WRO and OWR iterated models combined with the consensus protocol using safe-consensus objects of [4], allow us to conclude that the standard model enriched with safe-consensus shared objects is more powerful that the WRO and OWR iterated models. But there are still some unanswered questions regarding these two iterated models, see our conclusions at Section 6.

Solving consensus in the WOR iterated model
In this section, We investigate the solvability of consensus in the WOR iterated model. We show that there exists a protocol in the WOR iterated model for consensus with n 2 safe-consensus objects. Although the formal specification of this protocol is a bit complicated (see Section 5.2), the intuitive idea behind it is quite simple and this idea can be depicted in a graphical way. This is a nice property of our consensus protocol and it is a consequence of working in an (extended) iterated model of computation. As a byproduct of the design of the consensus protocol, we discovered the new g-2coalitions-consensus task, which is a new kind of "consensus task". More details can be found in Section 5.1. In Section 5.3, we present the main result of this paper, the lower bound on the number of safe-consensus objects needed by any protocol in the WOR iterated model which implements consensus. The lower bound proof is a result of combining a careful study of the connectivity of protocols in the WOR iterated model and the effects of invoking safe-consensus shared objects on the indistinguishability degree of paths connecting reachable states of the protocols. These effects are described in part combinatorially by a new application of Johnson graphs in distributed computing. We use terminology and results from Sections 2 and 3. For simplicity, we refer to any protocol in the WOR iterated model as a WOR protocol.

The coalitions-consensus task
In order to present the complete specification of the consensus protocol, we define the 2coalition-consensus task, which will be useful to give a simpler description of the consensus protocol of Figure 8 and prove its correctness in Theorem 5.6, but before that, we show that the 2coalitions-consensus task can be solved in the WOR iterated model in one round with one snapshot object and one safe-consensus object.
Intuitively, in the g-2coalitions-consensus task, g processes try to decide a consensus value from two proposed input values, there are exactly g − 2 processes which know the two input values, while each of the two remaining processes know only one input value and it is this last fact that makes the 2coalitionsconsensus task dificult to solve. We now give the formal definition of this new task. First, we need to define the set of all valid input values for this new task.
Let I be a non-empty set of names such that ⊥ / ∈ I and N = I ∪ {⊥}.
The g-2coalitions-consensus task We have g processes p 1 , . . . , p g and each process p i starts with a private input value of the form x i ∈ N × N such that C = (x 1 , . . . , x g ) ∈ C g , and C is called a global input. In any execution, the following properties must be true: • Termination: Each process must eventually output some value.
• Agreement: All processes output the same value.
• 2coalitions-Validity: If some process outputs c, then there must exists a process p j with input x j such that Notice that the sets C g (g 2) encapsulate the intuitive ideas given at the beginning of this section about the coalition-consensus task that we need: With an input C ∈ C g , there are two processes that know exactly one of the input values, while the rest of the processes do know the two input values. These processes could easily reach a consensus, but they still need the other two processes with unique input values to agree on the same value, and this is the difficult part of the g-2coalitions-consensus task.
The protocol of Figure 6 implements g-2coalitions-consensus. Each process p i receives as input a tuple with values satisfying the properties of the 2coalitions-consensus task and then in lines 3-5, p i writes its input tuple in shared memory using the snapshot object SM; invokes the safe-consensus object with its id as input, storing the unique output value u of the shared object in the local variable val and finally, p i takes a snapshot of the memory. Later, what happens in Lines 6-10 depends on the output value u of the safe-consensus object. If u = g, then by the Safe-Validity property, either p g invoked the object or at least two processes invoked the safe-consensus object concurrently and as there is only one process with input tuple v, ⊥ , p i will find an index j with sm [ j] .right = ⊥ in line 7, assign this value to dec and in line 11 p i decides. On the other hand, if u = g, then again by the Safe-Validity condition of the safe-consensus task, either process p u is running and invoked the safe-consensus object or two or more processes invoked concurrently the shared object and because all processes with id not equal to g have input tuple z, y with z = ⊥, it is guaranteed that p i can find an index j with sm [ j] .le f t = ⊥ and assign this value to dec to finally execute line 11 to decide its output value. All processes decide the same value because of the properties of the input tuples of the 2coalitions-consensus task and the Agreement property of the safe-consensus task.
We now prove that this g-2coalitions-consensus protocol is correct.
Lemma 5.1. The protocol of Figure 6 solves the g-2coalitions-consensus task using one snapshot object and one safe-consensus object.
Proof. Let p i ∈ {p 1 , . . . , p g }; after p i writes the tuple v 1 , v 2 to the snapshot object SM, it invokes the safe-consensus object and takes a snapshot of the shared memory, p i enters into the if/else block at lines 6-10. Suppose that the test in line 6 is successful, this says that the safe-consensus object returned the value g to process p i . By the Safe-Validity condition of the safe-consensus task, either process p g invoked the shared object or at least two processes p j , p k invoked the safe-consensus object concurrently (and it could happen that j, k = g). In any case, the participating processes wrote their input tuples to the snapshot object SM before accessing the safe-consensus object, so that p i can see these values in its local variable sm i , and remember that the coalitions tuple C consisting of all the input values of processes p 1 , . . . , p g satisfies the properties |l(C) − r(C)| = 1 and r(C) − l(C) = {g}.
Thus, the equation |l(C) − r(C)| = 1 tells us that only one process has input tuple x, ⊥ (x = ⊥), then when p i executes line 7, it will find a local register in sm i such that sm i [ j] .right = ⊥ and this value is assigned to dec i . Finally, p i executes line 11, where it decides the value stored in dec i and this variable contains a valid input value proposed by some process.
If the test at line 6 fails, the argument to show that dec i contains a valid proposed input value is very similar to the previous one. This proves that the protocol satisfies the 2coalitions-Validity condition of the g-2coalitions-consensus task.
The Agreement condition is satisfied because by the Agreement condition of the safe-consensus task, all participating processes receive the same output value from the shared object and therefore all processes have the same value in the local variables val i (1 i g), which means that all participating processes execute line 7 or all of them execute line 9. Then, for every process p r , dec r contains the value sm r [ j r ] .right or the value sm r [ j r ] .le f t where j r ( j r ) depends on p r . But because the input pairs of the processes constitute a coalitions tuple C, they satisfy property (b) of the definition of coalitions tuple, which implies that sm r [ j r ] .right = sm r [ j q ] .right whenever sm r [ j r ] .right and sm r [ j q ] .right are non-⊥ (a similar statement holds for the left sides). We conclude that all processes assign to the variables dec i (1 i g) the same value and thus all of them decide the same output value, that is, the Agreement property of the g-2coalitionsconsensus tasks is fulfilled. The Termination property is clearly satisfied.

The WOR protocol for consensus
We first give an intuitive description of the WOR protocol for consensus, using 2coalitions-consensus shared objects and then we introduce the formal specification and prove its correctness.

Intuitive description
A simple way to describe the protocol that solves consensus is by seeing it as a protocol in which the processes use a set of n 2 shared objects which implement our new g-2coalitions-consensus task. In this way, the protocol in Figure 8 can be described graphically as shown in Figure 7, for the case of n = 4. In each round of the protocol, some processes invoke a 2coalitions-consensus object, represented by the symbol 2CC i . In round one, p 1 and p 2 invoke the object 2CC 1 with input values v 1 , ⊥ and ⊥, v 2 respectively, (where v i is the initial input value of process p i ) and the consensus output u 1 of 2CC 1 is stored by p 1 and p 2 in some local variables. In round two, p 2 and p 3 invoke the 2CC 2 object with inputs v 2 , ⊥ and ⊥, v 3 respectively and they keep the output value u 2 in local variables. Round three is executed by p 3 and p 4 in a similar way, to obtain the consensus value u 3 from the 2coalition-consensus object 2CC 3 . At the beginning of round four, p 1 , p 2 and p 3 gather the values u 1 , u 2 obtained from the objects 2CC 1 and 2CC 2 to invoke the 2CC 4 2coalition-consensus object with the input values u 1 , ⊥ , u 1 , u 2 and ⊥, u 2 respectively (Notice that p 2 uses a tuple with both values u 1 and u 2 ) and they obtain a consensus value u 4 . Similar actions are taken by the processes p 2 , p 3 and p 4 in round five with the shared object 2CC 5 and the values u 2 , u 3 to compute an unique value u 5 . Finally, in round six, all processes invoke the last shared object 2CC 6 , with the respective input tuples u 4 , ⊥ , u 4 , u 5 , u 4 , u 5 , ⊥, u 5 , and the shared object returns to all processes an unique output value u, which is the decided output value of all processes, thus this is the final consensus of the processes.

Formal specification
The formal specification of the iterated consensus protocol with safe-consensus objects is given in Figure  8. This is a protocol that implements consensus using only n 2 2coalitions-consensus tasks. If we suppose that the protocol is correct, then we can use the g-2coalitions-consensus protocol presented in Section 5.1 ( Figure 6) to replace the call to the 2coalitions-consensus objects in Figure 8 to obtain a full iterated protocol that solves the consensus task using n 2 safe-consensus objects. We now give a short description of how the protocol works. There are precisely n 2 rounds executed by the processes and in each round, some subset of processes try to agree in a new consensus value among two given input values. The local variables step, f irstid and lastid are used by the processes to store information that tell them which is the current set of processes that must try to reach a new agreement in the current round, using a 2coalitions-consensus object (the symbol "id" contains the id of the process which is executing the code). The local array agreements contains enough local registers used by the processes to store the agreements made in each round of the protocol and two distinct processes can have different agreements in agreements. Each consensus value v stored in a register of agreements is associated with two integers i 1 , i r ∈ n (r 1), which represent a set of processes p i 1 , . . . , p i r (with i 1 < · · · < i r ) that have invoked a 2coalitions-consensus object to agree on the value v, thus we can say that v is an agreement made by the coalition of processes represented by the pair (i 1 , i r ). To be able to store v in the array agreements, the processes use a deterministic function tup : N × N → N, which maps bijectively N × N onto N. This map can be easily constructed, for example, here is a simple definition for tup Using all the elements described above, the processes can use the protocol of Figure 8 to implement consensus using n 2 2coalitions-consensus objects, building in the process the structure depicted in Figure  (1) init step, f irstid, lastid ← 1; C, D, dec, newagreement ← ⊥; agreements [tup(id, id)] ← input; (2) begin agreements [tup( f irstid, lastid)] = newagreement; (10) end if (11) if lastid < n then (12) f irstid = f irstid + 1; end for (18) dec ← agreements [tup(1, n)]; (19) decide dec; (20) end 7. From the first round and up to round n − 1, all the processes use their proposed input values to make new agreements in pairs, in round one, p 1 , p 2 invoke a 2coalitions-consensus shared object to agree on a common value, based on their input values; in round 2, p 2 and p 3 do the same with another 2coalitions-consensus object and their own input values; later, the turn comes to p 3 and p 4 to do the same with another shared object and their input values and so on until the round number n − 1, where p n−1 and p n agree on a common value in the way that we have already described. All the agreements obtained in these n − 1 rounds are stored on the local registers In this way, the processes build the first part of the structure shown in Figure 7. At the end of round n − 1, in lines 14-15, each process updates the values of the local variables step and f irstid and proceeds to round n. What happens in the next n − 2 rounds, is very similar to the case of the previous n − 1 rounds, but instead of making agreements in pairs, the processes reach new agreements in groups of three processes (see Figure 7) invoking new 2coalitions-consensus shared objects and the consensus values obtained in the first n − 1 rounds and when each process reaches round n − 1 + n − 2 = 2n − 3, it updates the values of its local variables step and f irstid and then the processes proceed to round 2n − 2.
In general, when the processes are about to begin executing round (∑ m j=1 n − j) + 1 (m < n), they will try to make n − (m + 1) new agreements in groups of size m + 2, with the aid of the 2coalitions-consensus objects and the agreements they obtained from the previous n − m rounds and store the new consensus values in their local arrays agreements, using the tup function. When a process finishes round (∑ m+1 j=1 n − j), the values of step and f irstid are updated to repeat the described behaviour for the next n − (m + 2) rounds, until the n 2 round, where the last agreement is made and this value is the output value of all the processes. Now we are ready to give the full proof of Theorem 5.6. We need a series of Lemmas.
Lemma 5.2. The protocol in Figure 8 solves the consensus task using n 2 g-2coalitions-consensus objects. Proof. The protocol clearly satisfies the Termination condition of the consensus task (the only loop is finite). We prove that it fulfils the Agreement and Validity conditions; to do this, we need some definitions and some intermediate results.
With respect to the protocol of Figure 8, let F = {i 1 , . . . , i r } ⊆ n be elements such that i 1 < · · · < i r . The set F will be called a coalition and will be denoted by F = [i 1 , . . . , i r ]. Let p i a process such that i ∈ F. We say that p i belongs to the coalition F if and only if the following condition is fulfilled: where v = ⊥ is a valid input value proposed by some participating process.
We ask the following agreement property to be satisfied by F: (2) if p i , p j are processes which belong to F and v, v are the values which satisfy (1) for p i and p j respectively, then v = v .
The value v of the first condition is called the name of the coalition. The second condition says that all processes that belong to the same coalition must agree on the coalition's name. For n > m 0, let γ(n, m) be defined by Proof. We prove this by induction on m. An easy analysis of the code in Figure 8 shows that the base case holds (when m = 1, in the first n − 1 rounds). Assume that for m < n − 1, the lemma is true. We first prove the following claim: When p i starts executing round γ(n, m) + 1, step i = m + 1 and f irstid i = 1. By the induction hypothesis, when process p i executed the protocol at round r = γ(n, m) = γ(n, m − 1) + c = γ(n, m − 1) + (n − m) before line 11, the local variables step i and f irstid i had the values of m and n − m respectively. When p i reached line 11, it executed the test of the if statement, but before that, p i executed line 4 of the protocol, gather that, lastid i = f irstid i + step i = (n − m) + m = n; thus the test in line 11 failed and p i executed lines 14-15 of the else statement ( f irstid i > 1 because m < n − 1) and then step i was incremented by one and f irstid i was set to 1 at the end of round r . Therefore, when p i starts executing round γ(n, m) + 1, step i = m + 1 and f irstid i = 1. Now suppose that p i executes the protocol at the beginning of round number r = γ(n, m) + c where 1 c n − (m + 1). If c = 1 then by the preceding argument, step i = m + 1 and f irstid i = 1 = c. Using this as a basis for an inductive argument, we can prove that for c ∈ {1, . . . , n − (m + 1)}, c = f irstid i and step i = m + 1. Proof. Let p i be any process that begins executing round r. By Lemma 5.3, we know that step i = m + 1 and f irstid i = c, which implies that lastid i = c + m + 1. If i ∈ {c, . . . , c + m + 1}, the if's test at line 5 is successful and after that what happens in lines 6,7 depends on i. If c i c + m, then p i is in the coalition P and if c + 1 i c + m + 1, p i is in the coalition Q, gather that, a valid input value is assigned to at least one of the variables C i or D i , so p i invokes in line 8 the (m + 2)-2coalitions-consensus object with the input x i = C i , D i . We now pause for a moment to argue that the tuple J = (x c , . . . , x c+m+1 ) built with the inputs of processes p c , . . . , p c+m+1 is a valid global input for the (m + 2)-2coalitions-consensus task. Indeed, from the hypothesis, it is easy to see that J satisfies the requirements  Proof. We apply Lemma 5.4 in each round γ(n, m) + c, where c ∈ {1, . . . , n − (m + 1)}. Now we can complete the proof of Lemma 5.2. Let p j be any process that executes the protocol. Just at the beginning of the first round (line 2), process p j belongs to the coalition [ j] (because of the assignments made to the local array agreements j in line 1, so that if p j executes the protocol for γ(n, 1) = n − 1 rounds, we can conclude using Lemma 5.5, that process p j belongs to some of the coalitions [i, i + 1] (1 i n − 1). Starting from this fact and using induction on m, we can prove that for all m = 1, . . . , n − 1; at the end of round γ(n, m), p j belongs to some of the coalitions [i, . . . , i + m] (1 i n − m). In the last round (when m = n − 1), after executing the main for block, process p j belongs to the coalition T = [1, . . . , n], thus when p j executes line 18, it will assign to the local variable dec i a valid proposed input value and this is the value decided by p j at line 19. All processes decide the same value because all of them are in the coalition T . Therefore the protocol satisfies the Agreement and Validity conditions of the consensus task.
The final result of this section is obtained by combining Lemmas 5.1 and 5.2.
Theorem 5.6. There exists a WOR protocol that solves the consensus task for n processes using n 2 safeconsensus objects.

The lower bound
The main result of this paper is a matching lower bound on the number of safe-consensus objects needed to solve consensus using safe-consensus. Our lower bound proof is based partly on standard bivalency arguments [2], but in order to be able to apply them, a careful combinatorial work is necessary.
The connectivity of iterated protocols with safe-consensus.
Roughly speaking, a typical consensus impossibility proof shows that a protocol A cannot solve consensus because there exists one execution of A in which processes decide a consensus value v and a second execution of A where the consensus output of the processes is v , with v = v , such that the global states of these executions can be connected with paths of connected states. The existence of such paths will imply that in some execution of A , some processes decide distinct output values [2,3,8,29], violating the Agreement requirement of consensus. Any protocol that solves consensus, must be able to destroy these paths of connected states.
Remember from Section 3.5 that the set Γ A (n, m) encodes all the valid subsets of processes of size m that can invoke safe-consensus objects in A . The cardinality of Γ A (n, m) is denoted by ν A (n, m) and For the case of our lower bound proof, the main property that will prevent A from solving consensus (i.e., from destroying paths of connected states) is that for some m 0 ∈ {2, . . . , n}, it is true that i.e., at most n − m 0 subsets of processes of size m 0 can invoke safe-consensus shared objects in the protocol A . We are ready to present our main result, it is the following Theorem 5.7. If A is a WOR protocol for n-consensus using safe-consensus objects, then for every m ∈ {2, . . . , n}, ν A (n, m) > n − m.
Theorem 5.7 describes the minimum number of different process groups, each of size m, that must invoke safe-consensus shared objects, in order to be able to solve the consensus task, for each m = 2, . . . , n. The lower bound on the total number of safe-consensus objects necessary to implement consensus, is an easy consequence of Theorem 5.7 and the definition of ν A (n).
To understand better the implications of Theorem 5.7 on the minimum number of safe-consensus shared objects needed to implement n-consensus, here is an example: Let n = 5 and suppose A is a WOR protocol that solves 5-consensus. By Theorem 5.7, for each m = 2, 3, 4, 5, A satisfies the following inequalities: In words, There must be at least 4 groups of 2 processes that invoke safe-consensus objects, 3 groups of 3 processes that invoke safe-consensus objects, 2 groups of 4 processes and finally, a group of 5 processes (e.g., all the processes) that must invoke a safe-consensus object. Thus the minimum total number of safeconsensus shared objects that the processes must invoke in A to implement consensus is Generalizing this example for arbitrary n, we obtain the inequality ν A (n) n 2 . Notice that we are not counting trivial boxes (safe-consensus objects invoked by one process) in the lower bound.
Theorem 5.7 will be proven by contradiction, that is, we will assume that for some m 0 , Equation (3) holds. There are two structural results about WOR protocols that will be needed: Lemmas 5. 16 and 5.19. Basically, these two results tell us how to find paths of connected reachable states in every round of an executing WOR protocol, whenever Equation (3) is satisfied. The proof of each lemma relies on the development of various results about the connectivity of states of WOR protocols with safe-consensus shared objects and additionally, these results give us information about the combinatorial interactions that exists between the sets of processes which cannot distinguish between the states of a path and the boxes that represent safe-consensus objects invoked by the processes. This extra information is provided by two results about the connectivity of subgraphs of Johnson graphs, Lemma 5.17 and Theorem 5.13. Since the theory and prior results needed to prove these two results are purely combinatorial, we defer their formal proofs to Appendix A.

Further model terminology
We will be using definitions and terminology given in Sections 2 and 3. Before giving the formal proof of our results, we need some technical definitions and lemmas. First, we define a set of round schedules that will be very useful for the rest of the paper. Given q 1 disjoint sets A 1 , . . . , A q ⊂ n, define the round schedule ξ (A 1 , . . . , A q ) for A as: where Y = n − ( q i=1 A i ). For any state S and u 0, define I.e. S · ξ u (A 1 , . . . , A q ) is the state that we obtain after we run the protocol A (starting from S) u rounds with the round schedule ξ (A 1 , . . . , A q ) each iteration.
Let A be a WOR protocol for n-processes, X ⊆ n, R a state of some round r > 0 and b ∈ Inv(R). We say that R is a ladder state for X with step b, if R = S · ξ (C 1 , . . . ,C u , B) (u 0), where S is a reachable state in A and • X = ( u j C j ) ∪ B; • for j = 1, . . . , u, 0 |C j | 2; The following definition is given for convenience. For each box b i and W ⊆ n, let the set W (i) be defined as Lemma 5.8. Let A be a WOR protocol for n 2 processes with safe-consensus objects and S a reachable state in A . Then for any two round schedules π 1 , π 2 , Inv(S · π 1 ) = Inv(S · π 2 ).
Proof. In Figure 3, notice that process p i executes the deterministic function h with the local state it has from the previous round (except from the round counter r), so that if r is the round number of S and p i starts executing the protocol A in round r + 1 with the local state it had in S, the input to the function h is given by the tuple (r + 1, i, sm S , val S ), where sm S , val S depend only on S. Thus in both successor states S · π 1 and S · π 2 , p i feeds the same input to h, gather that and the lemma is true.

The local structure of WOR protocols with safe-consensus objects
In this section, we present results that will be needed to prove Lemma 5.16. The goal here is to show Theorem 5.12, which give us a way to connect two states of the form S · ξ (X) and S · ξ (Y ) for X,Y ⊆ n and any reachable state S of a WOR protocol. Put it another way, with Theorem 5.12 we can connect for a given WOR protocol, a state that is obtained if the processes with ids in X first update the memory, invoke safe-consensus objects and finally they snapshot the shared memory and after that, processes with ids in n − X perform the same actions, with a state that is obtained when processes with ids in Y and ids in n −Y perform the same action in the same way. All this is done with a careful handling of the safe-consensus values returned by the shared objects to the processes, in order to keep the degree of indistinguishability of the path as high as possible. The ladder states defined previously play an important role in the construction of the path given by Theorem 5.12.
Lemma 5.9. Let n 2, ∅ = X ⊆ n, A a WOR protocol with safe-consensus objects, S a state that is reachable in A in some round r 0 and b ∈ Inv(S X ), where S X = S · ξ (X). Then there exists a state L, such that L is a ladder state for X with step b, such that S X and L are connected in round r + 1 with a path of states p with deg p n − 2.
Proof. Let Inv(S X ) = {b 1 , . . . , b q } (q 1). By Lemma 5.8, for any one-round successor state Q of S, Inv(Q) = Inv(S X ) and we can write Inv S instead of Inv(S X ). Without loss of generality, assume that b 1 = b. If q = 1, then b 1 = n and the result is immediate, because S X is a ladder state for X with step n. Suppose that q > 1. Partition X as X = X (1) ∪ · · · ∪ X (q) and build the following sequence of connected states where X (2) = α 2 i=1 Λ 2 (i) is a partition of X (2) such that |Λ 2 ( j)| = 1 for j = 2, . . . , α 2 . The set Λ 2 (1) has cardinality given by (notice that the Λ 2 ( j)'s and α 2 depend on b 2 and X (2) ), and we choose the safe-consensus value of every box in the set Inv S to be the same in each state of the previous sequence. This can be done because of the way we partition X (2) , the election of the elements of the set Λ 2 (1) and the properties of the safe-consensus task (Safe-Validity). We execute similar steps with box b 3 , so that we obtain the path (7) where the Λ 3 (i)'s and α 3 depend on b 3 and X (3) , just in the same way the Λ 2 ( j)'s and α 2 depend on b 2 and X (2) and each box has safe-consensus value equal to the value it has in the sequence of (6). We can repeat the very same steps for b 4 , . . . , b q to obtain the sequence ∼ · · · n−Λ q (α q ) ∼ S · ξ (Λ 2 (1), . . . , Λ q (α q ), X (1) ). (8) It is easy to prove that L = S · ξ (Λ 2 (1), . . . , Λ q (α q ), X (1) ) is a ladder state for X with step b 1 and that each of the sequences of equations (6), (7) and (8) has indistinguishability degree no less that n − 2. Combining all these sequences, we obtain a new path p : S X ∼ · · · ∼ L with deg p n − 2.
Lemma 5.10. Let n 2, X,Y ⊆ n, A a WOR protocol with safe-consensus objects and S a state that is reachable in A in some round r 0. Assume also that b j is a box representing a safe-consensus object invoked by some processes such that b j ∈ Inv(L 1 ) = Inv(L 2 ), where L 1 = S · ξ (C 1 , . . . ,C u , X ( j) ) is a ladder state for X with step b j and L 2 = S · ξ (C 1 , . . . ,C u ,Y ( j) ) is a ladder state for (X − X ( j) ) ∪ Y ( j) with step b j . Finally, suppose that if b j = n, scval(b j , L 1 ) = scval(b j , L 2 ). Then L 1 and L 2 are connected in round r + 1 with a C-regular path of states p that satisfies the following properties: ii) If scval(b j , L 1 ) = scval(b j , L 2 ) then deg p n − |b j | and n − b j ∈ iSets(p).
Proof. Partition n as the disjoint union n = X − ∪ (X ∩Y ) ∪Y − ∪W , where What we need to do to go from L 1 to L 2 is to "interchange" X ( j) with Y ( j) . We first construct a sequence of connected states p 1 given by where the following properties hold: • p 1 is a C-regular sequence (Lemma 5.8) with deg p 1 n − 2; • the safe-consensus value of every box b i is the same in each state of p 1 . This can be achieved by a proper selection of elements of the set Λ j (1) and the Safe-Validity property of the safe-consensus task.
Now, since the following equalities hold: we can write the state S · ξ (C 1 , . . . ,C u , X ( j) ∪Y − ∪W ) as We need to build a second path p 2 as follows: Let L 2 be the last state of the previous sequence. The next assertions are true for the path p 2 : • The sets Ω j (i) and ε j are defined for Y ( j) and b j in the same way as the Λ j (i) and α j are defined for X ( j) and b j ; • The sequence p 2 is C-regular (Lemma 5.8); • The safe-consensus value of every box c = b j is the same in every element of States(p 2 ); • the set U is defined by Notice that by the last assertion, we can deduce that deg p 2 n − |b j | and n − b j ∈ iSets(p 2 ) if scval(b j , L 1 ) = scval(b j , L 2 ) and deg p 2 n − 2 when scval(b j , L 1 ) = scval(b j , L 2 ). Thus we can use p 1 and p 2 to obtain a C-regular sequence p which fulfils properties i)-ii) of the lemma and that concludes the proof. Lemma 5.11. Let n 2, X,Y ⊆ n, A a WOR protocol with safe-consensus objects, S a state that is reachable in A in some round r 0 and b j a box representing a safe-consensus object invoked by some processes in round r +1 such that b j ∈ Inv(Q 1 ) = Inv(Q 2 ), where Q 1 = S ·ξ (X) and Q 2 = S ·ξ (Y ( j) ∪(X −X ( j) )). Assume also that if b j = n, scval(b j , Q 1 ) = scval(b j , Q 2 ). Then the states Q 1 and Q 2 are connected in round r + 1 with a C-regular path of states p that satisfies the following properties: Proof. By Lemma 5.9, the state Q 1 can be connected with a state of the form Q X ( j) = S · ξ (B 1 , . . . , B s , X ( j) ) with a C-regular path q 1 such that deg q 1 n − 2. Using Lemma 5.10, Q X ( j) can be connected with Q Y ( j) = S ·ξ (B 1 , . . . , B s ,Y ( j) ) by means of a C-regular sequence q 2 : Q X ( j) ∼ · · · ∼ Q Y ( j) such that q 2 satisfies properties i) and ii) of that Lemma. And we can apply Lemma 5.9 to connect Q Y ( j) with Q 2 with the C-regular path q 3 which has indistinguishability degree no less that n − 2. Therefore the sequence of connected states built by first gluing together the sequences q 1 and q 2 , followed by q 3 , is a C-regular sequence q such that the requirements a)-b) are satisfied.
With the three previous lemmas at hand, we are almost ready to state and prove Theorem 5.12, only one more definition is necessary. Let Q 1 , Q 2 be two reachable states in round r of an iterated protocol A for n processes with safe-consensus objects. The set D r In words, D r A (Q 1 , Q 2 ) represents the safe-consensus shared objects that the same subset of processes invoked in both states Q 1 and Q 2 , such that the shared objects returned different output values in each state. If there is no confusion about which round number and protocol we refer to, we will write D r A (Q 1 , Q 2 ) as D(Q 1 , Q 2 ).
Theorem 5.12. Let n 2 and X,Y ⊆ n, A a WOR protocol with safe-consensus objects, S a reachable state of A in some round r 0 and let Q 1 = S · ξ (X) and Q 2 = S · ξ (Y ) be such that n / ∈ D(Q 1 , Q 2 ). Then Q 1 and Q 2 are connected in round r + 1 with a C-regular path of states p such that (B) If the set D(Q 1 , Q 2 ) is not empty, then 1. deg p min{n − |b|} b∈D(Q 1 ,Q 2 ) ; 2. for every Z ∈ iSets(p) with |Z| < n − 2, there exists b ∈ D(Q 1 , Q 2 ) such that Z = n − b.

The main structural results
In this section, we prove Lemma 5.16. To do this, we need one more structural result, Lemma 5.14 and our main result about Johnson graphs: Theorem 5.13. We first introduce some combinatorial definitions before stating this theorem. Remember from Section 3.5 that for 1 m n, V n,m = {c ⊆ n | |c| = m} and let U ⊆ V n,m . We define the set ζ (U) as Notice that each f ∈ ζ (U) has size m + 1, thus ζ (U) ⊆ V n,m+1 . For any v = 0, . . . , n − m, the iterated ζ -operator ζ v is given by Since U ⊆ V n,m , we can check that ζ v (U) ⊆ V n,m+v .
The intuitive interpretation of U, ζ and the iterated ζ -operator from the point of view of WOR consensus protocols is the following: U represents a set of possible intermediate agreements between some subsets of processes of size m and ζ is some kind of method the processes use to extend the partial agreements specified by U to new agreements between sets of processes of size m + 1, but these new agreements can be made only if the required agreements of m processes exist inside U. The iterated ζ -operator is just a way to extend ζ to produce larger agreements, starting from agreements between sets of processes of size m. We are ready to state the combinatorial result needed to prove Lemma 5.16. With respect to the proofs of Lemmas 5.14 and 5.16, we need one more definition regarding paths of connected states of a WOR protocol and the boxes representing safe-consensus shared objects. For a given path s of connected states of an iterated protocol A , consider the set β A (s) = {b ∈ Γ A (n) | (∃X,Y ∈ iSets(s))(X = Y and |X ∩ b| = 1 and |Y ∩ b| = 1)}, and if m ∈ n, let β A (s; m) = β A (s)∩Γ A (n, m). Roughly speaking, the set β A (s) captures the safe-consensus shared objects the processes can invoke to decrease the degree of indistinguishability of paths composed of states which are succesor states of the elements of States(s). In other words, if the path s is composed of reachable states in A in round r, then the boxes (safe-consensus objects) in β A (s) can help the processes diminish the degree of indistinguishability of any posible path q such that each state in States(q) is a successor state of some member of States(s). If there is no confusion about which protocol we refer to, we write β (s) and β (s; m) instead of β A (s) and β A (s; m) respectively.
Lemma 5.14. Let n 3 and 1 v s n − 2 be fixed. Suppose that A is a WOR protocol with safeconsensus objects and that there exists a sequence s : S 0 of connected states of round r 0 such that Then in round r + 1 there exists a sequence q : Q 0 ∼ · · · ∼ Q u , of connected successor states of all the S j , such that the following statements hold: Ψ 3 For every Z ∈ iSets(q) with |Z| = v − 1, there exist X, X ∈ iSets(s) and b ∈ β (s; n − v + 1) such that Z = n − b = X ∩ X and b = c 1 ∪ c 2 , c k ∈ Γ A (n, n − v).
Proof. In order to find the path q that has the properties Ψ 1 -Ψ 5 , first we need to define a set of states of round r + 1, called Φ(s), which we will use to construct the path q. The key ingredient of Φ(s) is the safe-consensus values of the boxes used in each member of Φ(s). Define the set of states Φ(s) as Each element of Φ(s) is a state in round r + 1 which is obtained when all the processes with ids in some set X ∈ iSets(s) execute concurrently the operations of A , followed by all processes with ids in n − X. The safe-consensus values of each box for the states of Φ(s) in round r + 1 are defined by using the following rules: Let b be any box such that b / ∈ β (s).
• If |X ∩ b| = 1 for every X ∈ iSets(s), then we choose any value j such that j is the safe-consensus value of b in every state R ∈ Φ(s) with b ∈ Inv(R).
• If there exists exactly one set X ∈ iSets(s) such that X ∩ b = {x}, then b has j x as its safe-consensus value in every state Q ∈ Φ(s) with b ∈ Inv(Q), where j x is the value proposed by process p x when invoking the safe-consensus object represented by b.
Now we establish rules to define the safe-consensus values of every element of the set β (s), using the order on the set iSets(s) induced by the path s, when we traverse s from S 0 to S q . That is, iSets(s) is ordered as For each b ∈ β (s), let that X i , X i+z 1 , . . . , X i+z k , (1 i < i + z 1 < i + z 2 < · · · < i + z k q; z j > 0 and k 1) be the (ordered) subset of iSets(s) of all X ∈ iSets(s) with the property |X ∩ b| = 1. Take the set X i . If x i ∈ X i ∩ b, then we make the value proposed by process p x i (when invoking the shared object represented by b) the safe-consensus value of b for all the elements of Φ(s) of the form where b ∈ Inv(P j ). Next, in all states R u ∈ Φ(s) such that R u = S · ξ (X u ) with b ∈ Inv(R u ) and i + z 1 u i + z 2 − 1, b has safe-consensus value equal to the input value of the process with id x i+z 1 ∈ X i+z 1 ∩ b when invoking the safe-consensus object represented by b. In general, in all states T v ∈ Φ(s) of the form where b ∈ Inv(T v ), b has safe-consensus value equal to the input value of the process with id x i+z l ∈ X i+z l ∩ b feed to the safe-consensus object represented by b. Finally, in each state L w = S · ξ (X w ) ∈ Φ(s) with b ∈ Inv(L w ) and i + z k w q, b has safe-consensus value equal to the input value that the process with id x i+z k ∈ X i+z k ∩ b inputs to the safe-consensus shared object represented by b.
Using the Safe-Validity property of the safe-consensus task, it is an easy routine task to show that we can find states of A in round r + 1 which have the form of the states given in Φ(s) and with the desired safe-consensus values for every box.
We are ready to build the sequence q of the Lemma 6 . We use induction on q 1. For the base case when q = 1, we have that s : S 0 Here we easily build the sequence S 0 · ξ (X 1 ) which clearly satisfies properties Ψ 1 -Ψ 5 . Assume that for 1 w < q we have a path q : Q 0 ∼ · · · ∼ Q l (l 1), Satisfying conditions Ψ 1 -Ψ 5 and such that Q 0 = S 0 · ξ (X 1 ), Q l = S w · ξ (X w ). We now connect the state Q l with Q = S w+1 · ξ (X w+1 ). By Theorem 5.12, there is a C-regular sequence v : Q l ∼ · · · ∼ Q such that Q = S w · ξ (X w+1 ) and v, Q l and Q satisfy conditions (A)-(B) of that theorem. Clearly D(Q l , Q ) ⊆ β (s), because the only boxes used by A in the states Q l and Q with different safe-consensus value, are the boxes which intersect two different sets X, X ∈ iSets(s) in one element. Joining the sequence q with v, followed by the small path t : Q X w+1 ∼ Q (such that deg t v), we obtain a new sequence q : Q 0 ∼ · · · ∼ Q. We now need to show that q satisfies properties Ψ 1 -Ψ 5 . By the induction, hypothesis deg q v. It is also true that deg t v, therefore deg q v. Ψ 3 We remark first that iSets(q) = iSets(q )∪iSets(v)∪iSets(t). If we are given Z ∈ iSets(q) such that |Z| = v − 1, then Z ∈ iSets(q ) or Z ∈ iSets(v). When Z ∈ iSets(q ), we use our induction hypothesis to show that Z = Y ∩Y = n − d for some Y,Y ∈ iSets(s) and d ∈ β (s; On the other hand, if Z ∈ iSets(v), it must be true that D(Q l , Q ) = ∅ (if not, then deg v n − 2 by property (A) of Theorem 5.12 for v and this contradicts the size of Z). As v − 1 < n − 2, we can apply part 2 of condition (B) of Theorem 5.12 to deduce that Z = n − b for a unique b ∈ D(Q l , Q ). Because |Z| = v − 1, it is true that |b| = n − v + 1. Now, b ∈ D(Q l , Q ) ⊆ β (s), thus there exist X, X ∈ iSets(s) such that |X ∩ b| = 1 and |X ∩ b| = 1 Combining Equation (12) with the fact that the size of b is n − v + 1, we can check that |X| = |X | = v and n − b = X ∩ X , that is, and finally, we apply Λ 2 of the sequence s to X, X to find two unique boxes c, c ∈ Γ A (n, n − v) with X = n − c and X = n − c , so that then b = c ∪ c and condition Ψ 3 is satisfied by q. 6 Notice that the order given to Φ(s) in equation 11 is the precise order in which the states of this set will appear in the path q.
Ψ 4 The sequence q fulfils this property because of the induction hypothesis on q , condition Λ 2 for s and (B) of Theorem 5.12 for v.
We have shown by induction that we can build the path q from the sequence s, no matter how many states s has. This proves the Lemma.
The following corollary is a weaker version of Lemma 5.14, and it can be proven as a consequence of that result.
Corollary 5.15. Let n 3 and 1 s n−2 be fixed. Suppose that A is a WOR protocol with safe-consensus objects and there exists a sequence s : S 0 of connected states of round r 0 such that deg s s and n / ∈ β (s). Then in round r + 1 there exists a sequence q : Q 0 such that the following statements hold: Ψ 3 For every Z ∈ iSets(q) with |Z| = s − 1, there exist X, X ∈ iSets(s) and a unique b ∈ β (s; n − s + 1) such that Z = n − b = X ∩ X .
We have gathered all the required elements to prove one of the key ingredient of the full proof of Theorem 5.7. Lemma 5.16 expresses formally the fact that if in a WOR consensus protocol, the processes cannot make enough agreements of size m (ν A (n, m) n−m) then they won't be able to decrease the degree of indistinguishability of paths of connected states of reachable states in every round r 1 of the protocol. Lemma 5.16. Assume that 3 m n. Suppose that A is a WOR protocol with safe-consensus objects such that ν A (n, m) n − m. If S r , Q r are two reachable states in A for some round r 0, connected with a sequence q : S r ∼ · · · ∼ Q r of connected states such that deg q n − m + 1. Then for all u 0, there exist successor states S r+u , Q r+u of S r and Q r respectively, in round r + u of A , such that S r+u and Q r+u are connected.
Our final goal is to show that for all v s − 1, we can connect in each round r + v of A , successor states of S r and Q r . We first claim that for any w = 0, . . . , s − 1 and z 0, ζ z (β (q w ; n − s + 1)) ⊆ ζ z (Γ A (n, n − s + 1)), (this is true because ζ preserves ⊆) and combining this fact with the properties Ψ u,5 and induction, we can show that for 1 l < s β (q s−1 ; n − l + 1) ⊆ ζ s−l (β (q l−1 ; n − s + 1)) ⊆ ζ s−l (Γ A (n, n − s + 1)).
With all this data, Lemma 5.14 and an easy inductive argument (starting at the base case v = s − 1), we can find for all v s − 1, states S r+v , Q r+v of round r + v of A , which are successor states of S r and Q r respectively and connected with a sequence q v such that It is precisely these four properties of the path q v which allow us to find the path q v+1 , applying Lemma 5.14, such that q v+1 enjoys the same properties. Therefore, starting from round r, we can connect in all rounds of A , successor states of S r and Q r . The Lemma is proven.

5.6
The case ν A (n, 2) n − 2 In Section 5.5, we proved Lemma 5.16, a key result to prove Theorem 5.7, but that lemma does not cover the case ν A (n, 2) n − 2. In this section we prove Lemma 5.19, which covers the case ν A (n, 2) n − 2 and it is the last ingredient that we need to prove Theorem 5.7. This can be done easily using Lemma 5.18, a structural result concerning paths of connected states and the following combinatorial result. Lemma 5.17. Let U ⊂ V n,2 such that |U| n − 2. Then there exists a partition n = A ∪ B such that The proof of Lemma 5.17 can be found in Section A.3 of the Appendix. Lemma 5.17 describes the combinatorics of Lemma 5.19 for the case m = 2, just in the same way Theorem 5.13 does the same thing for Lemma 5.16. Intuitively, when |U| n − 2, there are not enough agreements between pairs of processes and this allow us to partition the set of processes Π into two sets and this partition can be used to build sequences of connected states in every round of an executing WOR protocol (Lemmas 5. 18 and 5.19). We now proceed to prove the required results.
Then in round r + 1 of A there exists a path q : Q 0 ∼ · · · ∼ Q s (s 1) of connected states and the following properties hold: Proof. The techniques needed to prove this result are similar to those used in the proof of Lemma 5.14.
We first define the safe-consensus value of every box b ∈ Γ A (n, 2), using property II) and the safe-Validity property of safe-consensus. After doing that, we apply induction on l to build the path q (of succesor states of elements from iSets(p)) satisfying a)-b). We omit the details. Lemma 5.19. Let n 2. If A is a WOR protocol for n processes using safe-consensus objects with ν A (n, 2) n − 2 and S is a reachable state in A for some round r 0, then there exists a partition of the set n = A ∪ B such that for all u 0, the states S · ξ u (A) and S · ξ u (B) are connected.
Proof. This proof is analogous to the proof of Lemma 5.16. We use Lemma 5.17 to find the partition of n and then we apply inductively Lemma 5.18. We omit the details.

The proof of Theorem 5.7
Here we give the proof of Theorem 5.7 for any n 2, thus completing all the necessary proofs of the paper.
Proof of Theorem 5.7 Assume that there exists a protocol A for consensus such that there is some m with 2 m n with ν A (n, m) n − m. Let O,U be the initial states in which all processes have as input values 0s and 1s respectively. We now find successor states of O and U in each round r 0, which are connected. There are two cases: Case m = 2. By Lemma 5.19, there exists a partition of n = A ∪ B such that for any state S and any r 0, S · ξ r (A) and S · ξ r (B) are connected. Let OU be the initial state in which all processes with ids in A have as input value 0s and all processes with ids in B have as input values 1s. Then for all r 0 we have that and by Lemma 5.19, the states OU · ξ r (A) and OU · ξ r (B) are connected. Thus, for any r-round partial execution of A , we can connect the states O r = O · ξ r (A) and U r = U · ξ r (B).
Case 3 m n. By Lemma 3.2, we know that any two initial states for consensus are connected, so that we can connect O and U with a sequence q of initial states of A and it is not hard to check that deg q n − 1 n − m + 1. By Lemma 5.16, for each round r 0 of A , there exist successor states O r ,U r of O and U respectively, such that O r and U r are connected.
In this way, we have connected successor states of O and U in each round of the protocol A . Now, O is a 0-valent, initial state, which is connected to the initial state U, so that we can apply Lemma 3.3 to conclude that U is 0-valent. But this contradicts the fact that U is a 1-valent state, so we have reached a contradiction. Therefore ν A (n, m) > n − m.

Conclusion
In this paper, we have introduced three extensions to the basic iterated model of distributed computing [16], using the safe-consensus task proposed by Yehuda, Gafni and Lieber in [4] and studied some of their properties and the solvability of the consensus task in each model. These extensions are very natural, in the sense that, for the set of new shared objects used by the processes (besides the snapshot objects), the protocols follow the conventions of the standard iterated model for the snapshot objects and the new shared objects: Each set of objects is arranged as an array and each object is used only once by each processes and each process can access at most one shared object. This gives the protocols of the extended models a well behaved structure and allows for an easier analysis of their executions, because of their inductive nature, even with the use of the new shared objects. We believe that iterated models extended with shared objects will play an important role in the development of the theory of models of distributed computing systems with shared objects, just in the same way the basic iterated model has played a fundamental role in the development of the theory of standard shared memory systems.
In the first iterated model that we investigated, the WRO iterated model, the processes first write to memory, then they snapshot it and after that, they invoke safe-consensus objects. We proved that in this model, the consensus task cannot be implemented. The impossibility proof uses simpler connectivity arguments that those used in the lower bound proof of the WOR iterated model. For the second iterated model, the OWR iterated model, processes first invoke safe-consensus objects, then they write to memory and then they snapshot the contents of the shared memory. We proved that this model is equivalent to the WRO iterated model for task solvability using simulations, thus we obtained as a corollary that consensus cannot be implemented in the OWR iterated model.
Finally, in the third model, the WOR iterated model, processes write to memory, invoke safe-consensus objects and they snapshot the shared memory. We first constructed a WOR protocol which can solve nconsensus with n 2 safe-consensus objects. To make this protocol more readable and simplify its analysis, we introduced a new group consensus task: The g-2coalitions-consensus task, which captures the difficulties of solving g processes consensus, even when almost all the processes know the proposed input values, except for two processes that only know one input value. This new task may be of independent interest in future research. We also proved that our WOR consensus protocol is sharp, by giving a n 2 lower bound on the number of safe-consensus objects necessary to implement n-consensus in the WOR iterated model with safe-consensus. This lower bound is the main result of this paper. To obtain this lower bound, we combined structural results about WOR protocols and combinatorial results applied to all the different subsets of processes that can invoke safe-consensus objects. At the very end, it is bivalency [2], but in order to be able to use bivalency, an intricate connectivity argument must be developed, in which we relate the way that the processes use the safe-consensus shared objects to solve consensus with subgraphs of the Johnson graphs. More specifically, our results suggest that for a given WOR protocol which solves n-consensus, the ability of the processes to make incremental partial agreements using safe-consensus objects to reach consensus, is encoded in the number of vertices and the connectivity of specific subgraphs of J n,m for 2 m n. It is somehow surprising that Johnson graphs played such an important role in the proof of Theorem 5.7, these graphs and their properties are known to have applications in coding theory, specifically, Johnson graphs are closely related to Johnson schemes [37]. It is the first time that they appear in the scene of distributed systems. Our results might suggest some kind of connection between distributed systems and coding theory.
Also, in all our structural results of iterated protocols with safe-consensus, we see that connectivity of graphs appear again in the scene for the consensus task, this suggests that topology will play an important role to understand better the behaviour of protocols that use shared objects more powerful that read/write shared memory registers. The proofs developed to obtain the lower bound say that the connectivity of the topological structures given by the shared objects used by the processes, can affect the connectivity of the topology of the protocol complex [24].
With respect to the relationship between the iterated models introduced in this paper and the standard model of distributed computing [1,38] extended with safe-consensus objects used in [4] to implement consensus using safe-consensus objects, we can conclude the following. Our results for the WRO and the OWR iterated models say that these two models are not equivalent to the standard model with safeconsensus (for task solvability), as consensus can be implement in the latter model [4], but consensus cannot be implemented in the WRO and OWR iterated models. Still, an open problem related to these two iterated models remains unsolved: The characterization of their exact computational power. Another closely related problem is: Are these two models more powerful than the standard shared memory model of distributed computing ?
On the other hand, the relationship between the standard model extended with safe-consensus and the WOR iterated model remains unknown. Are these two models equivalent? We conjecture that the answer is yes.
An interesting question for future work is the relation between safe consensus and abort objects. Hadzilacos and Toueg [39] introduced objects that behave like consensus objects except that any operation may abort without taking effect if it is concurrent with another operation.
are joined by at least one edge in G , thus every vertex of ζ (Z ) is connected with every vertex of ζ (Z b ), and as ζ (Z b ) ⊆ V , ζ (Z b ) ∪ ζ (Z ) ⊆ V . We can continue this process with every element of the set (The first equality comes from part (ii) of Lemma A.1). We prove the other inclusion, if V = {b}, we are done. Otherwise, let c ∈ V − {b}, if c ∈ ζ (Z b ), then c ∈ ζ O . In case that c / ∈ ζ (Z b ), there must exists some connected component Z c of G such that c ∈ ζ (Z c ) and Z c = Z b . In G , we can find a path b = v 1 , . . . , v q = c where v i ∈ V for i = 1, . . . , q. The set Q ⊂ U defined as Q = {X ∈ U | (∃ j)(1 j q and v j ∈ ζ (X))}, can be seen to have the property that every pair of vertices X, X ∈ Q are connected by a path in H . Since Z b , Z c ∈ Q, they are connected in H and as Z b ∈ O, then Z c ∈ O, gather that, c ∈ ζ ( O). Therefore V ⊆ ζ ( O) and the equality V = Z∈O ζ (Z) holds. This proves part 1 and finishes the proof. where O = Q∈Q O Q , gather that, property H1 is fulfilled. We now show that condition H2 holds. If W is another connected component of G s+1 , then applying the above procedure to W yields W = S∈S ζ (S), W = S∈S S and W m −1 +∑ X∈O X , with O = S∈S O S . By 2 of Lemma A.4, Q ∩ S = ∅, so that if Q ∈ Q and S ∈ S , then Q = S and the induction hypothesis tells us that O Q ∩ O S = ∅, thus and property H2 is satisfied, so that by induction we obtain the result.
A.3 Proofs of Theorem 5.13 and Lemma 5.17 Using all the results that we have developed in this appendix, we can now prove Theorem 5.13, (the main result of the combinatorial part of the proof of Theorem 5.7) and Lemma 5.17, which is used to prove Lemma 5.19. It is easy to show that n = A ∪ B is the partition of n that we need.