Documentation

CslibFrontier.Algorithms.WordRAM.OddCycleTransversal.Range

Range fill/copy routines, memory-readiness framing, and adjacency-matrix predicate #

This module certifies the low-level fillRange and copyRange Memory.Prog routines along with their frame, admissibility (MemReady), cost, and functional specs, plus the MatrixLoaded predicate linking encodeInput G k to linear memory.

Main definitions #

Main results #

Client reduction and frame helpers for Memory.Prog #

@[reducible, inline]

Graph dimension n encoded in a ((n, m), k) step-argument tuple.

@[reducible, inline]

Subgraph prefix size m encoded in a ((n, m), k) step-argument tuple.

@[reducible, inline]

Current loop index encoded in a (n, (idx, acc)) step-argument tuple.

@[reducible, inline]

Current accumulator or carry encoded in a (n, (idx, acc)) step-argument tuple.

theorem Cslib.Algorithms.WordRAM.OddCycleTransversal.preservesAt_iterate_fst {a : ℕ} {δ β : Type} {body : δ × ℕ × β → DataStructure.Memory.Prog (ℕ × β)} {d : δ} {m : ℕ} (b₀ : β) (hstep : ∀ i < m, ∀ (b : β), WordRAM.Realization.PreservesAt a (body (d, i, b)) ∧ ∀ (s : (DataStructure.Memory.spec 0).State), ((DataStructure.Memory.spec 0).clientResult s (body (d, i, b))).1 = i + 1) :

Frame lemma along an indexed iteration preserving the first state coordinate.

Array fill and copy helpers #

Fill len contiguous memory cells starting at base with val for d = ((base, val), len).

theorem Cslib.Algorithms.WordRAM.OddCycleTransversal.preservesAt_fillRange {a : ℕ} {d : (ℕ × ℕ) × ℕ} (hout : match d with | ((base, snd), len) => a < base ∨ base + len ≤ a) :

fillRange preserves addresses outside [base, base + len).

Copy len contiguous words from src to dst for d = ((src, dst), len).

Admissibility (ValidHistory) and memoryCost bounds #

@[reducible, inline]

Well-formed memory state with allocated workspace octWorkspace n.

theorem Cslib.Algorithms.WordRAM.OddCycleTransversal.memoryCost_boundedWhile_le_of {δ σ : Type} (guard : δ → σ → Prop) [(d : δ) → (a : σ) → Decidable (guard d a)] (body : δ × σ → DataStructure.Memory.Prog σ) (c : ℕ) (d : δ) (hstep : ∀ (a : σ) (s : DataStructure.Memory.State), guard d a → WordRAM.Realization.memoryCost (body (d, a)) s ≤ c) (m : ℕ) (a : σ) (s : DataStructure.Memory.State) :
theorem Cslib.Algorithms.WordRAM.OddCycleTransversal.validHistory_fillRange {w n : ℕ} {d : (ℕ × ℕ) × ℕ} {s : DataStructure.Memory.State} (hs : MemReady w n s) (hend : match d with | ((base, snd), len) => base + len ≤ octWorkspace n) (hval : match d, hend with | ((fst, val), snd), hend => WordRAM.Fits w val) :
theorem Cslib.Algorithms.WordRAM.OddCycleTransversal.validHistory_copyRange {w n : ℕ} {d : (ℕ × ℕ) × ℕ} {s : DataStructure.Memory.State} (hs : MemReady w n s) (hsrc : match d with | ((src, snd), len) => src + len ≤ octWorkspace n) (hdst : match d, hsrc with | ((fst, dst), len), hsrc => dst + len ≤ octWorkspace n) :
theorem Cslib.Algorithms.WordRAM.OddCycleTransversal.fillRange_spec (base val len : ℕ) (s : DataStructure.Memory.State) :
have s' := (DataStructure.Memory.spec 0).clientState s (fillRange ((base, val), len)); (∀ i < len, s'.mem (base + i) = val) ∧ ∀ (a : ℕ), a < base ∨ base + len ≤ a → s'.mem a = s.mem a
theorem Cslib.Algorithms.WordRAM.OddCycleTransversal.preservesAt_copyRange {a : ℕ} {d : (ℕ × ℕ) × ℕ} (hout : match d with | ((fst, dst), len) => a < dst ∨ dst + len ≤ a) :
theorem Cslib.Algorithms.WordRAM.OddCycleTransversal.copyRange_spec {srcB dstB len : ℕ} (hdisj : srcB + len ≤ dstB) (s : DataStructure.Memory.State) :
have s' := (DataStructure.Memory.spec 0).clientState s (copyRange ((srcB, dstB), len)); (∀ i < len, s'.mem (dstB + i) = s.mem (srcB + i)) ∧ ∀ (a : ℕ), a < dstB ∨ dstB + len ≤ a → s'.mem a = s.mem a

Invariant asserting that row-major adjacency matrix of G resides at memory offset 3.