All-Active Basic Two-Hop Unidirectional FIFO Ring Election Steps #
Intermediate steps for all-initially-active basic two-hop unidirectional asynchronous FIFO ring
election on Fin n (n ≥ 1) with injective identifiers uid : Fin n → U from a linear order U
(steps towards Peterson, not the spontaneous-wakeup or 1.44 n log₂ n
Fibonacci-threshold endpoints of [Peterson1982]).
All n processors start active (twoHopAllActiveInit), hold a current temporary identifier tid,
and execute two-hop comparison phases while eliminated processors act as passive FIFO relays
(.relay):
- First hop (
hop1): at the start of a phase, each active processorpemits.hop1 tid_p, which passive relays forward clockwise to the next active processorq. Iftid_p = tid_q,tid_qwrapped around the entire ring as the sole remaining active processor, soqbecomes.leader tid_qwithout emitting further messages. Otherwiseqrecordsntid := tid_p(.active2 tid_q tid_p) and emits.hop2 tid_p. - Second hop (
hop2):.hop2 tid_pis forwarded clockwise to the next active processorr, which has already receivedntid_r = tid_qin.hop1fromqand therefore knows all three consecutive active temporary identifiers(tid_p, tid_q, tid_r). Ifqis a strict local peak (tid_p < tid_q ∧ tid_r < tid_q),rremains active in the next phase adoptingtid' := tid_qand immediately emits.hop1 tid_q; otherwiserbecomes a passive.relay.
The proof combines two clean structural ingredients:
- Phase combinatorics (
twoHopSurvivors_card_halving,twoHopAllActive_phases_le_log): distinctness of active temporary identifiers and the global maximummax_j (uid j)are preserved across every phase (2 ≤ active), while adjacent active nodes cannot both be strict peaks, giving2 * active_{k + 1} ≤ active_kandtwoHopAllActivePhases uid ≤ Nat.log 2 nelimination phases. Telescoping the per-phase emissions (ninitial +(2n - active_k + active_{k + 1})per elimination phase +(n - 1)in the finalactive = 1pass) yields2 * n * K + nmessages on the canonical wave execution. - Strong weighted FIFO confluence (
twoHopStep_comm): enabled single-message deliveries at distinct nodesi ≠ jcommute in one step (twoHopStep j (twoHopStep i cfg) = twoHopStep i (twoHopStep j cfg)) with identical additive message emissions, because popping the head of a nonempty FIFO list commutes with appending to its tail. A general strip lemma transfers termination, the unique quiescent state, and the message bound2 * n * Nat.log 2 n + nto every asynchronous FIFO execution fromtwoHopAllActiveInit uid.
Main definitions #
Cslib.Distributed.RingElection.TwoHopMsg,TwoHopNode,TwoHopLocalOut,twoHopRecv: untagged two-hop message payloads, processor states, and local transition handler.Cslib.Distributed.RingElection.TwoHopConfig,twoHopAllActiveInit,twoHopStep,twoHopExec,twoHopLTS,twoHopAllActiveExecMsgs: global FIFO configurations, all-active initial state, asynchronous transitions, LTS, and cumulative edge-message counter.Cslib.Distributed.RingElection.backLen,prevActive,nextActive,twoHopSurvivors,TwoHopPhaseState,twoHopAllActivePhase,twoHopAllActivePhases: active-subring combinatorics and all-active phase evolution.
Main results #
Cslib.Distributed.RingElection.twoHopSurvivors_card_halving,Cslib.Distributed.RingElection.twoHopAllActive_phase_halving: per-phase halving steps2 * active_{k + 1} ≤ active_kwhenever2 ≤ active_k.Cslib.Distributed.RingElection.twoHopAllActive_phases_le_log: phase-bound steptwoHopAllActivePhases uid ≤ Nat.log 2 nand convergence to a single active processor.Cslib.Distributed.RingElection.twoHopStep_comm: one-step FIFO confluence step onFin n.Cslib.Distributed.RingElection.twoHopAllActive_elects_leader: bounded-termination and unique-leader step fromtwoHopAllActiveInit uidacross all asynchronous FIFO schedules.Cslib.Distributed.RingElection.twoHopAllActive_execMsgs_eq,Cslib.Distributed.RingElection.twoHopAllActive_messages_le: complete-run2 * n * twoHopAllActivePhases uid + nmessage-count step and≤ 2 * n * Nat.log 2 n + nbound step fromtwoHopAllActiveInit uid.
References #
Local processor machine and asynchronous FIFO ring LTS #
Message payload in the basic two-hop unidirectional ring election protocol.
Local state of a processor in the basic two-hop unidirectional ring election protocol.
- active1 {U : Type u_1} (tid : U) : TwoHopNode U
Active node at start of phase holding
tid, awaitinghop1from its predecessor. - active2 {U : Type u_1} (tid ntid : U) : TwoHopNode U
Active node holding
tidand predecessor'sntid, awaitinghop2(nnid). - relay {U : Type u_1} : TwoHopNode U
Passive relay node forwarding every incoming message unchanged.
- leader {U : Type u_1} (maxUid : U) : TwoHopNode U
Elected leader node holding the global maximum identifier
maxUid.
Whether a TwoHopNode is in the elected .leader state.
Output of a single message reception in the basic two-hop protocol: updated processor state and
outgoing FIFO messages appended to i → i + 1.
- nextNode : TwoHopNode U
Updated local state of the receiving processor.
Outgoing messages appended to the processor's clockwise channel.
Deterministic local transition handler for the basic two-hop protocol upon receiving msg.
Global configuration of the basic two-hop protocol on an asynchronous FIFO unidirectional
n-ring.
- node : Fin n → TwoHopNode U
Local state of each node
i : Fin n. Clockwise FIFO channel on directed edge
i → i + 1(head is oldest, tail is newest).
Whether node i has declared leadership in configuration cfg.
All-initially-active start configuration for the basic two-hop protocol (a step model towards
Peterson): every node i starts active with tid = uid i and injects
[.hop1 (uid i)] onto i → i + 1.
Deliver the oldest message on target - 1 → target to target (no-op if empty).
Number of messages emitted onto target → target + 1 by a single twoHopStep.
Execute a finite delivery schedule sched : List (Fin n) starting from cfg.
Cumulative messages emitted onto ring edges during sched starting from cfg.
Total messages transmitted across edges in schedule sched from twoHopAllActiveInit uid: the
n initial .hop1 injections plus all subsequent emissions.
Labelled transition system of enabled FIFO deliveries in the basic two-hop protocol on
Fin n.
Strong one-step FIFO confluence and strip lemma #
A one-step FIFO confluence step for the basic two-hop unidirectional ring protocol (a step
towards Peterson, not the cited endpoint): whenever two distinct processors i ≠ j
both have nonempty incoming channels in cfg, each remains enabled after the other steps, the two
delivery orders reach the same global configuration, and their emitted message counts commute.
Active sub-ring geometry and per-phase halving #
Surviving active nodes after a two-hop comparison phase on active set A with temporary
identifier assignment tidMap: nodes r ∈ A whose predecessor q = prevActive A r is a strict
local peak (tidMap (prevActive A q) < tidMap q ∧ tidMap r < tidMap q).
A combinatorial active-subring halving step for two-hop peak comparison (a step towards
Peterson, not the cited endpoint): adjacent active nodes cannot both be strict
peaks, so r and prevActive A r for r ∈ twoHopSurvivors A tidMap form disjoint subsets of A,
giving 2 * (twoHopSurvivors A tidMap).card ≤ A.card.
Combinatorial state of active nodes and their temporary identifiers at phase k.
Active node set
A_kat phasek.- tidMap : Fin n → U
Phase-by-phase combinatorial evolution of the all-initially-active basic two-hop protocol
(stabilizing once active.card ≤ 1).
Total number of elimination phases (2 ≤ active.card) executed by the all-initially-active
basic two-hop protocol on uid before active.card = 1.
A per-phase active-count halving step for all-initially-active basic two-hop ring election (a
step towards Peterson, not the cited endpoint): whenever
2 ≤ (twoHopAllActivePhase uid k).active.card, the next phase has at most half as many active
nodes.
A logarithmic phase-bound step for all-initially-active basic two-hop ring election (a step
towards Peterson, not the cited endpoint): for any injective uid : Fin n → U, the
number of elimination phases satisfies twoHopAllActivePhases uid ≤ Nat.log 2 n, and at phase
K = twoHopAllActivePhases uid (as well as at Nat.log 2 n), exactly 1 active processor
remains.
Canonical wave execution across passive relays and active nodes #
Canonical full-protocol run and main theorems #
A bounded-termination and unique-leader election step for all-initially-active basic two-hop
unidirectional FIFO ring election (a step towards Peterson, not the
spontaneous-wakeup or Fibonacci-threshold endpoint): for any injective uid : Fin n → U on Fin n:
- Every configuration reachable from
twoHopAllActiveInit uidextends to a quiescent (LTS.IsTerminal) configuration; - Every quiescent configuration reachable from
twoHopAllActiveInit uidcoincides with the unique terminal configuration where a single nodei*holds.leader maxUid(maxUid = max_j (uid j)) and allj ≠ i*are passive.relays (∃! i*, cfg.isLeader i* = true).
A complete-run message-accounting step for all-initially-active basic two-hop unidirectional
FIFO ring election (a step towards Peterson, not the cited endpoint): every complete
execution (twoHopLTS n U).MTr (twoHopAllActiveInit uid) sched cfg (IsTerminal cfg) transmits
2 * n * twoHopAllActivePhases uid + n messages regardless of the asynchronous FIFO delivery
order.
An asynchronous message-bound step for all-initially-active basic two-hop unidirectional FIFO
ring election (a step towards Peterson, not the spontaneous-wakeup or
1.44 n log₂ n Fibonacci-threshold endpoint): in every execution
(twoHopLTS n U).MTr (twoHopAllActiveInit uid) sched cfg (partial or complete), total messages
transmitted across all edges satisfy twoHopAllActiveExecMsgs uid sched ≤ 2 * n * Nat.log 2 n + n.