Documentation

CslibFrontier.Computability.Distributed.SetAgreement.AtomicSnapshot.TraceWrites

Internal trace write-step monotonicity and last-idle-step helpers #

Internal trace predicates (isWriteStep, lastIdleStep) and register-sequence monotonicity lemmas shared across ScanLoopInv, TraceInv, TracePreservation, LinearizationChunks, and Linearizability; never re-exported through AtomicSnapshot.

Main definitions #

Main results #

def Cslib.Distributed.SetAgreement.SnapshotTrace.isWriteStep {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} (τ : SnapshotTrace ord dInit) (j : P) (t : ℕ) :

Predicate identifying when event t < τ.events.length is the atomic register write of update_j (proc j = .readyToWrite ... and events[t] = .step j).

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.reg_step_iff {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} (τ : SnapshotTrace ord dInit) (j : P) {t : ℕ} (ht : t < τ.events.length) :
(τ.stateAt (t + 1)).reg j = (τ.stateAt t).reg j ∧ ¬τ.isWriteStep j t ∨ ∃ (opId : ℕ) (val : Data) (snap : P → Data), τ.events[t] = SnapshotEvent.step j ∧ (τ.stateAt t).proc j = ProcSnapshotState.readyToWrite opId val snap ∧ (τ.stateAt (t + 1)).reg j = { data := val, seq := ((τ.stateAt t).reg j).seq + 1, view := snap } ∧ (τ.stateAt (t + 1)).proc j = ProcSnapshotState.idle

Single-step register change characterization: reg j changes at step t if and only if isWriteStep τ j t holds, in which case (reg j).seq increments by 1.

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.seq_mono_and_const_of_eq {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} (τ : SnapshotTrace ord dInit) (j : P) {t₁ t₂ : ℕ} (hle : t₁ ≤ t₂) (ht₂ : t₂ ≤ τ.events.length) :
((τ.stateAt t₁).reg j).seq ≤ ((τ.stateAt t₂).reg j).seq ∧ (((τ.stateAt t₁).reg j).seq = ((τ.stateAt t₂).reg j).seq → ∀ (v : ℕ), t₁ ≤ v → v ≤ t₂ → (τ.stateAt v).reg j = (τ.stateAt t₂).reg j)

Sequence numbers on reg j are monotone along any trace, and equal across [t₁, t₂] iff reg j is constant across [t₁, t₂].

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.exists_writeStep_of_seq_ne {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} (τ : SnapshotTrace ord dInit) (j : P) {t₁ t₂ : ℕ} (hle : t₁ ≤ t₂) (ht₂ : t₂ ≤ τ.events.length) (hne : ((τ.stateAt t₁).reg j).seq ≠ ((τ.stateAt t₂).reg j).seq) :
∃ (w : ℕ), t₁ ≤ w ∧ w < t₂ ∧ τ.isWriteStep j w

If ((τ.stateAt t₁).reg j).seq ≠ ((τ.stateAt t₂).reg j).seq for t₁ ≤ t₂ ≤ τ.events.length, then j executed an atomic register write isWriteStep τ j w at some step t₁ ≤ w < t₂.

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.exists_last_writeStep_of_seq_pos {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} (τ : SnapshotTrace ord dInit) (j : P) {t : ℕ} (ht : t ≤ τ.events.length) (hpos : 0 < ((τ.stateAt t).reg j).seq) :
∃ w < t, τ.isWriteStep j w ∧ (τ.stateAt t).reg j = (τ.stateAt (w + 1)).reg j ∧ ∀ (m : ℕ), w + 1 ≤ m → m < t → ¬τ.isWriteStep j m

If (τ.stateAt t).reg j has .seq > 0 (t ≤ τ.events.length), there is a most recent isWriteStep τ j w with w < t such that (τ.stateAt t).reg j = (τ.stateAt (w + 1)).reg j and no write by j occurred in [w + 1, t).

noncomputable def Cslib.Distributed.SetAgreement.SnapshotTrace.lastIdleStep {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} (τ : SnapshotTrace ord dInit) (i : P) (t : ℕ) :

Proof-only helper: the largest step index m ≤ t at which (τ.stateAt m).proc i = .idle (well-defined since m = 0 always has (τ.stateAt 0).proc i = .idle).

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.le_lastIdleStep_of_idle {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} (τ : SnapshotTrace ord dInit) (i : P) {m t : ℕ} (hle : m ≤ t) (hidle : (τ.stateAt m).proc i = ProcSnapshotState.idle) :
m ≤ τ.lastIdleStep i t

Monotonicity of lastIdleStep with respect to any earlier idle step m ≤ t.

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.lastIdleStep_eq_of_step_not_idle {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} (τ : SnapshotTrace ord dInit) (i : P) {t : ℕ} (hnot : (τ.stateAt (t + 1)).proc i ≠ ProcSnapshotState.idle) :
τ.lastIdleStep i (t + 1) = if ((τ.stateAt t).proc i).isIdle = true then t else τ.lastIdleStep i t

Recurrence for lastIdleStep i (t + 1) when proc i is non-idle at step t + 1.

theorem Cslib.Distributed.SetAgreement.getElem_completeHistoryAt_of_status_ne {P : Type u_1} {Data : Type u_2} {hist : List (SnapshotOpRecord P Data)} {opId k : ℕ} {newSt st : SnapshotOpStatus P Data} (hne : st ≠ newSt) (hk : k < (completeHistoryAt hist opId newSt).length) (hst : (completeHistoryAt hist opId newSt)[k].status = st) :
∃ (hk₀ : k < hist.length), (completeHistoryAt hist opId newSt)[k] = hist[k]

History entry lookup when its updated status differs from newSt.