Documentation

CslibFrontier.Computability.Distributed.FailureDetectors.Consensus

Asynchronous-Round ◇S Consensus and |P| ≤ 2t Resilience Lower Bound #

Formalizes asynchronous-round consensus steps with unreliable failure detectors after Chandra and Toueg, §§6.2–6.3, Figure 6, Theorem 6.2.3, Corollary 6.2.4, and Theorem 6.3.1, pp. 242–248 (part of #7503).

Model scope relative to primary sources #

Chandra and Toueg, §6.2, Figure 6, p. 243 and Chandra, Hadzilacos and Toueg, §§2.3–2.4, pp. 690–692 model event-driven asynchronous automata (F, H_D, I, S, T) in which processes may occupy arbitrarily skewed asynchronous round numbers concurrently while running background diffusion R-broadcast. Here we formalize an explicit asynchronous-round model (FDAsyncRoundProtocol, AdmissibleFDNetwork) in which subround k completes at global tick tick k (StrictMono tick) under adversarial per-subround link delivery deliver : ℕ → P → P → Bool subject to:

  1. wait_or_suspect: for every subround k, correct recipient p ∈ F.Correct, and sender q, either q is alive at tick k and its subround-k message reaches p (q ∉ F (tick k) ∧ deliver k q p = true), or p's failure detector suspects q at tick k (q ∈ H p (tick k)). When StrongCompleteness F H fails (e.g. H = ∅ with a crashed process), no AdmissibleFDNetwork exists (not_admissibleFDNetwork_emptyDetector_of_crashed), capturing Phase-3 blocking on crashed coordinators.
  2. quorum_delivery: in every subround k, every correct process receives messages from at least Fintype.card P - t non-crashed senders (while an adversary freely chooses which subset of size ≥ |P| - t arrives).

Within this unified FDAsyncRoundProtocol interface we prove both directions of the 2 * t < |P| resilience threshold:

Event-driven step-schedule realizations of Figures 5–6 and the valence-DAG necessity reduction D ⪰ Ω ⪰ ◇W of Chandra, Hadzilacos and Toueg, §6 remain open in #7503.

Main definitions #

Main results #

References #

Asynchronous-round failure-detector protocol model #

structure Cslib.Distributed.FailureDetectors.FDAsyncRoundProtocol (P : Type u_1) (V : Type u_2) (State : Type u_3) (Msg : Type u_4) :
Type (max (max (max u_1 u_2) u_3) u_4)

A deterministic consensus protocol in the asynchronous-round model with failure detector queries (step model for #7503, after Chandra and Toueg, §§2.5, 6.2).

In subround k (occurring at global clock tick tick k), each non-crashed process p ∉ F (tick k) sends send k p s q to each recipient q, queries its local failure detector H p (tick k), and updates its state via update k p s (H p (tick k)) recv. Crashed processes stutter in their last pre-crash state and emit no messages.

  • init : P → V → State

    Initial local state of process p with proposed value v.

  • send : ℕ → P → State → P → Msg

    Message sent by non-crashed process p in state s to q in subround k.

  • update : ℕ → P → State → Finset P → (P → Option Msg) → State

    Next local state of p after subround k given suspected set H p (tick k) and delivered messages P → Option Msg.

  • output : P → State → Option V

    Optional decision read from local state (none while undecided).

structure Cslib.Distributed.FailureDetectors.AdmissibleFDNetwork {P : Type u_1} [Fintype P] [DecidableEq P] (F : FailurePattern P) (H : DetectorHistory P) (t : ℕ) (tick : ℕ → ℕ) (deliver : ℕ → P → P → Bool) :

Asynchronous network admissibility for subround clock tick and link schedule deliver under failure pattern F, detector history H, and fault budget t (step network model for #7503):

  • tick_strictMono: subround completion ticks advance strictly (k ≤ tick k).
  • wait_or_suspect: for each correct recipient p ∈ F.Correct and process q, either q is non-crashed at tick k and delivers to p, or p suspects q at tick k (q ∈ H p (tick k)).
  • quorum_delivery: every correct recipient receives messages from at least |P| - t non-crashed processes in every subround.
  • tick_strictMono : StrictMono tick

    Subrounds occur at strictly increasing global clock ticks.

  • wait_or_suspect (k : ℕ) (p : P) : p ∈ F.Correct → ∀ (q : P), q ∉ F.atTime (tick k) ∧ deliver k q p = true ∨ q ∈ H p (tick k)

    A correct process skips waiting for q's subround-k message only if q ∈ H p (tick k).

  • quorum_delivery (k : ℕ) (p : P) : p ∈ F.Correct → Fintype.card P - t ≤ {q : P | decide (q ∉ F.atTime (tick k) ∧ deliver k q p = true) = true}.card

    At least |P| - t non-crashed processes deliver to each correct process in each subround.

theorem Cslib.Distributed.FailureDetectors.AdmissibleFDNetwork.deliver_of_notMem {P : Type u_1} [Fintype P] [DecidableEq P] {F : FailurePattern P} {H : DetectorHistory P} {t : ℕ} {tick : ℕ → ℕ} {deliver : ℕ → P → P → Bool} (hadm : AdmissibleFDNetwork F H t tick deliver) {k : ℕ} {p q : P} (hp : p ∈ F.Correct) (hns : q ∉ H p (tick k)) :
deliver k q p = true

Immediate corollary of wait_or_suspect: if q is not suspected by p ∈ F.Correct at tick k, then q's subround-k message is delivered to p.

theorem Cslib.Distributed.FailureDetectors.exists_admissibleFDNetwork_of_strongCompleteness {P : Type u_1} [Fintype P] [DecidableEq P] {F : FailurePattern P} {H : DetectorHistory P} {t : ℕ} (hF : ∀ (s : ℕ), (F.atTime s).card ≤ t) (hSC : StrongCompleteness F H) :
∃ (tick : ℕ → ℕ) (deliver : ℕ → P → P → Bool), AdmissibleFDNetwork F H t tick deliver

Asynchronous-round step for #7503 (after Chandra and Toueg, §6.2, p. 243): whenever ∀ s, (F s).card ≤ t and StrongCompleteness F H holds, shifting tick k := T_sc + k with full delivery between alive processes yields an AdmissibleFDNetwork.

theorem Cslib.Distributed.FailureDetectors.not_admissibleFDNetwork_emptyDetector_of_crashed {P : Type u_1} [Fintype P] [DecidableEq P] {F : FailurePattern P} {t : ℕ} (hcorr : F.Correct.Nonempty) (hcrash : F.Crashed.Nonempty) {tick : ℕ → ℕ} {deliver : ℕ → P → P → Bool} :
¬AdmissibleFDNetwork F (fun (x : P) (x_1 : ℕ) => ∅) t tick deliver

Asynchronous-round step for #7503: if any process crashes in F while F.Correct.Nonempty, the blind detector fun _ _ => ∅ admits no AdmissibleFDNetwork (every correct process eventually blocks waiting for the crashed process).

def Cslib.Distributed.FailureDetectors.FDAsyncRoundProtocol.incoming {P : Type u_1} {V : Type u_2} {S : Type u_3} {M : Type u_4} [DecidableEq P] (π : FDAsyncRoundProtocol P V S M) (F : FailurePattern P) (tick : ℕ → ℕ) (deliver : ℕ → P → P → Bool) (st : P → S) (k : ℕ) (p q : P) :

Incoming message map delivered to p in subround k from alive senders.

def Cslib.Distributed.FailureDetectors.FDAsyncRoundProtocol.state {P : Type u_1} {V : Type u_2} {S : Type u_3} {M : Type u_4} [DecidableEq P] (π : FDAsyncRoundProtocol P V S M) (F : FailurePattern P) (H : DetectorHistory P) (tick : ℕ → ℕ) (deliver : ℕ → P → P → Bool) (x : P → V) :
ℕ → P → S

Local state of process p after k subrounds under (F, H, tick, deliver) and inputs x.

def Cslib.Distributed.FailureDetectors.FDAsyncRoundProtocol.decision {P : Type u_1} {V : Type u_2} {S : Type u_3} {M : Type u_4} [DecidableEq P] (π : FDAsyncRoundProtocol P V S M) (F : FailurePattern P) (H : DetectorHistory P) (tick : ℕ → ℕ) (deliver : ℕ → P → P → Bool) (x : P → V) (k : ℕ) (p : P) :

Optional decision of process p after k subrounds.

π solves t-crash-tolerant consensus in the asynchronous-round model using failure detectors satisfying DetPred (step specification for #7503, after Chandra and Toueg, §5, p. 239).

theorem Cslib.Distributed.FailureDetectors.FDAsyncRoundProtocol.SolvesFDAsyncRoundConsensus.mono {P : Type u_1} {V : Type u_2} {S : Type u_3} {M : Type u_4} [DecidableEq P] [Fintype P] {π : FDAsyncRoundProtocol P V S M} {t : ℕ} {DetPred₁ DetPred₂ : FailurePattern P → DetectorHistory P → Prop} (h : π.SolvesFDAsyncRoundConsensus t DetPred₂) (himp : ∀ (F : FailurePattern P), F.Correct.Nonempty → ∀ (H : DetectorHistory P), DetPred₁ F H → DetPred₂ F H) :

Monotonicity in the detector predicate: if DetPred₁ implies DetPred₂ (e.g. ◇P → ◇S), any protocol solving consensus under the weaker class DetPred₂ also solves it under DetPred₁.

Trivial zero-communication protocol deciding each process's own initial value when |P| ≤ 1.

Original base-case helper for #7503: when P is a subsingleton (Fintype.card P ≤ 1), ownInputFDProtocol solves SolvesFDAsyncRoundConsensus for any fault budget t and detector predicate DetPred.

Maximum-timestamp selector #

Deterministic selector returning an (estimate, timestamp) pair maximizing the timestamp in a nonempty list (Chandra and Toueg, §6.2, Figure 6, Phase 2, p. 243).

The 4-stage Chandra–Toueg ◇S rotating-coordinator round protocol #

Local process state for ctRoundProtocol (after Chandra and Toueg, §6.2, Figure 6, p. 243).

  • est : V

    Current estimate of the decision value (estimate_p, initially input_p).

  • ts : ℕ

    Round number (r + 1) in which est was last adopted (ts_p, initially 0).

  • proposal : Option (ℕ × V)

    Round-tagged coordinator proposal (r, v) selected in Subround 0 of round r.

  • reply : Option (ℕ × Bool)

    Round-tagged Phase-3 reply (r, true) (ack) or (r, false) (nack).

  • decided : Option V

    Write-once Consensus decision (none while undecided).

Subround messages of ctRoundProtocol across the four stages of round r = k / 4.

  • phase1 {V : Type u_1} (est : V) (ts : ℕ) : CTMsg V

    Subround 0 (Phase 1): process sends (est, ts) to coordinator c.

  • phase2 {V : Type u_1} (proposal : Option (ℕ × V)) : CTMsg V

    Subround 1 (Phase 2): coordinator broadcasts round-tagged proposal.

  • phase3 {V : Type u_1} (reply : Option (ℕ × Bool)) : CTMsg V

    Subround 2 (Phase 3): process sends round-tagged ack/nack reply to c.

  • phase4 {V : Type u_1} (decided : Option V) : CTMsg V

    Subround 3 (Phase 4): processes broadcast any latched decided value.

@[instance_reducible]
def Cslib.Distributed.FailureDetectors.instDecidableEqCTMsg.decEq {V✝ : Type u_1} [DecidableEq V✝] (x✝ x✝¹ : CTMsg V✝) :
Decidable (x✝ = x✝¹)

Extracts (est, ts) from a Subround-0 .phase1 message.

Checks whether m j is a Subround-2 ack (true) for round r.

Extracts a latched decision from a Subround-3 .phase4 message.

def Cslib.Distributed.FailureDetectors.ctSend {P : Type u_1} {V : Type u_2} (k : ℕ) (_p : P) (s : CTState V) (_dst : P) :

Outgoing subround message of ctRoundProtocol.

def Cslib.Distributed.FailureDetectors.ctUpdate {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] (procs : List P) (fallback : P) (k : ℕ) (p : P) (s : CTState V) (suspected : Finset P) (m : P → Option (CTMsg V)) :

State transition of ctRoundProtocol in subround k (r = k / 4, phase k % 4), using the t-oblivious strict-majority quorum threshold Fintype.card P / 2 + 1.

def Cslib.Distributed.FailureDetectors.ctRoundProtocol (P : Type u_1) (V : Type u_2) [Fintype P] [DecidableEq P] (procs : List P) (fallback : P) :

Asynchronous-round step for #7503 (after Chandra and Toueg, §6.2, Figure 6, p. 243, and remark on p. 244): t-oblivious 4-subround rotating-coordinator ◇S consensus protocol waiting for strict-majority quorums of size Fintype.card P / 2 + 1. Relative to Figure 6, this asynchronous-round realization uses 0-indexed rounds r = k / 4 storing updated timestamps ts := r + 1 (so 0 remains the unupdated initial timestamp) and lockstep global subrounds k with a Subround-3 (k % 4 = 3) .phase4 s.decided broadcast by all decided processes in place of skewed-round execution and Figure 4's asynchronous diffusion R-broadcast.

Unconditional safety of ctRoundProtocol #

def Cslib.Distributed.FailureDetectors.LockedInRound {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] (procs : List P) (fallback : P) (F : FailurePattern P) (H : DetectorHistory P) (tick : ℕ → ℕ) (deliver : ℕ → P → P → Bool) (x : P → V) (r : ℕ) (v : V) :

Round-r strict-majority quorum-locking predicate for ctRoundProtocol: coordinator c_r proposed (r, v) at the end of Subround 0, and at least Fintype.card P / 2 + 1 processes recorded ack (some (r, true)) at the end of Subround 1.

theorem Cslib.Distributed.FailureDetectors.ctRoundProtocol_irrevocable {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] {procs : List P} {fallback : P} (F : FailurePattern P) (H : DetectorHistory P) (tick : ℕ → ℕ) (deliver : ℕ → P → P → Bool) (x : P → V) {k₁ k₂ : ℕ} (hk : k₁ ≤ k₂) (p : P) (v : V) (hdec : (ctRoundProtocol P V procs fallback).decision F H tick deliver x k₁ p = some v) :
(ctRoundProtocol P V procs fallback).decision F H tick deliver x k₂ p = some v

Asynchronous-round step for #7503 (after Chandra and Toueg, §6.2, Figure 6, p. 243): once decided = some v at any process p (correct or faulty) in ctRoundProtocol, decided remains some v at all subsequent subrounds under arbitrary F, H, tick, deliver.

theorem Cslib.Distributed.FailureDetectors.ctRoundProtocol_lock_preservation {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] {procs : List P} {fallback : P} (F : FailurePattern P) (H : DetectorHistory P) (tick : ℕ → ℕ) (deliver : ℕ → P → P → Bool) (x : P → V) {r : ℕ} {v : V} (hlock : LockedInRound procs fallback F H tick deliver x r v) {r' : ℕ} :
r < r' → ∀ {w : V}, ((ctRoundProtocol P V procs fallback).state F H tick deliver x (4 * r' + 1) (rotatingCoordinator procs fallback r')).proposal = some (r', w) → w = v

Asynchronous-round step for #7503 (after Chandra and Toueg, Lemma 6.2.1, pp. 244–245): once LockedInRound holds for (r, v), every coordinator proposal (r', w) in any later round r' > r satisfies w = v, unconditionally across all P, F, H, tick, deliver.

theorem Cslib.Distributed.FailureDetectors.ctRoundProtocol_validity {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] {procs : List P} {fallback : P} (F : FailurePattern P) (H : DetectorHistory P) (tick : ℕ → ℕ) (deliver : ℕ → P → P → Bool) (x : P → V) {k : ℕ} {p : P} {v : V} (hdec : (ctRoundProtocol P V procs fallback).decision F H tick deliver x k p = some v) :
∃ (q : P), x q = v

Asynchronous-round step for #7503 (after Chandra and Toueg, Theorem 6.2.3, p. 246): any value decided by any process in ctRoundProtocol under any (F, H, tick, deliver) was proposed as some process's initial input x q.

theorem Cslib.Distributed.FailureDetectors.ctRoundProtocol_uniform_agreement {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] {procs : List P} {fallback : P} (F : FailurePattern P) (H : DetectorHistory P) (tick : ℕ → ℕ) (deliver : ℕ → P → P → Bool) (x : P → V) {k₁ k₂ : ℕ} {p₁ p₂ : P} {v₁ v₂ : V} (h₁ : (ctRoundProtocol P V procs fallback).decision F H tick deliver x k₁ p₁ = some v₁) (h₂ : (ctRoundProtocol P V procs fallback).decision F H tick deliver x k₂ p₂ = some v₂) :
v₁ = v₂

Asynchronous-round step for #7503 (after Chandra and Toueg, Lemma 6.2.1, pp. 244–245): no two processes (correct or faulty) ever decide distinct values in ctRoundProtocol under any (F, H, tick, deliver) (even if any number of processes crash or H is an arbitrarily lying failure detector).

Conditional termination under ◇S (IsEventuallyStrong) and ◇W (IsEventuallyWeak) #

theorem Cslib.Distributed.FailureDetectors.ctRoundProtocol_decides_in_good_round {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] {procs : List P} (hprocs : ∀ (p : P), p ∈ procs) (fallback : P) {t : ℕ} (ht : 2 * t < Fintype.card P) {F : FailurePattern P} {H : DetectorHistory P} {tick : ℕ → ℕ} {deliver : ℕ → P → P → Bool} (hadm : AdmissibleFDNetwork F H t tick deliver) (x : P → V) {rStar : ℕ} {qStar : P} (hqStar : qStar ∈ F.Correct) (hcoord : rotatingCoordinator procs fallback rStar = qStar) (hstab : ∀ (k : ℕ), 4 * rStar ≤ k → ∀ j ∉ F.atTime (tick k), j ∈ F.Correct) (hunsusp : ∀ (k : ℕ), 4 * rStar ≤ k → ∀ p ∈ F.Correct, qStar ∉ H p (tick k)) (p : P) :
p ∈ F.Correct → ((ctRoundProtocol P V procs fallback).decision F H tick deliver x (4 * (rStar + 1)) p).isSome = true

Asynchronous-round step for #7503 (after Chandra and Toueg, Lemma 6.2.2, pp. 245–246): under 2 * t < Fintype.card P, if rStar is coordinated by qStar ∈ F.Correct, all faulty processes have crashed by tick (4 * rStar), and no correct process suspects qStar from tick (4 * rStar) onward, then every p ∈ F.Correct has decided in ctRoundProtocol by subround 4 * (rStar + 1).

theorem Cslib.Distributed.FailureDetectors.ctRoundProtocol_terminates_of_isEventuallyStrong {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] {procs : List P} (hprocs : ∀ (p : P), p ∈ procs) (fallback : P) {t : ℕ} (ht : 2 * t < Fintype.card P) {F : FailurePattern P} {H : DetectorHistory P} {tick : ℕ → ℕ} {deliver : ℕ → P → P → Bool} (hadm : AdmissibleFDNetwork F H t tick deliver) (hES : IsEventuallyStrong F H) (x : P → V) :
∃ (kStar : ℕ), ∀ p ∈ F.Correct, ((ctRoundProtocol P V procs fallback).decision F H tick deliver x kStar p).isSome = true

Asynchronous-round step for #7503 (after Chandra and Toueg, Lemma 6.2.2, pp. 245–246): under 2 * t < Fintype.card P and IsEventuallyStrong F H (◇S), every correct process eventually decides in ctRoundProtocol.

theorem Cslib.Distributed.FailureDetectors.solvesFDAsyncRoundConsensus_ctRoundProtocol {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] {procs : List P} (hprocs : ∀ (p : P), p ∈ procs) (fallback : P) {t : ℕ} (ht : 2 * t < Fintype.card P) :

Asynchronous-round step for #7503 (after Chandra and Toueg, Theorem 6.2.3, p. 246): the t-oblivious protocol ctRoundProtocol P V procs fallback solves t-resilient consensus under IsEventuallyStrong (◇S) for every t with 2 * t < Fintype.card P.

theorem Cslib.Distributed.FailureDetectors.ctRoundProtocol_terminates_of_isEventuallyWeak_gossip {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] {procs : List P} (hprocs : ∀ (p : P), p ∈ procs) (fallback : P) {t : ℕ} (ht : 2 * t < Fintype.card P) {F : FailurePattern P} {H : DetectorHistory P} (hEW : IsEventuallyWeak F H) {gSched : P → ℕ → List (GossipPacket P)} (hgossip : AdmissibleGossipSchedule F gSched) {tick : ℕ → ℕ} {deliver : ℕ → P → P → Bool} (hadm : AdmissibleFDNetwork F (gossipHistory H gSched) t tick deliver) (x : P → V) :
∃ (kStar : ℕ), ∀ p ∈ F.Correct, ((ctRoundProtocol P V procs fallback).decision F (gossipHistory H gSched) tick deliver x kStar p).isSome = true

Asynchronous-round step for #7503 (after Chandra and Toueg, Corollary 6.2.4, pp. 246–247): given any ◇W history H (IsEventuallyWeak F H) and AdmissibleGossipSchedule F gSched, running ctRoundProtocol over the gossip-boosted history gossipHistory H gSched terminates across all F.Correct under any AdmissibleFDNetwork (which exists by exists_admissibleFDNetwork_of_strongCompleteness) whenever 2 * t < Fintype.card P.

2 ≤ Fintype.card P ≤ 2 * t Impossibility Even Under ◇P (IsEventuallyPerfect) #

Asynchronous-round step for #7503 (after Chandra and Toueg, Theorem 6.3.1, pp. 247–248): when 2 ≤ Fintype.card P ≤ 2 * t and V has at least two distinct values, no FDAsyncRoundProtocol solves SolvesFDAsyncRoundConsensus t IsEventuallyPerfect (and hence none solves it under ◇S or ◇W).

Exact asynchronous-round resilience characterizations #

Asynchronous-round step for #7503 (after Chandra and Toueg, Theorems 6.2.3 and 6.3.1, pp. 246–248): over [Nontrivial V], t-resilient consensus in FDAsyncRoundProtocol under IsEventuallyStrong (◇S) is solvable if and only if Fintype.card P ≤ 1 ∨ 2 * t < Fintype.card P.

Asynchronous-round step for #7503 (after Chandra and Toueg, Theorems 6.2.3 and 6.3.1, pp. 246–248): over [Nontrivial V], strengthening ◇S to ◇P (IsEventuallyPerfect) yields the identical asynchronous-round resilience threshold Fintype.card P ≤ 1 ∨ 2 * t < Fintype.card P.