Documentation

CslibFrontier.Computability.Distributed.ABD.Protocol

Cardinality-quorum multi-writer atomic register emulation #

This module formalizes abdProtocol, an independent cardinality-quorum point-to-point envelope specialization after the two-phase multi-writer multi-reader (MWMR) construction of Lynch and Shvartsman ([LS97], §4.1–4.2 in the December 2, 1996 manuscript) and the majority read write-back discipline of Attiya, Bar-Noy, and Dolev ([ABND95], §4), as a step toward full atomic-register emulation rather than the cited Theorem 4.5 or Theorem 4.9 endpoints:

For 2 * t < Fintype.card P, any two quorums of size at least n - t intersect (quorum_inter_nonempty), and replica tags never decrease (tr_repTag_mono). Consequently, every operation invoked after a completed operation a observes a tag at least a's Phase-2 tag (strictly greater when the later operation is a write), and sorting all completed operations together with Phase-2 pending writes by (tag, isRead, opId) yields an explicit valid linearization (abd_linearizable). Against any static faulty set F of size at most t, n - F.card ≥ n - t non-faulty replicas respond in each phase, establishing wait-free termination (abd_terminates) and implementsAtomicRegister_abd.

Main definitions #

Main results #

References #

Lexicographic version tags #

@[reducible, inline]
abbrev Cslib.Distributed.ABD.Tag (P : Type u_1) :
Type u_1

Lexicographically ordered ABD version tag (seq, writer), where (0, ⊥) marks the initial register value v₀ and (seq + 1, ↑w) marks a write by process w : P.

def Cslib.Distributed.ABD.Tag.seq {P : Type u_1} (τ : Tag P) :

Sequence-number component of an ABD Tag.

Optional writer component of an ABD Tag (⊥ for the initial value, ↑w for writer w).

Initial ABD tag toLex (0, ⊥) associated with the initial register value v₀.

def Cslib.Distributed.ABD.nextWriteTag {P : Type u_1} (maxSeq : ℕ) (w : P) :
Tag P

Fresh ABD tag toLex (maxSeq + 1, ↑w) chosen by writer w after observing maximum sequence number maxSeq across its Phase-1 quorum.

@[simp]
@[simp]
theorem Cslib.Distributed.ABD.nextWriteTag_seq {P : Type u_1} (s : ℕ) (w : P) :
(nextWriteTag s w).seq = s + 1
@[simp]
theorem Cslib.Distributed.ABD.nextWriteTag_writer {P : Type u_1} (s : ℕ) (w : P) :
(nextWriteTag s w).writer = ↑w
theorem Cslib.Distributed.ABD.initTag_le {P : Type u_1} [LinearOrder P] (τ : Tag P) :

initTag P ((0, ⊥)) is the least element of Tag P.

Every write tag nextWriteTag s w strictly exceeds initTag P.

Quorum intersection #

theorem Cslib.Distributed.ABD.quorum_inter_nonempty {P : Type u_1} [Fintype P] [DecidableEq P] {t : ℕ} (h2t : 2 * t < Fintype.card P) {Q₁ Q₂ : Finset P} (hQ₁ : Fintype.card P - t ≤ Q₁.card) (hQ₂ : Fintype.card P - t ≤ Q₂.card) :
(Q₁ ∩ Q₂).Nonempty

Quorum intersection: when 2 * t < Fintype.card P, any two subsets Q₁, Q₂ : Finset P of cardinality at least Fintype.card P - t share at least one server.

theorem Cslib.Distributed.ABD.quorum_inter_notMem {P : Type u_1} [Fintype P] [DecidableEq P] {t : ℕ} (h2t : 2 * t < Fintype.card P) {F Q₁ Q₂ : Finset P} (hQ₁ : Fintype.card P - t ≤ Q₁.card) (hQ₂ : Fintype.card P - t ≤ Q₂.card) (hlive : ∀ q ∈ Q₁, q ∉ F) :
∃ q ∈ Q₁ ∩ Q₂, q ∉ F

When Q₁ consists of non-faulty servers (∀ q ∈ Q₁, q ∉ F), any two (n - t)-quorums intersect in a live server outside F.

ABD protocol messages, state, and transitions #

inductive Cslib.Distributed.ABD.ABDMsg (P : Type u_1) (V : Type u_2) :
Type (max u_1 u_2)

Network messages exchanged by the two-phase ABD register emulation protocol.

  • query {P : Type u_1} {V : Type u_2} (reqId : ℕ) : ABDMsg P V

    Phase-1 query asking a replica for its current (repTag, repVal).

  • queryResp {P : Type u_1} {V : Type u_2} (reqId : ℕ) (tag : Tag P) (val : V) : ABDMsg P V

    Phase-1 reply reporting (tag, val) for reqId.

  • store {P : Type u_1} {V : Type u_2} (reqId : ℕ) (tag : Tag P) (val : V) : ABDMsg P V

    Phase-2 command asking a replica to store (tag, val) if tag exceeds its current tag.

  • ack {P : Type u_1} {V : Type u_2} (reqId : ℕ) : ABDMsg P V

    Phase-2 acknowledgment confirming processing of store reqId.

