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):
- Neutrality invariant (
Reachable.neutral_of_parent_none): for everyp ≠ root,parent p = noneimpliesactive p = false ∧ deficit p = 0(the single-parent counterpart of invariant P3 inEWD687a - 2, PDF p. 5). - Exact deficit conservation (
Reachable.deficit_eq_inFlight_add_children): for everyp,deficit p = inFlightBasicFrom p + inFlightSignalTo p + (children root p).card. - Engagement-tree reachability & acyclicity (
Reachable.engaged_reaches_root,Reachable.ancestor?_ne_self_of_pos): everyp ≠ rootwithparent p ≠ nonereachesrootalongparentlinks in0 < k < Fintype.card Phops, andparentpointers never form a cycle. Becausedeficit src ≥ 1while⟨src, dst⟩is in flight and whiledstremains attached as a child ofsrc,srccannot detach beforedsteither acknowledges immediately or detaches. - Termination soundness (
Reachable.terminated_implies_quiescent,Reachable.terminated_iff_globalQuiescence): in every reachable state,s.Terminated rootholds iffs.GlobalQuiescentholds (counterpart of Theorem 2 inEWD687a - 5, PDF p. 8). - Drain liveness (
Reachable.quiescent_drains_to_terminated): from any reachableComputationIdlestate (∀ p, active p = falseandbasicMsgs = 0), every enabled step is arecvSignalordetachstep reducingdrainMeasure = 2 * engagedCount + inFlightSignalsby1, and every maximal execution reachesTerminated rootin at most2 * Fintype.card P + inFlightSignalssteps (counterpart of Theorem 1 inEWD687a - 3, PDF p. 6). - Sequential-polling counterexample (
exists_phantom_termination_naive_poll): an original 3-role execution showing that sequentialactive = falsepolling without channel/deficit accounting reports false termination when a basic message crosses from an unpolled process to an already-polled process while Dijkstra–Scholten'sTerminated rootremainsfalse.
Main definitions #
Cslib.Distributed.DijkstraScholten.State.inFlightBasicFrom: count of in-flight basic messages sent byp.Cslib.Distributed.DijkstraScholten.State.inFlightSignalTo,Cslib.Distributed.DijkstraScholten.State.inFlightSignals: per-recipient and total in-flight signal counts.Cslib.Distributed.DijkstraScholten.State.children: set of non-root processesqwithparent q = some p.Cslib.Distributed.DijkstraScholten.State.engagedNodes,Cslib.Distributed.DijkstraScholten.State.engagedCount: non-root processes currently engaged in the tree (parent ≠ none) and their count.Cslib.Distributed.DijkstraScholten.State.drainMeasure: exact potential2 * engagedCount + inFlightSignalsstrictly decreasing during signal/detach draining.Cslib.Distributed.DijkstraScholten.State.ancestor?:k-hopparent-pointer walk fromp.
Main results #
Cslib.Distributed.DijkstraScholten.Reachable.root_parent_eq_none:rootnever acquires aparentpointer in any reachable configuration.Cslib.Distributed.DijkstraScholten.Reachable.neutral_of_parent_none,Cslib.Distributed.DijkstraScholten.Reachable.attach_iff: detached non-root processes are idle with zero deficit, matching full local neutrality.Cslib.Distributed.DijkstraScholten.Reachable.deficit_eq_inFlight_add_children: exact per-process deficit conservation across in-flight messages, signals, and tree children.Cslib.Distributed.DijkstraScholten.Reachable.engaged_reaches_root: every engaged non-root process followsparentpointers torootin fewer thanFintype.card Psteps.Cslib.Distributed.DijkstraScholten.Reachable.ancestor?_ne_self_of_pos:parentpointers form no cycles in any reachable configuration.Cslib.Distributed.DijkstraScholten.Reachable.terminated_implies_quiescent,Cslib.Distributed.DijkstraScholten.Reachable.terminated_iff_globalQuiescence: root termination implies (and is equivalent to) full network quiescence.Cslib.Distributed.DijkstraScholten.State.ComputationIdle.step_drainMeasure,Cslib.Distributed.DijkstraScholten.State.ComputationIdle.mtr_drainMeasure,Cslib.Distributed.DijkstraScholten.Reachable.isTerminal_iff_terminated_of_computationIdle,Cslib.Distributed.DijkstraScholten.Reachable.quiescent_drains_to_terminated: unit-drop drain potential, deadlock-freedom untilTerminated, and guaranteed bounded detection within2 * Fintype.card P + inFlightSignalssteps under every schedule once basic activity ceases.Cslib.Distributed.DijkstraScholten.exists_phantom_termination_naive_poll: sequential localactive = falsepolling admits phantom termination across an in-flight basic message.
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).
Shared frame helpers for children and engagedNodes #
Structural invariants: root parent, neutrality (P3), and exact deficit conservation #
root never acquires a parent pointer in any reachable configuration.
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.
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) #
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.
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 #
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.
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.
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 #
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:
rootis polled idle ats₁;- every
p ≠ r(includingq) is polled idle ats₂whileris actively computing; rsends basic message⟨r, q⟩to already-polledq, turns idle, and is polled idle ats₃(completing an all-falsesequential poll across the entire system);⟨r, q⟩arrives ats₄to re-activateq, while Dijkstra–Scholten'sTerminated rootremainsfalsethroughouts₁, s₂, s₃, s₄.