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:
seqrespects the real-time precedence orderprec hist(op₁completed strictly beforeop₂was invoked impliesop₁precedesop₂inseq), and- executing
seqsequentially from initial register valuev₀obeys atomic read/write semantics (seqValid, equivalentlyseqValid_iff_registerValAfter: every completedreadreturns the value written by the immediately precedingwriteinseq, orv₀if none precedes it).
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 #
Cslib.Distributed.ABD.Envelope: point-to-point message envelope carryingsrc,dest,body.Cslib.Distributed.ABD.OpKind,Cslib.Distributed.ABD.OpResp,Cslib.Distributed.ABD.OpStatus,Cslib.Distributed.ABD.OpRecord: client register invocations, responses, and recorded history entries.Cslib.Distributed.ABD.prec: real-time strict precedence onOpRecordindices (respStep < invStep).Cslib.Distributed.ABD.seqValid,Cslib.Distributed.ABD.registerValAfter,Cslib.Distributed.ABD.IsLinearization,Cslib.Distributed.ABD.Linearizable: sequential register semantics and Herlihy–Wing linearizability of an execution history.Cslib.Distributed.ABD.StepOut,Cslib.Distributed.ABD.PendingOp,Cslib.Distributed.ABD.ProcState,Cslib.Distributed.ABD.State,Cslib.Distributed.ABD.Action,Cslib.Distributed.ABD.Protocol: asynchronous register-emulation protocol and its labelled transition systemProtocol.lts.Cslib.Distributed.ABD.Protocol.Fair,Cslib.Distributed.ABD.Protocol.AdmissibleRun: fair delivery to non-faulty processes∉ Fand admissible infinite executions.Cslib.Distributed.ABD.Protocol.ImplementsAtomicRegister: safety (linearizable) and wait-free liveness (terminates) against up totcrash faults.Cslib.Distributed.ABD.localRegisterProtocol: zero-message local register protocol for at most one process.
Main results #
Cslib.Distributed.ABD.prec_irrefl,Cslib.Distributed.ABD.prec_trans: real-time precedence is irreflexive and transitive on well-timed histories.Cslib.Distributed.ABD.seqValid_iff_registerValAfter:seqValidholds iff every entry inseqis a completed read or (completed or pending) write and every completed read returnsregisterValAfter v₀ hist (seq.take k).Cslib.Distributed.ABD.instDecidableLinearizable: computableDecidableinstance forLinearizable v₀ histwhen[DecidableEq V].Cslib.Distributed.ABD.deliverHistory_entry_preserves,Cslib.Distributed.ABD.Protocol.mTr_history_entry_preserves: transitions preservecaller,kind, andinvStepof existing history records.Cslib.Distributed.ABD.Protocol.exists_fair_omegaExecution,Cslib.Distributed.ABD.Protocol.Reachable.exists_admissibleRun: every state extends via a delivery-only fair suffix to an infinite execution.Cslib.Distributed.ABD.Protocol.linearizable_iff_admissible: reachable-state linearizability is equivalent to prefix linearizability along allt-fault admissible runs.Cslib.Distributed.ABD.implementsAtomicRegister_local_of_card_le_one:localRegisterProtocolimplements a wait-free linearizable register for everytwhenFintype.card P ≤ 1.
References #
Envelopes and broadcast helper #
Broadcasting m from src sends an envelope ⟨src, q, m⟩ to every recipient q : P.
Client operations, execution histories, and linearizability #
Completion response emitted by a process for its active client operation.
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
readoperation completed at transition steprespStep, returningval. - doneWrite {V : Type u_1} (respStep : ℕ) : OpStatus V
A
writeoperation completed at transition steprespStep.
Boolean check for whether an operation has completed.
Record of an invoked client operation in a global execution history.
Every completed operation in a well-timed history satisfies invStep ≤ respStep, making
prec hist irreflexive.
On any well-timed history (invStep ≤ respStep for completed operations), real-time precedence
prec hist is transitive.
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
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.
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).
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 inseq;complete: every completed operation inhistappears inseq;respects_prec: ifi, j ∈ seqandprec hist i j(icompleted strictly beforejwas invoked), theniprecedesjinseq(seq.idxOf i < seq.idxOf j);valid:seqobeys sequential read/write register semantics fromv₀(and contains only completed reads, completed writes, and optionally pending writes).
- nodup : seq.Nodup
Each operation index occurs at most once.
Every completed operation is included in the linearization.
Real-time precedence is preserved.
- valid : seqValid v₀ hist seq
Sequential read/write register semantics hold from initial value
v₀.
Instances For
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.
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 #
Local transition output emitted by a process upon a client invocation or message delivery.
- nextState : S
Updated internal local state.
Outgoing
(dest, body)messages emitted onto the network.Optional completion response for the process's currently pending operation.
Local configuration of a process: protocol state paired with at most one active operation.
- state : S
Internal protocol state.
Active client operation (
nonewhen the process is idle).
Transition label for the asynchronous register-emulation LTS.
- invoke {P : Type u_1} {M : Type u_2} {V : Type u_3} (caller : P) (kind : OpKind V) : Action P M V
- deliver {P : Type u_1} {M : Type u_2} {V : Type u_3} (e : Envelope P M) : Action P M V
Deliver an in-flight envelope
etoe.dest. - stutter {P : Type u_1} {M : Type u_2} {V : Type u_3} : Action P M V
Stuttering step leaving the global state unchanged.
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.
State transition when in-flight envelope e is delivered to e.dest.
Unfolding equation for doInvoke when onInvoke does not complete immediately (resp = none).
Unfolding equation for doDeliver when onRecv emits no completion response (resp = none).
Unfolding equation for doDeliver when onRecv completes e.dest's pending operation.
Labelled transition system of π.
π.Reachable s means s is reachable from π.start under π.lts.
The initial state π.start is reachable.
Reachability from π.start composes with π.lts.CanReach.
Execution history length never decreases along a finite execution.
Every finite sequence of transitions preserves caller, kind, and invStep at every
already-invoked index i < s.history.length.
Completed entries in history never change across transitions.
An in-flight envelope e stays in msgs across any transition other than .deliver e.
Fairness, admissible executions, and round-robin scheduler #
Fairness relative to static faulty set F: every in-flight envelope addressed to a non-faulty
process e.dest ∉ F is eventually delivered.
An admissible infinite execution of π relative to static faulty set F.
Every state along an AdmissibleRun is reachable from π.start.
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).
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 #
π.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
tcrashed processes (F.card ≤ t), every operation invoked by a non-faulty process (caller ∉ F) eventually completes.
Safety (atomicity): every reachable global state has a linearizable execution history.
- terminates (F : Finset P) : F.card ≤ t → ∀ (ss : ωSequence (State P S M V)) (xs : ωSequence (Action P M V)), π.AdmissibleRun F ss xs → ∀ (k i : ℕ) (hi : i < (ss k).history.length), (ss k).history[i].caller ∉ F → ∃ (j : ℕ) (hij : i < (ss j).history.length), k ≤ j ∧ (ss j).history[i].status.isCompleted = true
Wait-free liveness: every operation invoked by a non-faulty process eventually completes in every
t-fault admissible execution.
Tolerating t crash faults implies tolerating at most t' ≤ t crash faults.
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.