Documentation

CslibFrontier.Computability.Distributed.RingElection.Anonymous

Rotational Symmetry Steps on Anonymous Rings #

Synchronous-round and sequential-FIFO-wave rotational symmetry steps on anonymous oriented rings Fin n (steps towards Angluin, not the general processor-network covering impossibility endpoints of [Angluin1980b]).

Every processor in an anonymous ring starts in the same initial state init without a distinct identifier and executes the same deterministic transition function. Because a protocol value may be chosen separately for each ring size n, these symmetry steps hold even when n is common knowledge among the processors. Both bidirectional and unidirectional message passing are covered in two concrete ring models:

  1. Synchronous rounds (AnonProtocol): in round r, each node i : Fin n sends toPred r s counter-clockwise to i - 1 and toSucc r s clockwise to i + 1, then updates via recv r s fromPred fromSucc. Shifting the initial state assignment by + k commutes with every round (AnonProtocol.stateFrom_shift_eq), so from a uniform initial state all nodes share the exact same state after every round (AnonProtocol.state_shift_eq). Consequently, for 2 ≤ n the set of self-declared leaders has cardinality 0 or n, never 1 (AnonProtocol.not_electsUniqueLeader_sync_of_two_le).
  2. Asynchronous FIFO schedules (AnonAsyncProtocol): directed edges i → i + 1 and i → i - 1 carry unbounded FIFO queues modelled as a Cslib.LTS. Finite delivery schedules commute with cyclic index shifts (AnonAsyncProtocol.exec_shift_eq). Moreover, sequential round-robin FIFO waves delivering one message along every clockwise or counter-clockwise edge (clockwiseWave, counterWave) are valid LTS.MTr executions whenever the corresponding queues are nonempty and preserve exact rotational symmetry across all nodes (AnonAsyncProtocol.exists_rotWave_trace_leaders_card_ne_one).

Main definitions #

Main results #

References #

Synchronous anonymous ring protocols #

structure Cslib.Distributed.RingElection.AnonProtocol (S : Type u_1) (M : Type u_2) :
Type (max u_1 u_2)

A deterministic synchronous message-passing protocol for an anonymous oriented ring.

Every node starts in the common initial state init. In round r, each node i sends toPred r s counter-clockwise to i - 1 and toSucc r s clockwise to i + 1, then updates its state via recv r s fromPred fromSucc where fromPred arrived from i - 1 and fromSucc arrived from i + 1. Because an AnonProtocol may depend on the ring size n, impossibility applies even when n is known to all nodes.

  • init : S

    Common initial local state shared by all nodes before round 0.

  • toPred : ℕ → S → M

    Message sent counter-clockwise to predecessor i - 1 in round r.

  • toSucc : ℕ → S → M

    Message sent clockwise to successor i + 1 in round r.

  • recv : ℕ → S → M → M → S

    Next state after round r from own state, message from i - 1, and message from i + 1.

  • isLeader : S → Bool

    Boolean output predicate indicating whether a node declares itself leader.

def Cslib.Distributed.RingElection.AnonProtocol.unidir {S : Type u_1} {M : Type u_2} (init : S) (send : ℕ → S → M) (recv : ℕ → S → M → S) (isLeader : S → Bool) :

Embed a unidirectional clockwise anonymous protocol (where each node sends send r s only to i + 1 and updates solely from its own state and the message received from i - 1) as an AnonProtocol. The counter-clockwise field toPred is ignored by recv.

def Cslib.Distributed.RingElection.AnonProtocol.stateFrom {S : Type u_1} {M : Type u_2} (P : AnonProtocol S M) {n : ℕ} [NeZero n] (s₀ : Fin n → S) :
ℕ → Fin n → S

State of node i : Fin n after r synchronous rounds from an arbitrary initial state assignment s₀ : Fin n → S.

def Cslib.Distributed.RingElection.AnonProtocol.run {S : Type u_1} {M : Type u_2} (P : AnonProtocol S M) (n : ℕ) [NeZero n] (r : ℕ) (i : Fin n) :
S

State of node i : Fin n after r synchronous rounds from the anonymous uniform initial configuration fun _ => P.init.

@[simp]
theorem Cslib.Distributed.RingElection.AnonProtocol.stateFrom_zero {S : Type u_1} {M : Type u_2} (P : AnonProtocol S M) {n : ℕ} [NeZero n] (s₀ : Fin n → S) (i : Fin n) :
P.stateFrom s₀ 0 i = s₀ i
@[simp]
theorem Cslib.Distributed.RingElection.AnonProtocol.run_zero {S : Type u_1} {M : Type u_2} (P : AnonProtocol S M) (n : ℕ) [NeZero n] (i : Fin n) :
P.run n 0 i = P.init
theorem Cslib.Distributed.RingElection.AnonProtocol.stateFrom_shift_eq {S : Type u_1} {M : Type u_2} (P : AnonProtocol S M) {n : ℕ} [NeZero n] (s₀ : Fin n → S) (k : Fin n) (r : ℕ) (i : Fin n) :
P.stateFrom s₀ r (i + k) = P.stateFrom (fun (j : Fin n) => s₀ (j + k)) r i

