Documentation

CslibFrontier.DataStructure.Memory.TripleFrame

Framed correctness-and-cost triples and block framing over memory #

This module extends Cslib.DataStructure.Memory.Triple with non-overlapping block copy (Triple.copy), introduces the explicit modification-set framing predicate Memory.Modifies, packages framed triples as FramedTriple with generic heap-frame preservation (FramedTriple.frame, FramedTriple.frame_mem, FramedTriple.mem_eq_of_frontier_eq), and provides Cslib.WordRAM.Block disjointness, strided slot framing (Block.slot), and consecutive list-write initialization (Block.writeList).

Main definitions #

Main results #

Non-overlapping copy triple #

theorem Cslib.DataStructure.Memory.Triple.copy {w : ℕ} {s : State} {src dst n : ℕ} (hdisj : src + n ≤ dst ∨ dst + n ≤ src) (hsrc : src + n ≤ s.frontier) (hdst : dst + n ≤ s.frontier) (hfit : ∀ i < n, WordRAM.Fits w (s.mem (src + i))) {Q : Unit → State → Prop} (hQ : Q () { mem := WordRAM.ArrayCopy.copyPrefix s.mem src dst n, frontier := s.frontier }) :
Triple w s (Memory.copy src dst n) (2 * n) Q

Non-overlapping block copy triple: copies n words at cost 2 * n.

Modification-set framing predicate #

Transition from s to s' preserves the frontier's monotonicity and leaves all cells below s.frontier outside S unchanged.

theorem Cslib.DataStructure.Memory.Modifies.trans {S : Set ℕ} {s₁ s₂ s₃ : State} (h₁ : Memory.Modifies S s₁ s₂) (h₂ : Memory.Modifies S s₂ s₃) :
Memory.Modifies S s₁ s₃

Transitivity of Memory.Modifies over a fixed set S.

theorem Cslib.DataStructure.Memory.Modifies.union {S₁ S₂ : Set ℕ} {s₁ s₂ s₃ : State} (h₁ : Memory.Modifies S₁ s₁ s₂) (h₂ : Memory.Modifies S₂ s₂ s₃) :
Memory.Modifies (S₁ ∪ S₂) s₁ s₃

Sequential composition of Memory.Modifies across different sets takes their union.

theorem Cslib.DataStructure.Memory.Modifies.mono {S₁ S₂ : Set ℕ} {s s' : State} (hsub : S₁ ⊆ S₂) (h : Memory.Modifies S₁ s s') :
Memory.Modifies S₂ s s'

Enlarging the permitted modification set weakens Memory.Modifies.

theorem Cslib.DataStructure.Memory.Modifies.write (s : State) (a v : ℕ) :
Memory.Modifies {a} s { mem := Function.update s.mem a v, frontier := s.frontier }

Writing cell a modifies at most {a}.

theorem Cslib.DataStructure.Memory.Modifies.set (s : State) (b : WordRAM.Block) {i : ℕ} (hi : i < b.length) (v : ℕ) :
Memory.Modifies (Set.Ico b.base (b.base + b.length)) s { mem := Function.update s.mem (b.base + i) v, frontier := s.frontier }

Writing entry i < b.length of b modifies at most Set.Ico b.base (b.base + b.length).

Zeroed allocation modifies no cell below the old frontier.

theorem Cslib.DataStructure.Memory.Modifies.allocDirty (s : State) (k : ℕ) :
Memory.Modifies ∅ s { mem := s.mem, frontier := s.frontier + k }

Dirty allocation modifies no cell below the old frontier.

theorem Cslib.DataStructure.Memory.Modifies.mem_eq_of_not_mem {S : Set ℕ} {s s' : State} (h : Memory.Modifies S s s') {a : ℕ} (ha : a < s.frontier) (haS : a ∉ S) :
s'.mem a = s.mem a

An allocated cell outside S retains its value.

theorem Cslib.DataStructure.Memory.Modifies.mem_eq_of_disjoint {S D : Set ℕ} {s s' : State} (h : Memory.Modifies S s s') (hdisj : Disjoint S D) {a : ℕ} (ha : a < s.frontier) (haD : a ∈ D) :
s'.mem a = s.mem a

Every allocated cell in a region D disjoint from S retains its value.

Framed triples #

