Documentation

CslibFrontier.DataStructure.Dictionary.WordRAM.PackedSlice

Parametric view and frame lemmas for disjoint bit-packed slices #

Companion to BitPackedArray.lean giving reusable congruence and disjoint-region frame lemmas for bounded bit-packed array views fun i => if i < len then readPacked base k w mem i else 0, together with readPacked_writePacked_bounded in BitPackedArray.lean.

Keeping these theorems parameterized by (base, k, w, len) lets metadata layout files such as ResizableSuccinct.MetaSync collapse repeated write*_effect theorems into compact instantiations instead of repeating funext/split_ifs/writePacked_outside boilerplate.

Main definitions #

Main results #

A word-memory write whose effect is confined to the half-open interval [lo, hi).

  • eq_outside (a : ℕ) : ¬(lo ≤ a ∧ a < hi) → mem' a = mem a

    Every word outside [lo, hi) is preserved.

Two half-open word intervals [lo₁, hi₁) and [lo₂, hi₂) are disjoint.

theorem Cslib.DataStructure.Dictionary.WordRAM.BitPackedArray.DisjointIntervals.symm {lo₁ hi₁ lo₂ hi₂ : ℕ} (h : DisjointIntervals lo₁ hi₁ lo₂ hi₂) :
DisjointIntervals lo₂ hi₂ lo₁ hi₁

Symmetry of DisjointIntervals.

theorem Cslib.DataStructure.Dictionary.WordRAM.BitPackedArray.WriteOutside.eq_on_disjoint {lo hi lo' hi' : ℕ} {mem mem' : ℕ → ℕ} (h : WriteOutside lo hi mem mem') (hdisj : DisjointIntervals lo hi lo' hi') (a : ℕ) :
lo' ≤ a ∧ a < hi' → mem' a = mem a

A write confined to [lo, hi) agrees with the original memory across any disjoint interval [lo', hi').

theorem Cslib.DataStructure.Dictionary.WordRAM.BitPackedArray.writePacked_writeOutside {base len k w idx val lo hi : ℕ} (hw : 0 < w) (hidx : idx < len) (hlo : lo ≤ base) (hhi : base + packedWords len k w ≤ hi) (mem : ℕ → ℕ) :
WriteOutside lo hi mem (writePacked base k w mem idx val)

Writing at idx < len in a packed array at base is confined to any [lo, hi) containing [base, base + packedWords len k w).

theorem Cslib.DataStructure.Dictionary.WordRAM.BitPackedArray.packedView_congr {base k w len : ℕ} (hw : 0 < w) {mem₁ mem₂ : ℕ → ℕ} (h : ∀ (addr : ℕ), base ≤ addr ∧ addr < base + packedWords len k w → mem₁ addr = mem₂ addr) :
(fun (i : ℕ) => if i < len then readPacked base k w mem₁ i else 0) = fun (i : ℕ) => if i < len then readPacked base k w mem₂ i else 0

A bounded k-bit packed array view if i < len then readPacked base k w mem i else 0 depends only on the half-open word interval [base, base + packedWords len k w).

theorem Cslib.DataStructure.Dictionary.WordRAM.BitPackedArray.packedView_writePacked_disjoint {base₁ k₁ len₁ base₂ k₂ len₂ w idx val : ℕ} (hw : 0 < w) (hidx : idx < len₂) (hdisj : DisjointIntervals base₁ (base₁ + packedWords len₁ k₁ w) base₂ (base₂ + packedWords len₂ k₂ w)) (mem : ℕ → ℕ) :
(fun (i : ℕ) => if i < len₁ then readPacked base₁ k₁ w (writePacked base₂ k₂ w mem idx val) i else 0) = fun (i : ℕ) => if i < len₁ then readPacked base₁ k₁ w mem i else 0

Writing inside a packed slice disjoint from [base₁, base₁ + packedWords len₁ k₁ w) leaves the bounded view at base₁ unchanged.