Shifting node indices by + k mod n commutes with every synchronous round on Fin n.

theorem Cslib.Distributed.RingElection.AnonProtocol.state_shift_eq {S : Type u_1} {M : Type u_2} (P : AnonProtocol S M) (n : ℕ) [NeZero n] (r : ℕ) (i k : Fin n) :
P.run n r (i + k) = P.run n r i

From a uniform initial state on Fin n, shifting any node index by + k mod n leaves its state unchanged after every synchronous round r.

def Cslib.Distributed.RingElection.AnonProtocol.leaders {S : Type u_1} {M : Type u_2} (P : AnonProtocol S M) (n : ℕ) [NeZero n] (r : ℕ) :

The set of nodes declaring isLeader = true after r rounds on Fin n.

Unique leader election at round r: exactly one node in Fin n declares isLeader = true.

ElectsUniqueLeader is equivalent to unique existence ∃! i, P.isLeader (P.run n r i) = true.

theorem Cslib.Distributed.RingElection.AnonProtocol.leaders_card_eq_zero_or_self {S : Type u_1} {M : Type u_2} (P : AnonProtocol S M) (n : ℕ) [NeZero n] (r : ℕ) :
(P.leaders n r).card = 0 ∨ (P.leaders n r).card = n

After any round r, the number of leaders in an anonymous n-ring is either 0 or n.

A synchronous-round symmetry step on anonymous oriented rings Fin n (a step towards Angluin, not the general processor-network covering endpoint): for 2 ≤ n, no deterministic AnonProtocol—bidirectional or unidirectional, even parameterized by n—elects a unique leader in any synchronous round r.

Asynchronous FIFO anonymous ring protocols #

Ring traversal direction for asynchronous FIFO channels: clockwise (i - 1 → i) or counter (i + 1 → i).

  • clockwise : RingDir

    Delivery along clockwise edge i - 1 → i.

  • counter : RingDir

    Delivery along counter-clockwise edge i + 1 → i.

structure Cslib.Distributed.RingElection.AnonAsyncOut (S : Type u_1) (M : Type u_2) :
Type (max u_1 u_2)

Output of a single asynchronous message reception: updated local state together with outgoing FIFO messages appended to counter-clockwise (toPred) and clockwise (toSucc) channels.

  • nextState : S

    Updated local state of the receiving processor.

  • toPred : List M

    Messages appended to the outgoing counter-clockwise channel i → i - 1.

  • toSucc : List M

    Messages appended to the outgoing clockwise channel i → i + 1.

def Cslib.Distributed.RingElection.instDecidableEqAnonAsyncOut.decEq {S✝ : Type u_1} {M✝ : Type u_2} [DecidableEq S✝] [DecidableEq M✝] (x✝ x✝¹ : AnonAsyncOut S✝ M✝) :
Decidable (x✝ = x✝¹)
@[instance_reducible]
structure Cslib.Distributed.RingElection.AnonAsyncProtocol (S : Type u_1) (M : Type u_2) :
Type (max u_1 u_2)

A deterministic asynchronous FIFO protocol for an anonymous bidirectional ring.

  • init : S

    Common initial local state of every node.

  • initToPred : List M

    Initial messages queued on every outgoing counter-clockwise channel i → i - 1.

  • initToSucc : List M

    Initial messages queued on every outgoing clockwise channel i → i + 1.

  • recvFromPred : S → M → AnonAsyncOut S M

    Handler invoked when receiving the head of incoming clockwise channel i - 1 → i.

  • recvFromSucc : S → M → AnonAsyncOut S M

    Handler invoked when receiving the head of incoming counter-clockwise channel i + 1 → i.

  • isLeader : S → Bool

    Boolean predicate indicating whether a node declares itself leader.

structure Cslib.Distributed.RingElection.AnonAsyncConfig (n : ℕ) (S : Type u_1) (M : Type u_2) :
Type (max u_1 u_2)

Global configuration of an asynchronous bidirectional FIFO ring on Fin n.

  • node : Fin n → S

    Local state of each node i : Fin n.

  • chanSucc : Fin n → List M

    Clockwise FIFO queue on directed edge i → i + 1 (head is oldest, tail is newest).

  • chanPred : Fin n → List M

    Counter-clockwise FIFO queue on directed edge i → i - 1 (head is oldest, tail is newest).

theorem Cslib.Distributed.RingElection.AnonAsyncConfig.ext {n : ℕ} {S : Type u_1} {M : Type u_2} {x y : AnonAsyncConfig n S M} (node : x.node = y.node) (chanSucc : x.chanSucc = y.chanSucc) (chanPred : x.chanPred = y.chanPred) :
x = y

