Chandy–Lamport consistent-cut permutation, stable-property detection, and liveness #
This module proves the main correctness and liveness theorems of the Chandy–Lamport global snapshot algorithm ([CL85], §3.3, §4 Theorem 1, and §5, pp. 70–75):
- FIFO cut invariant (
project_chan_eq_preInFlight_append_postInFlight,preRecv_pops_preInFlight,postRecv_records_iff_preInFlight): At every reachable augmented state, each channel(u, v)splits intopreInFlight(application messages sent beforeurecorded) followed bypostInFlight(application messages sent afterurecorded), separated by.markerwhile.markeris in transit. Pre-snapshot receives consume exclusively frompreInFlight(no post-snapshot message is ever received pre-snapshot), and post-snapshot receives appendmsgtochanRecif and only ifmsgcame frompreInFlight. - Causal permutation & consistent-cut reachability (
chandyLamport_perm_mTr,chandyLamport_consistent_cut): For any finite executionS_init →*[xl] S_finalstarting from a pre-snapshot stateS_initand ending at a snapshot-complete stateS_final, splitting the underlying application events ofxlinto pre-snapshot events (tracePreEvents S_init xl) followed by post-snapshot events (tracePostEvents S_init xl) yields a valid permutation oferaseTrace xlinsys.ltswhose intermediate state between all pre-snapshot events and all post-snapshot events is literallyextractSnapshot S_final. In particular:sys.lts.CanReach (project S_init) (extractSnapshot S_final) ∧sys.lts.CanReach (extractSnapshot S_final) (project S_final). - Stable-property detection (
stablePred_transfer): For everyIsStablePred sys Φ,(Φ (extractSnapshot S_final) → Φ (project S_final))and(¬ Φ (extractSnapshot S_final) → ¬ Φ (project S_init)). - Snapshot completion liveness (
snapshot_liveness,snapshot_liveness_complete,System.InputEnabled.exists_fair_snapOmegaExecution): Under weak FIFO channel fairness on any finite strongly connected communication graph (and in particular on the complete network⊤) with at least one process recording a snapshot, every process eventually records its state and every incoming channel recorder eventually reaches.done(and remains complete thereafter). Every input-enabled system admits fair infinite executions from any well-formed state.
Main definitions #
Cslib.Distributed.ChandyLamport.preInFlight,Cslib.Distributed.ChandyLamport.postInFlight: in-flight pre-snapshot and post-snapshot application message queues on channel(u, v).Cslib.Distributed.ChandyLamport.System.tracePreEvents,Cslib.Distributed.ChandyLamport.System.tracePostEvents: exact subsequences of pre-snapshot and post-snapshot application events along an augmented trace.Cslib.Distributed.ChandyLamport.SnapEvent.deliversOn,Cslib.Distributed.ChandyLamport.FairChannels: weak FIFO channel delivery fairness on infinite executions.Cslib.Distributed.ChandyLamport.StronglyConnected: strong connectivity of aDigraph P.Cslib.Distributed.ChandyLamport.System.InputEnabled: non-blocking receive assumption ensuring fair executions exist.
Main results #
Cslib.Distributed.ChandyLamport.project_chan_eq_preInFlight_append_postInFlight: exact FIFO partition of every channel intopreInFlight ++ postInFlight.Cslib.Distributed.ChandyLamport.System.preRecv_pops_preInFlight: zero post-snapshot sends are ever received pre-snapshot.Cslib.Distributed.ChandyLamport.System.postRecv_records_iff_preInFlight:chanRecrecords the exact pre-snapshot messages received post-snapshot.Cslib.Distributed.ChandyLamport.System.chandyLamport_perm_mTr: explicit causal permutation oferaseTrace xlintotracePreEvents ++ tracePostEventspassing throughextractSnapshot S_final.Cslib.Distributed.ChandyLamport.System.chandyLamport_consistent_cut:extractSnapshot S_finalis reachable fromproject S_initand can reachproject S_finalinsys.lts.Cslib.Distributed.ChandyLamport.System.stablePred_transfer: forward/backward transfer of any stable global predicateΦviaextractSnapshot S_final.Cslib.Distributed.ChandyLamport.System.snapshot_liveness,Cslib.Distributed.ChandyLamport.System.snapshot_liveness_complete: eventual snapshot completion under fair FIFO channel delivery on strongly connected (and complete) networks.Cslib.Distributed.ChandyLamport.System.InputEnabled.exists_fair_snapOmegaExecution: every well-formed state of an input-enabled system extends to a fair infinite execution.
References #
Part 1: FIFO channel cut partition (preInFlight and postInFlight) #
In-flight application messages on channel (u, v) sent before u recorded its snapshot.
In-flight application messages on channel (u, v) sent after u recorded its snapshot.
Every channel's underlying queue (project S_aug).chan u v decomposes into preInFlight
followed by postInFlight.
Private ghost cut structures for the permutation proof #
Zero post-snapshot sends received pre-snapshot: when an unrecorded process dest
(snapState = none) receives msg from src, msg comes from the head of
preInFlight S₁ src dest (which is non-empty).
chanRec captures the exact pre-snapshot sends received post-snapshot: when an
already-recorded process dest (snapState.isSome) receives msg from src:
- if
preInFlight S₁ src destis non-empty,msgis its head andchanRec srcappendsmsg; - if
preInFlight S₁ src dest = [],msgis the head ofpostInFlight S₁ src destandchanRec srcis already.doneand unchanged.
Part 2: Ghost cut executions & causal permutation (chandyLamport_consistent_cut) #
Subsequence of Pre-snapshot application events along augmented trace xl from S_aug
(events whose actor had snapState = none when the event fired).
Subsequence of Post-snapshot application events along augmented trace xl from S_aug
(events whose actor had snapState.isSome when the event fired).
Mapping sys.snapLts transitions into CutMTr #
Channel evolution helpers for .app e transitions #
Adjacent inversion swaps in CutMTr #
Pushing cross and post steps past pre and cross blocks #
Identifying the boundary state C₁.s = extractSnapshot S_final #
Chandy–Lamport explicit causal permutation theorem ([CL85], §4, Theorem 1,
pp. 72–73): for any finite execution S_init →*[xl] S_final from a pre-snapshot state S_init to
a snapshot-complete state S_final, executing all pre-snapshot events (tracePreEvents S_init xl)
from project S_init reaches extractSnapshot S_final in sys.lts, executing all post-snapshot
events (tracePostEvents S_init xl) from extractSnapshot S_final reaches project S_final in
sys.lts, and tracePreEvents S_init xl ++ tracePostEvents S_init xl is a permutation of
eraseTrace xl (any prefix before S_init and suffix after S_final compose unchanged via
LTS.MTr.comp).
Chandy–Lamport consistent-cut reachability theorem ([CL85], §4, Theorem 1,
p. 72): if a finite augmented execution starts before any snapshot action (IsPreSnapshot S_init)
and ends at a state where the global snapshot is complete (IsSnapshotComplete S_final), then in
the underlying FIFO system sys.lts, the assembled snapshot S* = extractSnapshot S_final is
reachable from project S_init and project S_final is reachable from S*.
Part 3: Stable-property detection corollary #
Stable-property detection (stablePred_transfer, [CL85], §5, pp. 74–75): for
every stable global predicate Φ of sys, if Φ holds in the recorded snapshot
extractSnapshot S_final, then Φ holds in the actual physical state project S_final once the
snapshot finishes; contrapositively (matching y(S_ι) → definite on p. 74), if Φ fails in
extractSnapshot S_final, then Φ had not yet become true at project S_init.
Part 4: Fair FIFO channel delivery & snapshot completion liveness #
Weak FIFO channel delivery fairness: whenever channel (src, dest) is non-empty at step k,
some step j ≥ k delivers from the head of (src, dest).
A directed communication graph G is strongly connected if every vertex v is reachable from
every vertex u by a directed path (Relation.ReflTransGen G.Adj u v).
The complete directed graph ⊤ is strongly connected.
Monotonicity of recorded process states and completed channel recorders #
Once process p records snapState = some s_p, every subsequent transition of sys.snapLts
preserves snapState = some s_p (write-once local snapshot).
Once process p has recorded (snapState.isSome) and finalized incoming recorder
chanRec q = .done saved, every subsequent transition of sys.snapLts preserves .done saved.
FIFO progress of .marker along a single edge #
Chandy–Lamport snapshot completion liveness ([CL85], §3.3, p. 71): on any
finite strongly connected communication graph, in any infinite execution starting from a
pre-snapshot state that satisfies weak FIFO channel delivery fairness (FairChannels, realizing
(L1) while atomic marker handling discharges (L2)) and in which at least one process records a
snapshot (((ss k₀).proc p₀).snapState.isSome), there exists a step K from which
IsSnapshotComplete (ss k) holds permanently (∀ k ≥ K).
Specialization of snapshot_liveness to the complete directed network sys.graph = ⊤.
Non-vacuity: fair FIFO scheduler for input-enabled systems #
A System is input-enabled if receiving a message at the head of an incident channel is
never locally blocked: for every edge (src, dest), local state st, and incoming message msg,
there exist st' and sent satisfying sys.recv and respecting sys.graph.
Round-robin channel-draining scheduler #
Existence of fair infinite executions (non-vacuity of FairChannels): if sys is
input-enabled, every augmented state S₀ with well-formed channels extends to an infinite execution
(ss, xs) of sys.snapLts starting at S₀ that satisfies FairChannels ss xs.