Documentation

CslibFrontier.Computability.Distributed.SelfStabilization.DijkstraRing

Dijkstra's K-state self-stabilizing token ring and enabled-move composite-ring symmetry step #

This module formalizes Dijkstra's first self-stabilizing mutual-exclusion / token-circulation protocol on a directed ring of n finite-state machines with K states per machine under a central daemon (Dijkstra, pp. 643–644; manuscript Dijkstra), together with an original simultaneous atomic-subset transition model (dijkstraDistRing), original sharp periodic converse counterexamples for both transition models, and scheduler-scoped enabled-move symmetry steps towards the composite-ring impossibility argument of Dijkstra (EWD391).

In Dijkstra (p. 644, left column), the ring consists of N + 1 machines numbered 0 through N; here n denotes the total ring size N + 1, indexed by Fin n:

Dijkstra (p. 643) explicitly assumes a central daemon (dijkstraRing n K) and excludes a distributed daemon, while the later section of Dijkstra (EWD391) discusses separate local reads and adjustments rather than atomic simultaneous updates from a single pre-step state. Accordingly, dijkstraDistRing n K (which fires any nonempty subset S of privileged machines atomically from the same old state) and its closure, convergence (2 ≤ n ≤ K), and sharpness (iff) theorems are original results for the simultaneous atomic-subset model.

We establish:

  1. Deadlock-freedom (exists_dijkstraPrivileged, dijkstraRing_not_isTerminal, dijkstraDistRing_not_isTerminal): every configuration has at least one privileged machine.
  2. Plateau characterization, closure, and round-robin circulation (dijkstraPrivilegedSet_eq_singleton_iff, dijkstraPrivilegedSet_step_of_eq_singleton, dijkstraRing_legitimate_closed, dijkstraDistRing_legitimate_closed, dijkstraRing_token_circulates): legitimate configurations are constant or two-plateau step functions, central and simultaneous atomic-subset transitions coincide on legitimate states, and the unique privilege advances from p to p + 1 on every step, visiting every machine once per n steps.
  3. Worst-case finite stabilization (dijkstraRing_selfStabilizing_of_pred_le, dijkstraRing_mTr_legitimate_of_le, dijkstraDistRing_mTr_legitimate_of_le, dijkstraDistRing_selfStabilizing_of_le): under a central daemon, n - 1 ≤ K (K ≥ N with 2 ≤ n and 2 ≤ K, Note 1 on p. 644 of Dijkstra) suffices for self-stabilization; in the original simultaneous atomic-subset model dijkstraDistRing n K, 2 ≤ n ≤ K yields stabilization within K * (n * (n - 1) / 2) + K steps without fairness assumptions.
  4. Sharpness and necessary-and-sufficient bounds (dijkstraRing_not_selfStabilizing_of_lt_pred, dijkstraDistRing_not_selfStabilizing_of_lt, dijkstraRing_selfStabilizing_iff, dijkstraDistRing_selfStabilizing_iff): original explicit periodic non-stabilizing executions show that for 2 ≤ n and 2 ≤ K, dijkstraRing n K is self-stabilizing iff n - 1 ≤ K and dijkstraDistRing n K is self-stabilizing iff n ≤ K.
  5. Enabled-move composite-ring symmetry steps (not_uniform_enabledMove_selfStabilizing_composite_ring, not_uniform_distEnabledMove_selfStabilizing_composite_ring): scheduler-scoped steps towards Dijkstra (EWD391) showing that on a composite ring of size n = a * b (2 ≤ a, 2 ≤ b), no uniform deterministic ring protocol self-stabilizes to unique-privilege states under arbitrary enabled-move central (π.centralLTS) or simultaneous-subset (π.distLTS) schedules; EWD391's fair-command composite-ring endpoint (where every machine receives infinitely many adjustment commands, permitting no-effect commands) remains open (#7291).

Main definitions #

Main results #

References #

Modular Fin arithmetic helpers and Dijkstra's K-state token ring #

Machine i is privileged in configuration s iff s 0 = s (0 - 1) when i = 0, and s i ≠ s (i - 1) when i > 0 (Dijkstra, p. 644, "Solution with K-state Machines").

