Documentation

CslibFrontier.Computability.Distributed.ClockSync.Basic

Lockstep drift-free clock-synchronization model and time-shift indistinguishability #

This module defines a deterministic synchronous lockstep, drift-free (hardwareClock c p t = t + c p) full-information R-round clock-synchronization model (LockstepProtocol P K R) on the complete network of processes P—an intermediate step towards Lundelius and Lynch, rather than that paper's general asynchronous event-driven message-passing model (tracked in #7202).

Each process p : P has a unit-rate, drift-free hardware clock whose reading at real time t : K is hardwareClock c p t = t + c p, where c : P → K is an unknown initial offset vector. Processes have no direct access to real time t: in each lockstep round r < R, process p schedules outgoing messages to every q : P at chosen local hardware clock readings τ and records its own local hardware clock reading upon receiving each incoming round-r message. When p sends a message at local reading τ and the message experiences transit delay δ r p q, it arrives at q at local reading arrivalReading c δ r p q τ = τ + δ r p q + c q - c p.

Within fixed-R-round lockstep all-to-all broadcast, passing full local observation histories (LocalView P K r) represents arbitrary deterministic local states and message payloads; asynchronous event-driven protocols where message sends are triggered dynamically outside fixed lockstep rounds remain open in #7202.

The key structural property proved in this lockstep drift-free model is time-shift indistinguishability (localView_shift_eq, adj_shift_eq): shifting hardware offsets to shiftOffsets c s p = c p + s p and transit delays to shiftDelays δ s r p q = δ r p q + s p - s q leaves every arrival reading and hence every process's LocalView and computed adjustment adj identically unchanged, while shifting each synchronized clock offset syncOffset by + s p (syncOffset_shift_eq).

This file also provides the midpoint-delay offset estimator estDiff and its error bound abs_add_estDiff_sub_le, shared by the lockstep fault-free averaging step in CslibFrontier.Computability.Distributed.ClockSync.LundeliusLynch and the lockstep drift-free Byzantine trimmed-midpoint step in CslibFrontier.Computability.Distributed.ClockSync.ByzantineSync.

Main definitions #

Main results #

References #

def Cslib.Distributed.ClockSync.hardwareClock {P : Type u} {K : Type v} [Add K] (c : P → K) (p : P) (t : K) :
K

The local reading t + c p of process p's unit-rate, drift-free hardware clock at real time t under initial hardware clock offsets c : P → K.

def Cslib.Distributed.ClockSync.arrivalReading {P : Type u} {K : Type v} [AddCommGroup K] (c : P → K) (δ : ℕ → P → P → K) (r : ℕ) (p q : P) (τ : K) :
K

The local hardware clock reading observed at recipient q on a drift-free clock when a round-r message sent by p at p's local clock reading τ arrives after real-time transit delay δ r p q.

theorem Cslib.Distributed.ClockSync.hardwareClock_arrival {P : Type u} {K : Type v} [AddCommGroup K] (c : P → K) (δ : ℕ → P → P → K) (r : ℕ) (p q : P) {t τ : K} (ht : hardwareClock c p t = τ) :
hardwareClock c q (t + δ r p q) = arrivalReading c δ r p q τ

If p sends a message at real time t when its drift-free hardware clock reads τ, and the message has transit delay δ r p q, then q's hardware clock at arrival time t + δ r p q reads arrivalReading c δ r p q τ.

def Cslib.Distributed.ClockSync.ValidDelays {P : Type u} {K : Type v} [LE K] (d_min d_max : K) (δ : ℕ → P → P → K) :

Every round's message transit delays lie within [d_min, d_max].

inductive Cslib.Distributed.ClockSync.LocalView (P : Type u) (K : Type v) :
ℕ → Type (max u v)

The full local observation history of a process after r lockstep message-passing rounds.

Before communication begins (init), a process has observed no arrival timestamps. After lockstep round r + 1 (step prev arrival relayed), a process retains its prior view prev, records for each sender q : P its own local clock reading arrival q upon receiving q's round-r message, and receives q's relayed prior view relayed q.

