The edit distance between two strings, ed(s,t), is the minimum number of edit operations (insertion, deletion, or replacement of a character) required to transform string s into string t.
An alignment of two strings (s,t) is a pair of strings (s′,t′) that meet the following criteria:
s′ and t′ are formed by inserting - (gap) characters into s and t respectively.
∣s′∣=∣t′∣. (The strings are the same length.)
If we remove all - characters from s′ and t′, we get s and t respectively.
A gap cannot appear in the same position in both s′ and t′. (No consecutive gaps.)
The cost of of an alignment (s′,t′) is the number of positions in which s′ and t′ differ, and it is denoted cost(s′,t′)=∣{i:si′=ti′}∣.
The alignment distance between two strings, ad(s,t), is the cost of their optimal (minimum-cost) alignment.
Theorem: For any two strings s,t∈Σ∗, we have ed(s,t)=ad(s,t).