Documentation

CslibFrontier.Computability.Distributed.DijkstraScholten.Correctness

Invariants, soundness, and drain liveness of the Dijkstra–Scholten overlay #

This module proves safety (no false termination) and drain liveness (guaranteed detection once the diffusing computation ceases) for the asynchronous single-parent Dijkstra–Scholten overlay defined in CslibFrontier/Computability/Distributed/DijkstraScholten/Basic.lean, as a milestone step toward #7286 after [DS80] (inspected in author manuscript EWD687a, EWD687a - 2–5, PDF pp. 5–8). General non-diffusing termination detection via message-counting vectors or credits (see [Mat87] for context) and EWD687a's deferred-cornet bags remain tracked in #7286.

All invariants are completely ghost-free (stated purely over active, deficit, parent, basicMsgs, and signals):

  1. Neutrality invariant (Reachable.neutral_of_parent_none): for every p ≠ root, parent p = none implies active p = false ∧ deficit p = 0 (the single-parent counterpart of invariant P3 in EWD687a - 2, PDF p. 5).
  2. Exact deficit conservation (Reachable.deficit_eq_inFlight_add_children): for every p, deficit p = inFlightBasicFrom p + inFlightSignalTo p + (children root p).card.
  3. Engagement-tree reachability & acyclicity (Reachable.engaged_reaches_root, Reachable.ancestor?_ne_self_of_pos): every p ≠ root with parent p ≠ none reaches root along parent links in 0 < k < Fintype.card P hops, and parent pointers never form a cycle. Because deficit src ≥ 1 while ⟨src, dst⟩ is in flight and while dst remains attached as a child of src, src cannot detach before dst either acknowledges immediately or detaches.
  4. Termination soundness (Reachable.terminated_implies_quiescent, Reachable.terminated_iff_globalQuiescence): in every reachable state, s.Terminated root holds iff s.GlobalQuiescent holds (counterpart of Theorem 2 in EWD687a - 5, PDF p. 8).
  5. Drain liveness (Reachable.quiescent_drains_to_terminated): from any reachable ComputationIdle state (∀ p, active p = false and basicMsgs = 0), every enabled step is a recvSignal or detach step reducing drainMeasure = 2 * engagedCount + inFlightSignals by 1, and every maximal execution reaches Terminated root in at most 2 * Fintype.card P + inFlightSignals steps (counterpart of Theorem 1 in EWD687a - 3, PDF p. 6).
  6. Sequential-polling counterexample (exists_phantom_termination_naive_poll): an original 3-role execution showing that sequential active = false polling without channel/deficit accounting reports false termination when a basic message crosses from an unpolled process to an already-polled process while Dijkstra–Scholten's Terminated root remains false.

Main definitions #

Main results #

References #

Number of in-flight basic messages sent by p.

Number of in-flight acknowledgement signals addressed to p.

Total number of acknowledgement signals currently in flight.

Finite set of non-root processes q currently attached with parent = some p.

Finite set of non-root processes currently engaged in the tree (parent ≠ none).

Number of non-root processes currently engaged in the tree.

Strict termination potential for control-traffic draining once basic computation ceases: each detach reduces engagedCount by 1 and emits 1 signal (net -1), while each recvSignal consumes 1 signal (net -1).

Follow parent pointers from p for k hops, returning none if parent = none is hit before k hops complete.

Shared frame helpers for children and engagedNodes #

Structural invariants: root parent, neutrality (P3), and exact deficit conservation #

theorem Cslib.Distributed.DijkstraScholten.Reachable.root_parent_eq_none {P : Type u_1} [DecidableEq P] {root : P} {s : State P} (hr : Reachable root s) :
(s.proc root).parent = none

root never acquires a parent pointer in any reachable configuration.

theorem Cslib.Distributed.DijkstraScholten.Reachable.neutral_of_parent_none {P : Type u_1} [DecidableEq P] {root : P} {s : State P} (hr : Reachable root s) {p : P} (hp : p ≠ root) (hpar : (s.proc p).parent = none) :
(s.proc p).active = false ∧ (s.proc p).deficit = 0

Single-parent counterpart of invariant P3 after [DS80] (EWD687a - 2, PDF p. 5) toward #7286: in any reachable state, every detached non-root process (parent = none) is idle and has zero deficit.

theorem Cslib.Distributed.DijkstraScholten.Reachable.attach_iff {P : Type u_1} [DecidableEq P] {root : P} {s : State P} (hr : Reachable root s) (dst : P) :
dst ≠ root ∧ (s.proc dst).parent = none ↔ dst ≠ root ∧ (s.proc dst).active = false ∧ (s.proc dst).deficit = 0 ∧ (s.proc dst).parent = none

In any reachable state, the tree-attachment check dst ≠ root ∧ parent dst = none is equivalent to full local neutrality (dst ≠ root ∧ active = false ∧ deficit = 0 ∧ parent = none).

Exact per-process deficit conservation for the single-parent asynchronous overlay after [DS80] (EWD687a - 1–5, PDF pp. 4–8) toward #7286: in every reachable configuration, deficit p equals the sum of in-flight basic messages from p, in-flight signals to p, and non-root children currently holding parent = some p.

Engagement-tree reachability to root and acyclicity (P4) #

theorem Cslib.Distributed.DijkstraScholten.Reachable.engaged_reaches_root {P : Type u_1} [Fintype P] [DecidableEq P] {root : P} {s : State P} (hr : Reachable root s) {p : P} (hp : p ≠ root) (hpar : (s.proc p).parent ≠ none) :
∃ k < Fintype.card P, 0 < k ∧ s.ancestor? k p = some root