Instances For
    def Cslib.Distributed.SelfStabilization.dijkstraNextVal {n K : ℕ} [NeZero n] [NeZero K] (s : Fin n → Fin K) (i : Fin n) :
    Fin K

    Next local value of machine i when firing: s 0 + 1 ((s 0 + 1) mod K) for bottom machine 0, and s (i - 1) for i > 0 (Dijkstra, p. 644).

    def Cslib.Distributed.SelfStabilization.dijkstraStep {n K : ℕ} [NeZero n] [NeZero K] (s : Fin n → Fin K) (i : Fin n) :
    Fin n → Fin K

    Single-machine configuration update when machine i moves.

    def Cslib.Distributed.SelfStabilization.dijkstraDistStep {n K : ℕ} [NeZero n] [NeZero K] (s : Fin n → Fin K) (S : Finset (Fin n)) :
    Fin n → Fin K

    Original simultaneous atomic-subset configuration update: every machine in S evaluates dijkstraNextVal on the same pre-step configuration s and updates simultaneously.

    Central-daemon labelled transition system for Dijkstra's K-state ring on Fin n (Dijkstra, pp. 643–644): each transition selects one privileged machine i.

    Original simultaneous atomic-subset labelled transition system for Dijkstra's K-state ring on Fin n: each transition selects a nonempty set S of privileged machines and updates them atomically from the pre-step configuration s (distinct from Dijkstra, p. 643, which excludes a distributed daemon, and from the separate read/adjust discussion in Dijkstra).

    Set of privileged machines in configuration s.

    Legitimate configurations of Dijkstra's token ring: configurations in which exactly one machine is privileged (Dijkstra, p. 644).

    Canonical two-plateau configuration placing the unique privilege at p with base value c.

    theorem Cslib.Distributed.SelfStabilization.dijkstraRing_tr_iff_distRing_singleton {n K : ℕ} [NeZero n] [NeZero K] (s : Fin n → Fin K) (i : Fin n) (s' : Fin n → Fin K) :
    (dijkstraRing n K).Tr s i s' ↔ (dijkstraDistRing n K).Tr s {i} s'

    A central-daemon step of machine i coincides with the singleton distributed-daemon step {i}.

    Deadlock-freedom #

    Every ring configuration has at least one privileged machine: if no machine i > 0 differs from its left neighbour, then all machines equal s 0, so bottom machine 0 is privileged.

    Dijkstra's K-state ring has no terminal configurations under a central daemon.

    Dijkstra's K-state ring has no terminal configurations in the simultaneous atomic-subset transition system dijkstraDistRing n K.

    Plateau characterization, closure, and round-robin circulation #

    theorem Cslib.Distributed.SelfStabilization.dijkstraPrivilegedSet_eq_singleton_iff {n K : ℕ} [NeZero n] (s : Fin n → Fin K) (p : Fin n) :
    dijkstraPrivilegedSet s = {p} ↔ if ↑p = 0 then ∀ (j : Fin n), s j = s 0 else s p ≠ s 0 ∧ (∀ (j : Fin n), ↑j < ↑p → s j = s 0) ∧ ∀ (j : Fin n), ↑p ≤ ↑j → s j = s p

    Explicit characterization of configurations whose unique privileged machine is p: constant configurations when p = 0, and two-plateau configurations jumping at p when p > 0.

    Every canonical plateau configuration dijkstraTokenConfig n K p c has p as its unique privileged machine when 2 ≤ K.

    Firing the unique privileged machine p in a legitimate configuration transfers the unique privilege to p + 1 (Dijkstra, p. 644).

    theorem Cslib.Distributed.SelfStabilization.dijkstraRing_legitimate_closed {n K : ℕ} [NeZero n] [NeZero K] (hK : 2 ≤ K) {s s' : Fin n → Fin K} {i : Fin n} (hs : s ∈ DijkstraLegitimate n K) (htr : (dijkstraRing n K).Tr s i s') :

    Closure of DijkstraLegitimate n K under central-daemon transitions (2 ≤ K).

    theorem Cslib.Distributed.SelfStabilization.dijkstraDistRing_tr_iff_dijkstraRing_of_legitimate {n K : ℕ} [NeZero n] [NeZero K] {s s' : Fin n → Fin K} (hs : s ∈ DijkstraLegitimate n K) (S : Finset (Fin n)) :
    (dijkstraDistRing n K).Tr s S s' ↔ ∃ (i : Fin n), S = {i} ∧ (dijkstraRing n K).Tr s i s'

    On DijkstraLegitimate n K, simultaneous atomic-subset transitions (dijkstraDistRing) coincide with central-daemon transitions (dijkstraRing) since only one machine is privileged.

    theorem Cslib.Distributed.SelfStabilization.dijkstraDistRing_legitimate_closed {n K : ℕ} [NeZero n] [NeZero K] (hK : 2 ≤ K) {s s' : Fin n → Fin K} {S : Finset (Fin n)} (hs : s ∈ DijkstraLegitimate n K) (htr : (dijkstraDistRing n K).Tr s S s') :

    Original closure theorem for the simultaneous atomic-subset model: DijkstraLegitimate n K is closed under dijkstraDistRing n K transitions when 2 ≤ K.

    theorem Cslib.Distributed.SelfStabilization.dijkstraRing_token_circulates {n K : ℕ} [NeZero n] [NeZero K] (hK : 2 ≤ K) {s s' : Fin n → Fin K} {p : Fin n} {μs : List (Fin n)} (hs : dijkstraPrivilegedSet s = {p}) (hmtr : (dijkstraRing n K).MTr s μs s') :
    dijkstraPrivilegedSet s' = {⟨(↑p + μs.length) % n, ⋯⟩} ∧ ∀ (k : ℕ) (hk : k < μs.length), μs[k] = ⟨(↑p + k) % n, ⋯⟩

    Round-robin token circulation: along any multistep execution from a legitimate configuration with unique privilege at p, the k-th step fires (p + k) mod n and the final configuration has unique privilege at (p + μs.length) mod n. In particular, over any n consecutive steps every machine fires once.

    Discrepancy potential and worst-case finite stabilization #

    theorem Cslib.Distributed.SelfStabilization.dijkstraDistRing_mTr_legitimate_of_le {n K : ℕ} [NeZero n] [NeZero K] (hn : 2 ≤ n) (hnK : n ≤ K) {s₀ s' : Fin n → Fin K} {μs : List (Finset (Fin n))} (hmtr : (dijkstraDistRing n K).MTr s₀ μs s') (hlen : K * (n * (n - 1) / 2) + K ≤ μs.length) :

    Original explicit worst-case convergence bound in the simultaneous atomic-subset model dijkstraDistRing n K: when 2 ≤ n ≤ K, every execution of length at least K * (n * (n - 1) / 2) + K ends in DijkstraLegitimate n K, with zero fairness assumptions.

    Original convergence theorem for the simultaneous atomic-subset model: whenever 2 ≤ n and n ≤ K, dijkstraDistRing n K is self-stabilizing to DijkstraLegitimate n K.

    theorem Cslib.Distributed.SelfStabilization.dijkstraRing_mTr_legitimate_of_le {n K : ℕ} [NeZero n] [NeZero K] (hn : 2 ≤ n) (hnK : n ≤ K) {s₀ s' : Fin n → Fin K} {μs : List (Fin n)} (hmtr : (dijkstraRing n K).MTr s₀ μs s') (hlen : K * (n * (n - 1) / 2) + K ≤ μs.length) :

    Original explicit worst-case convergence bound under a central daemon when 2 ≤ n ≤ K (quantitative refinement of Dijkstra, p. 644).

    Note 1 of Dijkstra (p. 644): under a central daemon, n - 1 ≤ K (K ≥ N for n = N + 1 machines, with 2 ≤ n and 2 ≤ K) suffices for self-stabilization, within at most (K + 1) * (n * (n - 1) / 2) + (K + 1) steps.

    Impossibility cycles and sharp necessary-and-sufficient characterizations #

    Original converse counterexample showing sharpness of Note 1 of Dijkstra (p. 644): when 2 ≤ K and K + 1 < n (K < N), Dijkstra's K-state ring admits an explicit periodic central-daemon execution that never enters DijkstraLegitimate n K, so dijkstraRing n K is not self-stabilizing.

    Original converse counterexample in the simultaneous atomic-subset model dijkstraDistRing: when 2 ≤ K and K < n, dijkstraDistRing n K is not self-stabilizing (at n = K + 1, synchronous execution from (0, K - 1, K - 2, …, 1, 0) cycles through K states in each of which all n ≥ 3 machines are privileged).

    Original exact characterization in the simultaneous atomic-subset model (2 ≤ n, 2 ≤ K): dijkstraDistRing n K is self-stabilizing iff n ≤ K.

    Exact characterization under a central daemon (2 ≤ n, 2 ≤ K), combining Note 1 of Dijkstra (p. 644, K ≥ N) with the original converse dijkstraRing_not_selfStabilizing_of_lt_pred: Dijkstra's K-state token ring is self-stabilizing iff n - 1 ≤ K.

    Enabled-move composite anonymous ring symmetry steps #

    A deterministic uniform (anonymous) local ring protocol over state space State, in which every node executes the identical local privilege predicate and state-transition function on its (left, self, right) neighbourhood (after Dijkstra; Dijkstra, pp. 643–644).

    • privileged : State → State → State → Bool

      Boolean privilege predicate reading (left, self, right) neighbour states.

    • step : State → State → State → State

      Next local state upon moving, reading (left, self, right) neighbour states.

    def Cslib.Distributed.SelfStabilization.IsRingPeriodic (a : ℕ) {n : ℕ} {State : Type u_1} (s : Fin n → State) :

    A ring configuration s : Fin n → State is a-periodic in residue classes when positions congruent modulo a carry equal states.

    def Cslib.Distributed.SelfStabilization.UniformRingProtocol.isPrivileged {State : Type u_1} (π : UniformRingProtocol State) {n : ℕ} [NeZero n] (s : Fin n → State) (i : Fin n) :

    Whether node i is privileged in configuration s.

    def Cslib.Distributed.SelfStabilization.UniformRingProtocol.nextVal {State : Type u_1} (π : UniformRingProtocol State) {n : ℕ} [NeZero n] (s : Fin n → State) (i : Fin n) :
    State

    Next state of node i in configuration s.

    Set of privileged nodes of π in configuration s.

    Configurations in which exactly one node is privileged under π.

    Enabled-move central-daemon labelled transition system of π on Fin n: transitions permit only privileged moves, with no per-machine fairness obligation across residue classes.

    Simultaneous atomic-subset enabled-move labelled transition system of π on Fin n: each transition updates a nonempty set of privileged nodes atomically from the pre-step state.

    theorem Cslib.Distributed.SelfStabilization.UniformRingProtocol.card_privilegedSet_dvd_of_isRingPeriodic {State : Type u_1} (π : UniformRingProtocol State) {a b : ℕ} (ha : 1 ≤ a) (hb : 1 ≤ b) [NeZero (a * b)] {s : Fin (a * b) → State} (hper : IsRingPeriodic a s) :

    On a ring of size a * b (1 ≤ a, 1 ≤ b), the number of privileged nodes in any a-periodic configuration is divisible by b.

    theorem Cslib.Distributed.SelfStabilization.UniformRingProtocol.isRingPeriodic_distStep {State : Type u_1} (π : UniformRingProtocol State) {a b : ℕ} (ha : 1 ≤ a) (hb : 1 ≤ b) [NeZero (a * b)] {s : Fin (a * b) → State} {S : Finset (Fin (a * b))} (hper : IsRingPeriodic a s) (hS : ∀ (i j : Fin (a * b)), ↑i % a = ↑j % a → (i ∈ S ↔ j ∈ S)) :
    IsRingPeriodic a fun (j : Fin (a * b)) => if j ∈ S then π.nextVal s j else s j

    Any distributed step whose firing set S is a union of a-residue classes preserves IsRingPeriodic a.

    theorem Cslib.Distributed.SelfStabilization.not_uniform_enabledMove_selfStabilizing_composite_ring {State : Type u_1} [Nonempty State] {a b : ℕ} (ha : 2 ≤ a) (hb : 2 ≤ b) [NeZero (a * b)] (π : UniformRingProtocol State) {Legitimate : Set (Fin (a * b) → State)} (hleg : Legitimate ⊆ π.UniquePrivilege (a * b)) :
    ¬SelfStabilizing (π.centralLTS (a * b)) Legitimate

    Scheduler-scoped enabled-move step towards the composite-ring symmetry argument of Dijkstra (EWD391), and not EWD391's fair-command impossibility endpoint: on a ring of composite size a * b (2 ≤ a, 2 ≤ b) over a nonempty state type, no uniform deterministic ring protocol satisfies SelfStabilizing (π.centralLTS (a * b)) Legitimate for any Legitimate ⊆ π.UniquePrivilege (a * b).

    Because 2 ≤ a and 2 ≤ b, the b positions in any single modulo-a residue class have pairwise ring distance at least 2. Stepping an enabled residue class sequentially in b-move blocks reaches a new a-periodic configuration every b moves while closure of Legitimate rules out intermediate visits to Legitimate. Note that π.centralLTS permits only privileged moves with no fairness obligation across residue classes, whereas EWD391's daemon issues infinitely many adjustment commands to every machine (permitting no-effect commands); EWD391's fair-command composite-ring endpoint remains open (#7291).

    theorem Cslib.Distributed.SelfStabilization.not_uniform_distEnabledMove_selfStabilizing_composite_ring {State : Type u_1} [Nonempty State] {a b : ℕ} (ha : 2 ≤ a) (hb : 2 ≤ b) [NeZero (a * b)] (π : UniformRingProtocol State) {Legitimate : Set (Fin (a * b) → State)} (hleg : Legitimate ⊆ π.UniquePrivilege (a * b)) :
    ¬SelfStabilizing (π.distLTS (a * b)) Legitimate

    Scheduler-scoped enabled-move step towards Dijkstra (EWD391) in the simultaneous atomic-subset model π.distLTS, and not EWD391's fair-command impossibility endpoint: on a composite ring of size a * b (2 ≤ a, 2 ≤ b) over a nonempty state type, no uniform deterministic ring protocol satisfies SelfStabilizing (π.distLTS (a * b)) Legitimate for any Legitimate ⊆ π.UniquePrivilege (a * b).