A single-message delivery event in an asynchronous ring, delivering the head of the dir channel incident to target.

Cyclically shift an AnonEvent by + k mod n.

def Cslib.Distributed.RingElection.AnonAsyncConfig.shift {n : ℕ} {S : Type u_1} {M : Type u_2} (k : Fin n) (cfg : AnonAsyncConfig n S M) :

Cyclically shift an AnonAsyncConfig by + k mod n.

Whether delivery event e is enabled in configuration cfg (its source FIFO queue is nonempty).

def Cslib.Distributed.RingElection.AnonAsyncConfig.IsUniform {n : ℕ} {S : Type u_1} {M : Type u_2} (cfg : AnonAsyncConfig n S M) (s : S) (cs cp : List M) :

A configuration is uniform (rotationally symmetric) with state s, clockwise queue cs, and counter-clockwise queue cp at every node.

Sequential clockwise FIFO wave delivering one message to each node 0, 1, …, n - 1 in order.

Sequential counter-clockwise FIFO wave delivering one message to each node 0, -1, -2, … in order (the i ↦ -i reflection of clockwiseWave).

Concatenation of sequential single-delivery FIFO waves for a list of directions.

def Cslib.Distributed.RingElection.AnonAsyncProtocol.unidir {S : Type u_1} {M : Type u_2} (init : S) (initMsgs : List M) (nextState : S → M → S) (sendSucc : S → M → List M) (isLeader : S → Bool) :

Construct a unidirectional clockwise asynchronous FIFO protocol where messages travel only along i → i + 1 (each reception from i - 1 produces nextState and outgoing messages sendSucc).

Initial uniform configuration of P on Fin n.

Deterministic single-event FIFO transition (no-op if the addressed incoming queue is empty).

def Cslib.Distributed.RingElection.AnonAsyncProtocol.exec {S : Type u_1} {M : Type u_2} (P : AnonAsyncProtocol S M) {n : ℕ} [NeZero n] (cfg : AnonAsyncConfig n S M) (sched : List (AnonEvent n)) :

Execute a finite asynchronous schedule sched starting from cfg.

Labelled transition system of enabled single-message FIFO deliveries on Fin n.

Set of nodes declaring isLeader = true in configuration cfg.

theorem Cslib.Distributed.RingElection.AnonAsyncProtocol.exec_shift_eq {S : Type u_1} {M : Type u_2} (P : AnonAsyncProtocol S M) {n : ℕ} [NeZero n] (cfg : AnonAsyncConfig n S M) (k : Fin n) (sched : List (AnonEvent n)) :

Shifting node indices by + k commutes with any finite asynchronous FIFO schedule on Fin n.

theorem Cslib.Distributed.RingElection.AnonAsyncProtocol.mtr_rotWave_uniform {S : Type u_1} {M : Type u_2} (P : AnonAsyncProtocol S M) {n : ℕ} [NeZero n] {cfg : AnonAsyncConfig n S M} {s : S} {cs cp : List M} (huni : cfg.IsUniform s cs cp) (d : RingDir) :
(match d with | RingDir.clockwise => cs ≠ [] → (P.lts n).MTr cfg (clockwiseWave n) (P.exec cfg (clockwiseWave n)) | RingDir.counter => cp ≠ [] → (P.lts n).MTr cfg (counterWave n) (P.exec cfg (counterWave n))) ∧ ∃ (s' : S) (cs' : List M) (cp' : List M), (P.exec cfg (match d with | RingDir.clockwise => clockwiseWave n | RingDir.counter => counterWave n)).IsUniform s' cs' cp'

Helper step for sequential FIFO waves on Fin n: from any uniform configuration, executing a clockwise wave (when clockwise queues are nonempty) or a counter-clockwise wave (when counter-clockwise queues are nonempty) is a valid multi-step LTS.MTr trace that leaves the ring in a uniform configuration.

theorem Cslib.Distributed.RingElection.AnonAsyncProtocol.exists_rotWave_trace_leaders_card_ne_one {S : Type u_1} {M : Type u_2} (P : AnonAsyncProtocol S M) {n : ℕ} [NeZero n] (hn : 2 ≤ n) (W : ℕ) :
∃ (sched : List (AnonEvent n)) (cfg : AnonAsyncConfig n S M), (P.lts n).MTr (P.initConfig n) sched cfg ∧ (W * n ≤ sched.length ∨ (P.lts n).IsTerminal cfg) ∧ (P.configLeaders cfg).card ≠ 1

A sequential-FIFO-wave symmetry step on anonymous oriented rings Fin n (a step towards Angluin, not the general asynchronous processor-network endpoint): from P.initConfig n (2 ≤ n), for every target wave count W there exists an enabled multi-step FIFO trace sched in P.lts n that either completes W nonempty waves or reaches a quiescent terminal configuration ((P.lts n).IsTerminal), with leader cardinality ≠ 1.