@[reducible, inline]
abbrev Cslib.DataStructure.Memory.FramedTriple {α : Type} (w : ℕ) (s : State) (p : Prog α) (c : ℕ) (S : Set ℕ) (Q : α → State → Prop) :

A Triple bundled with Memory.Modifies S s s' for automatic frame preservation.

theorem Cslib.DataStructure.Memory.framedTriple_iff {w : ℕ} {α : Type} {s : State} {p : Prog α} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} :

Unfold FramedTriple along the unique run of p.

theorem Cslib.DataStructure.Memory.FramedTriple.triple {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {p : Prog α} (h : FramedTriple w s p c S Q) :
Triple w s p c Q

Extract the underlying Triple (forgetting framing).

theorem Cslib.DataStructure.Memory.FramedTriple.validHistory {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {p : Prog α} (h : FramedTriple w s p c S Q) :

Extract admissibility of the run.

theorem Cslib.DataStructure.Memory.FramedTriple.cost_le {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {p : Prog α} (h : FramedTriple w s p c S Q) :

Extract the cost bound.

theorem Cslib.DataStructure.Memory.FramedTriple.frontier_le {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {p : Prog α} (h : FramedTriple w s p c S Q) :

Extract frontier monotonicity.

theorem Cslib.DataStructure.Memory.FramedTriple.modifies {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {p : Prog α} (h : FramedTriple w s p c S Q) :

Extract the Memory.Modifies frame guarantee.

theorem Cslib.DataStructure.Memory.FramedTriple.post {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {p : Prog α} (h : FramedTriple w s p c S Q) :
Q ((spec w).clientResult s p) ((spec w).clientState s p)

Extract the postcondition.

theorem Cslib.DataStructure.Memory.FramedTriple.mem_eq_of_frontier_eq {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {p : Prog α} (h : FramedTriple w s p c S Q) (hfr : ((spec w).clientState s p).frontier = s.frontier) (a : ℕ) :
a ∉ S → ((spec w).clientState s p).mem a = s.mem a

If a framed run does not advance the frontier, every cell outside S retains its initial value, including cells at or above s.frontier.

theorem Cslib.DataStructure.Memory.FramedTriple.mono {w : ℕ} {α : Type} {s : State} {c c' : ℕ} {S : Set ℕ} {Q Q' : α → State → Prop} {p : Prog α} (h : FramedTriple w s p c S Q) (hc : c ≤ c') (hQ : ∀ (a : α) (s' : State), Q a s' → Q' a s') :
FramedTriple w s p c' S Q'

Weaken the cost bound and postcondition.

theorem Cslib.DataStructure.Memory.FramedTriple.frame_mono {w : ℕ} {α : Type} {s : State} {c : ℕ} {S S' : Set ℕ} {Q : α → State → Prop} {p : Prog α} (h : FramedTriple w s p c S Q) (hsub : S ⊆ S') :
FramedTriple w s p c S' Q

Enlarge the permitted modification set.

theorem Cslib.DataStructure.Memory.FramedTriple.pure {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {a : α} (h : Q a s) :
FramedTriple w s (Pure.pure a) c S Q

Returning a value costs nothing and modifies nothing.

theorem Cslib.DataStructure.Memory.FramedTriple.read_bind {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {a : ℕ} {k : ℕ → Prog α} (ha : a < s.frontier) (h : FramedTriple w s (k (s.mem a)) c S Q) :
FramedTriple w s (Memory.read a >>= k) (c + 1) S Q

Read an allocated cell, then continue.

theorem Cslib.DataStructure.Memory.FramedTriple.read {w : ℕ} {s : State} {S : Set ℕ} {Q : ℕ → State → Prop} {a : ℕ} (ha : a < s.frontier) (h : Q (s.mem a) s) :

Read an allocated cell as a standalone framed program.

theorem Cslib.DataStructure.Memory.FramedTriple.write_bind {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {a v : ℕ} {k : Unit → Prog α} (ha : a < s.frontier) (hv : WordRAM.Fits w v) (h : FramedTriple w { mem := Function.update s.mem a v, frontier := s.frontier } (k ()) c S Q) :
FramedTriple w s (Memory.write a v >>= k) (c + 1) (insert a S) Q

Write a word to an allocated cell and continue, adding {a} to the modified set.

theorem Cslib.DataStructure.Memory.FramedTriple.write_bind_of_mem {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {a v : ℕ} {k : Unit → Prog α} (ha : a < s.frontier) (hv : WordRAM.Fits w v) (haS : a ∈ S) (h : FramedTriple w { mem := Function.update s.mem a v, frontier := s.frontier } (k ()) c S Q) :
FramedTriple w s (Memory.write a v >>= k) (c + 1) S Q

Write a word to an allocated cell already inside S, then continue.

theorem Cslib.DataStructure.Memory.FramedTriple.write {w : ℕ} {s : State} {S : Set ℕ} {Q : Unit → State → Prop} {a v : ℕ} (ha : a < s.frontier) (hv : WordRAM.Fits w v) (haS : a ∈ S) (h : Q () { mem := Function.update s.mem a v, frontier := s.frontier }) :
FramedTriple w s (Memory.write a v) 1 S Q

Write a word to an allocated cell as a standalone framed program.

theorem Cslib.DataStructure.Memory.FramedTriple.alloc_bind {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {k : ℕ} {next : ℕ → Prog α} (hk : WordRAM.Fits w (s.frontier + k)) (h : FramedTriple w { mem := WordRAM.clear s.mem s.frontier k, frontier := s.frontier + k } (next s.frontier) c S Q) :
FramedTriple w s (alloc k >>= next) (c + (k + 1)) S Q

Allocate k zeroed cells at the frontier, then continue.

theorem Cslib.DataStructure.Memory.FramedTriple.allocDirty_bind {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {k : ℕ} {next : ℕ → Prog α} (hk : WordRAM.Fits w (s.frontier + k)) (h : FramedTriple w { mem := s.mem, frontier := s.frontier + k } (next s.frontier) c S Q) :
FramedTriple w s (allocDirty k >>= next) (c + 1) S Q

Allocate k dirty cells at the frontier, then continue.

theorem Cslib.DataStructure.Memory.FramedTriple.allocBlock_bind {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {k : ℕ} {next : WordRAM.Block → Prog α} (hk : WordRAM.Fits w (s.frontier + k)) (h : FramedTriple w { mem := WordRAM.clear s.mem s.frontier k, frontier := s.frontier + k } (next { base := s.frontier, length := k }) c S Q) :
FramedTriple w s (allocBlock k >>= next) (c + (k + 1)) S Q

Allocate a zeroed block of k cells, then continue with the block handle.

theorem Cslib.DataStructure.Memory.FramedTriple.allocBlockDirty_bind {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {k : ℕ} {next : WordRAM.Block → Prog α} (hk : WordRAM.Fits w (s.frontier + k)) (h : FramedTriple w { mem := s.mem, frontier := s.frontier + k } (next { base := s.frontier, length := k }) c S Q) :
FramedTriple w s (allocBlockDirty k >>= next) (c + 1) S Q

Allocate a dirty block of k cells, then continue with the block handle.

theorem Cslib.DataStructure.Memory.FramedTriple.get_bind {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {b : WordRAM.Block} {i : ℕ} {k : ℕ → Prog α} (hb : b.Allocated s) (hi : i < b.length) (h : FramedTriple w s (k (s.mem (b.base + i))) c S Q) :
FramedTriple w s (b.get i >>= k) (c + 1) S Q

Read entry i of an allocated block, then continue.

theorem Cslib.DataStructure.Memory.FramedTriple.get {w : ℕ} {s : State} {S : Set ℕ} {Q : ℕ → State → Prop} {b : WordRAM.Block} {i : ℕ} (hb : b.Allocated s) (hi : i < b.length) (h : Q (s.mem (b.base + i)) s) :
FramedTriple w s (b.get i) 1 S Q

Read entry i of an allocated block as a standalone framed program.

theorem Cslib.DataStructure.Memory.FramedTriple.set_bind {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {b : WordRAM.Block} {i v : ℕ} {k : Unit → Prog α} (hb : b.Allocated s) (hi : i < b.length) (hv : WordRAM.Fits w v) (hsub : Set.Ico b.base (b.base + b.length) ⊆ S) (h : FramedTriple w { mem := Function.update s.mem (b.base + i) v, frontier := s.frontier } (k ()) c S Q) :
FramedTriple w s (b.set i v >>= k) (c + 1) S Q

Write v to entry i of an allocated block inside S, then continue.

theorem Cslib.DataStructure.Memory.FramedTriple.set {w : ℕ} {s : State} {S : Set ℕ} {Q : Unit → State → Prop} {b : WordRAM.Block} {i v : ℕ} (hb : b.Allocated s) (hi : i < b.length) (hv : WordRAM.Fits w v) (hsub : Set.Ico b.base (b.base + b.length) ⊆ S) (h : Q () { mem := Function.update s.mem (b.base + i) v, frontier := s.frontier }) :
FramedTriple w s (b.set i v) 1 S Q

Write v to entry i of an allocated block as a standalone framed program.

theorem Cslib.DataStructure.Memory.FramedTriple.bind {w : ℕ} {α β : Type} {s : State} {p : Prog α} {k : α → Prog β} {c₁ c₂ : ℕ} {S₁ S₂ : Set ℕ} {Q : β → State → Prop} (h : FramedTriple w s p c₁ S₁ fun (a : α) (s' : State) => FramedTriple w s' (k a) c₂ S₂ Q) :
FramedTriple w s (p >>= k) (c₁ + c₂) (S₁ ∪ S₂) Q

Sequential composition of framed triples takes the union of modification sets.

theorem Cslib.DataStructure.Memory.FramedTriple.bind_same {w : ℕ} {α β : Type} {s : State} {S : Set ℕ} {p : Prog α} {k : α → Prog β} {c₁ c₂ : ℕ} {Q : β → State → Prop} (h : FramedTriple w s p c₁ S fun (a : α) (s' : State) => FramedTriple w s' (k a) c₂ S Q) :
FramedTriple w s (p >>= k) (c₁ + c₂) S Q

Sequential composition of framed triples within a single shared modification set S.

theorem Cslib.DataStructure.Memory.FramedTriple.ite {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {cond : Prop} [Decidable cond] {p₁ p₂ : Prog α} (h₁ : cond → FramedTriple w s p₁ c S Q) (h₂ : ¬cond → FramedTriple w s p₂ c S Q) :
FramedTriple w s (if cond then p₁ else p₂) c S Q

Branching rule for FramedTriple.

theorem Cslib.DataStructure.Memory.FramedTriple.dite {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {cond : Prop} [Decidable cond] {p₁ : cond → Prog α} {p₂ : ¬cond → Prog α} (h₁ : ∀ (h : cond), FramedTriple w s (p₁ h) c S Q) (h₂ : ∀ (h : ¬cond), FramedTriple w s (p₂ h) c S Q) :
FramedTriple w s (if h : cond then p₁ h else p₂ h) c S Q

Dependent branching rule for FramedTriple.

theorem Cslib.DataStructure.Memory.FramedTriple.map {w : ℕ} {α β : Type} {s : State} {c : ℕ} {S : Set ℕ} (f : α → β) {p : Prog α} {Q : β → State → Prop} (h : FramedTriple w s p c S fun (a : α) (s' : State) => Q (f a) s') :
FramedTriple w s (f <$> p) c S Q

Map the answer of a FramedTriple without changing its cost or frame.

theorem Cslib.DataStructure.Memory.FramedTriple.copy {w : ℕ} {s : State} {src dst n : ℕ} (hdisj : src + n ≤ dst ∨ dst + n ≤ src) (hsrc : src + n ≤ s.frontier) (hdst : dst + n ≤ s.frontier) (hfit : ∀ i < n, WordRAM.Fits w (s.mem (src + i))) {Q : Unit → State → Prop} (hQ : Q () { mem := WordRAM.ArrayCopy.copyPrefix s.mem src dst n, frontier := s.frontier }) :
FramedTriple w s (Memory.copy src dst n) (2 * n) (Set.Ico dst (dst + n)) Q

Non-overlapping block copy with FramedTriple specification.

theorem Cslib.DataStructure.Memory.FramedTriple.wellFormed {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {p : Prog α} (hwf : WellFormed w s) (h : FramedTriple w s p c S Q) :
FramedTriple w s p c S fun (a : α) (s' : State) => Q a s' ∧ WellFormed w s'

Any FramedTriple preserves WellFormed w.

theorem Cslib.DataStructure.Memory.FramedTriple.zeroAbove {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {p : Prog α} (hz : ZeroAbove s) (h : FramedTriple w s p c S Q) :
FramedTriple w s p c S fun (a : α) (s' : State) => Q a s' ∧ ZeroAbove s'

Any FramedTriple preserves ZeroAbove.

theorem Cslib.DataStructure.Memory.FramedTriple.frame_mem {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {p : Prog α} {D : Set ℕ} {R : (ℕ → ℕ) → Prop} (h : FramedTriple w s p c S Q) (hR : R s.mem) (hdep : ∀ (m₁ m₂ : ℕ → ℕ), (∀ a ∈ D, m₁ a = m₂ a) → R m₁ → R m₂) (hdisj : Disjoint S D) (halloc : ∀ a ∈ D, a < s.frontier) :
FramedTriple w s p c S fun (a : α) (s' : State) => Q a s' ∧ R s'.mem

Automatic preservation of any raw-memory heap predicate R supported on allocated cells D disjoint from S.

theorem Cslib.DataStructure.Memory.FramedTriple.frame {w : ℕ} {α : Type} {s : State} {c : ℕ} {S : Set ℕ} {Q : α → State → Prop} {p : Prog α} {D : Set ℕ} {R : State → Prop} (h : FramedTriple w s p c S Q) (hR : R s) (hdep : ∀ (s₁ s₂ : State), (∀ a ∈ D, s₁.mem a = s₂.mem a) → R s₁ → R s₂) (hdisj : Disjoint S D) (halloc : ∀ a ∈ D, a < s.frontier) :
FramedTriple w s p c S fun (a : α) (s' : State) => Q a s' ∧ R s'

Automatic preservation of any frontier-invariant state predicate R supported on allocated cells D disjoint from S.

Block disjointness, strided slots, and multi-field writes #

Two blocks are disjoint when no address is owned by both.

Instances For
    theorem Cslib.WordRAM.Block.disjoint_iff {b₁ b₂ : Block} :
    b₁.Disjoint b₂ ↔ b₁.length = 0 ∨ b₂.length = 0 ∨ b₁.base + b₁.length ≤ b₂.base ∨ b₂.base + b₂.length ≤ b₁.base

    Characterization of block disjointness by emptiness or non-overlapping endpoints.

    @[instance_reducible]
    theorem Cslib.WordRAM.Block.Disjoint.symm {b₁ b₂ : Block} (h : b₁.Disjoint b₂) :
    b₂.Disjoint b₁

    Symmetry of block disjointness.

    theorem Cslib.WordRAM.Block.disjoint_of_le_left {b₁ b₂ : Block} (h : b₁.base + b₁.length ≤ b₂.base) :
    b₁.Disjoint b₂

    b₁ ending at or before b₂.base implies b₁.Disjoint b₂.

    theorem Cslib.WordRAM.Block.disjoint_of_le_right {b₁ b₂ : Block} (h : b₂.base + b₂.length ≤ b₁.base) :
    b₁.Disjoint b₂

    b₂ ending at or before b₁.base implies b₁.Disjoint b₂.

    An allocated block is disjoint from any block allocated at the current frontier.

    theorem Cslib.WordRAM.Block.disjoint_ico_iff {b₁ b₂ : Block} :
    _root_.Disjoint (Set.Ico b₁.base (b₁.base + b₁.length)) (Set.Ico b₂.base (b₂.base + b₂.length)) ↔ b₁.Disjoint b₂

    Block disjointness matches Set disjointness of half-open address intervals.

    Block disjointness matches Finset disjointness of Block.footprint.

    An allocated block stays allocated under Memory.Modifies.

    theorem Cslib.WordRAM.Block.mem_eq_of_modifies_disjoint {b : Block} {S : Set ℕ} {s s' : DataStructure.Memory.State} (hb : b.Allocated s) (hmod : DataStructure.Memory.Modifies S s s') (hdisj : _root_.Disjoint S (Set.Ico b.base (b.base + b.length))) (a : ℕ) :
    b.Owns a → s'.mem a = s.mem a

    An allocated block disjoint from S retains every cell across Memory.Modifies S s s'.

    An allocated block disjoint from S keeps its entries list unchanged across Memory.Modifies S s s'.

    theorem Cslib.WordRAM.Block.holdsList_of_modifies_disjoint {base : ℕ} {xs : List ℕ} {S : Set ℕ} {s s' : DataStructure.Memory.State} (hb : { base := base, length := xs.length }.Allocated s) (hh : HoldsList base xs s.mem) (hmod : DataStructure.Memory.Modifies S s s') (hdisj : _root_.Disjoint S (Set.Ico base (base + xs.length))) :
    HoldsList base xs s'.mem

    A HoldsList assertion on an allocated block disjoint from S survives Memory.Modifies S s s'.

    theorem Cslib.WordRAM.Block.mem_eq_of_modifies_block {b b' : Block} {s s' : DataStructure.Memory.State} (hb : b.Allocated s) (hd : b.Disjoint b') (hmod : DataStructure.Memory.Modifies (Set.Ico b'.base (b'.base + b'.length)) s s') (a : ℕ) :
    b.Owns a → s'.mem a = s.mem a

    Specialized block framing: writing inside a disjoint block b' preserves b.mem.

    theorem Cslib.WordRAM.Block.entries_eq_of_modifies_block {b b' : Block} {n : ℕ} {s s' : DataStructure.Memory.State} (hb : b.Allocated s) (hn : n ≤ b.length) (hd : b.Disjoint b') (hmod : DataStructure.Memory.Modifies (Set.Ico b'.base (b'.base + b'.length)) s s') :
    b.entries n s'.mem = b.entries n s.mem

    Specialized block framing: writing inside a disjoint block b' preserves b.entries.

    Strided record-array framing #

    def Cslib.WordRAM.Block.slot (base stride idx : ℕ) :

    The idx-th record slot of stride stride starting at base.

    @[simp]
    theorem Cslib.WordRAM.Block.slot_base (base stride idx : ℕ) :
    (slot base stride idx).base = base + stride * idx
    @[simp]
    theorem Cslib.WordRAM.Block.slot_length (base stride idx : ℕ) :
    (slot base stride idx).length = stride
    theorem Cslib.WordRAM.Block.slot_disjoint_of_ne {base stride i j : ℕ} (hne : i ≠ j) :
    (slot base stride i).Disjoint (slot base stride j)

    Distinct indices in a strided record array occupy disjoint blocks.

    theorem Cslib.WordRAM.Block.slot_allocated_of_lt {base stride n idx : ℕ} {s : DataStructure.Memory.State} (halloc : base + stride * n ≤ s.frontier) (hidx : idx < n) :
    (slot base stride idx).Allocated s

    Slot idx < n of an n-element strided array lies below the frontier when the whole array does.

    theorem Cslib.WordRAM.Block.slot_mem_eq_of_modifies_other {base stride i j : ℕ} {s s' : DataStructure.Memory.State} (hi : (slot base stride i).Allocated s) (hne : i ≠ j) (hmod : DataStructure.Memory.Modifies (Set.Ico (slot base stride j).base ((slot base stride j).base + stride)) s s') (a : ℕ) :
    (slot base stride i).Owns a → s'.mem a = s.mem a

    Modifying a different strided slot j ≠ i preserves all cells of slot i.

    theorem Cslib.WordRAM.Block.slot_entries_eq_of_modifies_other {base stride n i j : ℕ} {s s' : DataStructure.Memory.State} (hi : (slot base stride i).Allocated s) (hn : n ≤ stride) (hne : i ≠ j) (hmod : DataStructure.Memory.Modifies (Set.Ico (slot base stride j).base ((slot base stride j).base + stride)) s s') :
    (slot base stride i).entries n s'.mem = (slot base stride i).entries n s.mem

    Modifying a different strided slot j ≠ i preserves entries of slot i.

    Consecutive multi-field list writes #

    Write the list of words vs into consecutive cells base through base + vs.length - 1.

    @[simp]
    theorem Cslib.WordRAM.Block.writeList_cons (base v : ℕ) (vs : List ℕ) :
    writeList base (v :: vs) = do DataStructure.Memory.write base v writeList (base + 1) vs

    After writeList, [base, base + vs.length) realizes vs.

    writeList is admissible when [base, base + vs.length) is allocated and every written word fits w.

    theorem Cslib.WordRAM.Block.framedTriple_writeList {w base : ℕ} {vs : List ℕ} {s : DataStructure.Memory.State} (hwf : DataStructure.Memory.WellFormed w s) (hbound : base + vs.length ≤ s.frontier) (hfit : ∀ v ∈ vs, Fits w v) :

    General FramedTriple specification for Block.writeList, including fixed-frontier and WellFormed w preservation.