Documentation

CslibFrontier.Computability.Distributed.ConcurrentObjects.Progress

The Non-Blocking Progress Hierarchy: Wait-Freedom, Lock-Freedom, and Obstruction-Freedom #

This module formalizes the three classical non-blocking progress conditions for asynchronous shared-memory concurrent object implementations over processes P ([Her91], §§2.2–2.3, pp. 128–129; [HLM03], §1, pp. 1–2; [MS04], §1.1.3, pp. 1-5–1-6):

Unlike Cslib.Distributed.SharedMemory.Protocol (which models one-shot consensus where each process decides once and halts), ProgressSystem separates relational new-operation invocations by idle processes (Invoke) from a deterministic, always-enabled per-process implementation step (step : State → P → State × Bool), capturing long-lived concurrent objects where fast processes may repeatedly invoke and complete new operations while a slow process retries. Because active implementation steps cannot be passively disabled, passive conditional or lock waiting is modeled as spin-waiting (.exec p false): consequently, [Her91] §2.3 (p. 129)'s non-blocking Condition (2) follows from Condition (1) via IsWaitFree.isObstructionFree, and IsObstructionFree inspects the unique solo trajectory soloIter rather than quantifying over nondeterministic solo runs.

Main definitions #

Main results #

References #

Label of an asynchronous step in a ProgressSystem: either an idle process proc invoking a new operation, or an active process proc executing one implementation step (which finishes its pending operation iff completed = true).

  • invoke {P : Type u_1} (proc : P) : StepLabel P

    Idle process proc begins a new pending operation.

  • exec {P : Type u_1} (proc : P) (completed : Bool) : StepLabel P

    Active process proc executes one implementation step; completed = true iff its pending operation finishes on this step.

Process taking the step.

Whether the step is an implementation step (rather than a new invocation).

Whether the step completes a pending operation.

@[simp]
theorem Cslib.Distributed.ConcurrentObjects.StepLabel.proc_exec {P : Type u_1} (p : P) (done : Bool) :
(exec p done).proc = p
@[simp]
@[simp]