Engagement-tree invariant for the single-parent asynchronous overlay after [DS80] (EWD687a - 4–5, observations a)–c), PDF pp. 7–8) toward #7286: in every reachable configuration, every engaged non-root process follows parent pointers to root in 0 < k < Fintype.card P hops.

theorem Cslib.Distributed.DijkstraScholten.Reachable.ancestor?_ne_self_of_pos {P : Type u_1} [Finite P] [DecidableEq P] {root : P} {s : State P} (hr : Reachable root s) (p : P) {m : ℕ} (hm : 0 < m) :

Acyclicity of parent pointers across the entire network after [DS80] (EWD687a - 5, observation b), PDF p. 8) toward #7286: no process returns to itself along any positive number of parent hops in a reachable configuration.

Termination soundness: zero false positives (Terminated ↔ GlobalQuiescent) #

Termination soundness for the single-parent asynchronous overlay after [DS80] (counterpart of Theorem 2 in EWD687a - 5, PDF p. 8) toward #7286: in any reachable configuration, if root is idle with deficit = 0, then every process is idle with zero deficit and parent = none, and all basic and signal channels are empty.

In any reachable configuration of the single-parent asynchronous overlay after [DS80] (EWD687a - 5, Theorem 2, PDF p. 8) toward #7286, local root termination coincides with global network quiescence.

Drain liveness: strict potential decrease and guaranteed bounded detection #

theorem Cslib.Distributed.DijkstraScholten.State.ComputationIdle.step_drainMeasure {P : Type u_1} [Fintype P] [DecidableEq P] {root : P} {s s' : State P} {a : Action P} (hidle : s.ComputationIdle) (htr : (lts root).Tr s a s') :
((∃ (p : P), a = Action.recvSignal p) ∨ ∃ (p : P) (q : P), a = Action.detach p q) ∧ s'.ComputationIdle ∧ s'.drainMeasure root + 1 = s.drainMeasure root

From any ComputationIdle configuration, every enabled transition in lts root is either a recvSignal or detach control step, preserves ComputationIdle, and decreases drainMeasure by 1.

theorem Cslib.Distributed.DijkstraScholten.State.ComputationIdle.mtr_drainMeasure {P : Type u_1} [Fintype P] [DecidableEq P] {root : P} {s s' : State P} {tr : List (Action P)} (hidle : s.ComputationIdle) (hmtr : (lts root).MTr s tr s') :

Multi-step drain accounting: every trace from a ComputationIdle configuration preserves ComputationIdle and satisfies s'.drainMeasure root + tr.length = s.drainMeasure root.

Deadlock-freedom during draining: a reachable ComputationIdle configuration has no enabled transitions in lts root iff root has already detected Terminated.

theorem Cslib.Distributed.DijkstraScholten.Reachable.quiescent_drains_to_terminated {P : Type u_1} [Fintype P] [DecidableEq P] {root : P} {s : State P} (hr : Reachable root s) (hidle : s.ComputationIdle) :
(∃ (tr : List (Action P)) (s' : State P), (lts root).MTr s tr s' ∧ s'.Terminated root ∧ tr.length ≤ 2 * Fintype.card P + s.inFlightSignals) ∧ ∀ (tr : List (Action P)) (s' : State P), (lts root).MTr s tr s' → tr.length ≤ 2 * Fintype.card P + s.inFlightSignals ∧ ((lts root).IsTerminal s' → s'.Terminated root)

Drain liveness for the single-parent asynchronous overlay after [DS80] (counterpart of Theorem 1 in EWD687a - 3, PDF p. 6) toward #7286: from any reachable ComputationIdle configuration, a terminating control drain exists within 2 * Fintype.card P + s.inFlightSignals steps, AND every execution schedule is bounded by 2 * Fintype.card P + s.inFlightSignals steps and stops only at Terminated root.

Sequential-polling phantom termination counterexample #

theorem Cslib.Distributed.DijkstraScholten.exists_phantom_termination_naive_poll {P : Type u_1} [DecidableEq P] (root q r : P) (hr : r ≠ root) (hqr : q ≠ r) :
∃ (tr₁ : List (Action P)) (tr₂ : List (Action P)) (tr₃ : List (Action P)) (s₁ : State P) (s₂ : State P) (s₃ : State P) (s₄ : State P), (lts root).MTr (initState root) tr₁ s₁ ∧ (lts root).MTr s₁ tr₂ s₂ ∧ (lts root).MTr s₂ tr₃ s₃ ∧ (lts root).Tr s₃ (Action.recvBasic r q) s₄ ∧ (s₁.proc root).active = false ∧ (s₂.proc q).active = false ∧ (∀ (p : P), p ≠ r → (s₂.proc p).active = false) ∧ (s₂.proc r).active = true ∧ (s₃.proc r).active = false ∧ { src := r, dst := q } ∈ s₃.basicMsgs ∧ (s₄.proc q).active = true ∧ ¬s₁.Terminated root ∧ ¬s₂.Terminated root ∧ ¬s₃.Terminated root ∧ ¬s₄.Terminated root

Original counterexample showing why sequential local active = false polling without channel or deficit accounting suffers phantom termination: for any process type P with r ≠ root and q ≠ r, there is a reachable diffusing execution initState root →* s₁ →* s₂ →* s₃ → s₄ where:

  1. root is polled idle at s₁;
  2. every p ≠ r (including q) is polled idle at s₂ while r is actively computing;
  3. r sends basic message ⟨r, q⟩ to already-polled q, turns idle, and is polled idle at s₃ (completing an all-false sequential poll across the entire system);
  4. ⟨r, q⟩ arrives at s₄ to re-activate q, while Dijkstra–Scholten's Terminated root remains false throughout s₁, s₂, s₃, s₄.