Documentation

CslibFrontier.Computability.Distributed.SetAgreement.AtomicSnapshot.ScanLoopInv

Internal double-collect loop invariant #

Internal invariant ScanLoopInv and per-step preservation lemmas (readA, finishA, readB, restart) for active scan executions; never re-exported through AtomicSnapshot.

Main definitions #

Main results #

@[reducible, inline]

Whether local state ps belongs to an active operation with history index id.

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.active_opId_unique {P : Type u_1} {Data : Type u_2} {ps : ProcSnapshotState P Data} {id₁ id₂ : ℕ} (h₁ : HasActiveOpId ps id₁) (h₂ : HasActiveOpId ps id₂) :
id₁ = id₂

Uniqueness of active operation ID carried by ps.

def Cslib.Distributed.SetAgreement.SnapshotTrace.ScanLoopInv {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} (τ : SnapshotTrace ord dInit) (lo hi : ℕ) (st : ActiveScan P Data) :

Double-collect loop invariant for active scan st over trace window [lo, hi] (typically instantiated with lo = τ.lastIdleStep i hi).

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.ScanLoopInv.mono_hi {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} {τ : SnapshotTrace ord dInit} {lo hi hi' : ℕ} {st : ActiveScan P Data} (hle : hi ≤ hi') (h : τ.ScanLoopInv lo hi st) :
τ.ScanLoopInv lo hi' st

ScanLoopInv is monotone in its upper trace-step bound hi.

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.ScanLoopInv.readA {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} {τ : SnapshotTrace ord dInit} {lo t : ℕ} {st : ActiveScan P Data} {j : P} {rest : List P} (hph : st.phase = CollectPhase.collectA) (hrem : st.rem = j :: rest) (h : τ.ScanLoopInv lo t st) :
τ.ScanLoopInv lo (t + 1) { mode := st.mode, opId := st.opId, moved := st.moved, phase := CollectPhase.collectA, rem := rest, collectAVal := Function.update st.collectAVal j ((τ.stateAt t).reg j), collectBVal := st.collectBVal }

ScanLoopInv step: reading register j during collectA.

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.ScanLoopInv.finishA {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} {τ : SnapshotTrace ord dInit} {lo t : ℕ} {st : ActiveScan P Data} (hph : st.phase = CollectPhase.collectA) (hrem : st.rem = []) (h : τ.ScanLoopInv lo t st) :
τ.ScanLoopInv lo (t + 1) { mode := st.mode, opId := st.opId, moved := st.moved, phase := CollectPhase.collectB, rem := ord.elems, collectAVal := st.collectAVal, collectBVal := st.collectBVal }

ScanLoopInv step: transitioning from completed collectA (rem = []) to collectB.

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.ScanLoopInv.readB {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} {τ : SnapshotTrace ord dInit} {lo t : ℕ} {st : ActiveScan P Data} {j : P} {rest : List P} (hph : st.phase = CollectPhase.collectB) (hrem : st.rem = j :: rest) (h : τ.ScanLoopInv lo t st) :
τ.ScanLoopInv lo (t + 1) { mode := st.mode, opId := st.opId, moved := st.moved, phase := CollectPhase.collectB, rem := rest, collectAVal := st.collectAVal, collectBVal := Function.update st.collectBVal j ((τ.stateAt t).reg j) }

ScanLoopInv step: reading register j during collectB.

theorem Cslib.Distributed.SetAgreement.SnapshotTrace.ScanLoopInv.restart {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} {τ : SnapshotTrace ord dInit} {lo t : ℕ} (ht : t ≤ τ.events.length) {st : ActiveScan P Data} (hph : st.phase = CollectPhase.collectB) (hrem : st.rem = []) (h : τ.ScanLoopInv lo t st) :
τ.ScanLoopInv lo (t + 1) { mode := st.mode, opId := st.opId, moved := st.moved ∪ {k : P | (st.collectAVal k).seq ≠ (st.collectBVal k).seq}, phase := CollectPhase.collectA, rem := ord.elems, collectAVal := st.collectAVal, collectBVal := st.collectBVal }

ScanLoopInv step: adding all changed processes to moved and restarting collectA.