Documentation

CslibFrontier.Algorithms.WordRAM.VariableElimination.Memory

Monotone Memory Predicates, memScan, and writeDesc #

Factor descriptor invariants over allocated Word-RAM list blocks, together with the shared linear membership scanner memScan and 4-word descriptor writer writeDesc.

Main definitions #

Main results #

A step that changes only cells at or above F extends a prefix frame below F.

Factor descriptors #

A 4-word factor descriptor at descAddr points to f's scope and entries.

theorem Cslib.Algorithms.WordRAM.VariableElimination.HoldsFactor.mono {descAddr : ℕ} {f : Logic.PL.CSP.FactorTable ℕ ℕ} {F : ℕ} {s₀ s₁ : DataStructure.Memory.State} (h : HoldsFactor descAddr f s₀) (hF : descAddr + 4 ≤ F) (hsF : s₀.mem descAddr + f.scope.length ≤ F) (heF : s₀.mem (descAddr + 2) + f.entries.size ≤ F) (hp : WordRAM.Realization.PreservesBelow F s₀ s₁) :
HoldsFactor descAddr f s₁

Primitive 1: Linear membership scan (memScan) #

Arguments (ptr, len, key) for memScan and filterNe.

Instances For

    Linear scan returning 1 iff key occurs in the slice [ptr, ptr + len).

    theorem Cslib.Algorithms.WordRAM.VariableElimination.memScan_framed {w : ℕ} (args : MemScanArgs) {xs : List ℕ} {s : DataStructure.Memory.State} (hxs : WordRAM.Block.HoldsList args.base xs s.mem) (hlen : xs.length = args.len) (hb : args.base + args.len ≤ s.frontier) :
    DataStructure.Memory.FramedTriple w s (memScan args) args.len ∅ fun (r : ℕ) (t : DataStructure.Memory.State) => (r = if args.target ∈ xs then 1 else 0) ∧ t = s

    memScan reading a list xs below the frontier meets a framed triple that modifies nothing and fixes its result, 1 exactly when the key occurs in xs, and its final state.

    Descriptor writer (writeDesc), live partitioning (partitionLive), and buildOutScope #

    theorem Cslib.Algorithms.WordRAM.VariableElimination.HoldsFactor.frame_outside {descAddr : ℕ} {f : Logic.PL.CSP.FactorTable ℕ ℕ} {F : ℕ} {s₀ s₁ : DataStructure.Memory.State} (hf : HoldsFactor descAddr f s₀) (hsF : s₀.mem descAddr + f.scope.length ≤ F) (heF : s₀.mem (descAddr + 2) + f.entries.size ≤ F) (hpres : WordRAM.Realization.PreservesBelow F s₀ s₁) (hdesc : ∀ (a : ℕ), descAddr ≤ a → a < descAddr + 4 → s₁.mem a = s₀.mem a) :
    HoldsFactor descAddr f s₁

    Every scope/entry cell referenced by descriptors fs lies strictly below F.

    theorem Cslib.Algorithms.WordRAM.VariableElimination.AllDataBelow.frame {F base : ℕ} {fs : List (Logic.PL.CSP.FactorTable ℕ ℕ)} {s₀ s₁ : DataStructure.Memory.State} (h : AllDataBelow F base fs s₀) (hdesc : ∀ (a : ℕ), base ≤ a → a < base + 4 * fs.length → s₁.mem a = s₀.mem a) :
    AllDataBelow F base fs s₁
    theorem Cslib.Algorithms.WordRAM.VariableElimination.HoldsFactorList.frame_outside {F base : ℕ} {fs : List (Logic.PL.CSP.FactorTable ℕ ℕ)} {s₀ s₁ : DataStructure.Memory.State} (h : HoldsFactorList base fs s₀) (hdata : AllDataBelow F base fs s₀) (hpres : WordRAM.Realization.PreservesBelow F s₀ s₁) (hdesc : ∀ (a : ℕ), base ≤ a → a < base + 4 * fs.length → s₁.mem a = s₀.mem a) :
    HoldsFactorList base fs s₁

    Arguments for storing one 4-word factor descriptor at dst.

    Instances For

      Write a 4-word factor descriptor (scPtr, scLen, enPtr, enLen) at dst.

      An admissible writeDesc meets a framed triple of cost 4 that changes only cells at or above any F ≤ args.dst and fixes its result and final state.