Act XI · The Research Frontier
Part 59 of 61Distributed Computing Theory
What can n processes compute when each sees only its neighbours, or may crash, or may lie?
A million processes on a ring, each knowing only its own identifier and its successor's, must 3-colour themselves, and Cole and Vishkin's bit-position trick does it in seven rounds: a million colours, then 38, 12, 8, 6, 5, 4 and 3. Linial's lower bound shows that about log* n rounds are needed by any algorithm, through a speed-up lemma on neighbourhood graphs. The part then turns from locality to agreement. FloodSet is checked against every input and crash pattern, and f crashes are shown to need f + 1 rounds; the hexagon of Fischer, Lynch and Merritt, run against a two-round majority protocol, shows that three processes cannot survive one liar. Under asynchrony the FLP proof is given for three processes and Ben-Or's coins get around it, at a cost in phases that roughly doubles with every two processes. Shared memory brings Herlihy's consensus hierarchy, and the turn of the part is topological: one round of immediate snapshots subdivides a simplex, and Sperner's lemma makes k-set agreement impossible. Failure detectors, the Dolev-Reischuk message bound and population protocols follow, and the part ends on the classification of locally checkable problems.
What you need. Graphs and colourings, logarithms and binary notation, proof by contradiction; no topology is assumed.
- Mathematics, ideas and history
- the LOCAL model, Cole–Vishkin and Linial's log* n bound, round elimination, the n > 3f bound, consensus hierarchy, k-set agreement via Sperner's lemma
- What we build or compute
- 3-colouring a million-node ring; the hexagon argument run
What you will be able to do
Degree
- Run one round of Cole and Vishkin's rule on a short ring by hand, and explain why neighbours still differ afterwards.
- Compute log* n, and tell crash, omission and Byzantine faults and synchronous and asynchronous models apart.
Graduate
- Prove that b-bit colours shrink to 1 + ceil(log2 b) bits in a round, and bound the rounds by log* n plus a constant.
- Prove that f crashes need f + 1 synchronous rounds, and that Byzantine agreement without signatures needs n > 3f, by the hexagon argument.
- State Sperner's lemma and use it to show that three processes cannot solve wait-free 2-set agreement.
Research
- Prove Linial's speed-up lemma on neighbourhood graphs and derive the bound t >= (log* n)/2 - 1.
- State the asynchronous computability theorem, and explain why the subdivision after r rounds of immediate snapshots has no holes.
- State the classification of locally checkable labellings on rings, and name a gap on general graphs that is still open.
Industry
- Read a consensus library's fault assumptions (crash or Byzantine, n > 2f or n > 3f, timing) and say which theorem each one answers.
- Compare PBFT's and HotStuff's messages per view against the Dolev-Reischuk bound, and say what phi accrual and SWIM failure detectors trade.
Contents
Each chapter has a home level. Choose a track to see what to read and watch: Degree 13 min · Graduate 23 min · Research 52 min · Industry 23 min.
- 0What n processes can computeDegree2 min
- 1Models and faultsDegree4 min
- 2Locality: colouring a ringDegree5 min
- 3Linial's lower boundResearch5 min
- 4Synchronous agreement and its boundsResearch5 min
- 5Asynchrony: FLP and randomnessResearch5 min
- 6Shared memory and the consensus hierarchyResearch4 min
- 7Topology: why k-set agreement is impossibleResearch5 min
- 8Failure detectorsIndustry4 min
- 9The cost of agreementIndustry5 min
- 10Population protocolsResearch4 min
- 11Frontier: the complexity of localityResearch1 min
- Recap, problems, and where this comes backAll tracks2 min
Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · 中文 · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film.
What n processes can computeDegree2 min
A million processes stand in a ring, each knowing only its own identifier and its successor's. They must colour themselves with three colours so that no two neighbours match. At the start every identifier is its own colour: a million colours. In each round, every process compares its colour with its successor's, finds the first bit where they differ, and takes as its new colour that bit's position and value. Neighbours still differ, and a colour of b bits shrinks to about log b bits. A million colours become thirty-eight, then twelve, then eight, then six, and three more rounds remove the colours above two. Seven rounds for a million processes, and it would be only a little more for a billion: the number of times you take a logarithm before reaching one, written log star.
This part asks three questions. What can be computed locally, when each process sees only a few hops? Nathan Linial proved in 1992 that our seven rounds are essentially the best possible: no algorithm can three-colour a ring in fewer than about log star of n rounds. What can be agreed when processes fail? Three processes cannot reach agreement if one of them lies; f crashes need f plus one rounds; and with no clocks at all, Part 38's FLP theorem rules agreement out. And what can be computed at all? Some tasks are impossible for reasons that turned out to be topological. Part 38 built Raft. This part is the theory underneath it.
1Models and faultsDegree4 min
A model fixes three things: how time behaves, how processes talk, and how they may fail. Start with time. In a synchronous system the processes move in lockstep rounds. In each round every process sends its messages, every message arrives before the round ends, and then each process computes. So if an expected message does not arrive, its sender has certainly failed. In an asynchronous system there is no bound on how long a message takes or how fast a process runs. A message that has not arrived may still be on its way, so no process can ever tell a slow neighbour from a dead one, which is the root of Part 38's FLP theorem. Real networks sit in between: Dwork, Lynch and Stockmeyer's partial synchrony, where bounds hold only eventually, is where Raft lives.
Next, how processes talk. In message passing, processes are nodes of a network and communicate only by sending messages along its links, which may be delayed, reordered or lost. In shared memory, processes never send anything: they read and write shared registers, or use stronger objects like the compare-and-swap of Part 33, and Chapter six ranks those objects by power. The two worlds are closer than they look. Hagit Attiya, Amotz Bar-Noy and Danny Dolev showed in 1995 that as long as a majority of processes is correct, messages can simulate a shared register, so an algorithm for one model often runs in the other.
Third, how processes fail. A crashed process simply stops, possibly halfway through sending a round's messages, and never returns. An omission fault is subtler: the process keeps running but some of its messages are never sent or never received. And a Byzantine process may do anything at all, including telling different processes different things. The name comes from Leslie Lamport, Robert Shostak and Marshall Pease's paper of 1982 on the Byzantine generals. Each kind contains the one before, so an algorithm that survives liars survives crashes too. Every bound in this part is stated for n processes of which at most f are faulty, and the harder the faults, the more it costs.
The problem at the centre of the theory is consensus. Each process starts with an input, here a bit, and must decide on an output. Three rules: agreement, no two correct processes decide differently; validity, if every input is the same value then that is the decision; and termination, every correct process eventually decides. Without validity, always deciding zero would do. Here is the map this part will prove. With synchronous rounds and crashes, any number of faults can be tolerated, at a cost of f plus one rounds. Byzantine faults need more than three f processes, unless messages are signed. Without synchrony, no deterministic algorithm survives even one crash, but coins rescue us, and in shared memory the answer depends on the objects you are given.
One more pair of models measures something else: not fault tolerance, but distance. In the LOCAL model the network itself is the input. There are no faults, every node has a unique identifier, and in each synchronous round every node may send a message of any size to each neighbour. The only cost is the number of rounds. In each round, information moves one hop. The CONGEST model is the same, except that a message may carry only about log n bits, a few identifiers, so bandwidth matters too. In LOCAL, every problem can be solved in as many rounds as the network's diameter: gather the whole graph and compute. The interesting question is what can be done in far fewer, and the next two chapters answer it for colouring a ring. David Peleg's book of 2000 fixed these names.
2Locality: colouring a ringDegree5 min
The LOCAL model turns distance into time. Put sixteen nodes on an oriented ring, where each knows which neighbour is its successor, and watch one node, v. Each round, every node tells both neighbours everything it knows. After one round v knows the identifiers one hop away; after t rounds, its whole neighbourhood of radius t, and nothing beyond. So a t-round algorithm is just a function from such views to outputs, and on a ring a view is two t plus one identifiers in a row. Identifiers matter: on an anonymous ring every node sees the same thing forever, and no deterministic algorithm can colour it. With them we start from a proper colouring with n colours, and must shrink it to three.
Here is Richard Cole and Uzi Vishkin's trick of 1986, on numbers from our run. Node v's identifier is one million, nine hundred and ninety-nine thousand, five hundred and ninety-one; its successor's is one million, six hundred and sixty-four thousand, two hundred. Write both in binary. Find the lowest bit where they differ: here, bit zero. The new colour is twice that position plus v's own bit there: two times zero, plus one, is one. Every node does this at once, and the next rounds work on the new, shorter colours; in round three v finds its first difference at position two and becomes four. A twenty-one-bit identifier has only twenty-one positions, so after one round at most forty-two colours remain.
Why can neighbours never collide? Take v, its successor w, and w's successor. Node v chose its position by comparing itself with w, but w compared itself with its own successor. Suppose v and w get the same new colour. Two i plus a bit determines both the position and the bit, so they chose the same position i and have the same bit there. But v chose i precisely as a position where its colour and w's differ, a contradiction. The new colouring is proper whatever the identifiers were, so the step can be repeated, and because each node has a single successor to compare with, all nodes act at once.
How quickly do the colours shrink? If every colour fits in b bits, the position i is at most b minus one, so the new colour, two i plus a bit, is less than two b. Writing it takes one plus the logarithm of b bits: a colour's length collapses to roughly its own logarithm in one round. In our run: twenty-one bits, then six, four, three. The bound allows forty-two colours after round one and the run used thirty-eight; then twelve, eight and six, exactly at the bound. At three bits the trick stops helping: two i plus a bit is again below six. Since each round takes a logarithm, reaching six colours takes about as many rounds as the logarithms needed to bring n down to a constant.
Now watch it run. Twenty-four consecutive nodes of our million-node ring, each starting with its twenty-one-bit identifier: a million colours. One round of the bit trick, and the ring is down to thirty-eight colours; then twelve, eight, six. Then a different step takes over. Nodes of colour five are never neighbours, so all of them recolour at once, each taking the smallest of zero, one and two that neither neighbour uses. Then colour four goes, then three. Seven rounds, and our instrument checked every edge of the million: no two neighbours share a colour.
The count of rounds has a name. Log star of n is the number of times you take the base-two logarithm before reaching one: sixty-five thousand five hundred and thirty-six becomes sixteen, four, two, one; four logarithms. It grows absurdly slowly: two to the power sixty-five thousand five hundred and thirty-six, vastly more than the atoms in the universe, has log star five. Cole and Vishkin's rounds track it: from ten nodes to a million, our instrument needs log star of n plus two or three. So three-colouring a ring takes almost constant time. Could a cleverer rule do it in constant time? The next chapter's answer is no.
3Linial's lower boundResearch5 min
Nathan Linial proved in 1987, in a paper published in full in 1992, that log star cannot be beaten. On an oriented ring, after t rounds a node knows the two t plus one identifiers centred on it, and nothing more. So any t-round algorithm is a function f from such windows to colours, and its successor's colour is f of the same window shifted one place. For a proper colouring, f must give every window and its shift different colours, since any row of distinct identifiers appears on some ring. So f properly colours a graph whose vertices are windows, the neighbourhood graph, which must therefore have chromatic number at most three.
The neighbourhood graph is enormous, so the argument studies a piece of it. Keep only windows whose identifiers increase, joined to their increasing shifts; call this graph B k, for windows of length k. A subgraph never needs more colours, so a t-round three-colouring of the ring three-colours B two t plus one. Now the smallest case, windows of length one. Any two identifiers form an increasing pair, so B one is the complete graph on n vertices, and it needs n colours. The proof walks from long windows down to short ones, one identifier at a time, counting how fast the colours may grow.
Here is the heart of the proof. If windows of length k can be properly coloured with c colours, windows of length k minus one can be coloured with two to the c. Colour each short window by a set: the colours f gives to all its increasing extensions by one more identifier y. Suppose two neighbouring short windows got the same set. The first set contains a, the colour of the first window extended by x k. So a is in the second set too: some extension of the second window by a larger y also has colour a. But those two long windows are neighbours in B k with the same colour, which is impossible. So the set colouring is proper, and its values are subsets of c colours: at most two to the c of them.
Let us run the lemma on five identifiers. These are the windows of length two, increasing pairs, with a b joined to b c. Three colours suffice here; one way is to colour a b by the highest bit where a minus one and b minus one differ. Now give each identifier the set of colours on the pairs that start with it. One gets all three; five, which starts no pair, gets the empty set. All five sets differ, so they properly colour the complete graph on five vertices, as the lemma promised: at most eight sets were allowed, and five were needed.
Now apply the lemma again and again. A t-round algorithm three-colours windows of length two t plus one. One identifier shorter, at most eight colours; then two hundred and fifty-six; then two to the two hundred and fifty-six; and so on, down to windows of length one, which need n. So n is at most a tower of two t twos with a three on top. Each logarithm peels off one level, so log star of n is at most two t plus two, and t is at least half of log star of n, minus one. For our million-node ring log star is five, so every algorithm needs at least two rounds; Cole and Vishkin's used seven. The constants differ, the growth does not.
Look at the shape of that proof. A t-round algorithm for one problem became a faster algorithm for a derived problem, and again, until a zero-round algorithm had to exist for a problem that plainly has none. Linial's lemma is one such step, trading one identifier of view for exponentially more colours. In 2019 Sebastian Brandt showed that for a wide class of problems on graphs that look locally like trees, the derived problem can be computed mechanically, so lower bounds can be searched for by a program: round elimination. Linial's paper also went the other way, colouring any graph of maximum degree delta with order delta squared colours in log star rounds. Chapter eleven returns to this map.
4Synchronous agreement and its boundsResearch5 min
With synchronous rounds and crashes, agreement has a simple algorithm. In FloodSet each process keeps the set of values it has seen. Every round it sends the set to everyone and adds what it receives; after f plus one rounds it decides the smallest value in its set. Four processes, one crash. In round one, process two, the only one holding a zero, crashes after sending to process three alone. In round two process three passes the zero on, and everyone decides zero. Why does it work? With f crashes in f plus one rounds, some round has no crash. In that clean round every live process hears every other, so afterwards their sets are equal, and stay equal. Equal sets, equal minima.
Is the extra round really needed? Here is how an adversary defeats FloodSet with only f rounds, for f equal to two. Process one alone holds a zero. In round one it sends it only to process two, and crashes. In round two, process two passes it only to process three, and crashes too. Process three decides zero; process four never heard of it and decides one. Our instrument checked FloodSet exhaustively: every input, and every pattern of who crashes, when, and who still hears from it. With f rounds or fewer it always finds a run that breaks agreement. With f plus one rounds every run agrees, all fifty-six thousand eight hundred and forty-eight of them for four processes and two crashes.
FloodSet needs f plus one rounds; could a cleverer algorithm need fewer? No, and the proof is a chain. Suppose an algorithm always decides within f rounds. Line up runs from one where every input is zero, which must decide zero, to one where every input is one. Each run differs from the next so little that some correct process sees exactly the same in both. That process decides the same in both, and agreement drags everyone along, so the decision never changes along the chain: zero equals one. The chain changes one input at a time, crashing that process first, and removes messages one at a time. A last-round message changes only its receiver's view; an earlier one is removed by first silencing its receiver in the next round, at the cost of another crash. One crash per round: f crashes cover f rounds, never f plus one.
Now let processes lie. Pease, Shostak and Lamport proved in 1980 that Byzantine agreement needs more than three f processes; the cleanest proof, by Fischer, Lynch and Merritt in 1986, is a hexagon. Take any protocol for three processes, A, B and C, meant to survive one liar. Wire six honest copies into a ring, the zero copies with input zero and the one copies with input one, each treating its two ring neighbours as the other two. Any two neighbours see exactly what they would in a three-process run where the third lies, playing a different copy to each. So validity makes A zero and B zero decide zero and B one decide one, and agreement makes every neighbouring pair match. Around the ring, zero equals one. Our instrument ran a natural two-round majority protocol on the hexagon, and it breaks where it must: C zero disagrees with A one, and C one with A zero.
That bound assumes a liar can claim anything about what others said. Part 30's signatures take that power away. In Danny Dolev and Ray Strong's protocol of 1983 the sender signs its value. A process that in round r receives a value carrying r distinct signatures, the sender's first, accepts it, adds its signature and relays it. After f plus one rounds it decides the value if it accepted exactly one, and a default otherwise. Why do correct processes agree? A value a correct process accepts by round f is relayed, so everyone accepts it a round later. A value first accepted in the last round carries f plus one signatures, so one signer was correct and relayed it earlier. A sender who signs two values is exposed to all. It works for any number of faulty processes, in f plus one rounds, the minimum.
5Asynchrony: FLP and randomnessResearch5 min
Part 38 told this theorem's story; here is the machinery of its proof. Three processes, any one of which may crash. Line up the starting configurations, changing one input at a time. All zeros must decide zero, and all ones must decide one. Suppose no start is bivalent. Then somewhere two neighbours have opposite valencies, here C one and C two. They differ only in process two's input. Run both with process two crashed from the very start. The others see exactly the same in both runs, so they decide the same. But one start was zero-valent and the other one-valent. So some start is bivalent: the inputs alone do not fix the outcome.
The second step is the heart. Take a bivalent configuration C and any pending step e: process p receiving message m. Let the adversary take any other steps first, and only then apply e. The claim is that some of the results are still bivalent, so the adversary can deliver e without letting a decision happen. Suppose not, so every result is univalent. Both valencies must appear, because from C either decision can still be reached. So somewhere there are two neighbours, C zero and C one, one step e prime apart, where applying e to the first gives zero-valent and to the second one-valent. Call that a decisive step.
Two cases destroy it. If e prime is a step of some process other than p, the two steps commute: applying them in either order gives the same configuration. Then D one is reachable from D zero, a one-valent configuration below a zero-valent one. Impossible. If e prime is a step of p itself, let p fall silent. A protocol that survives one crash must have a finite run from C zero, call it sigma, in which p never moves and someone decides. Sigma involves no step of p, so it commutes with both of p's steps. From its end A, one path reaches zero-valent, another one-valent. So A is bivalent, yet a decision was made there. Contradiction either way.
The third step builds the bad run. Keep the processes in a queue. At each stage, take the next process and the oldest message waiting for it; the second lemma lets the adversary deliver exactly that message and land in a bivalent configuration again. Repeat for ever. Every process takes infinitely many steps, every message arrives, nobody crashes, and nobody ever decides. That is the theorem of 1985. Notice that the crash never happens. Its mere possibility forces the protocol to wait, and waiting is what the adversary exploits.
Michael Ben-Or's protocol of 1983 escapes by flipping coins, and survives any minority of crashes. Each phase has two votes. First every process sends its value and waits for n minus f of them. If more than half of all n processes reported the same value, it proposes that value, otherwise a question mark. Then it waits for n minus f proposals. More than f proposals of v: decide v. At least one: adopt v. None: flip a coin. Why is it safe? Two different values are never proposed in one phase, since each would need a majority of reports. And if anyone decides v, more than f processes proposed it. Every process misses at most f proposals, so each sees a v and adopts it, and the next phase decides v everywhere.
Safety never depends on the coins; termination does. In any phase, the processes that flip may all land on the value the others hold, with probability at least one over two to the n. Each phase is a fresh try, so failing t phases in a row has probability at most one minus two to the minus n, to the power t, and the expected wait is at most two to the n phases, plus one to decide. Our instrument ran it with split inputs and just under half the processes crashed. Four processes took four point eight phases on average; six, nine point three; eight, eighteen point two; ten, thirty-three point nine. Every run agreed and ended, but the mean roughly doubles with every two processes. A common coin, seen alike by everyone, makes it constant.
6Shared memory and the consensus hierarchyResearch4 min
Now the processes share memory instead of sending messages. The simplest shared object is an atomic register. Processes read it and write it, and each operation, though it takes time, behaves as if it happened at one instant inside its interval. Part 33 called this linearizability. A read that overlaps a write may return the old value or the new one, but the instants line up into one sequential history. The standard of progress is wait-freedom: every operation finishes in a bounded number of its own steps, even if all the other processes have crashed. No locks, and no waiting for anyone. That is the shared-memory version of surviving n minus one crashes.
Reading many registers at once is harder than it looks. A snapshot object lets each process update its own register, and scan all of them as if at one instant. Can we build it from registers? Collect: read the registers one by one. Meanwhile process two writes, and a second collect differs. Collect again. Two equal collects in a row mean nothing changed in between, so that collect is a true snapshot. But busy writers could make a scanner retry for ever. The fix, by Afek, Attiya, Dolev, Gafni, Merritt and Shavit in 1993: every update first takes a scan and stores it beside its value. A scanner that sees one process move twice borrows that process's scan, taken entirely during its own. After at most n plus one collects someone has moved twice, so every scan is wait-free.
Maurice Herlihy turned this into a ranking in 1991. The consensus number of an object is the largest number of processes that can solve wait-free consensus using copies of it and registers. Registers, and even snapshots, have consensus number one. Test-and-set, swap, fetch-and-add, queues and stacks have two. Part 33 built two-process consensus from test-and-set; a queue does it too. Put win and then lose in the queue. Each process writes its proposal and dequeues: whoever gets win decides its own value, the other decides its rival's. Compare-and-swap, and load-linked with store-conditional, sit at infinity. The ranking has teeth: no object implements a higher one wait-free, so there is no wait-free queue built from registers alone.
Why can registers not do it for even two processes? Part 33 sketched the argument; here are its cases. Every run of a wait-free protocol is finite, so following bivalent configurations we reach a critical one: bivalent, but p's next step makes it zero-valent and q's next step makes it one-valent. If p's step is a read, it changes only p. After q's step, the two configurations differ only inside p. A read by q is the same with roles swapped. If they write different registers, the steps commute, and the order cannot matter. If they write the same register, q's write hides p's. Either way q, running alone, sees the same memory and its own same state. It must decide, and decides alike, though one side was zero-valent and the other one-valent.
7Topology: why k-set agreement is impossibleResearch5 min
Maurice Herlihy and Nir Shavit's idea was to draw a task as a shape. Two processes, p in blue and q in orange, each start with a bit. A vertex is a process with its value, and an edge joins values that can occur in the same run. All four combinations can, so the inputs form a square. The outputs of consensus are just two edges: both decide zero, or both decide one. The task is a map, delta, from each input simplex to the outputs it allows. Inputs zero and zero allow only zero and zero. Inputs zero and one allow either edge, but never a mixture.
Now run a protocol. In each round a process writes its state, then takes an immediate snapshot of memory, a form of round Borowsky and Gafni introduced. Start from inputs zero and one. If p goes first, it sees only itself and q sees both; together, both see both; if q goes first, it sees only itself. The edge becomes a path of three. Each further round cuts every piece in three again: always one connected path. At one end p ran alone. It cannot tell this from a run where both inputs were zero and q was slow, so it must decide zero; at the other end q must decide one. Somewhere the decision switches, and that edge is a run where they disagree.
With three processes the same thing happens in two dimensions. The inputs form a triangle, one vertex per process. One round of immediate snapshots cuts it into thirteen triangles, one for each way the three can be ordered, ties allowed. The middle triangle is the run where all three move together; this corner one, the run where p zero goes alone first. Every small triangle has one vertex of each colour: three views that occur together in one run. Two rounds give a hundred and sixty-nine. However many rounds, the protocol complex is a subdivision of the triangle, with no holes, and that is what the impossibility proof will use.
The tool is a lemma Emanuel Sperner proved in 1928. Cut a triangle into small ones and colour the vertices: the corners zero, one and two; a vertex on a side, one of that side's corner colours; inside, anything. Then some small triangle has all three colours; in fact an odd number do, here nineteen of sixty-four. The proof counts doors, edges coloured zero and one. Over all small triangles, an inside door is counted twice and a boundary door once. A rainbow triangle has exactly one door, any other none or two. So the rainbow count has the parity of the boundary doors, which all lie on the zero-one side, where the colour switches an odd number of times. Two hundred more random colourings, of a finer grid of a hundred triangles: always odd.
Soma Chaudhuri asked in 1990 about a weaker agreement. In k-set agreement each process decides one of the inputs, and at most k different values may be decided. With f crashes it is easy when k is more than f: wait for n minus f values and decide the smallest. And for smaller k? Take three processes, two values allowed, no waiting, and give process i the input i. A process may only decide an id it has seen, so a corner decides its own, and a vertex on a side one of that side's ends. That is a Sperner colouring. So some triangle is rainbow: a run in which three values are decided. In 1993 three teams proved the general case: k-set agreement is impossible whenever k is at most f.
Herlihy and Shavit turned the picture into a theorem. Running a wait-free protocol with registers subdivides the input complex. The decisions are a map from that subdivision to the outputs, sending each vertex to a vertex of the same process, and each simplex to an output that delta allows. The asynchronous computability theorem says that is all there is: a task is solvable wait-free with registers exactly when such a subdivision and such a map exist. Solvability became a question about shape. The 2004 Gödel Prize went to Herlihy and Shavit, and to Saks and Zaharoglou, for this work.
8Failure detectorsIndustry4 min
Chapter five showed that one possible crash makes asynchronous consensus impossible. In 1996 Tushar Chandra and Sam Toueg asked how much knowledge about crashes would be enough. Give every process a local oracle, a failure detector, which outputs the processes it currently suspects of having crashed. When process three crashes, the others' detectors come to suspect it. But a detector may be wrong. Process one suspects process five, which is merely slow, and trusts it again when its message arrives. The insight was to describe detectors by the mistakes they may make, not by how they are built.
How is such a detector built? With heartbeats. Process q sends one every period, and p suspects q when none arrives within a timeout. One heartbeat is delayed, the timer expires, and p suspects a healthy q. When it arrives, p trusts q again and doubles the timeout. When q really crashes, the heartbeats stop and p suspects it for ever. Under partial synchrony, once the network settles, heartbeats are at most the delay bound plus the period apart. Each mistake doubles the timeout, so after logarithmically many mistakes there are no more. The result is an eventually perfect detector.
Chandra and Toueg sorted detectors by two properties. Completeness: every crashed process is eventually suspected for ever, by every correct process, or in the weak version by some correct process. Accuracy: strongly, no process is suspected before it crashes; weakly, some correct process is never suspected. And eventual versions, which hold only after some unknown time. That makes eight classes. But weak completeness becomes strong if every process forwards its suspicions to everyone, so four remain. Our heartbeat detector is eventually perfect, and the weakest, eventually strong, will turn out to be enough.
Here is Chandra and Toueg's algorithm for an eventually strong detector and a correct majority. A coordinator rotates from round to round, and everyone sends it an estimate, stamped with the round in which it was adopted. In round one the coordinator is slow, the detectors suspect it, and the others refuse and move on. Mistakes cost time, never safety. In round two, process two gathers a majority of estimates, takes the latest, and proposes it; the others adopt it and acknowledge. With a majority of acknowledgements it decides. Safety is counting: two majorities always share a process, so every later coordinator sees the adopted value.
Why must a majority be correct? Split the processes into two halves, inputs zero and inputs one, and allow half of them to crash. In run one the right half crashes at the start. The left half must decide alone; it has seen only zeros, so it decides zero, at some time t A. In run two the left half crashes, and the right half decides one, at time t B. In run three nobody crashes, but messages across are slow, and each half suspects the other until both have decided, which eventual accuracy allows. Each half sees what it saw before: one decides zero, the other one. A strong detector needs no majority at all.
Is eventually strong the least a detector can offer? Omega outputs just one process, a leader. Outputs may disagree and change, and a trusted process may crash, but eventually every correct process trusts the same correct one for ever. In 1996 Chandra, Vassos Hadzilacos and Toueg proved that any detector with which consensus can be solved can simulate omega: it is the weakest. The proof reuses chapter five's valency argument: simulate runs with sampled detector outputs and find the step that decides the outcome; whoever takes it must be correct. Omega is equivalent to eventually strong, and it is the leader election of Paxos and Raft.
9The cost of agreementIndustry5 min
How expensive is agreement? Count the messages. In one all-to-all round, each of n processes sends to the n minus one others: forty-two messages for seven processes. The flooding protocol of chapter four repeats that for f plus one rounds. Against a third of the processes failing, that is about a third of n cubed. The original Byzantine protocol of Lamport, Shostak and Pease is far worse: processes relay every chain of names, and the count grows like n to the power f plus one. We count the messages correct processes send, or the words they carry, a value or a signature each. Which of this cost is necessary?
In 1985 Danny Dolev and Rüdiger Reischuk showed that much of it is. Every deterministic Byzantine agreement protocol has runs in which the correct processes send on the order of n plus f squared messages, and signatures do not help. Draw who sends to whom as a matrix; all-to-all fills it. The proof finds a set V of f over two processes, each of which must hear about f over two messages: at least f squared over four. Allow the most faults, a third of n, and that is about n squared over thirty-six: quadratic, whatever the protocol. They also showed that authenticated protocols need on the order of n times f signatures.
Here is the heart of it, as Ittai Abraham and colleagues retold it in 2019. Suppose a protocol always sends fewer than f over two, squared, messages. Corrupt a set V of f over two processes, which behave honestly but ignore the first f over two messages each receives. With so few messages, some member p of V receives fewer than f over two: it ignores everything. Now a second world: p is honest, and the few processes that wrote to p are corrupted instead, silent towards it. Still fewer than f faults. Everyone else sees the first world again. p, hearing nothing, decides some fixed value b; give the sender the other value, and validity makes the rest decide it.
Practical protocols meet this cost in different ways. PBFT, Miguel Castro and Barbara Liskov's protocol of 1999, has every replica send its vote to every other: n times n minus one messages in each phase. HotStuff, from Maofan Yin, Dahlia Malkhi, Michael Reiter, Guy Golan Gueta and Ittai Abraham in 2019, sends the votes to the leader instead. The leader combines two f plus one votes into one threshold signature, a quorum certificate, and sends that single word back: two times n minus one messages a phase. Linear instead of quadratic, and it stays linear when a leader is replaced, where PBFT's view change costs on the order of n cubed words.
Does that beat Dolev and Reischuk? No. A faulty leader can simply stay silent; its view is wasted, and HotStuff moves on to the next leader. With f bad leaders in a row, each view costs about n words, so the total is f times n, and with f a third of n that is quadratic again. The lower bound is about the worst case, and the worst case is a run of bad leaders. And the bound is tight. Protocols that are quadratic in the worst case were found for synchrony by Atsuki Momose and Ling Ren in 2021, and for partial synchrony by Pierre Civit and colleagues in 2022.
The bound is for deterministic protocols. What does randomness buy? Choose a small random committee, let it agree among itself, and have it tell everyone: c squared plus c times n messages. If under a third of all processes are faulty, a random committee is half faulty only with probability exponentially small in its size, so a committee of logarithmic size will do, and the cost falls to about n log n. The catch is an adaptive adversary, who corrupts the committee once it is known. Algorand, by Jing Chen and Silvio Micali, lets members select themselves secretly and speak only once. But against an adversary who can also erase messages already sent, Abraham and colleagues showed that even randomized protocols need f squared. Randomness also buys time: Pesech Feldman and Silvio Micali reached a constant expected number of rounds.
10Population protocolsResearch4 min
The last model is the most minimal of all. In 2004 Dana Angluin, James Aspnes, Zoë Diamadi, Michael Fischer and René Peralta imagined tiny sensors carried by a flock of birds. The agents are anonymous, and each is a finite-state machine whose number of states does not grow with the population. A random scheduler picks two agents at a time, and both update by one fixed rule. Time is counted in parallel time: interactions divided by n. The simplest protocol is an epidemic. One informed agent informs whoever it meets, and everyone knows in logarithmic parallel time. No agent ever learns that the computation is over; the answer only has to stabilise.
Can such agents decide which of two opinions is in the majority? Four states suffice: strong opinions A and B, and weak ones, small a and small b. When two strong opposite opinions meet, both become weak. A strong agent converts a weak agent of the other side. Watch the difference between the strong counts. Cancelling removes one strong A and one strong B, and converting touches only weak agents, so strong A minus strong B is the initial margin, for ever. If A started ahead, strong As never run out; strong Bs must, since while both remain they keep meeting; and then every weak b is converted. Everyone outputs A. It is always right, though a tie never settles.
Here is our instrument's run: a hundred agents, fifty-two for A and forty-eight for B, a margin of four. Strong agents are filled, weak ones hollow. Within a few units of parallel time most strong opinions have cancelled. The strong counts fall together, and their difference never moves: twenty-seven minus twenty-three, down to four minus zero. The last strong B is gone by time twenty. Then four strong As must find every remaining weak b, and that slow mop-up takes most of the time. After fifty-eight units, every agent says A.
Why so slow? Look at the mop-up. With m strong As left, a particular weak b meets one of them in a given interaction with probability two m over n times n minus one. With k weak bs left, some b converts with k times that probability. Waiting for each in turn gives a harmonic sum, and dividing by n gives about n over two m, times the natural logarithm of n. Our instrument ran margin two with fifty, a hundred, two hundred and four hundred agents: sixty-four, a hundred and thirty-six, two hundred and eighty-four and six hundred and seventy-three units, close to the estimate. More states make it far faster: in 2021 David Doty and colleagues reached logarithmic time with logarithmically many states.
What, exactly, can a population compute? A classic example: are at least five birds sick? Each agent counts up to five. When two meet, one takes the sum and the other drops to zero; once a sum reaches five, both say yes, and yes spreads like an epidemic. Majority is the same kind of question: x A greater than x B means x A minus x B is at least one, a threshold. Thresholds, remainders and their combinations are the semilinear predicates, those of Presburger arithmetic. Angluin and colleagues showed that all of them can be computed, and in 2006 Angluin, Aspnes and Eisenstat showed that nothing else can. Squares and powers of two are not. Chemical reaction networks are the same model with molecules; without errors they compute exactly the semilinear functions, and DNA can implement them.
11Frontier: the complexity of localityResearch1 min
Which local problems need how many rounds? Linial's bound has grown into a theory. A locally checkable labelling is a problem whose solution each node can verify by looking at its neighbourhood, like a colouring. Moni Naor and Larry Stockmeyer introduced them in 1995. On rings and paths, every such problem takes either constant time, or log star time, or time linear in n, and nothing in between. Three colours is log star; two colours on an even ring is linear, because a node must know the parity of its position. On trees and general graphs the landscape is richer, and charting it, with tools such as round elimination, is active research.
Three threads have moved fast. In 2020 Václav Rozhoň and Mohsen Ghaffari showed how to split any network into clusters of small diameter deterministically in polylogarithmic rounds, a question open for decades, and many deterministic algorithms followed from it. In the CONGEST model each message is only logarithmically many bits, and shortest paths, cuts and matchings get lower bounds from communication complexity. And how much randomness helps locality is still being settled, problem by problem. The same ideas now run inside ordinary algorithms, giving fast parallel and sublinear-time methods.
Recap, problems, and where this comes backAll tracks2 min
What we built in this part. Models of distributed computation, and the faults they allow. Cole and Vishkin's colouring of a million-node ring in seven rounds, and Linial's proof that log star is unavoidable. The f plus one round bound for crashes, and the hexagon that shows three processes cannot survive one liar. Randomized consensus that escapes FLP; the consensus hierarchy of shared objects; the topological proof that k-set agreement is impossible; failure detectors; and protocols for populations of anonymous agents. One idea runs through it: in a distributed system, what each process cannot know limits what all of them can do.
Where this comes back. Part 60's accelerators are networks of processing elements that pass messages to neighbours. Part 61 asks how to choose an open problem and measure honestly. And looking back, it is the theory under Part 38's consensus, Part 39's replication, and the protocols Part 54 checked.
In practice. State the fault model: which failures, and how many. For Byzantine faults no protocol can tolerate a third or more of the processes lying. Use partial synchrony: safety always, progress once the network settles. Use randomness to break symmetry where determinism cannot. And spread state by gossip, which reaches everyone in a logarithmic number of rounds.
Six problems, with full solutions in the part's notes. Pause on any of them. The fifth is a build problem: implement Ben-Or's randomized consensus and measure how its rounds grow. The last, marked with a star, is a research problem: matching bounds for maximal independent set in the LOCAL model.
Next time, Part 60: hardware built for one job. When the free speedups ended, the answer was specialization. We build a systolic array in Pebble's gate simulator, put it on the roofline, and end with the Job in hardware.
The books and papers this part follows are on screen and in the notes. Thank you for watching.
Where it goes next. Part 60's accelerators are networks of cells that pass values to their neighbours, the same picture as the LOCAL model. Part 61 asks how to choose an open problem and how to measure honestly. Looking back, this is the theory under Part 38's consensus, Part 39's replication and the protocols Part 54 checked.
Key results
The part's results in one place, for revision.
Try it
Lab 59 · Locality, a liar and a lemma
Run Cole and Vishkin's colouring on oriented rings of ten to a million nodes and compare the rounds with log* n and the colours with the bound the bit trick allows; run the hexagon argument against a three-process majority protocol; and check Sperner's lemma on 200 random colourings.
python -m videos.cs.labs 59
needs numpy, scipy, matplotlib · download lab59.py ·
source on GitHubring size n 10 100 1,000 10,000 100,000 1,000,000
rounds used 5 6 7 7 7 7
log* n 3 4 4 4 5 5
colours after each round, n = 1,000,000 38 12 8 6 5 4 3
the bound 2b for those rounds 42 12 8 6 5 4 3
hexagon: decisions of A0 B0 C0 A1 B1 C1 0 0 0 1 1 1
pairs that break agreement or validity C0-A1, C1-A0 (theory: at least one)
rainbow triangles in 200 random colourings 7 to 37, odd in 200 of 200 (theory: all)
exact majority, 52 against 48 correct in 100% of 10 runs, mean parallel time 56
A ring of a million nodes is 3-coloured in 7 rounds because each round replaces a colour by the position of one bit; the hexagon and Sperner's lemma are the counting arguments behind two impossibility theorems, and here they are run.
The code (88 lines; it asserts its own result)
"""Lab 59: 3-colour rings of up to a million nodes, run the hexagon against a protocol, and count Sperner's triangles."""
from videos.coursekit import labs # noqa: I001 (must stay first: it lets explainer.cs import without manim)
import math
import numpy as np
from explainer.cs.disttheory import theory
TITLE = "Locality, a liar and a lemma"
GOAL = ("Run Cole and Vishkin's colouring on oriented rings of ten to a million nodes and compare the rounds with "
"log* n and the colours with the bound the bit trick allows; run the hexagon argument against a three-process "
"majority protocol; and check Sperner's lemma on 200 random colourings.")
TASKS = [
"Give every node the same identifier before the first round (c[:] = 7 in cole_vishkin). Which line fails, and "
"what does that say about anonymous rings?",
"Change _protocol to decide the minimum of what a process heard instead of the majority, and rerun hexagon(). "
"Which pairs break now, and why must some pair always break?",
"In sperner(), let the vertices on the side between corners 0 and 1 take colour 2 as well. Find a colouring with "
"an even number of rainbow triangles.",
]
def run(seed=0):
lab = labs.Lab()
# 1. Cole-Vishkin: proper, about log* n rounds, colours within the bound b bits -> 2 b colours
ns = (10, 100, 1000, 10_000, 100_000, 1_000_000)
runs = [theory.cole_vishkin(n, seed=seed) for n in ns]
for r in runs:
assert r["proper"], "three colours, different on every edge"
assert r["rounds"] <= r["log_star"] + 3, "log* n plus two or three rounds"
assert r["rounds"] >= 0.5 * r["log_star"] - 1, "Linial: no algorithm does better"
lab.row("ring size n", " ".join(f"{n:,}" for n in ns))
lab.row("rounds used", " ".join(str(r["rounds"]) for r in runs))
lab.row("log* n", " ".join(str(r["log_star"]) for r in runs))
big = runs[-1]
bits = math.ceil(math.log2(ns[-1] + 2 ** 20)) # identifiers lie below n + 2^20
bound, colours = [], big["colours"]
for used in colours[1:-3]: # the bit-position rounds: b-bit colours become colours below 2 b
bound.append(2 * bits)
assert used <= bound[-1], "a b-bit colour becomes a pair (bit position, bit): at most 2 b of them"
bits = math.ceil(math.log2(2 * bits))
assert colours[-3:] == [5, 4, 3], "the clean-up removes colours 5, 4 and 3"
lab.row("colours after each round, n = 1,000,000", " ".join(f"{c:,}" for c in colours[1:]))
lab.row("the bound 2b for those rounds", " ".join(str(b) for b in bound) + " 5 4 3")
# 2. the hexagon: a three-process protocol cannot survive one liar
hx = theory.hexagon()
broken = sorted(tuple(p["pair"]) for p in hx["violations"])
lab.row("hexagon: decisions of A0 B0 C0 A1 B1 C1", " ".join(str(hx["decisions"][k]) for k in hx["names"]))
lab.row("pairs that break agreement or validity", ", ".join(f"{a}-{b}" for a, b in broken) + " (theory: at least one)")
assert len(broken) >= 1, "n = 3, f = 1: some adjacent pair must fail"
assert all(p["byzantine"] == "B" for p in hx["violations"]) and broken == [("C0", "A1"), ("C1", "A0")]
# 3. Sperner's lemma: the number of rainbow triangles is odd
counts = np.array([theory.sperner(k=10, seed=1000 * seed + s)["count"] for s in range(200)])
lab.row("rainbow triangles in 200 random colourings", f"{counts.min()} to {counts.max()}, odd in "
f"{int((counts % 2 == 1).sum())} of 200 (theory: all)")
assert np.all(counts % 2 == 1), "Sperner: an odd number, so at least one"
# 4. exact majority by four states: #A - #B never changes, so the majority wins
maj = theory.majority(n=100, margin=4, trials=10, seed=seed)
strong = [h["A"] - h["B"] for h in maj["trace"]]
lab.row("exact majority, 52 against 48", f"correct in {maj['correct']:.0%} of 10 runs, mean parallel time "
f"{maj['parallel_time_mean']:.0f}")
assert maj["correct"] == 1.0 and set(strong) == {4}, "the strong margin is invariant"
lab.note = ("A ring of a million nodes is 3-coloured in 7 rounds because each round replaces a colour by the "
"position of one bit; the hexagon and Sperner's lemma are the counting arguments behind two "
"impossibility theorems, and here they are run.")
fig, ax = labs.figure(2, size=(11, 4.4))
rounds = np.arange(len(colours))
ax[0].plot(rounds, colours, "o-", color=labs.BLUE, label="colours in use, n = 1,000,000")
ax[0].plot(rounds[1:], bound + [5, 4, 3], "--", color=labs.MUTED, label="allowed: 2b, then 5, 4, 3")
ax[0].axhline(3, color=labs.GREEN, lw=1, label="three colours")
ax[0].set(yscale="log", xlabel="round", ylabel="colours", title="Cole-Vishkin: a million colours to three")
ax[0].legend()
values = np.arange(counts.min() - 1, counts.max() + 2)
ax[1].bar(values, [(counts == v).sum() for v in values],
color=[labs.GOLD if v % 2 else labs.RED for v in values], width=0.8)
ax[1].set(xlabel="rainbow triangles among the 100 small ones", ylabel="colourings of 200",
title="Sperner's lemma: the count is always odd")
ax[1].set_axisbelow(True)
ax[1].text(0.98, 0.94, "even counts: none", transform=ax[1].transAxes, ha="right", va="top", color=labs.MUTED)
lab.fig = fig
return lab
Now change it
- Give every node the same identifier before the first round (c[:] = 7 in cole_vishkin). Which line fails, and what does that say about anonymous rings?
- Change _protocol to decide the minimum of what a process heard instead of the majority, and rerun hexagon(). Which pairs break now, and why must some pair always break?
- In sperner(), let the vertices on the side between corners 0 and 1 take colour 2 as well. Find a colouring with an even number of rainbow triangles.
Problems, with solutions
Try each problem before opening its solution.
-
Cole–Vishkin. Prove that one Cole–Vishkin step keeps neighbouring colours different.
Solution
On an oriented ring let w = succ v, and suppose the current colouring c is proper, so c_v ≠ c_w and their binary expansions differ somewhere. Node v takes i_v, the lowest index at which c_v and c_w differ, and its new colour c′(v) = 2i_v + c_v[i_v]; node w does the same against its own successor, so c′(w) = 2i_w + c_w[i_w]. Since a bit is 0 or 1, the number 2i + b determines i (as ⌊(2i + b)/2⌋) and b (as its parity). So if c′(v) = c′(w), then i_v = i_w = i and c_v[i] = c_w[i]; but i = i_v was chosen as an index where c_v and c_w differ, a contradiction. Hence c′ is proper whatever the colours were, the step can be repeated, and since each node reads only its own colour and its successor's, all nodes take it in the same round. In our run node 0 has identifier 1,999,591 = 111101000001011100111₂ and its successor 1,664,200 = 110010110010011001000₂; they differ at bit 0, where v has a 1, so c′(v) = 2·0 + 1 = 1. In round 3, colours 1 = 001₂ and 5 = 101₂ first differ at bit 2, where v has a 0, so v becomes 4. With b-bit colours, i ≤ b − 1 and c′ ≤ 2b − 1, so the 21-bit identifiers leave at most 42 colours after one round; the run used 38.
-
FloodSet. Show that FloodSet with f crashes reaches agreement in f + 1 rounds.
Solution
Each process starts with W = {its input}; in each synchronous round it sends W to everyone and adds every set it receives; after f + 1 rounds it decides min W. Termination is by construction, and validity holds because W only ever contains inputs (if every input is v, W = {v}). For agreement: at most f processes crash and there are f + 1 rounds, so by the pigeonhole principle some round r has no crash. Let L be the processes alive at the start of round r. None of them crashes during r, so each sends its set to all, and every process alive at the end of round r holds U = ⋃_{p ∈ L} W_p (its own set is among them). From then on every message carries U, and a union of copies of U is U, so all processes alive after the last round hold U and decide min U. A crash in an earlier round, delivering its last message to only some processes, is exactly what makes the sets differ, and a clean round repairs it. Our instrument checked every input vector and every crash pattern (who crashes, in which round, and which of its last messages arrive): with f + 1 rounds, agreement held in all 200 runs for n = 3, f = 1, all 1,040 for n = 4, f = 1, and all 56,848 for n = 4, f = 2; with f rounds or fewer it found a violating run every time, such as Chapter 4's chain of crashes passing a 0 to one new process per round. The chain argument of Chapter 4 shows no algorithm does better when n ≥ f + 2.
-
The hexagon. Use the hexagon argument to show that 3 processes cannot tolerate 1 Byzantine fault.
Solution
Suppose a deterministic protocol for processes A, B and C, without signatures, solves Byzantine agreement (agreement, validity, termination) whenever at most one of them is faulty. Build a system S of six copies wired in a ring, A0 B0 C0 A1 B1 C1, each running its letter's code with its two ring neighbours in the places of the other two letters (A0 talks to C1 and B0), the copies with index 0 having input 0 and those with index 1 input 1. S is not a run of the protocol, but every copy behaves deterministically in it. Take any two neighbours in S, say A0 and B0. Their views in S are exactly their views in a three-process run in which A and B are correct with inputs 0 and 0 and C is Byzantine, showing A the behaviour of C1 and B the behaviour of C0 (C can compute both, by simulating S). In that run A and B decide in finite time, so A0 and B0 decide in S, and by validity both decide 0. Likewise A1 and B1, with C the liar, decide 1. The pair B0 and C0 sees a run with A faulty, so by agreement C0 decides as B0, 0; the pair C0 and A1 sees a run with B faulty and inputs 0 and 1, so by agreement A1 decides as C0, 0. But A1 decides 1: a contradiction, so no such protocol exists. For n ≤ 3f, split the processes into three groups of at most f and let A, B and C each simulate one group: a protocol for n processes tolerating f faults would give one for three tolerating one. Our instrument ran a natural deterministic two-round protocol (decide the majority of your input and the four values relayed to you) on the hexagon: A0, B0 and C0 decide 0 and A1, B1 and C1 decide 1, so validity holds for both pairs with equal inputs, and agreement fails exactly on the edges C0–A1 and C1–A0, the two pairs that see a run in which B lies. With signatures the argument fails, because C cannot forge what A1 signed when talking to B0: Dolev and Strong's protocol tolerates any number of faults.
-
Sperner's lemma. Prove Sperner's lemma in two dimensions by counting doors.
Solution
Subdivide a triangle with corners coloured 0, 1 and 2 into small triangles, and colour each vertex on a side with one of that side's two corner colours, interior vertices arbitrarily. Call an edge coloured 0–1 a door. Count pairs (small triangle, door on its boundary) in two ways. By triangles: a rainbow triangle (colours 0, 1, 2) has exactly one door; a triangle coloured 0, 0, 1 or 0, 1, 1 has two; any other has none, since it lacks a 0 or a 1. So the count is #rainbow + 2(…). By doors: an interior door borders two small triangles and a boundary door one, so the count is 2D_in + D_∂. Hence #rainbow ≡ D_∂ (mod 2). The sides from 0 to 2 and from 1 to 2 use only colours {0, 2} and {1, 2}, so every boundary door lies on the side from 0 to 1. Walking along that side from corner 0 to corner 1, the colour starts at 0, ends at 1 and takes only the values 0 and 1, so it switches an odd number of times: D_∂ is odd, and so is the number of rainbow triangles, which is therefore at least one. (The same count gives a search: enter through a boundary door and keep leaving each triangle by its other door; the walk never revisits a triangle, so it either stops in a rainbow triangle or leaves through another boundary door, and since the boundary doors are odd in number, some walk must stop in a rainbow triangle.) In our example, k = 8, the side from 0 to 1 is coloured 0 0 1 0 1 1 0 0 1, which has 5 doors; of the 64 small triangles 19 have one door, 5 have two and 40 have none, so the triangle count is 19 + 10 = 29 = 2·12 + 5, with 12 interior doors, and 19 is odd. The 200 further random colourings (k = 10) gave 7 to 37 rainbow triangles, always odd.
-
Build. Implement Ben-Or's consensus and measure its rounds against n with split inputs.
Solution
Solution notes. Start from
ben_orinexplainer/cs/dist/consensus.pyand the harnessben_or_roundsinexplainer/cs/disttheory/theory.py, but make the asynchrony real. Run the processes on an event queue with random message delays, as Part 38's Raft network does; a process in phase r broadcasts (r, report, x), waits for n − f reports of phase r, broadcasts (r, proposal, v or ?), waits for n − f proposals of phase r, and buffers messages of later phases. Propose v if more than n/2 of all n reports are v; decide v on more than f proposals of v, adopt v on at least one, and otherwise flip a private coin; a process that decides keeps taking part for one more phase so that others can finish. Crash up to f processes at random times, possibly in the middle of a broadcast, and check agreement, validity and termination in every run. Measure the phase in which the last correct process decides, over many seeds, for n = 4, 6, 8, 10, … with f = n/2 − 1 and inputs split half and half. For comparison, our instrument (f crashed from the start, 200 runs each) took 4.8, 9.3, 18.2 and 33.9 phases on average. There, every live process hears the same n − f = n/2 + 1 reports, more than n/2 equal only if all are, so a phase succeeds only when all n − f coins agree, with probability 2^{1−(n−f)}; the expected decision phase is 1 + 2^{n−f−1}, that is 5, 9, 17 and 33, matching the measurement and doubling with every two processes. With random delays and late crashes, processes hear different subsets and the numbers change, but private coins can still need exponentially many phases in n. Then replace the private coin by a common coin (one random bit per phase seen by all, here simply shared by the simulator) and observe a constant expected number of phases. -
★ Research. The deterministic LOCAL complexity of maximal independent set.
Discussion. Open. A maximal independent set takes Θ(log* n) rounds on rings and paths, and O(Δ + log* n) on graphs of maximum degree Δ (Barenboim, Elkin and Kuhn), but on general graphs the deterministic complexity as a function of n is not known. Since Rozhoň and Ghaffari's network decomposition (2020) it is polylogarithmic, and later work has lowered the exponent; the best lower bound for deterministic algorithms is Ω(min{Δ, log n / log log n}) (Balliu, Brandt, Hirvonen, Olivetti, Rabie and Suomela 2019, by round elimination), with Kuhn, Moscibroda and Wattenhofer's earlier bounds, which hold even for randomized algorithms. The gap is therefore between about log n / log log n and a power of log n larger than one. A full answer would give matching upper and lower bounds up to constant factors; good partial answers would push the lower bound above log n, bring the upper bound down to O(log n) or below, or settle the question on a natural family of graphs.
Notes and sources
Glossary
- synchronous, asynchronous, partial synchrony — lockstep rounds; no bound on delays or speeds; bounds that hold only eventually.
- message passing, shared memory, atomic register — sending along links; reading and writing shared objects; a register whose operations appear instantaneous.
- crash, omission and Byzantine faults; n and f — stopping for ever; losing messages; arbitrary behaviour, including lies; processes in all and faulty ones at most.
- consensus: agreement, validity, termination — no two correct processes decide differently; equal inputs force the decision; every correct process decides.
- LOCAL, CONGEST, radius-t view, diameter — synchronous rounds with unbounded messages; the same with O(log n) bits a link a round; what a node knows after t rounds; the rounds that suffice for anything in LOCAL.
- oriented ring, proper colouring, Cole–Vishkin (deterministic coin tossing), log n* — a ring where each node knows its successor; neighbours coloured differently; the bit-position step; logarithms taken until reaching 1.
- neighbourhood graph, speed-up lemma, round elimination — windows of ids joined to their shifts; one id shorter, exponentially more colours; turning a t-round algorithm into a (t − 1)-round one for a derived problem.
- locally checkable labelling (LCL), network decomposition, maximal independent set — a problem whose solution each node can verify locally; clusters of small diameter coloured with few colours; pairwise non-adjacent nodes to which no node can be added.
- FloodSet, clean round, chain argument, hexagon argument — flooding the values seen and deciding the minimum; a round with no crash; runs linked by indistinguishability; six honest copies fooling a three-process protocol.
- authenticated (signed) agreement, Dolev–Strong — agreement with unforgeable signatures, for any number of faults in f + 1 rounds.
- valency: bivalent, univalent (0- and 1-valent), critical configuration, decisive step — whether both decisions are still reachable; a configuration whose every next step fixes the outcome; a step that would decide.
- randomized consensus, private coin, common coin — Ben-Or's escape from FLP; coins each process flips alone; one coin seen alike by all.
- wait-free, snapshot, double collect, consensus number, universality — progress whatever the others do; reading all registers at one instant; two equal reads in a row; the most processes an object lets agree; consensus builds any object.
- simplicial complex, simplex, chromatic subdivision, immediate snapshot — values that can occur together, drawn as a shape; one round of reading, drawn as a subdivided triangle.
- Sperner colouring, rainbow triangle, door — corners distinct, sides from their ends; a small triangle with all three colours; an edge coloured 0–1.
- k-set agreement, asynchronous computability theorem — at most k different decisions; solvability as the existence of a colour-preserving map from a subdivision.
- failure detector, completeness, accuracy, P, S, ◇P, ◇S, Ω — a module of suspicions; crashed processes are suspected; correct ones are not, always or eventually; the classes; an eventual common leader.
- heartbeat, timeout, φ accrual, SWIM — periodic messages; a deadline for them; suspicion as −log₁₀ of the chance a heartbeat is still on its way; probing random members and gossiping verdicts.
- message and word complexity, Dolev–Reischuk bound, quorum certificate, threshold signature, view change — messages or values and signatures sent; Ω(n + f²); 2f + 1 votes in one signature; replacing a leader.
- adaptive adversary, committee, after-the-fact removal — corruption chosen as the protocol runs; a random subset that agrees for all; erasing messages already sent.
- population protocol, parallel time, stable computation — anonymous finite-state agents meeting in random pairs; interactions divided by n; outputs that eventually stop changing.
- exact and approximate majority, semilinear predicate, chemical reaction network — always right and slow, or fast and right with high probability; Boolean combinations of thresholds and remainders; molecules as agents.
Sources
- N. Lynch, Distributed Algorithms (1996); H. Attiya and J. Welch, Distributed Computing: Fundamentals, Simulations, and Advanced Topics (2nd ed., 2004); M. Herlihy, D. Kozlov and S. Rajsbaum, Distributed Computing through Combinatorial Topology (2013); D. Peleg, Distributed Computing: A Locality-Sensitive Approach (2000).
- R. Cole and U. Vishkin, "Deterministic coin tossing with applications to optimal parallel list ranking", Information and Control 1986; N. Linial, "Locality in distributed graph algorithms", SIAM J. Comput. 1992 (FOCS 1987); S. Brandt, "An automatic speedup theorem for distributed problems", PODC 2019.
- M. Naor and L. Stockmeyer, "What can be computed locally?", SIAM J. Comput. 1995; Y.-J. Chang and S. Pettie, "A time hierarchy theorem for the LOCAL model", FOCS 2017; V. Rozhoň and M. Ghaffari, "Polylogarithmic-time deterministic network decomposition and distributed derandomization", STOC 2020; A. Balliu, S. Brandt, J. Hirvonen, D. Olivetti, M. Rabie and J. Suomela, "Lower bounds for maximal matchings and maximal independent sets", FOCS 2019.
- L. Lamport, R. Shostak and M. Pease, "The Byzantine generals problem", TOPLAS 1982; M. Fischer and N. Lynch, "A lower bound for the time to assure interactive consistency", Information Processing Letters 1982; D. Dolev and H. R. Strong, "Authenticated algorithms for Byzantine agreement", SIAM J. Comput. 1983; M. Fischer, N. Lynch and M. Merritt, "Easy impossibility proofs for distributed consensus problems", Distributed Computing 1986.
- M. Fischer, N. Lynch and M. Paterson, "Impossibility of distributed consensus with one faulty process", J. ACM 1985; M. Ben-Or, "Another advantage of free choice: completely asynchronous agreement protocols", PODC 1983; G. Bracha, "Asynchronous Byzantine agreement protocols", Information and Computation 1987; C. Dwork, N. Lynch and L. Stockmeyer, "Consensus in the presence of partial synchrony", J. ACM 1988.
- H. Attiya, A. Bar-Noy and D. Dolev, "Sharing memory robustly in message-passing systems", J. ACM 1995; M. Herlihy, "Wait-free synchronization", TOPLAS 1991; Y. Afek, H. Attiya, D. Dolev, E. Gafni, M. Merritt and N. Shavit, "Atomic snapshots of shared memory", J. ACM 1993.
- S. Chaudhuri, "Agreement is harder than consensus: set consensus problems in totally asynchronous systems", PODC 1990; E. Borowsky and E. Gafni, "Generalized FLP impossibility result for t-resilient asynchronous computations", STOC 1993, and "Immediate atomic snapshots and fast renaming", PODC 1993; M. Herlihy and N. Shavit, "The topological structure of asynchronous computability", J. ACM 1999 (STOC 1993); M. Saks and F. Zaharoglou, "Wait-free k-set agreement is impossible: the topology of public knowledge", SIAM J. Comput. 2000 (STOC 1993); E. Sperner, "Neuer Beweis für die Invarianz der Dimensionszahl und des Gebietes", Abh. Math. Sem. Univ. Hamburg 1928.
- T. Chandra and S. Toueg, "Unreliable failure detectors for reliable distributed systems", J. ACM 1996; T. Chandra, V. Hadzilacos and S. Toueg, "The weakest failure detector for solving consensus", J. ACM 1996; N. Hayashibara, X. Défago, R. Yared and T. Katayama, "The φ accrual failure detector", SRDS 2004; A. Das, I. Gupta and A. Motivala, "SWIM: scalable weakly-consistent infection-style process group membership protocol", DSN 2002.
- D. Dolev and R. Reischuk, "Bounds on information exchange for Byzantine agreement", J. ACM 1985; I. Abraham, T.-H. H. Chan, D. Dolev, K. Nayak, R. Pass, L. Ren and E. Shi, "Communication complexity of Byzantine agreement, revisited", PODC 2019; M. Castro and B. Liskov, "Practical Byzantine fault tolerance", OSDI 1999; M. Yin, D. Malkhi, M. Reiter, G. Golan Gueta and I. Abraham, "HotStuff: BFT consensus with linearity and responsiveness", PODC 2019; A. Momose and L. Ren, "Optimal communication complexity of authenticated Byzantine agreement", DISC 2021; P. Civit et al., "Byzantine consensus is Θ(n²): the Dolev–Reischuk bound is tight even in partial synchrony!", DISC 2022; J. Chen and S. Micali, "Algorand: a secure and efficient distributed ledger", Theoretical Computer Science 2019; P. Feldman and S. Micali, "An optimal probabilistic protocol for synchronous Byzantine agreement", SIAM J. Comput. 1997.
- D. Angluin, J. Aspnes, Z. Diamadi, M. Fischer and R. Peralta, "Computation in networks of passively mobile finite-state sensors", PODC 2004 (Distributed Computing 2006); D. Angluin, J. Aspnes and D. Eisenstat, "Stably computable predicates are semilinear", PODC 2006, and "A simple population protocol for fast robust approximate majority", Distributed Computing 2008; M. Draief and M. Vojnović, "Convergence speed of binary interval consensus", SIAM J. Control Optim. 2012; G. Mertzios, S. Nikoletseas, C. Raptopoulos and P. Spirakis, "Determining majority in networks with local interactions and very small local memory", ICALP 2014; D. Doty, M. Eftekhari, L. Gąsieniec, E. Severson, G. Stachowiak and P. Uznański, "A time and space optimal stable population protocol solving exact majority", FOCS 2021.
- L. Cardelli and A. Csikász-Nagy, "The cell cycle switch computes approximate majority", Scientific Reports 2012; H.-L. Chen, D. Doty and D. Soloveichik, "Deterministic function computation with chemical reaction networks", DNA Computing and Molecular Programming 2012; D. Soloveichik, G. Seelig and E. Winfree, "DNA as a universal substrate for chemical kinetics", PNAS 2010.
About this partfrom its README
Part 59 of a sixty-one-part course in computer science (see the series plan and the syllabus), the fourth part of Act XI, The Research Frontier. Part 38 proved that consensus is impossible in one model and built Raft in another; this part is the theory underneath: what n processes can and cannot compute when each sees only its neighbours, or may crash, or may lie. Some of the answers are lower bounds as sharp as log* n, and one of them came from algebraic topology.
The instruments are in explainer/cs/disttheory/ (tested in tests/test_cs59_disttheory.py), with two of Part 38's
reused:
disttheory/theory.py: log* n; Cole and Vishkin's 3-colouring of an oriented ring of a million nodes in numpy (each round the bit-position step, every node at once, with the colouring checked proper on every edge; then three rounds that remove colours 5, 4 and 3), the colours left after each round, and the first 24 nodes' colours for drawing; the rounds against log* n from 10 to a million nodes; the log* table up to 2^65536; the hexagon argument run against a natural deterministic two-round majority protocol for three processes (six copies A0 B0 C0 A1 B1 C1 wired in a ring with inputs 0 0 0 1 1 1, each adjacent pair checked for validity and agreement); FloodSet's table and Ben-Or's rounds, wrapping the two Part 38 instruments below; Sperner colourings of a triangle cut into k² small triangles (corners fixed, sides from their ends' colours, interiors at random), with the rainbow triangles listed and a 200-trial parity check; and the four-state exact-majority population protocol under a random pairwise scheduler: one run's counts per unit of parallel time, and parallel time against n.dist/consensus.py(Part 38):floodset, checked against every input vector and every crash pattern (who crashes, in which round, and which of its last messages still arrive);ben_or, Ben-Or's randomized binary consensus with f processes crashed from the start and each live process hearing n − f reports per vote. (Since exactly n − f processes are then alive, every process hears all of them, so the runs are randomized only by the coins; see Problem 5.)
The chromatic subdivisions of Chapter 7, and the decide-the-smallest-id protocol run on them, are computed in the
scene module s08_topology.py by enumerating ordered partitions; the approximate-majority run and the epidemic of
Chapter 10 are seeded simulations in s11_population.py. The other pictures (Linial's five-id example, the FLP
configuration graphs, the failure-detector timelines, the message matrices) are illustrative and drawn inline.
Chapter notes
- Hook. A million processes on a ring, each knowing only its own identifier and its successor's, must 3-colour themselves: 24 neighbours shown, a million colours at round 0, then 38, 12, 8, 6, 5, 4 and 3 — seven rounds, about log* n. Three questions: what can be computed locally (Linial: Ω(log* n)), what can be agreed (three processes cannot survive one liar; f crashes need f + 1 rounds; asynchrony rules agreement out, Part 38's FLP), and what can be computed at all (k-set agreement, by Sperner's lemma). Part 38 built Raft; this part is the theory underneath. The plan.
- 1. Models and faults. Synchronous lockstep rounds, where a missing message proves a fault, against asynchrony, where a slow process looks like a dead one; partial synchrony (Dwork, Lynch and Stockmeyer 1988) in between, the world Raft lives in. Message passing against shared memory, and Attiya, Bar-Noy and Dolev's 1995 simulation of a register while a majority is correct. Crash inside omission inside Byzantine (Lamport, Shostak and Pease 1982). Consensus (agreement, validity, termination) and the map the part proves: synchronous crashes, any f in f + 1 rounds; Byzantine, n > 3f or signatures; asynchronous, deterministically impossible, randomized with n > 2f (n > 3f for Byzantine, Bracha 1987); shared memory, a hierarchy. LOCAL and CONGEST (Peleg 2000): information moves one hop a round, and every problem takes at most the diameter.
- 2. Locality: colouring a ring. On a 16-node oriented ring, a t-round algorithm is a function of 2t + 1 identifiers in a row; on an anonymous ring no deterministic algorithm can even 2-colour. The bit-position trick on node 0 of our run: identifier 1,999,591 against its successor's 1,664,200, the lowest differing bit is 0, so the new colour is 2·0 + 1 = 1; rounds 2 and 3 tabulated (in round 3 the first difference is at position 2, and v becomes 4). Why neighbours still differ: 2i + b determines i and b. How fast colours shrink: b bits become 1 + ⌈log₂ b⌉, so 21 bits, then 6, 4, 3; the bound allows 42, 12, 8 and 6 colours after rounds 1 to 4, and the run used 38, 12, 8 and 6; at 3 bits the trick stops. The 24 drawn nodes recoloured round by round, then colours 5, 4 and 3 removed (their nodes are never neighbours, so all at once): 7 rounds, proper on every edge of the million. log* 65,536 = 4, log* 2^65536 = 5; rounds against log* n for n = 10, 100, 1,000, 10,000, 100,000 and 1,000,000: 5 against 3, 6 against 4, 7 against 4, 7 against 4, 7 against 5, 7 against 5 — log* n plus two or three.
- 3. Linial's lower bound. Linial (1987; in full 1992): a t-round algorithm properly colours the neighbourhood graph of windows of 2t + 1 ids, hence its subgraph B_{2t+1} of increasing windows; B_1 is the complete graph and needs n colours. The speed-up lemma, χ(B_k) ≤ c ⇒ χ(B_{k−1}) ≤ 2^c, proved by colouring each short window with the set of colours of its extensions. Run on five ids, with B_2 coloured by the highest bit where a − 1 and b − 1 differ: the sets {0, 1, 2}, {1, 2}, {0, 2}, {2} and ∅ are five different sets, at most 2³ = 8 allowed. Iterated: 3, 8, 256, 2^256, … up to n, so log* n ≤ 2t + 2 and t ≥ ½ log* n − 1; for the million-node ring (log* n = 5) every algorithm needs at least 2 rounds, Cole and Vishkin used 7: Θ(log* n). Round elimination as a proof machine, and Brandt's 2019 automatic version for problems on locally tree-like graphs; Linial's O(Δ²) colours in O(log* n) rounds on any graph.
- 4. Synchronous agreement and its bounds. FloodSet on four processes, one crash: process 2, the only holder of a 0, crashes after sending to process 3 alone; process 3 passes it on in round 2; all decide 0; the clean-round argument. An adversary defeats f rounds (f = 2: each crash passes the 0 to one process and dies). Exhaustively checked, every input and crash pattern: for n = 3, f = 1, 1 round can fail (104 runs), 2 always agree (200); for n = 4, f = 1, 528 and 1,040; for n = 4, f = 2, 1 and 2 rounds can fail (6,672 and 25,616 runs) and 3 rounds always agree, all 56,848 runs. Every algorithm needs f + 1 rounds: the chain of runs from all-0 to all-1, one crash per round (Fischer and Lynch 1982; Dolev and Strong 1983; n ≥ f + 2). Three processes cannot survive one liar: the hexagon (Fischer, Lynch and Merritt 1986), run against a natural two-round majority protocol, whose copies decide 0 0 0 1 1 1 and break where they must, C0 against A1 and C1 against A0, with B the liar; n ≤ 3f by grouping. Dolev and Strong's signed relay: any number of faults in f + 1 rounds, and a sender who signs two values is exposed.
- 5. Asynchrony: FLP and randomness. The proof's machinery for three processes (the story was Part 38's). Lemma 1, a bivalent start, from the chain 000, 100, 110, 111 and a process crashed from the start; Lemma 2, any pending step can be delivered into a bivalent configuration, since a decisive step dies in both cases (steps of different processes commute; if both are p's, a finite run σ without p reaches a configuration that is both decided and bivalent); Lemma 3, the run that never decides, with every process stepping, every message delivered and no crash (Fischer, Lynch and Paterson 1985). Ben-Or (1983): two votes and a coin; never two values proposed in a phase; a decision by more than f proposals is adopted by all. Expected phases at most 2^n with private coins. Measured with split inputs and f = 1, 2, 3, 4 crashed, 200 runs each: n = 4, 6, 8 and 10 take 4.8, 9.3, 18.2 and 33.9 phases on average (longest 23, 36, 106 and 192); every run agreed and ended; the mean roughly doubles with every two processes, and a common coin would make it constant.
- 6. Shared memory and the consensus hierarchy. Atomic registers (linearizable, Part 33) and wait-freedom, the shared-memory version of surviving n − 1 crashes. A snapshot from registers: two equal collects in a row, retried when a writer moves; Afek, Attiya, Dolev, Gafni, Merritt and Shavit's 1993 fix (updates embed a scan, borrowed from a process seen moving twice) makes every scan wait-free in at most n + 1 collects. Herlihy's hierarchy (1991): registers and snapshots 1; test-and-set, swap, fetch-and-add, queues and stacks 2 (two-process consensus from a queue holding win and lose); compare-and-swap and LL/SC ∞; no wait-free queue from registers. Registers cannot solve consensus for two, by the cases at a critical configuration (a read, writes to different registers, writes to the same one); test-and-set stops at two, because a third process sees the same memory whoever won; compare-and-swap returns what it found.
- 7. Topology: why k-set agreement is impossible. A task as a map Δ between complexes: two processes' inputs form a square, consensus's outputs two edges. One round of write-then-immediate-snapshot (Borowsky and Gafni 1993) cuts an edge into a path of three, 3^r edges after r rounds, always connected, so some edge joins a 0 and a 1: registers cannot solve consensus. For three processes the chromatic subdivision has 13 triangles after one round (one per ordered partition) and 169 after two, with no holes. Sperner's lemma (1928) on k = 8: 19 rainbow triangles of 64, 5 boundary doors; 200 more random colourings (of a 100-triangle subdivision) have 7 to 37 rainbow triangles, always an odd number. k-set agreement (Chaudhuri 1990): solvable for k > f by deciding the smallest of n − f values; for three processes, k = 2, wait-free, "decide the smallest id seen" after two rounds is a Sperner colouring, and 1 of the 169 triangles is a run with three decisions. Impossible for k ≤ f (Borowsky and Gafni; Herlihy and Shavit; Saks and Zaharoglou, 1993); the asynchronous computability theorem; the 2004 Gödel Prize.
- 8. Failure detectors. Chandra and Toueg (1996): a local oracle of suspicions, described by the mistakes it may make. Heartbeats with a timeout doubled after each false suspicion make an eventually perfect detector ◇P under partial synchrony. Strong and weak completeness, strong, weak and eventual accuracy: eight classes, four after gossiping suspicions (P, S, ◇P, ◇S, with ◇S the weakest). The rotating-coordinator algorithm with ◇S and a correct majority (n = 5, p₅ crashed, a suspected coordinator in round 1, a decision in round 2; two majorities intersect). Why a majority is needed with ◇P (three runs, two halves deciding 0 and 1), and why S needs none. Ω, a leader that is eventually the same correct process everywhere, is the weakest detector for consensus (Chandra, Hadzilacos and Toueg 1996), equivalent to ◇S, and the leader election of Paxos and Raft (Part 38). In practice: φ accrual (Hayashibara, Défago, Yared and Katayama 2004; a threshold of 8 means a mistake would have probability 10⁻⁸) and SWIM (Das, Gupta and Motivala 2002).
- 9. The cost of agreement. One all-to-all round of seven processes: 42 messages; FloodSet's (f + 1)n(n − 1), about n³/3 with f near n/3; Lamport, Shostak and Pease's relays, like n^{f+1}. Dolev and Reischuk (1985): every deterministic Byzantine agreement protocol has runs with Ω(n + f²) messages from correct processes, even with signatures (illustrated for n = 25, f = 8): f²/4, about n²/36 at f = (n − 1)/3; Ω(nf) signatures for authenticated protocols. The proof by starving one process, as retold by Abraham et al. (2019). PBFT (Castro and Liskov 1999), n(n − 1) messages a phase, against HotStuff (Yin, Malkhi, Reiter, Gueta and Abraham 2019), 2(n − 1) with a quorum certificate; PBFT's view change O(n³) words by HotStuff's authors' count. Linear per view, but f silent leaders in a row cost O(fn) = O(n²): the bound is tight (Momose and Ren 2021 in synchrony; Civit et al. 2022 in partial synchrony). Randomness: a committee of size Θ(log n), O(n log n) messages; adaptive adversaries and Algorand (Chen and Micali 2019); Ω(f²) again if sent messages can be erased (Abraham et al. 2019); constant expected rounds (Feldman and Micali).
- 10. Population protocols. Anonymous finite-state agents meeting in random pairs (Angluin, Aspnes, Diamadi, Fischer and Peralta 2004); parallel time; an epidemic among 20 agents; outputs that only stabilise. Exact majority with four states (Draief and Vojnović 2012; Mertzios et al. 2014): #A − #B is invariant, so with a positive margin everyone ends on A; a tie never settles. Our run: 100 agents, 52 for A against 48, a margin of 4; strong counts 27 − 23 after one unit of parallel time, down to 4 − 0; the last strong B gone at time 20, every agent outputs A at time 58. The mop-up, about (n/2m) ln n; with margin 2, 50, 100, 200 and 400 agents take 64, 136, 284 and 673 units (20 runs each, all correct), against the estimate drawn as white ticks; O(log n) time with O(log n) states (Doty et al. 2021). Approximate majority in three states (Angluin, Aspnes and Eisenstat 2008): O(log n) time, correct with high probability when the margin exceeds about √n log n; an illustrative run of 10 x against 6 y; the cell-cycle switch (Cardelli and Csikász-Nagy 2012). Counting sick birds up to five; stably computable = semilinear = Presburger-definable (Angluin et al. 2004 and 2006; Angluin, Aspnes and Eisenstat 2006); chemical reaction networks (Chen, Doty and Soloveichik 2012) and DNA strand displacement (Soloveichik, Seelig and Winfree 2010).
- 11. Frontier: the complexity of locality. On rings and paths every locally checkable labelling (Naor and Stockmeyer 1995) takes O(1), Θ(log* n) or Θ(n) rounds (three-colouring, maximal independent set and maximal matching are log*; two-colouring an even ring is linear); on trees and general graphs the landscape is richer (Chang and Pettie 2017; Balliu et al.), with gaps proved by round elimination. Rozhoň and Ghaffari's deterministic network decomposition (2020); CONGEST lower bounds from communication complexity; randomness against determinism; local ideas inside parallel and sublinear-time algorithms. Four open problems and the ★ research problem.
- Outro. Recap, payoffs (Parts 60, 61; Parts 38, 39 and 54), practice, problems, next part.
Companion material in this repository
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
- Models: synchronous and asynchronous; message passing and shared memory; crash, omission and Byzantine faults.
- The LOCAL model: what a node knows after t rounds; Cole–Vishkin's 3-colouring of a ring in O(log n)*, run.
- Linial's lower bound (1992): no o(log* n) algorithm; round elimination (Brandt 2019) as a proof machine.
- Synchronous consensus: the f + 1 round lower bound; the n > 3f bound for Byzantine agreement, proved by the hexagon argument; authenticated agreement (Dolev–Strong).
- Asynchronous impossibility: FLP revisited (Part 38) as a valency argument; randomized consensus (Ben-Or 1983).
- Shared memory: registers, the consensus hierarchy (Herlihy 1991, callback to Part 33); universality.
- Topology: k-set agreement is impossible (Herlihy & Shavit; Borowsky & Gafni; Saks & Zaharoglou, 1993), via Sperner's lemma; the asynchronous computability theorem.
- Failure detectors (Chandra & Toueg 1996); Ω as the weakest for consensus.
- Lower bounds in communication: the cost of Byzantine agreement (Dolev–Reischuk); recent quadratic bounds.
- Population protocols and the theory of chemical computation.
- Frontier: the complexity theory of locality (LCL classification); distributed graph algorithms (CONGEST); open problems.
- Outro.
Computed: Cole–Vishkin on rings of 10⁶ nodes, rounds against log* n; round elimination steps for sinkless orientation; the hexagon counterexample run; Ben-Or's expected rounds; Sperner colourings of subdivided triangles checked; a population protocol computing majority. Visuals: colours collapsing round by round on a ring; the hexagon of processes fooling a Byzantine protocol; a simplex subdivided, its Sperner triangle found. In practice: the guarantees behind consensus libraries, blockchains' Byzantine assumptions, gossip protocols, self-stabilizing network protocols. Reading: Lynch, Distributed Algorithms; Attiya & Welch, Distributed Computing; Herlihy, Kozlov & Rajsbaum, Distributed Computing through Combinatorial Topology; Peleg, Distributed Computing: A Locality-Sensitive Approach; Linial 1992; Cole & Vishkin 1986; Fischer, Lynch & Paterson 1985; Herlihy & Shavit 1999; Brandt 2019.
中文讲义
本讲的中文部分(与英文版对应)。
习题与解答
-
Cole–Vishkin。 证明 Cole–Vishkin 的一步保持相邻颜色不同。
解答
在有向环上设 w = succ v,并设当前着色 c 是正常着色,所以 c_v ≠ c_w,它们的二进制展开在某一位不同。结点 v 取 i_v 为 c_v 与 c_w 不同的最低位,新颜色为 c′(v) = 2i_v + c_v[i_v];结点 w 对它自己的后继做同样的事,所以 c′(w) = 2i_w + c_w[i_w]。因为一个比特只能是 0 或 1,数 2i + b 唯一确定 i(即 ⌊(2i + b)/2⌋)和 b(即它的奇偶性)。所以若 c′(v) = c′(w),则 i_v = i_w = i 且 c_v[i] = c_w[i];但 i = i_v 正是选作 c_v 与 c_w 不同的一位,矛盾。因此无论原来的颜色 是什么,c′ 都是正常着色,这一步可以重复;而且每个结点只读自己和后继的颜色,所以所有结点在同一轮里同时进行。在我们的 运行中,结点 0 的标识符是 1,999,591 = 111101000001011100111₂,它的后继是 1,664,200 = 110010110010011001000₂;二者在第 0 位就不同,v 在这一位是 1,所以 c′(v) = 2·0 + 1 = 1。第 3 轮中,颜色 1 = 001₂ 和 5 = 101₂ 第一次不同在第 2 位,v 在那里 是 0,于是 v 变成 4。颜色有 b 位时,i ≤ b − 1,c′ ≤ 2b − 1,所以 21 位的标识符在一轮之后至多剩 42 种颜色;实际用了 38 种。
-
FloodSet。 证明在 f 次崩溃下,FloodSet 在 f + 1 轮内达成一致。
解答
每个进程从 W = {自己的输入} 开始;每个同步轮中它把 W 发给所有进程,并把收到的集合都并进来;f + 1 轮后它决定 min W。终止性由构造保证;有效性成立,因为 W 里只有输入值(若所有输入都是 v,则 W = {v})。关于一致性:至多 f 个进程 崩溃,而共有 f + 1 轮,由鸽巢原理,某一轮 r 中没有崩溃。设 L 是第 r 轮开始时活着的进程。它们在第 r 轮中都不崩溃,所以 每个都把自己的集合发给所有进程,第 r 轮结束时每个活着的进程都持有 U = ⋃_{p ∈ L} W_p(它自己的集合也在其中)。此后每条 消息携带的都是 U,若干个 U 的并仍是 U,所以最后一轮之后所有活着的进程都持有 U,都决定 min U。较早一轮里的崩溃只把最后 的消息送到一部分进程,这正是集合出现差别的原因,而干净的一轮把差别抹平。我们的工具检查了每一个输入向量和每一种崩溃 模式(谁崩溃、在哪一轮、它最后的消息还送到了谁):用 f + 1 轮时,n = 3、f = 1 的全部 200 次运行,n = 4、f = 1 的全部 1,040 次,n = 4、f = 2 的全部 56,848 次都达成一致;只用 f 轮或更少时,每一次都找到了破坏一致性的运行,例如第 4 章那条 崩溃之链:每一轮把 0 只传给一个新的进程。第 4 章的链式论证表明,当 n ≥ f + 2 时,没有算法能做得更好。
-
六边形。 用六边形论证证明:3 个进程无法容忍 1 个拜占庭故障。
解答
假设有一个不用签名的确定性协议,在 A、B、C 三个进程中至多一个出故障时总能解决拜占庭一致(一致性、有效性、 终止性)。构造一个由六个副本连成环的系统 S:A0 B0 C0 A1 B1 C1,每个副本运行自己字母的代码,把环上的两个邻居当作另外两 个字母(A0 与 C1 和 B0 通信),下标为 0 的副本输入 0,下标为 1 的输入 1。S 不是协议的一次运行,但其中每个副本的行为都 是确定的。任取 S 中两个相邻的副本,比如 A0 和 B0。它们在 S 中看到的,恰好是一次三进程运行中看到的:A 和 B 正确、输入 都是 0,C 是拜占庭进程,对 A 表现得像 C1,对 B 表现得像 C0(C 可以通过模拟 S 算出这两种行为)。在那次运行中 A 和 B 在 有限时间内做出决定,所以 A0 和 B0 在 S 中也做出决定,由有效性,二者都决定 0。同理,C 撒谎时,A1 和 B1 决定 1。B0 和 C0 这一对看到的是 A 出故障的运行,由一致性,C0 和 B0 一样决定 0;C0 和 A1 这一对看到的是 B 出故障、输入为 0 和 1 的运行, 由一致性,A1 和 C0 一样决定 0。但 A1 决定的是 1:矛盾,所以这样的协议不存在。对 n ≤ 3f,把进程分成三组,每组至多 f 个, 让 A、B、C 各模拟一组:一个容忍 f 个故障的 n 进程协议就会给出一个容忍 1 个故障的三进程协议。我们的工具在六边形上运行了 一个自然的确定性两轮协议(取自己的输入和转发给自己的四个值的多数):A0、B0、C0 决定 0,A1、B1、C1 决定 1,所以两对输入 相同的副本都满足有效性,而一致性恰好在 C0–A1 和 C1–A0 这两条边上被破坏,正是看到“B 在撒谎”的那两对。有了签名,论证就 不成立了,因为 C 无法伪造 A1 在与 B0 通信时签过的内容:Dolev 和 Strong 的协议能容忍任意多个故障。
-
斯佩纳引理。 用数门的方法证明二维的斯佩纳引理(Sperner's lemma)。
解答
把一个三个角分别着色 0、1、2 的三角形剖分成小三角形,边上的顶点用该边两端的颜色之一着色,内部顶点任意着色。 把颜色为 0–1 的边称为门。用两种方式数(小三角形,它边界上的一扇门)这样的对。按三角形数:彩虹三角形(颜色 0、1、2) 恰有一扇门;颜色为 0、0、1 或 0、1、1 的三角形有两扇;其余的没有门,因为缺 0 或缺 1。所以总数是 #彩虹 + 2(…)。按门数: 内部的门与两个小三角形相邻,边界上的门只与一个相邻,所以总数是 2D_in + D_∂。因此 #彩虹 ≡ D_∂ (mod 2)。从 0 到 2 和从 1 到 2 的两条边只用颜色 {0, 2} 和 {1, 2},所以边界上的门都在从 0 到 1 的那条边上。沿这条边从角 0 走到角 1,颜色从 0 开始、以 1 结束,而且只取 0 和 1,所以它切换了奇数次:D_∂ 是奇数,彩虹三角形的个数也是奇数,因此至少有一个。(同样的 计数给出一种搜索:从边界上的一扇门进入,每次从三角形的另一扇门离开;这条路不会重复经过同一个三角形,所以要么停在一个 彩虹三角形里,要么从另一扇边界门出去;边界门的个数是奇数,所以总有一条路停在彩虹三角形里。)在我们的例子 k = 8 中, 从 0 到 1 的边着色为 0 0 1 0 1 1 0 0 1,有 5 扇门;64 个小三角形中,19 个有一扇门,5 个有两扇,40 个没有,所以计数为 19 + 10 = 29 = 2·12 + 5,内部有 12 扇门,而 19 是奇数。另外 200 次随机着色(k = 10)得到 7 到 37 个彩虹三角形,总是 奇数。
-
动手。 实现 Ben-Or 的共识算法,在输入一半一半的情况下测量它的轮数随 n 的变化。
解答
解答要点。 从
explainer/cs/dist/consensus.py里的ben_or和explainer/cs/disttheory/theory.py里的测量框架ben_or_rounds出发,但要让异步成为真的。把进程放在带随机消息延迟的事件队列上运行,就像第38部分的 Raft 网络那样;处于 第 r 阶段的进程广播 (r, report, x),等待 n − f 个第 r 阶段的报告,再广播 (r, proposal, v 或 ?),等待 n − f 个第 r 阶段的 提议,并把更晚阶段的消息缓存起来。若全部 n 个进程中超过 n/2 报告 v,就提议 v;收到超过 f 个 v 的提议就决定 v,至少一个 就采纳 v,否则掷一枚私有硬币;已经决定的进程再参与一个阶段,好让其他进程也能结束。在随机时刻让至多 f 个进程崩溃,可以 在广播的中途,并在每次运行中检查一致性、有效性和终止性。对 n = 4、6、8、10、……,取 f = n/2 − 1、输入一半一半,在许多个 随机种子上测量最后一个正确进程做出决定的阶段。作为对照,我们的工具(f 个进程一开始就崩溃,每组 200 次运行)平均用了 4.8、9.3、18.2 和 33.9 个阶段。在那里,每个活着的进程听到的都是同样的 n − f = n/2 + 1 个报告,超过 n/2 个相同只有在全部相同时 才会发生,所以一个阶段只有当 n − f 枚硬币全部一致时才成功,概率为 2^{1−(n−f)};做出决定的阶段的期望是 1 + 2^{n−f−1}, 即 5、9、17 和 33,与测量相符,并且每多两个进程就翻一倍。有了随机延迟和较晚的崩溃,各进程听到的子集不同,数字会变, 但私有硬币仍可能需要随 n 指数增长的阶段数。然后把私有硬币换成公共硬币(每个阶段一个所有进程都看到的随机比特,这里直接 由模拟器共享),观察到期望阶段数变成常数。 -
★ 研究。 极大独立集的确定性 LOCAL 复杂度。
讨论。 尚未解决。极大独立集在环和路径上需要 Θ(log* n) 轮,在最大度为 Δ 的图上需要 O(Δ + log* n) 轮(Barenboim、 Elkin 和 Kuhn),但在一般图上,它作为 n 的函数的确定性复杂度仍不清楚。自 Rozhoň 和 Ghaffari 的网络分解(2020)以来,它是 多对数的,后来的工作又降低了指数;确定性算法最好的下界是 Ω(min{Δ, log n / log log n})(Balliu、Brandt、Hirvonen、 Olivetti、Rabie 和 Suomela 2019,用轮消去证明),此外还有 Kuhn、Moscibroda 和 Wattenhofer 更早的、对随机算法也成立的下界。 所以差距在大约 log n / log log n 与 log n 的某个大于一的幂之间。完整的答案应给出相差常数因子以内的上下界;好的部分结果 可以是把下界推到 log n 以上,把上界降到 O(log n) 或更低,或在某个自然的图族上解决这个问题。
Build the film
python -m videos.cs.cs59.compute # the part's numbers, into .cache/cs59
python tools/build.py cs59 # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py cs59 Hook # one chapter, silent, with a contact sheet
Scenes: videos/cs/cs59. Setup: see the course page. Source of these notes: the README and the scenes' narration.
Build it
python -m videos.cs.cs59.compute
python -m unittest tests.test_cs59_disttheory
python tools/build.py cs59