Relative Prefix Distance Between Languages

  • Timothy NgEmail author
  • David Rappaport
  • Kai Salomaa
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10396)


The prefix distance between two words x and y is defined as the number of symbols in x and y that do not belong to their longest common prefix. The relative prefix distance from a language \(L_1\) to a language \(L_2\), if finite, is the smallest integer k such that for every word in \(L_1\), there is a word in \(L_2\) with prefix distance at most k. We study the prefix distance between regular, visibly pushdown, deterministic context-free, and context-free languages. We show how to compute the distance between regular languages and determine whether the distance is bounded. For deterministic context-free languages and visibly pushdown languages, we show that the relative prefix distance to and from regular languages is decidable.


  1. 1.
    Alur, R., Madhusudan, P.: Adding nesting structure to words. J. ACM 56(3) (2009)Google Scholar
  2. 2.
    Béal, M.P., Carton, O., Prieur, C., Sakarovitch, J.: Squaring transducers: an efficient procedure for deciding functionality and sequentiality. Theor. Comput. Sci. 292(1), 45–63 (2003)MathSciNetCrossRefzbMATHGoogle Scholar
  3. 3.
    Benedikt, M., Puppis, G., Riveros, C.: Bounded repairability of word languages. J. Comput. Syst. Sci. 79(8), 1302–1321 (2013)MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Benedikt, M., Puppis, G., Riveros, C.: The per-character cost of repairing word languages. Theor. Comput. Sci. 539, 38–67 (2014)MathSciNetCrossRefzbMATHGoogle Scholar
  5. 5.
    Bruschi, D., Pighizzini, G.: String distances and intrusion detection: bridging the gap between formal languages and computer security. RAIRO Inform. Théor. et Appl. 40, 303–313 (2006)MathSciNetCrossRefzbMATHGoogle Scholar
  6. 6.
    Calude, C.S., Salomaa, K., Yu, S.: Additive distances and quasi-distances between words. J. Univ. Comput. Sci. 8(2), 141–152 (2002)MathSciNetzbMATHGoogle Scholar
  7. 7.
    Chatterjee, K., Henzinger, T.A., Ibsen-Jensen, R., Otop, J.: Edit distance for pushdown automata. In: Halldórsson, M.M., Iwama, K., Kobayashi, N., Speckmann, B. (eds.) ICALP 2015. LNCS, vol. 9135, pp. 121–133. Springer, Heidelberg (2015). doi: 10.1007/978-3-662-47666-6_10 CrossRefGoogle Scholar
  8. 8.
    Choffrut, C., Pighizzini, G.: Distances between languages and reflexivity of relations. Theor. Comput. Sci. 286(1), 117–138 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  9. 9.
    Deza, M.M., Deza, E.: Encyclopedia of Distances. Springer, Heidelberg (2009)CrossRefzbMATHGoogle Scholar
  10. 10.
    Han, Y.-S., Ko, S.-K.: Edit-distance between visibly pushdown languages. In: Steffen, B., Baier, C., Brand, M., Eder, J., Hinchey, M., Margaria, T. (eds.) SOFSEM 2017. LNCS, vol. 10139, pp. 387–401. Springer, Cham (2017). doi: 10.1007/978-3-319-51963-0_30 CrossRefGoogle Scholar
  11. 11.
    Han, Y.S., Ko, S.K., Salomaa, K.: The edit-distance between a regular language and a context-free language. Int. J. Found. Comput. Sci. 24(07), 1067–1082 (2013)MathSciNetCrossRefzbMATHGoogle Scholar
  12. 12.
    Kutrib, M., Meckel, K., Wendlandt, M.: Parameterized prefix distance between regular languages. In: Geffert, V., Preneel, B., Rovan, B., Štuller, J., Tjoa, A.M. (eds.) SOFSEM 2014. LNCS, vol. 8327, pp. 419–430. Springer, Cham (2014). doi: 10.1007/978-3-319-04298-5_37 CrossRefGoogle Scholar
  13. 13.
    Mohri, M.: Edit-distance of weighted automata: general definitions and algorithms. Int. J. Found. Comput. Sci. 14(6), 957–982 (2003)MathSciNetCrossRefzbMATHGoogle Scholar
  14. 14.
    Ng, T.: Prefix distance between regular languages. In: Han, Y.-S., Salomaa, K. (eds.) CIAA 2016. LNCS, vol. 9705, pp. 224–235. Springer, Cham (2016). doi: 10.1007/978-3-319-40946-7_19 CrossRefGoogle Scholar
  15. 15.
    Ng, T., Rappaport, D., Salomaa, K.: Descriptional complexity of error detection. In: Adamatzky, A. (ed.) Emergent Computation: A Festschrift for Selim G. Akl. ECC, vol. 24, pp. 101–119. Springer, Cham (2017). doi: 10.1007/978-3-319-46376-6_6 CrossRefGoogle Scholar
  16. 16.
    Ng, T., Rappaport, D., Salomaa, K.: State complexity of prefix distance. Theor. Comput. Sci. 679, 107–117 (2017)MathSciNetCrossRefzbMATHGoogle Scholar
  17. 17.
    Pighizzini, G.: How hard is computing the edit distance? Inf. Comput. 165(1), 1–13 (2001)MathSciNetCrossRefzbMATHGoogle Scholar
  18. 18.
    Shallit, J.: A Second Course in Formal Languages and Automata Theory. Cambridge University Press, Cambridge (2009)zbMATHGoogle Scholar
  19. 19.
    Skala, M.: Counting distance permutations. J. Discrete Algorithms 7(1), 49–61 (2009)MathSciNetCrossRefzbMATHGoogle Scholar
  20. 20.
    Yu, S.: Regular languages. In: Rozenberg, G., Salomaa, A. (eds.) Handbook of Formal Languages, pp. 41–110. Springer, Heidelberg (1997). doi: 10.1007/978-3-642-59136-5_2 CrossRefGoogle Scholar

Copyright information

© Springer International Publishing AG 2017

Authors and Affiliations

  1. 1.School of ComputingQueen’s UniversityKingstonCanada

Personalised recommendations