Edit distance
Definition
Let be a finite alphabet and let be the set of finite strings over . An edit operation changes a string in one of these ways:
- insertion of one symbol of at some place in ;
- deletion of one symbol of ;
- substitution of one symbol of by a different symbol of .
The edit distance, or Levenshtein distance, of is the least number of edit operations that turn into .
Remarks
Example: . Deleting and then inserting at the end turns into , so . A single operation either changes the length or changes exactly one position, while and have equal length and differ in two positions, so .
Non-example: if only substitutions are allowed, the strings and are at no finite distance, since substitution never changes the length. That restricted distance is the Hamming distance, defined only for strings of equal length.
Since each operation can be undone by one operation, is symmetric, and is a metric on . For and , let be the edit distance of the prefixes and . Then , , and where is if and otherwise. This gives in time . Other edit distances use other sets of operations, for example adding the transposition of two adjacent symbols.
Reading path
To understand this page from the ground up, read these 19 pages in order. The foundations come first.
Show the path as a graph
- no evidence level
- Alphabet concept
- Element definition
- Hamming distance concept
- Proposition concept
- Real numbers object
- String concept
- Set definition
- Implication definition
- Predicate definition
- Ordered pair definition
- Existential quantifier definition
- Universal quantifier definition
- Cartesian product definition
- Subset definition
- Uniqueness quantifier definition
- Binary relation definition
- Function definition
- Metric space definition
- Edit distance definition
Further reading
About this page
| Tag | 4E3R6ZAFV7 |
|---|---|
| URI | m2://4E3R6ZAFV7 |
| Kind | definition |
| Writing | W0 stub |
| MSC | 68W32, 68R15, 68P30 |
| Defines | Edit distance |
| Uses | Alphabet, String, Metric space, Hamming distance |
| Changed | 3 November 2026 |
Markdown · JSON · Edit on GitHub
What this page needs for W1
- an inventory row: the row of the inventory that the node accounts for (0 of 1)
- a source with a locator (0 of 1)
The writing levels say how complete the text of a page is. They do not measure its truth.
What links here
No page links to this page yet.