Documentation

CslibFrontier.Computability.WordRAM.Realization.PrefixFrame

Framing allocated Word-RAM memory #

PreservesBelow and FrameOutsideRange describe the cells retained across memory states with nondecreasing allocation frontiers. HoldsIn combines a contiguous list representation with its allocation bound, so the same assertion supplies both safe addresses and their contents.

Allocation and update rules propagate these predicates through individual memory operations.

Monotone memory preservation and materialized list blocks #

s₁ extends s₀'s frontier monotonically while keeping every cell below F unchanged.

theorem Cslib.WordRAM.Realization.PreservesBelow.mono_bound {F₁ F₂ : ℕ} {s₀ s₁ : DataStructure.Memory.State} (h : PreservesBelow F₂ s₀ s₁) (hle : F₁ ≤ F₂) :
PreservesBelow F₁ s₀ s₁
theorem Cslib.WordRAM.Realization.PreservesBelow.trans {F : ℕ} {s₀ s₁ s₂ : DataStructure.Memory.State} (h₁ : PreservesBelow F s₀ s₁) (h₂ : PreservesBelow F s₁ s₂) :
PreservesBelow F s₀ s₂
theorem Cslib.WordRAM.Realization.preservesBelow_write {F a v : ℕ} {s : DataStructure.Memory.State} (hF : F ≤ a) (ha : a < s.frontier) :
PreservesBelow F s { mem := Function.update s.mem a v, frontier := s.frontier }
theorem Cslib.WordRAM.Realization.PreservesBelow.trans_frontier {F : ℕ} {s₀ s₁ s₂ : DataStructure.Memory.State} (h₁ : PreservesBelow F s₀ s₁) (h₂ : PreservesBelow s₁.frontier s₁ s₂) :
PreservesBelow F s₀ s₂

A step preserving all allocated cells of the intermediate state composes with a prefix frame from the original state.

xs is stored contiguously starting at base within s's allocated frontier.

theorem Cslib.WordRAM.Realization.HoldsIn.mono {base : ℕ} {xs : List ℕ} {F : ℕ} {s₀ s₁ : DataStructure.Memory.State} (h : HoldsIn base xs s₀) (hF : base + xs.length ≤ F) (hp : PreservesBelow F s₀ s₁) :
HoldsIn base xs s₁
theorem Cslib.WordRAM.Realization.HoldsIn.mono_frontier {base : ℕ} {xs : List ℕ} {s₀ s₁ : DataStructure.Memory.State} (h : HoldsIn base xs s₀) (hp : PreservesBelow s₀.frontier s₀ s₁) :
HoldsIn base xs s₁
theorem Cslib.WordRAM.Realization.HoldsIn.get {base : ℕ} {xs : List ℕ} {s : DataStructure.Memory.State} (h : HoldsIn base xs s) (i : ℕ) (hi : i < xs.length) :
s.mem (base + i) = xs[i]
theorem Cslib.WordRAM.Realization.HoldsIn.cons_iff {base a : ℕ} {xs : List ℕ} {s : DataStructure.Memory.State} :
HoldsIn base (a :: xs) s ↔ base + 1 + xs.length ≤ s.frontier ∧ s.mem base = a ∧ HoldsIn (base + 1) xs s
theorem Cslib.WordRAM.Realization.HoldsIn.cons {base x : ℕ} {xs : List ℕ} {s : DataStructure.Memory.State} (h : HoldsIn base (x :: xs) s) :
base < s.frontier ∧ s.mem base = x ∧ HoldsIn (base + 1) xs s

A nonempty represented list has a readable head cell and a represented tail.

theorem Cslib.WordRAM.Realization.HoldsIn.append_iff {base : ℕ} {xs ys : List ℕ} {s : DataStructure.Memory.State} :
HoldsIn base (xs ++ ys) s ↔ HoldsIn base xs s ∧ HoldsIn (base + xs.length) ys s
theorem Cslib.WordRAM.Realization.HoldsIn.drop {base : ℕ} {xs : List ℕ} {s : DataStructure.Memory.State} (h : HoldsIn base xs s) (k : ℕ) (hk : k ≤ xs.length) :
HoldsIn (base + k) (List.drop k xs) s
theorem Cslib.WordRAM.Realization.holdsIn_set {base idx v : ℕ} {xs : List ℕ} {s : DataStructure.Memory.State} (h : HoldsIn base xs s) :
HoldsIn base (xs.set idx v) { mem := Function.update s.mem (base + idx) v, frontier := s.frontier }
theorem Cslib.WordRAM.Realization.holdsIn_write_outside {base a v : ℕ} {xs : List ℕ} {s : DataStructure.Memory.State} (h : HoldsIn base xs s) (hout : a < base ∨ base + xs.length ≤ a) :
HoldsIn base xs { mem := Function.update s.mem a v, frontier := s.frontier }
theorem Cslib.WordRAM.Realization.holdsIn_append_one {base v : ℕ} {xs : List ℕ} {s : DataStructure.Memory.State} (h : HoldsIn base xs s) (hbound : base + xs.length + 1 ≤ s.frontier) :
HoldsIn base (xs ++ [v]) { mem := Function.update s.mem (base + xs.length) v, frontier := s.frontier }

Frames around a writable interval #

Memory framing invariant: s₁ extends s₀'s frontier and preserves every previously allocated address outside [lo, hi).

theorem Cslib.WordRAM.Realization.FrameOutsideRange.mono_range {lo₁ hi₁ lo₂ hi₂ : ℕ} {s₀ s₁ : DataStructure.Memory.State} (h : FrameOutsideRange lo₁ hi₁ s₀ s₁) (hlo : lo₂ ≤ lo₁) (hhi : hi₁ ≤ hi₂) :
FrameOutsideRange lo₂ hi₂ s₀ s₁
theorem Cslib.WordRAM.Realization.FrameOutsideRange.trans {lo hi : ℕ} {s₀ s₁ s₂ : DataStructure.Memory.State} (h₁ : FrameOutsideRange lo hi s₀ s₁) (h₂ : FrameOutsideRange lo hi s₁ s₂) :
FrameOutsideRange lo hi s₀ s₂
theorem Cslib.WordRAM.Realization.HoldsIn.frame_outsideRange {base lo hi : ℕ} {xs : List ℕ} {s₀ s₁ : DataStructure.Memory.State} (h : HoldsIn base xs s₀) (hdisj : base + xs.length ≤ lo ∨ hi ≤ base) (hf : FrameOutsideRange lo hi s₀ s₁) :
HoldsIn base xs s₁