Documentation

CslibFrontier.Computability.Distributed.ABD.Basic

Asynchronous crash-fault message passing and linearizable atomic register specification #

This module models deterministic asynchronous point-to-point message passing with crash faults and client read / write invocations, together with the linearizability (atomicity) and wait-free termination specifications for emulating a shared multi-writer multi-reader atomic register ([ABND95]; [LS97]).

Following Cslib.FLP, processes in a finite set P communicate over an unordered multiset of in-flight point-to-point envelopes (Envelope P M), and crash faults are modeled through the fairness condition (Protocol.Fair F): every envelope addressed to a non-faulty process dest ∉ F is eventually delivered, while faulty processes p ∈ F may stop receiving messages or taking steps at any point in an execution (including initially or mid-broadcast). Unlike the per-edge ping-pong channels and message/time accounting of [ABND95] (§§2.1, 3–4) or the conditional delay bounds of [LS97] (§4.3), Protocol tracks pure asynchronous reachability and eventual delivery outside F.

Each idle process p : P may invoke OpKind.read or OpKind.write v via Action.invoke p kind. Every invocation appends an OpRecord P V to the global execution history recording its caller, operation kind, invocation step invStep, and completion status (pending, doneRead respStep val, or doneWrite respStep). An execution history hist is linearizable (Linearizable v₀ hist) if there exists a duplicate-free sequence seq : List ℕ of operation indices containing every completed operation and optionally a subset of pending writes such that:

When Fintype.card P ≤ 1, a single process needs no network coordination: localRegisterProtocol executes read and write locally in zero messages and satisfies ImplementsAtomicRegister v₀ t for every fault bound t.

Relationship to Cslib.DistributedConsistency #

Upstream Cslib.DistributedConsistency (AbstractExecution.Linearizability, following Burckhardt 2014) axiomatizes consistency guarantees over abstract event sets equipped with declarative visibility (vis) and arbitration (ar) relations on a ReplicatedDataType. Here Linearizable instead formalizes Herlihy–Wing shared-register linearizability directly on finite operational LTS histories List (OpRecord P V), handling incomplete execution prefixes via subsets of pending writes and providing a kernel-reducible Decidable instance (instDecidableLinearizable) for concrete protocol traces.

Main definitions #

Main results #

References #

Envelopes and broadcast helper #

structure Cslib.Distributed.ABD.Envelope (P : Type u_1) (M : Type u_2) :
Type (max u_1 u_2)

A point-to-point message envelope in transit from src to dest carrying payload body.

  • src : P

    Sender process identity.

  • dest : P

    Destination process identity.

  • body : M

    Message payload.

theorem Cslib.Distributed.ABD.Envelope.ext_iff {P : Type u_1} {M : Type u_2} {x y : Envelope P M} :
x = y ↔ x.src = y.src ∧ x.dest = y.dest ∧ x.body = y.body
theorem Cslib.Distributed.ABD.Envelope.ext {P : Type u_1} {M : Type u_2} {x y : Envelope P M} (src : x.src = y.src) (dest : x.dest = y.dest) (body : x.body = y.body) :
x = y
@[instance_reducible]
instance Cslib.Distributed.ABD.instDecidableEqEnvelope {P✝ : Type u_1} {M✝ : Type u_2} [DecidableEq P✝] [DecidableEq M✝] :
DecidableEq (Envelope P✝ M✝)
def Cslib.Distributed.ABD.instDecidableEqEnvelope.decEq {P✝ : Type u_1} {M✝ : Type u_2} [DecidableEq P✝] [DecidableEq M✝] (x✝ x✝¹ : Envelope P✝ M✝) :
Decidable (x✝ = x✝¹)
def Cslib.Distributed.ABD.tagSender {P : Type u_1} {M : Type u_2} (src : P) :
P × M → Envelope P M

Tag a (dest, body) pair emitted by src as an Envelope.

@[simp]
theorem Cslib.Distributed.ABD.tagSender_src {P : Type u_1} {M : Type u_2} (src : P) (pm : P × M) :
(tagSender src pm).src = src
@[simp]
theorem Cslib.Distributed.ABD.tagSender_dest {P : Type u_1} {M : Type u_2} (src : P) (pm : P × M) :
(tagSender src pm).dest = pm.1
@[simp]
theorem Cslib.Distributed.ABD.tagSender_body {P : Type u_1} {M : Type u_2} (src : P) (pm : P × M) :
(tagSender src pm).body = pm.2
def Cslib.Distributed.ABD.broadcastAll (P : Type u_1) {M : Type u_2} [Fintype P] (m : M) :
Multiset (P × M)