def Cslib.Distributed.ABD.instDecidableEqABDMsg.decEq {P✝ : Type u_1} {V✝ : Type u_2} [DecidableEq P✝] [DecidableEq V✝] (x✝ x✝¹ : ABDMsg P✝ V✝) :
Decidable (x✝ = x✝¹)
@[instance_reducible]
instance Cslib.Distributed.ABD.instDecidableEqABDMsg {P✝ : Type u_1} {V✝ : Type u_2} [DecidableEq P✝] [DecidableEq V✝] :
DecidableEq (ABDMsg P✝ V✝)
inductive Cslib.Distributed.ABD.ClientPhase (P : Type u_1) (V : Type u_2) :
Type (max u_1 u_2)

Client-side phase state of a process in the ABD protocol.

  • idle {P : Type u_1} {V : Type u_2} : ClientPhase P V

    No client operation is currently active.

  • phase1 {P : Type u_1} {V : Type u_2} (reqId : ℕ) (kind : OpKind V) (responses : Finset P) (bestTag : Tag P) (bestVal : V) : ClientPhase P V

    Phase 1: collecting (tag, val) replies from n - t distinct replicas.

  • phase2 {P : Type u_1} {V : Type u_2} (reqId : ℕ) (kind : OpKind V) (chosenTag : Tag P) (chosenVal : V) (acks : Finset P) : ClientPhase P V

    Phase 2: broadcasting store(chosenTag, chosenVal) (write or read write-back) and collecting n - t acknowledgments.

@[instance_reducible]
instance Cslib.Distributed.ABD.instDecidableEqClientPhase {P✝ : Type u_1} {V✝ : Type u_2} [DecidableEq P✝] [DecidableEq V✝] :
def Cslib.Distributed.ABD.instDecidableEqClientPhase.decEq {P✝ : Type u_1} {V✝ : Type u_2} [DecidableEq P✝] [DecidableEq V✝] (x✝ x✝¹ : ClientPhase P✝ V✝) :
Decidable (x✝ = x✝¹)
structure Cslib.Distributed.ABD.ABDState (P : Type u_1) (V : Type u_2) :
Type (max u_1 u_2)

Local state of process p : P in the ABD protocol, combining its replica storage and its client state machine.

  • repTag : Tag P

    Highest version tag stored at this replica.

  • repVal : V

    Value associated with repTag at this replica.

  • nextReqId : ℕ

    Counter generating fresh request nonces for this process's client invocations.

  • phase : ClientPhase P V

    Active client phase (.idle, .phase1, or .phase2).

theorem Cslib.Distributed.ABD.ABDState.ext {P : Type u_1} {V : Type u_2} {x y : ABDState P V} (repTag : x.repTag = y.repTag) (repVal : x.repVal = y.repVal) (nextReqId : x.nextReqId = y.nextReqId) (phase : x.phase = y.phase) :
x = y
def Cslib.Distributed.ABD.instDecidableEqABDState.decEq {P✝ : Type u_1} {V✝ : Type u_2} [DecidableEq P✝] [DecidableEq V✝] (x✝ x✝¹ : ABDState P✝ V✝) :
Decidable (x✝ = x✝¹)
@[instance_reducible]
instance Cslib.Distributed.ABD.instDecidableEqABDState {P✝ : Type u_1} {V✝ : Type u_2} [DecidableEq P✝] [DecidableEq V✝] :
DecidableEq (ABDState P✝ V✝)
def Cslib.Distributed.ABD.abdInit (P : Type u_1) {V : Type u_2} (v₀ : V) :

Initial local state of each ABD process.

def Cslib.Distributed.ABD.abdOnInvoke {P : Type u_1} {V : Type u_2} [Fintype P] (v₀ : V) (_caller : P) (st : ABDState P V) (kind : OpKind V) :
StepOut P (ABDMsg P V) (ABDState P V) V

Client invocation handler for the ABD protocol: enter .phase1 with a fresh reqId and broadcast .query reqId to every replica.

def Cslib.Distributed.ABD.abdOnRecv {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] [LinearOrder P] (t : ℕ) (dest : P) (st : ABDState P V) (src : P) (msg : ABDMsg P V) :
StepOut P (ABDMsg P V) (ABDState P V) V

Message reception handler for the ABD protocol at recipient dest from sender src, using quorum threshold Fintype.card P - t.

