Active item intervals at a scan boundary in a Catalan placement
ProvedCatalanHashing.Dynamic.scan_interval_stacksConsider a placement with the Catalan nesting property, positive item lengths and an empty cell. Scan forward from . At each boundary before reading the first empty cell, there are two lists of item identifiers, and .
consists exactly of items whose first word has been read and whose last word is still to come. It is initially empty. The concatenation of and has distinct entries. When has a head, its interval is the innermost among the still-unclosed intervals containing whose first cell differs from .
A first word belongs to an item absent from both lists, with no earlier word seen in the scan. Every subsequent word belongs to the head of the concatenated list. A multiword item's first word pushes its identifier onto . Its last word pops if possible, and otherwise pops . Singletons and interior words preserve both lists. These facts about item positions supply the interval-order argument in the proof of Lemma A.1.
import Definitions.Def_CatalanHashing_Dynamic_Static
namespace CatalanHashing.Dynamic
theorem scan_interval_stacks {m : ℕ} {ι : Type*} (len : ι → ℕ) (hlen : ∀ x, 1 ≤ len x)
(occ : Occupancy m ι) (hpl : IsPlacement len occ) (hnest : CatalanNesting len occ)
(hempty : ∃ d, occ d = none) (t : Fin m) :
∃ V H : ℕ → List ι, V 0 = [] ∧
∀ n, (∀ d < n, occ (shift t d) ≠ none) →
(V n ++ H n).Nodup ∧
(∀ x, x ∈ V n ↔ ∃ a e, occ a = some (x, 0) ∧ occ e = some (x, len x - 1) ∧
cdist t a < n ∧ n ≤ cdist t e) ∧
(∀ w, (H n).head? = some w →
(∃ a, occ a = some (w, 0) ∧ a ≠ t ∧ InInterval len occ w t) ∧
(∃ e, occ e = some (w, len w - 1) ∧ n ≤ cdist t e) ∧
∀ w', w' ≠ w → (∃ a, occ a = some (w', 0) ∧ a ≠ t ∧ InInterval len occ w' t) →
(∃ e, occ e = some (w', len w' - 1) ∧ n ≤ cdist t e) →
StrictSubInterval len occ w w') ∧
∀ x j, occ (shift t n) = some (x, j) →
(j = 0 → x ∉ V n ++ H n ∧ ∀ k < n, ∀ i, occ (shift t k) ≠ some (x, i)) ∧
(0 < j → (V n ++ H n).head? = some x) ∧
V (n+1) = (if len x = 1 then V n else if j = 0 then x :: V n
else if j + 1 = len x then (V n).tail else V n) ∧
H (n+1) = (if 0 < j ∧ j + 1 = len x ∧ V n = [] then (H n).tail else H n) := by sorry
end CatalanHashing.Dynamic