Documentation

CslibFrontier.Computability.WordRAM.InputArray

Array blocks in ordinary initialized inputs #

Main results #

This is a representation API for the existing Data.init, with no alternate input convention. It lives in a narrow input-array module to keep the list getD dependency and initialization bridge out of Allocation. This avoids changing the allocation interface and rebuilding its unrelated importers when the input representation API changes.

theorem Cslib.WordRAM.Data.init_mem_append {r : ℕ} (pre rest : List ℕ) (k : ℕ) :
(init (pre ++ rest)).mem (pre.length + 1 + k) = rest.getD k 0

Reading word k after an arbitrary prefix pre in Data.init (pre ++ rest). The extra address word is the standard unsigned input-length header at address 0.

theorem Cslib.WordRAM.Data.init_mem_of_length_lt {r : ℕ} {input : List ℕ} {a : ℕ} (h : input.length < a) :
(init input).mem a = 0

Every cell past the input is 0 in Data.init.

theorem Cslib.WordRAM.Data.init_realizes_append {r : ℕ} (pre payload post : List ℕ) :
{ base := pre.length + 1, length := payload.length }.Realizes (init (pre ++ (payload ++ post))).mem payload.get

The payload between an arbitrary prefix and suffix occupies its corresponding actual input block. The extra address word is the standard unsigned input-length header.

theorem Cslib.WordRAM.Data.init_mem_flatMap_finRange {r n d : ℕ} (pre : List ℕ) (f : Fin n → Fin d → ℕ) (i : Fin n) (j : Fin d) :
(init (pre ++ List.flatMap (fun (i' : Fin n) => List.map (f i') (List.finRange d)) (List.finRange n))).mem (pre.length + 1 + (↑i * d + ↑j)) = f i j

Reading entry (i, j) of a flattened n × d row-major block after a header prefix pre in Data.init.

theorem Cslib.WordRAM.InputFits.flatMap_finRange {w n d : ℕ} (pre : List ℕ) (f : Fin n → Fin d → ℕ) (hlen : Fits w (pre.length + n * d)) (hpre : ∀ x ∈ pre, Fits w x) (hf : ∀ (i : Fin n) (j : Fin d), Fits w (f i j)) :
InputFits w (pre ++ List.flatMap (fun (i : Fin n) => List.map (f i) (List.finRange d)) (List.finRange n))

InputFits for a header prefix pre followed by a flattened n × d row-major block.