def Cslib.Distributed.ABD.abdProtocol (P : Type u_1) (V : Type u_2) [Fintype P] [DecidableEq P] [LinearOrder P] (v₀ : V) (t : ℕ) :
Protocol P (ABDState P V) (ABDMsg P V) V

Uniform two-phase (n - t)-cardinality quorum multi-writer multi-reader register protocol over unordered envelopes with idle-only invocations, lexicographic (seq, writer) tags, and Phase-2 read write-back (an independent cardinality-quorum specialization after [LS97], §4.1 and [ABND95], §4, replacing separate read/write quorum families, broadcast primitives, and per-processor request queues with concrete envelope steps).

Replica tag monotonicity #

theorem Cslib.Distributed.ABD.tr_repTag_mono {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] [LinearOrder P] [DecidableEq V] {v₀ : V} {t : ℕ} {s s' : State P (ABDState P V) (ABDMsg P V) V} {a : Action P (ABDMsg P V) V} (htr : (abdProtocol P V v₀ t).lts.Tr s a s') (q : P) :

Replica tag monotonicity (single transition): no replica's stored repTag ever decreases across any transition of abdProtocol.

theorem Cslib.Distributed.ABD.mTr_repTag_mono {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] [LinearOrder P] [DecidableEq V] {v₀ : V} {t : ℕ} {s s' : State P (ABDState P V) (ABDMsg P V) V} {xl : List (Action P (ABDMsg P V) V)} (hmtr : (abdProtocol P V v₀ t).lts.MTr s xl s') (q : P) :

Replica tag monotonicity (finite execution): no replica's stored repTag ever decreases along any finite execution of abdProtocol.

Global invariant for linearizability #

Explicit linearization order by (tag, isRead, opId) #

theorem Cslib.Distributed.ABD.abd_linearizable {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] [LinearOrder P] [DecidableEq V] {t : ℕ} (h2t : 2 * t < Fintype.card P) (v₀ : V) {s : State P (ABDState P V) (ABDMsg P V) V} (hr : (abdProtocol P V v₀ t).Reachable s) :

Independent cardinality-quorum envelope safety specialization (abd_linearizable), after [LS97], §4.1–4.2 (and not the cited Theorem 4.5 or [ABND95] Theorem 4.9 endpoint): when 2 * t < Fintype.card P, every state s reachable under abdProtocol P V v₀ t satisfies Linearizable v₀ s.history. Whereas [LS97] (§4.1–4.2, Theorem 4.5) proves atomicity over separate fixed read/write quorum families, a broadcast abstraction, and a per-processor client request queue, this theorem proves linearizability for Lean's concrete (n - t)-cardinality quorum envelope protocol with idle-only client invocations.

Wait-free termination (abd_terminates) #

theorem Cslib.Distributed.ABD.abd_terminates {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] [LinearOrder P] [DecidableEq V] {t : ℕ} (h2t : 2 * t < Fintype.card P) (v₀ : V) {F : Finset P} (hF : F.card ≤ t) {ss : ωSequence (State P (ABDState P V) (ABDMsg P V) V)} {xs : ωSequence (Action P (ABDMsg P V) V)} (ha : (abdProtocol P V v₀ t).AdmissibleRun F ss xs) (k₀ i : ℕ) (hi₀ : i < (ss k₀).history.length) (hc : (ss k₀).history[i].caller ∉ F) :
∃ (j : ℕ) (hij : i < (ss j).history.length), k₀ ≤ j ∧ (ss j).history[i].status.isCompleted = true

Fair-crash termination (abd_terminates) for the cardinality-quorum envelope protocol abdProtocol: when 2 * t < Fintype.card P and F.card ≤ t, every operation invoked by a non-faulty process (caller ∉ F) eventually completes in every Protocol.Fair F execution (a separate envelope-liveness property accompanying abd_linearizable, without message or time cost bounds).

theorem Cslib.Distributed.ABD.implementsAtomicRegister_abd {P : Type u_1} {V : Type u_2} [Fintype P] [DecidableEq P] [LinearOrder P] [DecidableEq V] {t : ℕ} (h2t : 2 * t < Fintype.card P) (v₀ : V) :

Combined safety and fair-crash termination (implementsAtomicRegister_abd) for the cardinality-quorum envelope specialization after [LS97], §4.1–4.2 (and not the cited Theorem 4.5 or [ABND95] Theorem 4.9 endpoint): when 2 * t < Fintype.card P, abdProtocol P V v₀ t satisfies ImplementsAtomicRegister v₀ t over concrete point-to-point envelopes with (n - t)-cardinality quorums, idle-only invocations, and eventual delivery outside F (pairing abd_linearizable with the separate liveness property abd_terminates, without read/write quorum-family generality, per-processor request queues, or cost bounds).