Documentation

CslibFrontier.Computability.Distributed.SetAgreement.AtomicSnapshot.Model

Snapshot registers, scan orders, histories, and linearizability #

Defines single-writer multi-reader registers (SnapshotReg), collect scan orders (ScanOrder), client history records (SnapshotOpKind, SnapshotOpStatus, SnapshotOpRecord), and Herlihy–Wing linearizability (IsSnapshotLinearization, SnapshotLinearizable) against the canonical sequential snapshot specification (seqSnapshotValid, [AAD+93], §2.1, Figure 1, Definition 1).

Main definitions #

Main results #

Single-writer registers and scan orders #

structure Cslib.Distributed.SetAgreement.SnapshotReg (P : Type u_1) (Data : Type u_2) :
Type (max u_1 u_2)

Single-writer, multi-reader (SWMR) register owned by one process in the unbounded snapshot algorithm ([AAD+93], §3, Figure 3, p. 8).

  • data : Data

    Current data word written by the owner process.

  • seq : ℕ

    Monotone sequence number incremented by 1 on each update write.

  • view : P → Data

    Snapshot view obtained by the embedded scan of the writing update.

theorem Cslib.Distributed.SetAgreement.SnapshotReg.ext_iff {P : Type u_1} {Data : Type u_2} {x y : SnapshotReg P Data} :
x = y ↔ x.data = y.data ∧ x.seq = y.seq ∧ x.view = y.view
theorem Cslib.Distributed.SetAgreement.SnapshotReg.ext {P : Type u_1} {Data : Type u_2} {x y : SnapshotReg P Data} (data : x.data = y.data) (seq : x.seq = y.seq) (view : x.view = y.view) :
x = y
@[instance_reducible]
def Cslib.Distributed.SetAgreement.SnapshotReg.init {P : Type u_1} {Data : Type u_2} (dInit : Data) :

Initial register state (dInit, 0, fun _ => dInit).

def Cslib.Distributed.SetAgreement.memSnapshot {P : Type u_1} {Data : Type u_2} (reg : P → SnapshotReg P Data) :
P → Data

Instantaneous snapshot of the data fields across all single-writer registers (snapshot(τ_k) in [AAD+93], §3.1, p. 8).

Duplicate-free register reading order covering all processes P for collect.

  • elems : List P

    Ordered list of registers read during each collect.

  • nodup : self.elems.Nodup

    Each register appears at most once per collect.

  • complete (j : P) : j ∈ self.elems

    Every process in P appears in elems.

Canonical 0, 1, …, n - 1 scan order on Fin n.

Client operations, history records, and canonical snapshot linearizability #

Client operation kind on a single-writer atomic snapshot memory.

  • scan {Data : Type u_1} : SnapshotOpKind Data

    Instantaneous full-memory read (ScanRequest_i).

  • update {Data : Type u_1} (val : Data) : SnapshotOpKind Data

    Single-writer word update (UpdateRequest_i(val)).

def Cslib.Distributed.SetAgreement.instDecidableEqSnapshotOpKind.decEq {Data✝ : Type u_1} [DecidableEq Data✝] (x✝ x✝¹ : SnapshotOpKind Data✝) :
Decidable (x✝ = x✝¹)
@[instance_reducible]
inductive Cslib.Distributed.SetAgreement.SnapshotOpStatus (P : Type u_1) (Data : Type u_2) :
Type (max u_1 u_2)

Completion status of a recorded client operation in an execution history.

structure Cslib.Distributed.SetAgreement.SnapshotOpRecord (P : Type u_1) (Data : Type u_2) :
Type (max u_1 u_2)

Recorded operation entry in an execution history of a snapshot memory.

  • caller : P

    Invoking process i : P (for update, also the updated cell index).

  • kind : SnapshotOpKind Data

    Operation kind (scan or update val).

  • invStep : ℕ

    Trace step index at which the client invoked the operation.

  • status : SnapshotOpStatus P Data

    Current completion status and response timestamp/payload.

theorem Cslib.Distributed.SetAgreement.SnapshotOpRecord.ext {P : Type u_1} {Data : Type u_2} {x y : SnapshotOpRecord P Data} (caller : x.caller = y.caller) (kind : x.kind = y.kind) (invStep : x.invStep = y.invStep) (status : x.status = y.status) :
x = y

Whether a recorded snapshot operation has returned.

Response step of a completed operation (none if still pending).

def Cslib.Distributed.SetAgreement.seqSnapshotValid {P : Type u_1} {Data : Type u_2} [DecidableEq P] (mem : P → Data) (hist : List (SnapshotOpRecord P Data)) :

Sequential canonical single-writer snapshot check (Figure 1 of [AAD+93], p. 4): replay operation indices seq from initial memory mem : P → Data, updating mem caller := val on completed updates and verifying snap = mem on completed scans.

def Cslib.Distributed.SetAgreement.seqSnapshotMemAfter {P : Type u_1} {Data : Type u_2} [DecidableEq P] (mem : P → Data) (hist : List (SnapshotOpRecord P Data)) :
List ℕ → P → Data

Sequential memory state produced after replaying a list of operation indices from mem.

theorem Cslib.Distributed.SetAgreement.seqSnapshotValid_append {P : Type u_1} {Data : Type u_2} [DecidableEq P] (mem : P → Data) (hist : List (SnapshotOpRecord P Data)) (xs ys : List ℕ) :
seqSnapshotValid mem hist (xs ++ ys) ↔ seqSnapshotValid mem hist xs ∧ seqSnapshotValid (seqSnapshotMemAfter mem hist xs) hist ys
structure Cslib.Distributed.SetAgreement.IsSnapshotLinearization {P : Type u_1} {Data : Type u_2} [DecidableEq P] (dInit : Data) (hist : List (SnapshotOpRecord P Data)) (seq : List ℕ) :

seq is a valid Herlihy–Wing linearization of snapshot history hist from initial value dInit ([AAD+93], §2.1, Definition 1):

  1. seq is duplicate-free (seq.Nodup) with all indices < hist.length,
  2. every completed operation in hist appears in seq (and any other entry in seq is a pending update that has already taken effect),
  3. real-time precedence holds (respStep op₁ ≤ invStep op₂ implies op₁ precedes op₂ in seq),
  4. seqSnapshotValid (fun _ => dInit) hist seq holds.
def Cslib.Distributed.SetAgreement.SnapshotLinearizable {P : Type u_1} {Data : Type u_2} [DecidableEq P] (dInit : Data) (hist : List (SnapshotOpRecord P Data)) :

An execution history hist is linearizable against the canonical single-writer snapshot memory with initial value dInit.