Broadcast payload m to every process q : P (including the sender itself).

@[simp]
theorem Cslib.Distributed.ABD.card_broadcastAll {P : Type u_1} {M : Type u_2} [Fintype P] (m : M) :
theorem Cslib.Distributed.ABD.mem_broadcastAll_tag {P : Type u_1} {M : Type u_2} [Fintype P] (src q : P) (m : M) :
{ src := src, dest := q, body := m } ∈ Multiset.map (tagSender src) (broadcastAll P m)

Broadcasting m from src sends an envelope ⟨src, q, m⟩ to every recipient q : P.

Client operations, execution histories, and linearizability #

inductive Cslib.Distributed.ABD.OpKind (V : Type u_1) :
Type u_1

Client operation invoked on an emulated shared register.

  • read {V : Type u_1} : OpKind V

    Read the current value of the register.

  • write {V : Type u_1} (v : V) : OpKind V

    Write value v to the register.

@[instance_reducible]
def Cslib.Distributed.ABD.instDecidableEqOpKind.decEq {V✝ : Type u_1} [DecidableEq V✝] (x✝ x✝¹ : OpKind V✝) :
Decidable (x✝ = x✝¹)
inductive Cslib.Distributed.ABD.OpResp (V : Type u_1) :
Type u_1

Completion response emitted by a process for its active client operation.

  • readRet {V : Type u_1} (val : V) : OpResp V

    Complete an active read operation, returning val.

  • writeAck {V : Type u_1} : OpResp V

    Complete an active write operation.

@[instance_reducible]
def Cslib.Distributed.ABD.instDecidableEqOpResp.decEq {V✝ : Type u_1} [DecidableEq V✝] (x✝ x✝¹ : OpResp V✝) :
Decidable (x✝ = x✝¹)
inductive Cslib.Distributed.ABD.OpStatus (V : Type u_1) :
Type u_1

Completion status of an invoked register operation in a global execution history.

  • pending {V : Type u_1} : OpStatus V

    Operation has been invoked and has not yet completed.

  • doneRead {V : Type u_1} (respStep : ℕ) (val : V) : OpStatus V

    A read operation completed at transition step respStep, returning val.

  • doneWrite {V : Type u_1} (respStep : ℕ) : OpStatus V

    A write operation completed at transition step respStep.

@[instance_reducible]
def Cslib.Distributed.ABD.instDecidableEqOpStatus.decEq {V✝ : Type u_1} [DecidableEq V✝] (x✝ x✝¹ : OpStatus V✝) :
Decidable (x✝ = x✝¹)

Transition step at which an operation completed, or none if still pending.

Boolean check for whether an operation has completed.

structure Cslib.Distributed.ABD.OpRecord (P : Type u_1) (V : Type u_2) :
Type (max u_1 u_2)

Record of an invoked client operation in a global execution history.

  • caller : P

    Process that invoked the operation.

  • kind : OpKind V

    Operation invoked (read or write v).

  • invStep : ℕ

    Global non-stutter step counter when the operation was invoked.

  • status : OpStatus V

    Current completion status.

theorem Cslib.Distributed.ABD.OpRecord.ext {P : Type u_1} {V : Type u_2} {x y : OpRecord P V} (caller : x.caller = y.caller) (kind : x.kind = y.kind) (invStep : x.invStep = y.invStep) (status : x.status = y.status) :
x = y
def Cslib.Distributed.ABD.instDecidableEqOpRecord.decEq {P✝ : Type u_1} {V✝ : Type u_2} [DecidableEq P✝] [DecidableEq V✝] (x✝ x✝¹ : OpRecord P✝ V✝) :
Decidable (x✝ = x✝¹)
@[instance_reducible]
instance Cslib.Distributed.ABD.instDecidableEqOpRecord {P✝ : Type u_1} {V✝ : Type u_2} [DecidableEq P✝] [DecidableEq V✝] :
DecidableEq (OpRecord P✝ V✝)
def Cslib.Distributed.ABD.OpRecord.isEligible {P : Type u_1} {V : Type u_2} (rec : OpRecord P V) :

Check whether an OpRecord is a valid participant in a linearization: either a completed read, a completed write, or a pending write.

