principle of optimality for the minimum edit distance problem