def Cslib.Distributed.ClockSync.LocalView.lastArrival {P : Type u} {K : Type v} {r : ℕ} :
LocalView P K (r + 1) → P → K

Extract the vector of arrival timestamps observed in the final round of a non-empty view.

@[simp]
theorem Cslib.Distributed.ClockSync.LocalView.lastArrival_step {P : Type u} {K : Type v} {r : ℕ} (prev : LocalView P K r) (arrival : P → K) (relayed : P → LocalView P K r) :
(prev.step arrival relayed).lastArrival = arrival

LocalView.lastArrival returns the arrival vector of the most recent round.

@[instance_reducible]

Decidable equality on LocalView P K r over finite process sets P.

structure Cslib.Distributed.ClockSync.LockstepProtocol (P : Type u) (K : Type v) (R : ℕ) :
Type (max u v)

A deterministic R-round lockstep full-information clock-synchronization protocol on the complete network of processes P with drift-free clock values in K (a synchronous lockstep step towards Lundelius and Lynch; asynchronous event-driven protocols are tracked in #7202).

In each lockstep round r : Fin R, process p with local history v : LocalView P K r sends its round-r message to q when p's local hardware clock reads sendTime r p v q. After R rounds, process p with final history v : LocalView P K R shifts its hardware clock by adjust p v.

  • sendTime (r : Fin R) : P → LocalView P K ↑r → P → K

    Local hardware clock reading at which p sends its round-r message to q.

  • adjust : P → LocalView P K R → K

    Local clock adjustment computed by p after R lockstep rounds.

def Cslib.Distributed.ClockSync.LockstepProtocol.localView {P : Type u} {K : Type v} [AddCommGroup K] {R : ℕ} (π : LockstepProtocol P K R) (c : P → K) (δ : ℕ → P → P → K) (r : ℕ) :
r ≤ R → P → LocalView P K r

Process p's local observation history after r ≤ R lockstep rounds under drift-free hardware clock offsets c and message transit delays δ.

def Cslib.Distributed.ClockSync.LockstepProtocol.adj {P : Type u} {K : Type v} [AddCommGroup K] {R : ℕ} (π : LockstepProtocol P K R) (c : P → K) (δ : ℕ → P → P → K) (p : P) :
K

The local clock adjustment vector computed by π after all R lockstep rounds.

def Cslib.Distributed.ClockSync.LockstepProtocol.syncOffset {P : Type u} {K : Type v} [AddCommGroup K] {R : ℕ} (π : LockstepProtocol P K R) (c : P → K) (δ : ℕ → P → P → K) (p : P) :
K

Process p's synchronized clock offset c p + π.adj c δ p after π finishes: at real time t, p's adjusted drift-free clock reads t + π.syncOffset c δ p.

def Cslib.Distributed.ClockSync.AchievesLockstepSkew {P : Type u} {K : Type v} [AddCommGroup K] [LinearOrder K] {R : ℕ} (π : LockstepProtocol P K R) (d_min d_max γ : K) :

Lockstep protocol π achieves worst-case synchronized clock skew at most γ across all initial drift-free hardware clock offsets c and all message transit delays δ in [d_min, d_max] (a synchronous lockstep step after Lundelius and Lynch; asynchronous event-driven clock synchronization is tracked in #7202).

theorem Cslib.Distributed.ClockSync.AchievesLockstepSkew.mono {P : Type u} {K : Type v} [AddCommGroup K] [LinearOrder K] {R : ℕ} {π : LockstepProtocol P K R} {d_min d_max γ γ' : K} (h : AchievesLockstepSkew π d_min d_max γ) (hγ : γ ≤ γ') :
AchievesLockstepSkew π d_min d_max γ'

Achieving lockstep clock skew γ implies achieving any larger skew bound γ' ≥ γ.

Time-shift indistinguishability #

def Cslib.Distributed.ClockSync.shiftOffsets {P : Type u} {K : Type v} [Add K] (c s : P → K) (p : P) :
K

Shift each process p's hardware clock offset by s p, corresponding to advancing events at p by s p units of real time while keeping p's local clock readings unchanged.

def Cslib.Distributed.ClockSync.shiftDelays {P : Type u} {K : Type v} [AddCommGroup K] (δ : ℕ → P → P → K) (s : P → K) (r : ℕ) (p q : P) :
K

Shift transit delays consistently with shiftOffsets c s: when p's events occur s p earlier and q's events occur s q earlier, a message from p to q is in transit for δ r p q + s p - s q.

@[simp]
theorem Cslib.Distributed.ClockSync.arrivalReading_shift_eq {P : Type u} {K : Type v} [AddCommGroup K] (c : P → K) (δ : ℕ → P → P → K) (s : P → K) (r : ℕ) (p q : P) (τ : K) :
arrivalReading (shiftOffsets c s) (shiftDelays δ s) r p q τ = arrivalReading c δ r p q τ

Shifting drift-free hardware offsets by s and transit delays by s p - s q preserves every local arrival clock reading identically.

@[simp]
theorem Cslib.Distributed.ClockSync.localView_shift_eq {P : Type u} {K : Type v} [AddCommGroup K] {R : ℕ} (π : LockstepProtocol P K R) (c : P → K) (δ : ℕ → P → P → K) (s : P → K) (r : ℕ) (hr : r ≤ R) (p : P) :
π.localView (shiftOffsets c s) (shiftDelays δ s) r hr p = π.localView c δ r hr p

A synchronous lockstep, drift-free R-round step towards the execution-shift indistinguishability lemma of Lundelius and Lynch, and not the cited asynchronous event-driven result (#7202): shifting hardware offsets to shiftOffsets c s and transit delays to shiftDelays δ s leaves every process's LocalView unchanged at every round r ≤ R.

@[simp]
theorem Cslib.Distributed.ClockSync.adj_shift_eq {P : Type u} {K : Type v} [AddCommGroup K] {R : ℕ} (π : LockstepProtocol P K R) (c : P → K) (δ : ℕ → P → P → K) (s : P → K) :
π.adj (shiftOffsets c s) (shiftDelays δ s) = π.adj c δ

A synchronous lockstep, drift-free R-round step towards Lundelius and Lynch, and not the cited asynchronous event-driven result (#7202): every deterministic R-round LockstepProtocol computes the exact same clock adjustment vector under (shiftOffsets c s, shiftDelays δ s) as under (c, δ).

@[simp]
theorem Cslib.Distributed.ClockSync.syncOffset_shift_eq {P : Type u} {K : Type v} [AddCommGroup K] {R : ℕ} (π : LockstepProtocol P K R) (c : P → K) (δ : ℕ → P → P → K) (s : P → K) (p : P) :
π.syncOffset (shiftOffsets c s) (shiftDelays δ s) p = π.syncOffset c δ p + s p

Under a real-time shift s, process p's synchronized offset in LockstepProtocol translates by + s p.

def Cslib.Distributed.ClockSync.estDiff {P : Type u} [DecidableEq P] {K : Type v} [Field K] (d_min d_max : K) (p : P) (recv : P → K) (q : P) :
K

Midpoint-delay estimator of c q - c p: given p's local arrival readings recv : P → K for messages broadcast at local reading 0, estimates 0 for q = p and (d_min + d_max) / 2 - recv q for q ≠ p.

theorem Cslib.Distributed.ClockSync.abs_add_estDiff_sub_le {P : Type u} [DecidableEq P] {K : Type v} [Field K] [LinearOrder K] [IsStrictOrderedRing K] {d_min d_max : K} (hd : d_min ≤ d_max) (c : P → K) (p q : P) (recv : P → K) {d : K} (hrecv : q ≠ p → recv q = d + c p - c q) (hd_min : q ≠ p → d_min ≤ d) (hd_max : q ≠ p → d ≤ d_max) :
|c p + estDiff d_min d_max p recv q - c q| ≤ (d_max - d_min) / 2

On drift-free clocks, adding p's hardware offset c p to estDiff d_min d_max p recv q approximates sender q's hardware offset c q within (d_max - d_min) / 2 whenever q ≠ p arrived with delay d ∈ [d_min, d_max].