Documentation

CslibFrontier.Algorithms.Lean.EditDistance.PatternMatching

Metric properties of Levenshtein edit distance and pattern matching distance #

Establishes the metric properties and structural monotonicity laws of unit-cost Levenshtein edit distance (Cslib.Algorithms.Lean.EditDistance.editDist Costs.unit), its characterization via deletion-substitution scripts to a common target word, and the exact guard-padding reduction from substring pattern matching distance to global edit distance:

Main definitions #

Main results #

1. Metric and Lipschitz properties of unit-cost edit distance #

Difference in letter multiplicity is bounded by unit-cost edit distance.

Filtering by any Boolean predicate p does not increase unit-cost edit distance.

2. Common-target deletion-substitution characterization #

An edit script uses only deletions and substitutions (no insertions).

Unit-cost edit distance equals the minimum over all common target words z of the combined cost of deletion-substitution scripts transforming x to z and y to z.

3. Pattern matching distance and fresh-guard reduction to edit distance #

Pattern matching distance from a pattern p to a text t: the minimum unit-cost edit distance editDist Costs.unit p x over all contiguous substrings x <:+: t.

patternDist p t is the least value of editDist Costs.unit p x over x <:+: t.

Fresh-guard reduction from pattern matching distance to edit distance: if a guard symbol g does not occur in t, then flanking p on both sides with |t| copies of g shifts unit-cost edit distance by 2 * |t| above patternDist p t: editDist Costs.unit (g^{|t|} ++ p ++ g^{|t|}) t = 2 * |t| + patternDist p t.