Adjacent deduplication with full multiplicities #
The output is a list of key/count pairs with positive counts and strictly increasing keys. Expanding those runs recovers the sorted input exactly. This specifies the whole finite set and all multiplicities, rather than a one-way membership condition. These proofs are original.
Main definitions #
expand: expand key/count pairs into their repeated keys.RunEncoding: positive, strictly ordered runs reconstructing the input.
Main results #
RunEncoding.keys_nodup: each key occurs once.RunEncoding.mem_iff: the keys enumerate exactly the input set.RunEncoding.multiplicity: each count is the full input multiplicity.
Runs with positive counts and strictly increasing keys reconstruct exactly xs.
Each emitted run is nonempty.
- ordered : List.Pairwise (fun (p q : ℕ × ℕ) => p.1 < q.1) rs
A key never reappears after a different key.
All input positions are accounted for, with their exact order and multiplicity.
Instances For
theorem Cslib.Algorithms.WordRAM.Deduplicate.first_run (k : ℕ) (xs : List ℕ) (hs : List.Pairwise (fun (x1 x2 : ℕ) => x1 ≤ x2) (k :: xs)) :
A nonempty sorted list starts with a positive run of its head, followed only by larger keys. This is a mathematical decomposition used to verify the adjacent scan, not an oracle operation of the program.