English

Computing the longest common prefix of a context-free language in polynomial time

Formal Languages and Automata Theory 2018-01-09 v2

Abstract

We present two structural results concerning longest common prefixes of non-empty languages. First, we show that the longest common prefix of the language generated by a context-free grammar of size NN equals the longest common prefix of the same grammar where the heights of the derivation trees are bounded by 4N4N. Second, we show that each nonempty language LL has a representative subset of at most three elements which behaves like LL w.r.t. the longest common prefix as well as w.r.t. longest common prefixes of LL after unions or concatenations with arbitrary other languages. From that, we conclude that the longest common prefix, and thus the longest common suffix, of a context-free language can be computed in polynomial time.

Cite

@article{arxiv.1702.06698,
  title  = {Computing the longest common prefix of a context-free language in polynomial time},
  author = {Michael Luttenberger and Raphaela Palenta and Helmut Seidl},
  journal= {arXiv preprint arXiv:1702.06698},
  year   = {2018}
}
R2 v1 2026-06-22T18:24:59.112Z