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

**Authors:** Michael Luttenberger, Raphaela Palenta, Helmut Seidl

arXiv: 1702.06698 · 2018-01-09

## TL;DR

This paper proves that the longest common prefix of a context-free language can be computed efficiently in polynomial time by establishing structural bounds and representative subsets.

## Contribution

It introduces structural bounds on derivation tree heights and a small representative subset for context-free languages, enabling polynomial-time computation of common prefixes.

## Key findings

- Longest common prefix can be computed in polynomial time
- Bounded derivation tree heights suffice for prefix analysis
- Small representative subset captures prefix properties

## 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 $N$ equals the longest common prefix of the same grammar where the heights of the derivation trees are bounded by $4N$. Second, we show that each nonempty language $L$ has a representative subset of at most three elements which behaves like $L$ w.r.t. the longest common prefix as well as w.r.t. longest common prefixes of $L$ 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.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1702.06698/full.md

## Figures

1 figure with captions in the complete paper: https://tomesphere.com/paper/1702.06698/full.md

## References

12 references — full list in the complete paper: https://tomesphere.com/paper/1702.06698/full.md

---
Source: https://tomesphere.com/paper/1702.06698