Herlihy's wait-free shared-memory consensus hierarchy (1 < 2 < ∞) #
Different shared-memory synchronization primitives have strictly different wait-free consensus
numbers — the maximum number of asynchronous crash-prone processes for which they can solve
wait-free consensus ([Her91], §3, Definition 1, p. 130 & Figure 1, p. 126; see also prior
shared-register impossibility results in [LAA87] noted in [Her91], §3.1, p. 132).
Building on the bivalence and critical-configuration engine in
CslibFrontier/Computability/Distributed/SharedMemory/Basic.lean, this module establishes the
three fundamental levels 1 < 2 < ∞ of Herlihy's hierarchy:
Level
1— Atomic read/write registers ([Her91], §3.1, Theorem 2, pp. 131–133):oneProcProtocol/solvesWaitFreeConsensus_one: whenFintype.card P ≤ 1, a single-step protocol solves wait-free consensus over any value type and any nonempty object family.not_waitFreeConsensus_registers: when2 ≤ Fintype.card P, no wait-free protocol using only atomic multi-reader multi-writer read/write registers (registerObj) solves binary consensus ([Her91], §3.1, Theorem 2 & Figures 3–5, pp. 131–133). At a critical configurationc*withp ≠ qstepping tofalse-univalent andtrue-univalent configurations, operations on distinct registers or two reads commute, a read followed by a write is invisible to the writer's solo continuation, and a write followed by a write overwrites the earlier write without returning the overwritten value.exists_register_consensus_iff: binary wait-free consensus is solvable from atomic read/write registers if and only ifFintype.card P ≤ 1.
Level
2— Commuting-or-overwriting read-modify-write primitives ([Her91], §3.2, Figure 7 & Theorem 4, p. 134):IsCommutingOrOverwritingcaptures Herlihy's "interfering" algebraic obstruction for consensus number2([Her91], §3.2, p. 134): any two operations on the same object either commute on the object's state or one overwrites the other's effect on the state. Atomic registers (registerObj),testAndSetObj,swapObj, andfetchAndAddObj(over anyAddCommSemigroup) all satisfyIsCommutingOrOverwriting.testAndSetProtocol/solvesWaitFreeConsensus_testAndSet_two: an explicit 3-step protocol (write own proposal register, invoketestAndSetObj, read the winning process's proposal register) formalizing the concretetest&setinstance of [Her91], §3.2, Figure 7 (p. 134) solves wait-free consensus wheneverFintype.card P ≤ 2(Theorem 3's general 2-process lower bound over arbitrary nontrivial RMW functions remains open in#7199).not_waitFreeConsensus_rmw_of_three_le: when3 ≤ Fintype.card P, no wait-free protocol over any indexed family of commuting-or-overwriting objects (including any mix of registers,TestAndSet,Swap, andFetchAndAdd; [Her91], §3.2, Theorem 4, p. 134) solves binary consensus, because a third bystander processw ∉ {p, q}running solo cannot distinguish the post-critical object states.exists_testAndSet_consensus_iff: binary wait-free consensus is solvable fromTestAndSetobjects and atomic registers if and only ifFintype.card P ≤ 2.
Level
∞—CompareAndSwap([Her91], §3.2, Theorem 5 & Figures 8–9, p. 135):not_isCommutingOrOverwriting_casObj/not_isCommutingOrOverwriting_casObj_option:casObjis not commuting-or-overwriting whenever the state type has at least three distinct values (such asOption Vfor[Nontrivial V]; note that on a 2-element domain without an uninitialized sentinelnone, conditional 1-bit updates degenerate toTestAndSet/reset).casConsensusProtocol/solvesWaitFreeConsensus_cas: a 1-step protocol over a singlecasObj (none : Option V)([Her91], §3.2, Figure 9, p. 135) solves wait-free consensus for every finite process setPand every decidable value typeV.
Main definitions #
Cslib.Distributed.SharedMemory.RegOp,Cslib.Distributed.SharedMemory.registerObj: atomic multi-reader multi-writer read/write register specification.Cslib.Distributed.SharedMemory.oneProcProtocol: 1-step consensus protocol for|P| ≤ 1.Cslib.Distributed.SharedMemory.IsCommutingOrOverwriting: algebraic commuting-or-overwriting property of a deterministic shared object.Cslib.Distributed.SharedMemory.testAndSetObj,Cslib.Distributed.SharedMemory.swapObj,Cslib.Distributed.SharedMemory.fetchAndAddObj: commuting-or-overwriting RMW objects.Cslib.Distributed.SharedMemory.TASRegKind: descriptor for families combiningTestAndSetobjects and atomic registers.Cslib.Distributed.SharedMemory.TASObjId,Cslib.Distributed.SharedMemory.TASState,Cslib.Distributed.SharedMemory.testAndSetProtocol: 3-step 2-processTestAndSetconsensus protocol.Cslib.Distributed.SharedMemory.CASOp,Cslib.Distributed.SharedMemory.casObj,Cslib.Distributed.SharedMemory.casConsensusProtocol:CompareAndSwapobject and 1-stepn-process wait-free consensus protocol.
Main results #
Cslib.Distributed.SharedMemory.solvesWaitFreeConsensus_one: 1-process consensus sufficiency.Cslib.Distributed.SharedMemory.not_waitFreeConsensus_registers: 2-process impossibility for atomic read/write registers ([Her91], §3.1, Theorem 2).Cslib.Distributed.SharedMemory.exists_register_consensus_iff: register consensus solvable iffFintype.card P ≤ 1.Cslib.Distributed.SharedMemory.isCommutingOrOverwriting_registerObj,Cslib.Distributed.SharedMemory.isCommutingOrOverwriting_testAndSetObj,Cslib.Distributed.SharedMemory.isCommutingOrOverwriting_swapObj,Cslib.Distributed.SharedMemory.isCommutingOrOverwriting_fetchAndAddObj: commuting-or-overwriting proofs for registers,TestAndSet,Swap, andFetchAndAdd.Cslib.Distributed.SharedMemory.solvesWaitFreeConsensus_testAndSetProtocol,Cslib.Distributed.SharedMemory.solvesWaitFreeConsensus_testAndSet_two: 2-processTestAndSetconsensus sufficiency.Cslib.Distributed.SharedMemory.not_waitFreeConsensus_rmw_of_three_le: 3-process impossibility for any family of commuting-or-overwriting objects ([Her91]).Cslib.Distributed.SharedMemory.exists_testAndSet_consensus_iff:TestAndSet+ registers consensus solvable iffFintype.card P ≤ 2.Cslib.Distributed.SharedMemory.not_isCommutingOrOverwriting_casObj,Cslib.Distributed.SharedMemory.not_isCommutingOrOverwriting_casObj_option:casObjescapes the commuting-or-overwriting barrier on domains of size at least3.Cslib.Distributed.SharedMemory.solvesWaitFreeConsensus_cas:n-process wait-free consensus from a singleCompareAndSwapobject ([Her91]).