Internal global trace invariant and per-actor frame lemma #
Defines the trace invariant TraceInv and its shared per-actor frame specialization
TraceInv.of_actor_step; never re-exported through AtomicSnapshot.
Main definitions #
Cslib.Distributed.SetAgreement.SnapshotTrace.TraceInv: global invariant overSnapshotTrace.
Main results #
Cslib.Distributed.SetAgreement.SnapshotTrace.lastIdleStep_keep,Cslib.Distributed.SetAgreement.SnapshotTrace.TraceInv.of_actor_step: idle-step invariance and per-actor transition frame lemma.
structure Cslib.Distributed.SetAgreement.SnapshotTrace.TraceInv {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} (τ : SnapshotTrace ord dInit) (t : ℕ) :
Combined trace invariant at step t ≤ τ.events.length powering Lemmas 3.1–3.3 and Theorem 1:
(τ.stateAt t).stepCount = t.- For every register
jwith((τ.stateAt t).reg j).seq > 0whose most recent write occurred atw < t, there exists a serialization statevwithτ.lastIdleStep j w + 1 ≤ v ≤ wsuch thatmemSnapshot (τ.stateAt v).reg = ((τ.stateAt t).reg j).view. - For every active process
i:- if
proc i = .readyToWrite opId val snap:opId < history.length,history[opId]is pendingupdate valbyiwithinvStep = τ.lastIdleStep i t < t, and there existsvwithinvStep + 1 ≤ v ≤ tandmemSnapshot (τ.stateAt v).reg = snap; - if
proc i = .scanning st:opId < history.length,history[opId]is pending (scanorupdate valmatchingst.mode) byiwithinvStep = τ.lastIdleStep i t < t, andScanLoopInv τ (τ.lastIdleStep i t) t stholds.
- if
- For every history index
id < history.lengthwith recordrec:- if
rec.status = .pending, thenproc rec.calleris active withopId = idandrec.invStep = τ.lastIdleStep rec.caller t < t; - if
rec.status = .doneScan resp snap, thenrec.kind = .scan,rec.invStep < resp < t, and there existsvwithrec.invStep + 1 ≤ v ≤ respandmemSnapshot (τ.stateAt v).reg = snap; - if
rec.status = .doneUpdate resp, thenrec.kind = .update val(for someval),rec.invStep < resp < t,τ.isWriteStep rec.caller resp, and((τ.stateAt (resp + 1)).reg rec.caller).data = val; - conversely, EVERY
isWriteStep τ j wwithw < thas a uniqueid < history.lengthwithcaller = jandstatus = .doneUpdate w.
- if
- proc_ready (i : P) (opId : ℕ) (val : Data) (snap : P → Data) : (τ.stateAt t).proc i = ProcSnapshotState.readyToWrite opId val snap → ∃ (hId : opId < (τ.stateAt t).history.length), (τ.stateAt t).history[opId] = { caller := i, kind := SnapshotOpKind.update val, invStep := τ.lastIdleStep i t, status := SnapshotOpStatus.pending } ∧ τ.lastIdleStep i t < t ∧ ∃ (v : ℕ), τ.lastIdleStep i t + 1 ≤ v ∧ v ≤ t ∧ memSnapshot (τ.stateAt v).reg = snap
- proc_scan (i : P) (st : ActiveScan P Data) : (τ.stateAt t).proc i = ProcSnapshotState.scanning st → ∃ (hId : st.opId < (τ.stateAt t).history.length), (τ.stateAt t).history[st.opId] = { caller := i, kind := match st.mode with | ScanMode.external => SnapshotOpKind.scan | ScanMode.embedded val => SnapshotOpKind.update val, invStep := τ.lastIdleStep i t, status := SnapshotOpStatus.pending } ∧ τ.lastIdleStep i t < t ∧ τ.ScanLoopInv (τ.lastIdleStep i t) t st
- hist_pending (id : ℕ) (hId : id < (τ.stateAt t).history.length) : (τ.stateAt t).history[id].status = SnapshotOpStatus.pending → (τ.stateAt t).history[id].invStep = τ.lastIdleStep (τ.stateAt t).history[id].caller t ∧ (τ.stateAt t).history[id].invStep < t ∧ HasActiveOpId ((τ.stateAt t).proc (τ.stateAt t).history[id].caller) id
- hist_doneScan (id : ℕ) (hId : id < (τ.stateAt t).history.length) (resp : ℕ) (snap : P → Data) : (τ.stateAt t).history[id].status = SnapshotOpStatus.doneScan resp snap → (τ.stateAt t).history[id].kind = SnapshotOpKind.scan ∧ (τ.stateAt t).history[id].invStep < resp ∧ resp < t ∧ ∃ (v : ℕ), (τ.stateAt t).history[id].invStep + 1 ≤ v ∧ v ≤ resp ∧ memSnapshot (τ.stateAt v).reg = snap
- hist_doneUpdate (id : ℕ) (hId : id < (τ.stateAt t).history.length) (resp : ℕ) : (τ.stateAt t).history[id].status = SnapshotOpStatus.doneUpdate resp → ∃ (val : Data), (τ.stateAt t).history[id].kind = SnapshotOpKind.update val ∧ (τ.stateAt t).history[id].invStep < resp ∧ resp < t ∧ τ.isWriteStep (τ.stateAt t).history[id].caller resp ∧ (τ.stateAt (resp + 1)).reg (τ.stateAt t).history[id].caller = { data := val, seq := ((τ.stateAt resp).reg (τ.stateAt t).history[id].caller).seq + 1, view := ((τ.stateAt (resp + 1)).reg (τ.stateAt t).history[id].caller).view }
theorem Cslib.Distributed.SetAgreement.SnapshotTrace.lastIdleStep_keep {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} (τ : SnapshotTrace ord dInit) (i : P) {t : ℕ} (h0 : (τ.stateAt t).proc i ≠ ProcSnapshotState.idle) (h1 : (τ.stateAt (t + 1)).proc i ≠ ProcSnapshotState.idle) :
If proc i stays non-idle across t → t + 1, lastIdleStep i is unchanged.
theorem Cslib.Distributed.SetAgreement.SnapshotTrace.TraceInv.of_actor_step {P : Type u_1} {Data : Type u_2} [Fintype P] [DecidableEq P] {ord : ScanOrder P} {dInit : Data} {τ : SnapshotTrace ord dInit} {t : ℕ} (inv : τ.TraceInv t) (i : P) (modId : ℕ) (hstepCount : (τ.stateAt (t + 1)).stepCount = t + 1) (hproc_other : ∀ (p : P), p ≠ i → (τ.stateAt (t + 1)).proc p = (τ.stateAt t).proc p) (hhist_len : (τ.stateAt t).history.length ≤ (τ.stateAt (t + 1)).history.length) (hbound_unchanged : ∀ id < (τ.stateAt (t + 1)).history.length, id ≠ modId → id < (τ.stateAt t).history.length) (hhist_unchanged :
∀ (id : ℕ) (h₁ : id < (τ.stateAt (t + 1)).history.length) (h₀ : id < (τ.stateAt t).history.length),
id ≠ modId → (τ.stateAt (t + 1)).history[id] = (τ.stateAt t).history[id]) (hmod_old :
∀ (h₀ : modId < (τ.stateAt t).history.length),
(τ.stateAt t).history[modId].caller = i ∧ (τ.stateAt t).history[modId].status = SnapshotOpStatus.pending) (hreg_t :
∀ (j : P),
τ.isWriteStep j t →
∃ (v : ℕ), τ.lastIdleStep j t + 1 ≤ v ∧ v ≤ t ∧ memSnapshot (τ.stateAt v).reg = ((τ.stateAt (t + 1)).reg j).view) (hready_i :
∀ (opId : ℕ) (val : Data) (snap : P → Data),
(τ.stateAt (t + 1)).proc i = ProcSnapshotState.readyToWrite opId val snap →
∃ (hId : opId < (τ.stateAt (t + 1)).history.length),
(τ.stateAt (t + 1)).history[opId] = { caller := i, kind := SnapshotOpKind.update val, invStep := τ.lastIdleStep i (t + 1),
status := SnapshotOpStatus.pending } ∧ τ.lastIdleStep i (t + 1) < t + 1 ∧ ∃ (v : ℕ), τ.lastIdleStep i (t + 1) + 1 ≤ v ∧ v ≤ t + 1 ∧ memSnapshot (τ.stateAt v).reg = snap) (hscan_i :
∀ (st : ActiveScan P Data),
(τ.stateAt (t + 1)).proc i = ProcSnapshotState.scanning st →
∃ (hId : st.opId < (τ.stateAt (t + 1)).history.length),
(τ.stateAt (t + 1)).history[st.opId] = { caller := i,
kind :=
match st.mode with
| ScanMode.external => SnapshotOpKind.scan
| ScanMode.embedded val => SnapshotOpKind.update val,
invStep := τ.lastIdleStep i (t + 1), status := SnapshotOpStatus.pending } ∧ τ.lastIdleStep i (t + 1) < t + 1 ∧ τ.ScanLoopInv (τ.lastIdleStep i (t + 1)) (t + 1) st) (hpending_i :
∀ (id : ℕ) (hId : id < (τ.stateAt (t + 1)).history.length),
id = modId ∨ (τ.stateAt (t + 1)).history[id].caller = i →
(τ.stateAt (t + 1)).history[id].status = SnapshotOpStatus.pending →
(τ.stateAt (t + 1)).history[id].invStep = τ.lastIdleStep (τ.stateAt (t + 1)).history[id].caller (t + 1) ∧ (τ.stateAt (t + 1)).history[id].invStep < t + 1 ∧ HasActiveOpId ((τ.stateAt (t + 1)).proc (τ.stateAt (t + 1)).history[id].caller) id) (hdoneScan_mod :
∀ (hId : modId < (τ.stateAt (t + 1)).history.length) (resp : ℕ) (snap : P → Data),
(τ.stateAt (t + 1)).history[modId].status = SnapshotOpStatus.doneScan resp snap →
(τ.stateAt (t + 1)).history[modId].kind = SnapshotOpKind.scan ∧ (τ.stateAt (t + 1)).history[modId].invStep < resp ∧ resp < t + 1 ∧ ∃ (v : ℕ),
(τ.stateAt (t + 1)).history[modId].invStep + 1 ≤ v ∧ v ≤ resp ∧ memSnapshot (τ.stateAt v).reg = snap) (hdoneUpdate_mod :
∀ (hId : modId < (τ.stateAt (t + 1)).history.length) (resp : ℕ),
(τ.stateAt (t + 1)).history[modId].status = SnapshotOpStatus.doneUpdate resp →
∃ (val : Data),
(τ.stateAt (t + 1)).history[modId].kind = SnapshotOpKind.update val ∧ (τ.stateAt (t + 1)).history[modId].invStep < resp ∧ resp < t + 1 ∧ τ.isWriteStep (τ.stateAt (t + 1)).history[modId].caller resp ∧ (τ.stateAt (resp + 1)).reg (τ.stateAt (t + 1)).history[modId].caller = { data := val, seq := ((τ.stateAt resp).reg (τ.stateAt (t + 1)).history[modId].caller).seq + 1,
view := ((τ.stateAt (resp + 1)).reg (τ.stateAt (t + 1)).history[modId].caller).view }) (hwrite_t :
∀ (j : P),
τ.isWriteStep j t →
∃ (id : ℕ) (hId : id < (τ.stateAt (t + 1)).history.length),
(τ.stateAt (t + 1)).history[id].caller = j ∧ (τ.stateAt (t + 1)).history[id].status = SnapshotOpStatus.doneUpdate t) :
Per-actor frame lemma for TraceInv: given TraceInv τ t, if actor i transitions from t
to t + 1 leaving every other process p ≠ i unchanged and modifying history at most at a
single index modId (either modId = history.length for an append/no-op, or an existing pending
entry of i), then all frame obligations for p ≠ i, id ≠ modId, and w < t follow
automatically from TraceInv τ t.