OAI/Combinatorics/BinaryEdit/CheapTranslations.lean
26 declarations, 0 contain sorry, 0 declared as axioms
Inexpensive translations
Elementary unrestricted edit scripts give the translation estimates in
lem:finite-cost.
- theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.unitEdit_prefixline 21 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.script_prefixline 31 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.unitEdit_suffixline 37 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.script_suffixline 50 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.script_transline 56 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.script_delete_prefixline 65 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.script_insert_prefixline 72 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.script_insert_suffixline 79 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.editDistance_le_scriptline 83 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.editDistance_prefix_suffixline 89Source documentation
Retain a common middle word, delete the initial segment and insert the terminal segment. Intermediate words are not subject to any length cap.
theorem editDistance_prefix_suffix (p x s : List α) : ed (p ++ x) (x ++ s) ≤ p.length + s.length := by …Mentions: OAI.TreeEdit.ed
- def
OAI.TreeEdit.BinaryLower.CheapTranslations.rowWindowline 95Source documentation
A consecutive finite window of rows, concatenated in increasing order.
def rowWindow (rows : ℕ → List α) (start count : ℕ) : List α := …
- theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.rowWindow_addline 98 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.rowWindow_shift_indexline 104 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.rowWindow_lengthline 114 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.script_rowWindow_shiftline 128Source documentation
An explicit script for sliding a fixed number of rows. Its exact cost is useful when the same local operation is repeated in a larger concatenation.
theorem script_rowWindow_shift (rows : ℕ → List α) (a T s B : ℕ) (hs : s ≤ T) (hlen : ∀ j, (rows j).length = B) : EditScript (rowWindow rows a T) (rowWindow rows (a + s) T) (2 * s * B) := by …Mentions: OAI.TreeEdit.EditScript, OAI.TreeEdit.BinaryLower.CheapTranslations.rowWindow
- theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.editDistance_rowWindow_shiftline 153Source documentation
Sliding
Tequally long rows bys ≤ Tretains the middleT-srows and costs at most2*s*Bedits.theorem editDistance_rowWindow_shift (rows : ℕ → List α) (a T s B : ℕ) (hs : s ≤ T) (hlen : ∀ j, (rows j).length = B) : ed (rowWindow rows a T) (rowWindow rows (a + s) T) ≤ 2 * s * B := …Mentions: OAI.TreeEdit.ed, OAI.TreeEdit.BinaryLower.CheapTranslations.rowWindow
- def
OAI.TreeEdit.BinaryLower.CheapTranslations.orbitRowsline 162Source documentation
The row word arising from repeated translation in an additive parameter space. This is the row operation in both tree constructions.
def orbitRows {A : Type v} [AddMonoid A] (row : A → List α) (x u : A) (T : ℕ) : List α := … - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.orbitRows_shiftline 166 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.script_orbitRows_shiftline 181Source documentation
An additive state translation by
s*uis the exact row-window script, also whenxalready includes offsets contributed by ancestor nodes.theorem script_orbitRows_shift {A : Type v} [AddMonoid A] (row : A → List α) (x u : A) (T s B : ℕ) (hs : s ≤ T) (hlen : ∀ y, (row y).length = B) : EditScript (orbitRows row x u T) (orbitRows row (x + s • u) u T) (2 * s * B) := by …Mentions: OAI.TreeEdit.EditScript, OAI.TreeEdit.BinaryLower.CheapTranslations.orbitRows
- theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.editDistance_orbitRows_shiftline 191 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.script_map_mismatchesline 201Source documentation
Substituting exactly the differing positions gives a script whose cost is the Hamming mismatch count; repeated positions in
xsare counted with their multiplicity, as required for leaf occurrences in the tree words.theorem script_map_mismatches {β : Type v} [DecidableEq β] (xs : List α) (f g : α → β) : EditScript (xs.map f) (xs.map g) (xs.countP fun a => decide (f a ≠ g a)) := by …Mentions: OAI.TreeEdit.EditScript
- theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.editDistance_map_le_mismatchesline 214 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.script_map_supportedline 224Source documentation
If a change is supported on a Boolean predicate, one substitution at each supported occurrence suffices. No decidable equality on the output alphabet is needed, and harmless substitutions at unchanged supported occurrences are allowed by the ordinary-script definition.
theorem script_map_supported {β : Type v} (xs : List α) (f g : α → β) (p : α → Bool) (hfg : ∀ a ∈ xs, p a = false → f a = g a) : EditScript (xs.map f) (xs.map g) (xs.countP p) := by …Mentions: OAI.TreeEdit.EditScript
- theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.editDistance_map_le_supportline 243 - theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.script_flatMapline 252Source documentation
Scripts in corresponding concatenated blocks add their costs. This allows a local row translation to be performed separately at every copy of a descendant word, without altering the other blocks.
theorem script_flatMap {ι : Type v} (indices : List ι) (f g : ι → List α) (cost : ι → ℕ) (h : ∀ i ∈ indices, EditScript (f i) (g i) (cost i)) : EditScript (indices.flatMap f) (indices.flatMap g) ((indices.map cost).sum) := by …Mentions: OAI.TreeEdit.EditScript
- theorem
OAI.TreeEdit.BinaryLower.CheapTranslations.editDistance_flatMap_le_costline 268