Instances For
    @[instance_reducible]
    def Cslib.Distributed.ABD.prec {P : Type u_1} {V : Type u_2} (hist : List (OpRecord P V)) (i j : ℕ) :

    Real-time strict precedence between operations i and j in hist: operation i completed at some step r strictly before operation j was invoked (r < hist[j].invStep).

    Instances For
      @[instance_reducible]
      instance Cslib.Distributed.ABD.instDecidablePrec {P : Type u_1} {V : Type u_2} (hist : List (OpRecord P V)) (i j : ℕ) :
      Decidable (prec hist i j)
      theorem Cslib.Distributed.ABD.prec_irrefl {P : Type u_1} {V : Type u_2} {hist : List (OpRecord P V)} (hwf : ∀ (i : ℕ) (hi : i < hist.length) (r : ℕ), hist[i].status.respStep? = some r → hist[i].invStep ≤ r) (i : ℕ) :
      ¬prec hist i i

      Every completed operation in a well-timed history satisfies invStep ≤ respStep, making prec hist irreflexive.

      theorem Cslib.Distributed.ABD.prec_trans {P : Type u_1} {V : Type u_2} {hist : List (OpRecord P V)} (hwf : ∀ (i : ℕ) (hi : i < hist.length) (r : ℕ), hist[i].status.respStep? = some r → hist[i].invStep ≤ r) {i j k : ℕ} (hij : prec hist i j) (hjk : prec hist j k) :
      prec hist i k

      On any well-timed history (invStep ≤ respStep for completed operations), real-time precedence prec hist is transitive.

      def Cslib.Distributed.ABD.seqValid {P : Type u_1} {V : Type u_2} (cur : V) (hist : List (OpRecord P V)) :

      Sequential atomic read/write register validity along a list seq of operation indices starting from current value cur: each write v (completed or pending) updates the register to v, and each completed read returns the current register value cur.

      Instances For
        @[instance_reducible]
        instance Cslib.Distributed.ABD.instDecidableSeqValid {P : Type u_1} {V : Type u_2} [DecidableEq V] (cur : V) (hist : List (OpRecord P V)) (seq : List ℕ) :
        Decidable (seqValid cur hist seq)
        def Cslib.Distributed.ABD.registerValAfter {P : Type u_1} {V : Type u_2} (v₀ : V) (hist : List (OpRecord P V)) (pref : List ℕ) :
        V

        Register value produced after sequentially executing a prefix pref of operation indices from initial value v₀: the value written by the last write in pref, or v₀ if pref contains no write.

        @[simp]
        theorem Cslib.Distributed.ABD.registerValAfter_nil {P : Type u_1} {V : Type u_2} (v₀ : V) (hist : List (OpRecord P V)) :
        registerValAfter v₀ hist [] = v₀
        @[simp]
        theorem Cslib.Distributed.ABD.registerValAfter_cons {P : Type u_1} {V : Type u_2} (v₀ : V) (hist : List (OpRecord P V)) (i : ℕ) (rest : List ℕ) :
        registerValAfter v₀ hist (i :: rest) = registerValAfter (match hist[i]? with | some rec => match rec.kind with | OpKind.write v => v | OpKind.read => v₀ | none => v₀) hist rest
        theorem Cslib.Distributed.ABD.registerValAfter_append {P : Type u_1} {V : Type u_2} (v₀ : V) (hist : List (OpRecord P V)) (l₁ l₂ : List ℕ) :
        registerValAfter v₀ hist (l₁ ++ l₂) = registerValAfter (registerValAfter v₀ hist l₁) hist l₂

        Sequential register evaluation splits across list concatenation.

        theorem Cslib.Distributed.ABD.seqValid_iff_registerValAfter {P : Type u_1} {V : Type u_2} (v₀ : V) (hist : List (OpRecord P V)) (seq : List ℕ) :
        seqValid v₀ hist seq ↔ (∀ i ∈ seq, ∃ (hi : i < hist.length), hist[i].isEligible) ∧ ∀ (k : ℕ) (hk : k < seq.length) (hi : seq[k] < hist.length) (s : ℕ) (r : V), hist[seq[k]].status = OpStatus.doneRead s r → r = registerValAfter v₀ hist (List.take k seq)

        Preceding-write characterization of seqValid: a sequence seq satisfies seqValid v₀ hist seq if and only if every index in seq is an in-bounds eligible operation (completed read, completed write, or pending write) and every completed read at position k returns registerValAfter v₀ hist (seq.take k) (the value written by the immediately preceding write in seq, or v₀ if no write precedes position k).

        structure Cslib.Distributed.ABD.IsLinearization {P : Type u_1} {V : Type u_2} (v₀ : V) (hist : List (OpRecord P V)) (seq : List ℕ) :

        IsLinearization v₀ hist seq states that seq is a valid linearization of execution history hist for an atomic read/write register initialized to v₀:

        • nodup: no operation index appears twice in seq;
        • complete: every completed operation in hist appears in seq;
        • respects_prec: if i, j ∈ seq and prec hist i j (i completed strictly before j was invoked), then i precedes j in seq (seq.idxOf i < seq.idxOf j);
        • valid: seq obeys sequential read/write register semantics from v₀ (and contains only completed reads, completed writes, and optionally pending writes).
        • nodup : seq.Nodup

          Each operation index occurs at most once.

        • complete (i : ℕ) (hi : i < hist.length) : hist[i].status.isCompleted = true → i ∈ seq

          Every completed operation is included in the linearization.

        • respects_prec (i : ℕ) : i ∈ seq → ∀ j ∈ seq, prec hist i j → List.idxOf i seq < List.idxOf j seq

          Real-time precedence is preserved.

        • valid : seqValid v₀ hist seq

          Sequential read/write register semantics hold from initial value v₀.

        Instances For
          @[instance_reducible]
          instance Cslib.Distributed.ABD.instDecidableIsLinearization {P : Type u_1} {V : Type u_2} [DecidableEq V] (v₀ : V) (hist : List (OpRecord P V)) (seq : List ℕ) :
          Decidable (IsLinearization v₀ hist seq)
          def Cslib.Distributed.ABD.Linearizable {P : Type u_1} {V : Type u_2} (v₀ : V) (hist : List (OpRecord P V)) :

          An execution history hist is linearizable (atomic) with initial value v₀ if there exists a valid linearization sequence seq.

          Instances For
            @[simp]
            theorem Cslib.Distributed.ABD.linearizable_nil {P : Type u_1} {V : Type u_2} (v₀ : V) :

            The empty execution history is trivially linearizable for every initial value v₀.

            Insert index k at every position in ys. Marked @[expose] so instDecidableLinearizable reduces completely under decide in downstream module clients.

            Enumerate all duplicate-free sequences of indices strictly below n.

            @[instance_reducible]
            instance Cslib.Distributed.ABD.instDecidableLinearizable {P : Type u_1} {V : Type u_2} [DecidableEq V] (v₀ : V) (hist : List (OpRecord P V)) :

            Computable Decidable instance for Linearizable v₀ hist over finite histories when V has decidable equality, obtained by checking candidateSeqs hist.length.

            Asynchronous message-passing protocol and LTS #

            structure Cslib.Distributed.ABD.StepOut (P : Type u_1) (M : Type u_2) (S : Type u_3) (V : Type u_4) :
            Type (max (max (max u_1 u_2) u_3) u_4)

            Local transition output emitted by a process upon a client invocation or message delivery.

            • nextState : S

              Updated internal local state.

            • outgoing : Multiset (P × M)

              Outgoing (dest, body) messages emitted onto the network.

            • resp : Option (OpResp V)

              Optional completion response for the process's currently pending operation.

            theorem Cslib.Distributed.ABD.StepOut.ext {P : Type u_1} {M : Type u_2} {S : Type u_3} {V : Type u_4} {x y : StepOut P M S V} (nextState : x.nextState = y.nextState) (outgoing : x.outgoing = y.outgoing) (resp : x.resp = y.resp) :
            x = y
            theorem Cslib.Distributed.ABD.StepOut.ext_iff {P : Type u_1} {M : Type u_2} {S : Type u_3} {V : Type u_4} {x y : StepOut P M S V} :
            @[instance_reducible]
            instance Cslib.Distributed.ABD.instDecidableEqStepOut {P✝ : Type u_1} {M✝ : Type u_2} {S✝ : Type u_3} {V✝ : Type u_4} [DecidableEq P✝] [DecidableEq M✝] [DecidableEq S✝] [DecidableEq V✝] :
            DecidableEq (StepOut P✝ M✝ S✝ V✝)
            def Cslib.Distributed.ABD.instDecidableEqStepOut.decEq {P✝ : Type u_1} {M✝ : Type u_2} {S✝ : Type u_3} {V✝ : Type u_4} [DecidableEq P✝] [DecidableEq M✝] [DecidableEq S✝] [DecidableEq V✝] (x✝ x✝¹ : StepOut P✝ M✝ S✝ V✝) :
            Decidable (x✝ = x✝¹)
            structure Cslib.Distributed.ABD.PendingOp (V : Type u_1) :
            Type u_1

            Active client operation currently pending at a process.

            theorem Cslib.Distributed.ABD.PendingOp.ext {V : Type u_1} {x y : PendingOp V} (opId : x.opId = y.opId) (kind : x.kind = y.kind) :
            x = y
            def Cslib.Distributed.ABD.instDecidableEqPendingOp.decEq {V✝ : Type u_1} [DecidableEq V✝] (x✝ x✝¹ : PendingOp V✝) :
            Decidable (x✝ = x✝¹)
            @[instance_reducible]
            structure Cslib.Distributed.ABD.ProcState (S : Type u_1) (V : Type u_2) :
            Type (max u_1 u_2)

            Local configuration of a process: protocol state paired with at most one active operation.

            • state : S

              Internal protocol state.

            • pending : Option (PendingOp V)

              Active client operation (none when the process is idle).

            theorem Cslib.Distributed.ABD.ProcState.ext_iff {S : Type u_1} {V : Type u_2} {x y : ProcState S V} :
            theorem Cslib.Distributed.ABD.ProcState.ext {S : Type u_1} {V : Type u_2} {x y : ProcState S V} (state : x.state = y.state) (pending : x.pending = y.pending) :
            x = y
            @[instance_reducible]
            instance Cslib.Distributed.ABD.instDecidableEqProcState {S✝ : Type u_1} {V✝ : Type u_2} [DecidableEq S✝] [DecidableEq V✝] :
            def Cslib.Distributed.ABD.instDecidableEqProcState.decEq {S✝ : Type u_1} {V✝ : Type u_2} [DecidableEq S✝] [DecidableEq V✝] (x✝ x✝¹ : ProcState S✝ V✝) :
            Decidable (x✝ = x✝¹)
            structure Cslib.Distributed.ABD.State (P : Type u_1) (S : Type u_2) (M : Type u_3) (V : Type u_4) :
            Type (max (max (max u_1 u_2) u_3) u_4)

            Global configuration of an asynchronous register-emulation network.

            • msgs : Multiset (Envelope P M)

              Multiset of unordered point-to-point envelopes currently in transit.

            • proc : P → ProcState S V

              Local state and active client status of every process.

            • history : List (OpRecord P V)

              Chronological log of all client operations invoked so far.

            • step : ℕ

              Number of non-stutter transitions elapsed so far (used for invStep and respStep).

            theorem Cslib.Distributed.ABD.State.ext {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} {x y : State P S M V} (msgs : x.msgs = y.msgs) (proc : x.proc = y.proc) (history : x.history = y.history) (step : x.step = y.step) :
            x = y
            theorem Cslib.Distributed.ABD.State.ext_iff {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} {x y : State P S M V} :
            inductive Cslib.Distributed.ABD.Action (P : Type u_1) (M : Type u_2) (V : Type u_3) :
            Type (max (max u_1 u_2) u_3)

            Transition label for the asynchronous register-emulation LTS.

            @[instance_reducible]
            instance Cslib.Distributed.ABD.instDecidableEqAction {P✝ : Type u_1} {M✝ : Type u_2} {V✝ : Type u_3} [DecidableEq P✝] [DecidableEq M✝] [DecidableEq V✝] :
            DecidableEq (Action P✝ M✝ V✝)
            def Cslib.Distributed.ABD.instDecidableEqAction.decEq {P✝ : Type u_1} {M✝ : Type u_2} {V✝ : Type u_3} [DecidableEq P✝] [DecidableEq M✝] [DecidableEq V✝] (x✝ x✝¹ : Action P✝ M✝ V✝) :
            Decidable (x✝ = x✝¹)
            structure Cslib.Distributed.ABD.Protocol (P : Type u_1) (S : Type u_2) (M : Type u_3) (V : Type u_4) :
            Type (max (max (max u_1 u_2) u_3) u_4)

            Deterministic asynchronous message-passing protocol emulating a shared register over P.

            • init : P → S

              Initial internal state of process p.

            • initMsgs : P → Multiset (P × M)

              Initial outgoing messages (dest, body) emitted by process p at boot.

            • onInvoke : P → S → OpKind V → StepOut P M S V

              Local transition when process p in state st invokes client operation kind.

            • onRecv : P → S → P → M → StepOut P M S V

              Local transition when process dest in state st receives body from src.

            def Cslib.Distributed.ABD.matchCompletion {V : Type u_1} (kind : OpKind V) (resp : Option (OpResp V)) (step : ℕ) :

            Match an emitted OpResp against the active OpKind to form a completed OpStatus at step (or none if no matching completion was emitted).

            def Cslib.Distributed.ABD.invokePending {V : Type u_1} (opId : ℕ) (kind : OpKind V) (resp : Option (OpResp V)) (step : ℕ) :

            Updated pending field after invoking kind at opId.

            def Cslib.Distributed.ABD.deliverPending {V : Type u_1} (pend? : Option (PendingOp V)) (resp : Option (OpResp V)) (step : ℕ) :

            Updated pending field after delivering a message with completion output resp.

            def Cslib.Distributed.ABD.deliverHistory {P : Type u_1} {V : Type u_2} (hist : List (OpRecord P V)) (resp : Option (OpResp V)) (step : ℕ) :

            Updated history list after delivering a message with completion output resp.

            @[simp]
            theorem Cslib.Distributed.ABD.matchCompletion_none {V : Type u_1} (kind : OpKind V) (step : ℕ) :
            @[simp]
            theorem Cslib.Distributed.ABD.invokePending_none {V : Type u_1} (opId : ℕ) (kind : OpKind V) (step : ℕ) :
            invokePending opId kind none step = some { opId := opId, kind := kind }
            @[simp]
            theorem Cslib.Distributed.ABD.deliverPending_none {V : Type u_1} (pend? : Option (PendingOp V)) (step : ℕ) :
            deliverPending pend? none step = pend?
            @[simp]
            theorem Cslib.Distributed.ABD.deliverHistory_none {P : Type u_1} {V : Type u_2} (hist : List (OpRecord P V)) (step : ℕ) (pend? : Option (PendingOp V)) :
            deliverHistory hist none step pend? = hist
            @[simp]
            theorem Cslib.Distributed.ABD.length_deliverHistory {P : Type u_1} {V : Type u_2} (hist : List (OpRecord P V)) (resp : Option (OpResp V)) (step : ℕ) (pend? : Option (PendingOp V)) :
            (deliverHistory hist resp step pend?).length = hist.length
            theorem Cslib.Distributed.ABD.deliverHistory_entry_preserves {P : Type u_1} {V : Type u_2} (hist : List (OpRecord P V)) (resp : Option (OpResp V)) (step : ℕ) (pend? : Option (PendingOp V)) {i : ℕ} (hi : i < hist.length) (hi' : i < (deliverHistory hist resp step pend?).length) :
            (deliverHistory hist resp step pend?)[i].caller = hist[i].caller ∧ (deliverHistory hist resp step pend?)[i].kind = hist[i].kind ∧ (deliverHistory hist resp step pend?)[i].invStep = hist[i].invStep ∧ ∀ (r : ℕ), (deliverHistory hist resp step pend?)[i].status.respStep? = some r → hist[i].status.respStep? = some r ∨ r = step

            Delivering a response preserves caller, kind, and invStep at every index i < hist.length, and any response timestamp in deliverHistory either was already present in hist or equals step.

            def Cslib.Distributed.ABD.Protocol.start {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} (π : Protocol P S M V) [Fintype P] :
            State P S M V

            Initial global state of π: all processes are idle in π.init p, history is empty, and step = 0.

            def Cslib.Distributed.ABD.Protocol.doInvoke {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] (π : Protocol P S M V) (caller : P) (kind : OpKind V) (s : State P S M V) :
            State P S M V

            State transition when idle process caller invokes kind.

            def Cslib.Distributed.ABD.Protocol.doDeliver {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) (e : Envelope P M) (s : State P S M V) :
            State P S M V

            State transition when in-flight envelope e is delivered to e.dest.

            theorem Cslib.Distributed.ABD.Protocol.doInvoke_of_resp_eq_none {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] (π : Protocol P S M V) {caller : P} {kind : OpKind V} {s : State P S M V} {nextSt : S} {outMsgs : Multiset (P × M)} (hout : π.onInvoke caller (s.proc caller).state kind = { nextState := nextSt, outgoing := outMsgs, resp := none }) :
            π.doInvoke caller kind s = { msgs := s.msgs + Multiset.map (tagSender caller) outMsgs, proc := Function.update s.proc caller { state := nextSt, pending := some { opId := s.history.length, kind := kind } }, history := s.history ++ [{ caller := caller, kind := kind, invStep := s.step, status := OpStatus.pending }], step := s.step + 1 }

            Unfolding equation for doInvoke when onInvoke does not complete immediately (resp = none).

            theorem Cslib.Distributed.ABD.Protocol.doDeliver_of_resp_eq_none {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) {e : Envelope P M} {s : State P S M V} {nextSt : S} {outMsgs : Multiset (P × M)} (hout : π.onRecv e.dest (s.proc e.dest).state e.src e.body = { nextState := nextSt, outgoing := outMsgs, resp := none }) :
            π.doDeliver e s = { msgs := s.msgs.erase e + Multiset.map (tagSender e.dest) outMsgs, proc := Function.update s.proc e.dest { state := nextSt, pending := (s.proc e.dest).pending }, history := s.history, step := s.step + 1 }

            Unfolding equation for doDeliver when onRecv emits no completion response (resp = none).

            theorem Cslib.Distributed.ABD.Protocol.doDeliver_of_complete {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) {e : Envelope P M} {s : State P S M V} {nextSt : S} {outMsgs : Multiset (P × M)} {resp : Option (OpResp V)} {pend : PendingOp V} {stDone : OpStatus V} (hout : π.onRecv e.dest (s.proc e.dest).state e.src e.body = { nextState := nextSt, outgoing := outMsgs, resp := resp }) (hpend : (s.proc e.dest).pending = some pend) (hmatch : matchCompletion pend.kind resp s.step = some stDone) (hi : pend.opId < s.history.length) :
            π.doDeliver e s = { msgs := s.msgs.erase e + Multiset.map (tagSender e.dest) outMsgs, proc := Function.update s.proc e.dest { state := nextSt, pending := none }, history := s.history.set pend.opId (have __src := s.history[pend.opId]; { caller := __src.caller, kind := __src.kind, invStep := __src.invStep, status := stDone }), step := s.step + 1 }

            Unfolding equation for doDeliver when onRecv completes e.dest's pending operation.

            def Cslib.Distributed.ABD.Protocol.lts {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) :
            LTS (State P S M V) (Action P M V)

            Labelled transition system of π.

            def Cslib.Distributed.ABD.Protocol.Reachable {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) [Fintype P] (s : State P S M V) :

            π.Reachable s means s is reachable from π.start under π.lts.

            theorem Cslib.Distributed.ABD.Protocol.reachable_start {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) [Fintype P] :

            The initial state π.start is reachable.

            theorem Cslib.Distributed.ABD.Protocol.Reachable.trans {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] [Fintype P] {π : Protocol P S M V} {s s' : State P S M V} (hs : π.Reachable s) (hreach : π.lts.CanReach s s') :
            π.Reachable s'

            Reachability from π.start composes with π.lts.CanReach.

            Structural invariants of history and msgs #

            theorem Cslib.Distributed.ABD.Protocol.mTr_history_length_le {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) {s t : State P S M V} {xl : List (Action P M V)} (hmtr : π.lts.MTr s xl t) :

            Execution history length never decreases along a finite execution.

            theorem Cslib.Distributed.ABD.Protocol.mTr_history_entry_preserves {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) {s t : State P S M V} {xl : List (Action P M V)} (hmtr : π.lts.MTr s xl t) {i : ℕ} (hi : i < s.history.length) (hit : i < t.history.length) :

            Every finite sequence of transitions preserves caller, kind, and invStep at every already-invoked index i < s.history.length.

            theorem Cslib.Distributed.ABD.Protocol.tr_history_completed_stable {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) {s s' : State P S M V} {a : Action P M V} (htr : π.lts.Tr s a s') {i : ℕ} (hi : i < s.history.length) (hcomp : s.history[i].status.isCompleted = true) (hpend : ∀ (p : P) (pend : PendingOp V), (s.proc p).pending = some pend → ∃ (hlt : pend.opId < s.history.length), s.history[pend.opId].status = OpStatus.pending) :
            ∃ (hi' : i < s'.history.length), s'.history[i] = s.history[i]

            Completed entries in history never change across transitions.

            theorem Cslib.Distributed.ABD.Protocol.tr_notDelivered_mem {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) {s s' : State P S M V} {a : Action P M V} {e : Envelope P M} (he : e ∈ s.msgs) (ha : a ≠ Action.deliver e) (htr : π.lts.Tr s a s') :
            e ∈ s'.msgs

            An in-flight envelope e stays in msgs across any transition other than .deliver e.

            Fairness, admissible executions, and round-robin scheduler #

            def Cslib.Distributed.ABD.Protocol.Fair {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} (F : Finset P) (ss : ωSequence (State P S M V)) (xs : ωSequence (Action P M V)) :

            Fairness relative to static faulty set F: every in-flight envelope addressed to a non-faulty process e.dest ∉ F is eventually delivered.

            def Cslib.Distributed.ABD.Protocol.AdmissibleRun {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) [Fintype P] (F : Finset P) (ss : ωSequence (State P S M V)) (xs : ωSequence (Action P M V)) :

            An admissible infinite execution of π relative to static faulty set F.

            theorem Cslib.Distributed.ABD.Protocol.admissibleRun_reachable {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) [Fintype P] {F : Finset P} {ss : ωSequence (State P S M V)} {xs : ωSequence (Action P M V)} (ha : π.AdmissibleRun F ss xs) (k : ℕ) :
            π.Reachable (ss k)

            Every state along an AdmissibleRun is reachable from π.start.

            def Cslib.Distributed.ABD.Protocol.IsDrainAction {P : Type u_1} {M : Type u_3} {V : Type u_4} (F : Finset P) :
            Action P M V → Prop

            Predicate for delivery/stutter actions that do not invoke new client operations and only deliver to destinations outside F.

            theorem Cslib.Distributed.ABD.Protocol.exists_fair_omegaExecution {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) (F : Finset P) (s₀ : State P S M V) :
            ∃ (ss : ωSequence (State P S M V)) (xs : ωSequence (Action P M V)), ss 0 = s₀ ∧ π.lts.OmegaExecution ss xs ∧ Fair F ss xs ∧ ∀ (k : ℕ), IsDrainAction F (xs k)

            Every state s₀ extends to a fair infinite execution in which no new client operations are invoked and no envelopes addressed to F are delivered (IsDrainAction F).

            theorem Cslib.Distributed.ABD.Protocol.Reachable.exists_admissibleRun {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] [Fintype P] {π : Protocol P S M V} (F : Finset P) {s : State P S M V} (hr : π.Reachable s) :
            ∃ (ss : ωSequence (State P S M V)) (xs : ωSequence (Action P M V)) (k : ℕ), π.AdmissibleRun F ss xs ∧ ss k = s ∧ ∀ (j : ℕ), k ≤ j → IsDrainAction F (xs j)

            Every reachable state occurs in an AdmissibleRun F whose suffix from step k onward performs only IsDrainAction F steps.

            Wait-free linearizable atomic register specification #

            structure Cslib.Distributed.ABD.Protocol.ImplementsAtomicRegister {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) [Fintype P] (v₀ : V) (t : ℕ) :

            π.ImplementsAtomicRegister v₀ t means π emulates a wait-free linearizable (atomic) multi-writer multi-reader shared register initialized to v₀, tolerating up to t crash faults ([ABND95]):

            • linearizable (safety / atomicity): every reachable execution history is linearizable from initial value v₀;
            • terminates (wait-free liveness): in every fair execution with at most t crashed processes (F.card ≤ t), every operation invoked by a non-faulty process (caller ∉ F) eventually completes.
            theorem Cslib.Distributed.ABD.Protocol.ImplementsAtomicRegister.mono {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] [Fintype P] {π : Protocol P S M V} {v₀ : V} {t t' : ℕ} (h : π.ImplementsAtomicRegister v₀ t) (ht : t' ≤ t) :

            Tolerating t crash faults implies tolerating at most t' ≤ t crash faults.

            theorem Cslib.Distributed.ABD.Protocol.linearizable_iff_admissible {P : Type u_1} {S : Type u_2} {M : Type u_3} {V : Type u_4} [DecidableEq P] [DecidableEq M] (π : Protocol P S M V) [Fintype P] (v₀ : V) (t : ℕ) :
            (∀ (s : State P S M V), π.Reachable s → Linearizable v₀ s.history) ↔ ∀ (F : Finset P), F.card ≤ t → ∀ (ss : ωSequence (State P S M V)) (xs : ωSequence (Action P M V)), π.AdmissibleRun F ss xs → ∀ (k : ℕ), Linearizable v₀ (ss k).history

            Linearizability across all reachable states is equivalent to linearizability of every finite prefix along all t-fault admissible infinite executions.

            Zero-message local register baseline (Fintype.card P ≤ 1) #

            Single-process local register protocol: each process stores a local value initialized to v₀ and completes read and write invocations immediately in zero messages. When Fintype.card P ≤ 1, no second process exists to observe a divergent copy, so this protocol implements a wait-free linearizable register against any fault bound t.

            When Fintype.card P ≤ 1, localRegisterProtocol implements a wait-free linearizable atomic register for any fault bound t.