Operational transition system of a concurrent shared-memory object implementation over processes P with per-process pending operations ([Her91], §§2.2–2.3, pp. 128–129; [HLM03], §1, pp. 1–2; [MS04], §1.1.3, pp. 1-5–1-6). Invocations Invoke are relational, whereas step : State → P → State × Bool is deterministic and always enabled whenever Active s p holds (modeling passive lock or conditional waiting via non-completing spin steps .exec p false, so each active process has a unique soloIter trajectory).

  • State : Type u

    Global configuration (shared memory together with per-process local execution phases).

  • init : self.State

    Initial global configuration.

  • Active : self.State → P → Prop

    Active s p holds when process p has an uncompleted pending operation in state s.

  • Invoke : self.State → P → self.State → Prop

    Invoke s p s' transitions idle process p into a new pending operation in state s'.

  • step : self.State → P → self.State × Bool

    step s p = (s', done) executes one implementation step of active process p, returning the successor state s' and whether p's pending operation completed (done = true).

  • invoke_only_idle {s : self.State} {p : P} {s' : self.State} : self.Invoke s p s' → ¬self.Active s p

    Only an idle process may invoke a new operation.

  • active_after_invoke {s : self.State} {p : P} {s' : self.State} : self.Invoke s p s' → self.Active s' p

    Invoking an operation makes p active.

  • invoke_frame_active {s : self.State} {p q : P} {s' : self.State} : self.Invoke s p s' → q ≠ p → (self.Active s' q ↔ self.Active s q)

    An invocation by p does not change whether any other process q ≠ p is active.

  • active_after_step_false {s : self.State} {p : P} : self.Active s p → (self.step s p).2 = false → self.Active (self.step s p).1 p

    A non-completing step (done = false) keeps p active.

  • idle_after_step_true {s : self.State} {p : P} : self.Active s p → (self.step s p).2 = true → ¬self.Active (self.step s p).1 p

    A completing step (done = true) returns p to idle.

  • step_frame_active {s : self.State} {p q : P} : self.Active s p → q ≠ p → (self.Active (self.step s p).1 q ↔ self.Active s q)

    An implementation step by p does not change whether any other process q ≠ p is active.

State s is reachable from sys.init via a finite sequence of invocations and implementation steps.

theorem Cslib.Distributed.ConcurrentObjects.ProgressSystem.Reachable.step {P : Type u_1} {sys : ProgressSystem P} {s s' : sys.State} {lbl : StepLabel P} (hs : sys.Reachable s) (htr : sys.lts.Tr s lbl s') :
sys.Reachable s'
theorem Cslib.Distributed.ConcurrentObjects.ProgressSystem.Reachable.induction {P : Type u_1} {sys : ProgressSystem P} {motive : sys.State → Prop} (hinit : motive sys.init) (hstep : ∀ {s : sys.State} {lbl : StepLabel P} {s' : sys.State}, sys.Reachable s → sys.lts.Tr s lbl s' → motive s → motive s') {s : sys.State} (hs : sys.Reachable s) :
motive s

An infinite execution of sys starting from a reachable state states 0.

  • states : ℕ → sys.State

    Sequence of global states visited along the execution.

  • labels : ℕ → StepLabel P

    Sequence of transition labels taken along the execution.

  • reachable_zero : sys.Reachable (self.states 0)

    The starting state states 0 is reachable from sys.init.

  • valid (n : ℕ) : sys.lts.Tr (self.states n) (self.labels n) (self.states (n + 1))

    Every index n is a valid transition Tr (states n) (labels n) (states (n + 1)).

State reached after k solo implementation steps of process p starting from s.

@[simp]
theorem Cslib.Distributed.ConcurrentObjects.ProgressSystem.soloIter_zero {P : Type u_1} (sys : ProgressSystem P) (s : sys.State) (p : P) :
sys.soloIter s p 0 = s
@[simp]
theorem Cslib.Distributed.ConcurrentObjects.ProgressSystem.soloIter_succ {P : Type u_1} (sys : ProgressSystem P) (s : sys.State) (p : P) (k : ℕ) :
sys.soloIter s p (k + 1) = (sys.step (sys.soloIter s p k) p).1

Wait-freedom ([Her91], §2.3, p. 129; [MS04], §1.1.3, p. 1-5): in every infinite execution from a reachable state, if process p has a pending operation at index t₀ and takes infinitely many implementation steps at or after t₀, then p completes its pending operation at some index n ≥ t₀.

Lock-freedom ([HLM03], §1, p. 1; [MS04], §1.1.3, p. 1-5): in every infinite execution from a reachable state in which infinitely many implementation steps are taken, infinitely many operations complete.

Obstruction-freedom ([HLM03], §1, p. 1; [MS04], §1.1.3, p. 1-5): from every reachable state s, any active process p completes its pending operation within finitely many steps when scheduled in isolation.

Preservation of active status without completions and finite-process properties #

theorem Cslib.Distributed.ConcurrentObjects.ProgressSystem.InfiniteExec.active_of_no_completion {P : Type u_1} {sys : ProgressSystem P} (exec : sys.InfiniteExec) {p : P} {n₁ n₂ : ℕ} (hle : n₁ ≤ n₂) (hact : sys.Active (exec.states n₁) p) (hno : ∀ (m : ℕ), n₁ ≤ m → m < n₂ → (exec.labels m).isCompleted = false) :
sys.Active (exec.states n₂) p

If no operation completes in [n₁, n₂), any process active at n₁ remains active at n₂.

theorem Cslib.Distributed.ConcurrentObjects.ProgressSystem.InfiniteExec.invoke_injective_of_no_completion {P : Type u_1} {sys : ProgressSystem P} (exec : sys.InfiniteExec) {N n₁ n₂ : ℕ} {p₁ p₂ : P} (hno : ∀ m ≥ N, (exec.labels m).isCompleted = false) (hN : N ≤ n₁) (hlt : n₁ < n₂) (hl₁ : exec.labels n₁ = StepLabel.invoke p₁) (hl₂ : exec.labels n₂ = StepLabel.invoke p₂) :
p₁ ≠ p₂

Without completions in [N, ∞), no process can invoke more than once at or after N.

theorem Cslib.Distributed.ConcurrentObjects.ProgressSystem.InfiniteExec.eventually_isExec_of_no_completion {P : Type u_1} [Finite P] {sys : ProgressSystem P} (exec : sys.InfiniteExec) {N : ℕ} (hno : ∀ m ≥ N, (exec.labels m).isCompleted = false) :
∃ N₁ ≥ N, ∀ n ≥ N₁, (exec.labels n).isExec = true

Over finitely many processes [Finite P], if no operation completes at or after N, then eventually every transition is an implementation step (.exec).

Over finitely many processes [Finite P], every infinite execution takes infinitely many implementation steps (.exec).

The Non-Blocking Progress Hierarchy (IsWaitFree → IsLockFree → IsObstructionFree) #

In a deterministic ProgressSystem over finitely many processes ([Finite P]), wait-freedom implies lock-freedom (after [MS04], §1.1.3, p. 1-5): in any infinite execution taking infinitely many implementation steps, some process steps infinitely often by infinite pigeonhole (Finite.exists_infinite_fiber) and therefore completes infinitely often.

In a deterministic ProgressSystem, lock-freedom implies obstruction-freedom (after [HLM03], §1, p. 1; [MS04], §1.1.3, p. 1-5): if an active process p failed to complete in every finite prefix of its solo trajectory soloIter from a reachable state s, scheduling p forever in isolation would yield a valid infinite execution with zero completions.

In a deterministic ProgressSystem over arbitrary P (including infinite process sets, without [Finite P]), wait-freedom implies obstruction-freedom (after [Her91], §2.3, p. 129; [MS04], §1.1.3, p. 1-5): scheduling an active process p along its always-enabled solo trajectory soloIter gives p infinitely many implementation steps, so IsWaitFree forces p to complete at some step n.

Reusable bounded-shared-change engine for lock-free CAS implementations #

theorem Cslib.Distributed.ConcurrentObjects.ProgressSystem.isLockFree_of_bounded_shared_changes {P : Type u_1} [Finite P] {sys : ProgressSystem P} {α : Type u_2} (shared : sys.State → α) (Committed : sys.State → P → Prop) (rank : sys.State → P → ℕ) (committed_of_shared_ne : ∀ {s : sys.State} {p : P}, sys.Active s p → (sys.step s p).2 = false → shared (sys.step s p).1 ≠ shared s → Committed (sys.step s p).1 p) (committed_frame : ∀ {s : sys.State} {p q : P}, sys.Active s p → (sys.step s p).2 = false → q ≠ p → Committed s q → Committed (sys.step s p).1 q) (complete_of_committed : ∀ {s : sys.State} {p : P}, sys.Active s p → Committed s p → (sys.step s p).2 = true) (rank_lt_of_shared_eq : ∀ {s : sys.State} {p : P}, sys.Active s p → (sys.step s p).2 = false → shared (sys.step s p).1 = shared s → rank (sys.step s p).1 p < rank s p) (rank_le_of_shared_eq_ne : ∀ {s : sys.State} {p q : P}, sys.Active s p → (sys.step s p).2 = false → shared (sys.step s p).1 = shared s → q ≠ p → rank (sys.step s p).1 q ≤ rank s q) :

Bounded-shared-change lock-freedom criterion: in an optimistic CAS-based implementation over [Finite P], suppose:

  1. Every non-completing step of p that modifies the shared projection shared places p into a Committed state (committed_of_shared_ne), Committed is preserved by other processes' non-completing steps (committed_frame), and any step by an already-Committed process immediately completes (complete_of_committed); hence shared can change at most |P| times without an operation completing.
  2. Whenever shared is unchanged across a non-completing step of p, a natural-number measure rank s p strictly decreases for p (rank_lt_of_shared_eq) and does not increase for any q ≠ p (rank_le_of_shared_eq_ne).

Then sys is lock-free (sys.IsLockFree). Both casCounterSystem and treiberFreshNodeSystem instantiate this criterion directly.

Concrete separating shared-memory implementations #

State of a single-step atomic increment counter over processes P: counter holds the shared natural number and pending p = true iff p has an uncompleted increment invocation.

  • counter : ℕ

    Current shared counter value.

  • pending : P → Bool

    Per-process pending-operation flag.

theorem Cslib.Distributed.ConcurrentObjects.AtomicIncState.ext {P : Type u_1} {x y : AtomicIncState P} (counter : x.counter = y.counter) (pending : x.pending = y.pending) :
x = y

Wait-free single-step atomic increment system over processes P.

Single-step atomic increment is wait-free.

Separating Lock-Freedom from Wait-Freedom: Two-Step CAS Counter #

Local execution phase of a process in the two-step CAS fetch-and-increment counter ([MS04], §1.1.3, p. 1-6).

  • idle : CASCounterPhase

    No pending operation.

  • readCounter : CASCounterPhase

    Ready to read the current value of the shared counter.

  • tryCAS (expected : ℕ) : CASCounterPhase

    Read expected from the shared counter; ready to execute CAS(&counter, expected, expected + 1), retrying from readCounter on failure.

Global configuration of the two-step CAS fetch-and-increment counter over processes P.

  • counter : ℕ

    Shared CAS register holding the current counter value.

  • threads : P → CASCounterPhase

    Per-process local control phase.

theorem Cslib.Distributed.ConcurrentObjects.CASCounterState.ext {P : Type u_1} {x y : CASCounterState P} (counter : x.counter = y.counter) (threads : x.threads = y.threads) :
x = y

Original two-step optimistic CAS fetch-and-increment counter model (illustrating the CAS retry-loop starvation mechanism discussed in [MS04], §1.1.3, p. 1-6): each operation reads c := counter in one step and attempts CAS(&counter, c, c + 1) in the next, retrying from readCounter whenever a concurrent CAS has modified counter.

Original lock-freedom proof for casCounterSystem over finitely many processes ([Finite P], illustrating [MS04], §1.1.3, p. 1-6).

Original CAS-starvation witness over [Nontrivial P] (illustrating [MS04], §1.1.3, p. 1-6): casCounterSystem P is not wait-free because a fast process repeatedly invoking, reading, and succeeding at CAS starves a slow process whose CAS continually sees a stale counter value and retries forever.

Original concrete ProgressSystem separation of lock-freedom from wait-freedom (illustrating [MS04], §1.1.3, p. 1-6): there exists a finite-process concurrent-object transition system that is lock-free yet not wait-free.

Separating Obstruction-Freedom from Lock-Freedom: Racing Claim-and-Verify Protocol #

Local execution phase of a process in the original minimal shared-register claim-and-verify witness isolating two-thread contention livelock ([HLM03], §1, pp. 1–2).

  • idle : ClaimPhase

    No pending operation.

  • writeClaim : ClaimPhase

    Ready to write own process ID into the shared owner register.

  • verifyClaim : ClaimPhase

    Wrote own ID into owner; ready to verify owner = some p and complete if uncontested, or retry from writeClaim if overwritten by a concurrent process.

Global configuration of the racing shared-register claim-and-verify protocol over P.

  • owner : Option P

    Shared atomic register recording the last process to execute writeClaim.

  • threads : P → ClaimPhase

    Per-process local control phase.

Original minimal shared-register claim-and-verify system (isolating the two-thread livelock mechanism discussed in [HLM03], §1, pp. 1–2): an active process writes its ID to owner (writeClaim) and completes on the next step (verifyClaim) iff no other process overwrote owner in between; otherwise it retries from writeClaim.

Original obstruction-freedom proof for racingClaimSystem (illustrating [HLM03], §1, p. 1): from any state, any active process p completes within at most 3 solo steps (k ∈ {0, 1, 2}).

Original two-thread livelock witness over [Nontrivial P] (illustrating [HLM03], §1, pp. 1–2): racingClaimSystem P is not lock-free because two active processes alternating writeClaim and verifyClaim out of phase overwrite each other's claim on every cycle so neither operation ever completes.

Original concrete ProgressSystem separation of obstruction-freedom from lock-freedom (illustrating [HLM03], §1, pp. 1–2): there exists a finite-process concurrent-object transition system that is obstruction-free yet not lock-free.