Documentation

CslibFrontier.DataStructure.FusionTree.WordRAM.Static

Static fusion trees for finite sets #

Every finite set of distinct unsigned word keys has a static fusion-tree representation. Preprocessing sorts the set, builds the tree, and chooses its proved compression parameters; no RAM preprocessing-time bound is claimed. Query execution uses the actual standard-basis program, whose bounded-size nonuniform code family depends only on physical word width.

The explicit arena contract covers the whole allocation frontier, in addition to the keys and query fitting words. The returned option is two words: presence in register 32 and a key in register 33. This distinguishes absence from key zero without requiring an extra data bit. The answer is the conventional inclusive predecessor: the greatest key at most the query, OrderedSet.greatest (s.filter (· ≤ q)), or none when every key exceeds the query.

Main definitions #

Main results #

References #

Sorting is part of static preprocessing; queries do not scan this list.

The concrete tree for a finite key set.

Preprocessed memory, query, and base address, with zero initial workspace registers.

All allocated data and working registers. The compiled program has a separate uniform size bound of 201051 instructions, including halt; it contains the width-only constants.

A uniform linear bound, including the empty structure and all query registers.

For nonempty sets, the additive workspace and empty-root constants are absorbed in n.

theorem Cslib.DataStructure.FusionTree.WordRAM.Static.arenaFits_of_bound {w base : ℕ} (s : Finset ℕ) (ha : WordRAM.Fits w (base + 126 * s.card + 18)) :
ArenaFits w base (tree w s)

A sufficient input-size-only address condition for the actual allocation.

theorem Cslib.DataStructure.FusionTree.WordRAM.Static.query_spec {w base q : ℕ} (s : Finset ℕ) (hw : 2 ≤ w) (hk : ∀ k ∈ s, WordRAM.Fits w k) (ha : ArenaFits w base (tree w s)) (hq : WordRAM.Fits w q) :
WordRAM.Data.Bounded w (initial w s base q) ∧ workingWords w s ≤ 126 * s.card + 1042 ∧ ∃ (y : WordRAM.Data QueryProgram.registers) (k : ℕ), k + 1 ≤ 3100000 * (Nat.log w s.card + 1) ∧ WordRAM.Runs w (QueryProgram.program w) { pc := 0, data := initial w s base q } { pc := (QueryProgram.code w).size, data := y } k ∧ WordRAM.Executes w (QueryProgram.program w) { pc := 0, data := initial w s base q } (y.regs QueryProgram.value) (k + 1) ∧ QueryProgram.answer y = OrderedSet.greatest ({x ∈ s | x ≤ q}) ∧ y.mem = (initial w s base q).mem ∧ y.regs QueryProgram.query = q

Every arbitrary finite key set receives an actual bounded RAM representation and correct halting predecessor execution. Time includes initialization, all node instructions, traversal, and halt. Space includes the allocated records, auxiliary data, and all working registers. Width selects the code family; the key set, address, and query are runtime data.