Discrete Applied Mathematics 98 (1999) 147–149
Note
On the equivalence problem of context-free and DT0L languages Juha Honkala a;b b Turku
a Department
of Mathematics, University of Turku, FIN-20014 Turku, Finland Centre for Computer Science (TUCS), Lemminkaisenkatu 14, FIN-20520 Turku, Finland
Abstract It is undecidable whether or not a given context-free language and a propagating DT0L language are equal. We show that equivalence is decidable between context-free and everywhere growing DT0L languages. ? 1999 Elsevier Science B.V. All rights reserved. Keywords: DT0L language; Context-free language; Equivalence problem
1. Introduction Equivalence problems for various classes of languages are among the most important decision problems considered in language theory (see, e.g., [1,4,7,8]). Equivalence problems between dierent classes of languages are equally important. For example, Salomaa has shown that it is decidable whether or not a given D0L language and a given context-free language are equal [9]. In this note we consider the equivalence problem between DT0L and context-free languages. It is an easy consequence of earlier undecidability results that equivalence is undecidable between context-free and PDT0L languages. On the other hand, it is noteworthy that equivalence is decidable between context-free and everywhere growing DT0L languages. The proof is a nice blend of earlier results concerning context-free and DT0L languages. For further background and all unexplained notation we refer to [3,7,8]. 2. The equivalence problem Suppose that G = (X; h1 ; : : : ; hn ; w) is a DT0L system. Here X is a nite alphabet, w ∈ X ∗ and hi : X ∗ → X ∗ are morphisms, 16i6n. G is said to be a propagating E-mail address: juha.honkala@utu. (J. Honkala) 0166-218X/99/$ - see front matter ? 1999 Elsevier Science B.V. All rights reserved. PII: S 0 1 6 6 - 2 1 8 X ( 9 9 ) 0 0 1 2 0 - 1
148
J. Honkala / Discrete Applied Mathematics 98 (1999) 147–149
system (abbreviated as PDT0L system) if hi (x) is nonempty for all x ∈ X; 16i6n. Everywhere growing DT0L systems are special cases of PDT0L systems. By de nition, G is an everywhere growing DT0L system (abbreviated as GDT0L system) if the length of hi (x) is at least two for all x ∈ X; 16i6n. Example. Let X = {a; b} and de ne the DT0L system G = (X; g; h; a) by g(a) = ab; g(b) = b2 ; h(a) = ab3 ; h(b) = b2 . Then G is everywhere growing and L(G) = {a; ab2n+1 | n¿0} is a regular language. For the proof of the following result see [10]. Theorem 1. There is no algorithm for deciding whether or not two linear -free grammars generate the same sentential forms. It is easy to see that the set of sentential forms generated by a linear -free grammar is a PDT0L language (see [10]). Therefore Theorem 1 implies the next result. Theorem 2. It is undecidable whether or not a given context-free language equals a given PDT0L language. For the proof of the decidability of CF-GDT0L equivalence we rst recall some earlier results. By de nition, a language L is sparse or poly-slender if and only if there exists a polynomial P(x) such that L contains at most P(n) words of length n for all n. (Note that in the de nition of sparseness it makes no dierence whether we count words of length n or words of length at most n.) Theorem 3. If L is a GDT0L language then L is sparse. Proof. By Theorem 3:2 in [2] there exist constants ; such that the number k (L) of subwords of L of length k satis es k (L)6k for every k¿1 (for another proof see [5]). This implies the claim. The following theorem gives a characterization of sparse context-free languages due to Latteux and Thierrin [6]. By de nition, a language L ⊆ X ∗ is bounded if there exist words w1 ; : : : ; wm ∈ X ∗ such that L ⊆ w1∗ w2∗ · · · wm∗ : Theorem 4. A context-free language L is sparse if and only if L is bounded. Note that bounded context-free languages are closed under nite union and morphic image. The following two results are proved in [3]. Theorem 5. It is decidable whether or not a given context-free language is bounded.
J. Honkala / Discrete Applied Mathematics 98 (1999) 147–149
149
Theorem 6. Equivalence is decidable for bounded context-free languages. Now we can state and prove the main result. Theorem 7. It is decidable whether or not a given context-free language and a given everywhere growing DT0L language are equal. Proof. Let G=(X; h1 ; : : : ; hn ; w) be an everywhere growing DT0L system and L1 =L(G) be the language generated by G. Let L2 be an arbitrary context-free language. By Theorem 3, L1 is sparse. Therefore, rst decide by Theorem 5 whether or not L2 is bounded. If not, by Theorem 4, L2 is not sparse and consequently L1 6= L2 . We proceed with the assumption that L2 is bounded. Next, consider the language equation Y = {w} ∪ h1 (Y ) ∪ · · · ∪ hn (Y ):
(1)
Suppose that K ⊆ X ∗ is a solution of (1). Then L1 ⊆ K. We claim that K = L1 or K = L1 ∪ {}. Suppose on the contrary that there exist nonempty words in K which are not in L1 , and choose u among the shortest nonempty words in K − L1 . Clearly, u 6= w. Because K satis es (1), there exist v ∈ K and 16i6n such that u = hi (v). Here v 6∈ L1 because otherwise we would have u ∈ L1 . Hence v ∈ K − L1 and is shorter than u. This contradiction proves that K = L1 or K = L1 ∪ {}. Next, decide whether or not L2 = {w} ∪ h1 (L2 ) ∪ · · · ∪ hn (L2 ):
(2)
Here L2 and {w} ∪ h1 (L2 ) ∪ · · · ∪ hn (L2 ) are bounded context-free languages. Hence the decision is possible by Theorem 6. If Eq. (2) does not hold, L1 6= L2 . If Eq. (2) holds we have L1 = L2 or L1 ∪ {} = L2 . If ∈ L1 , necessarily L1 = L2 . Otherwise, L1 = L2 if and only if 6∈ L2 . References [1] K. Culik II, New techniques for proving the decidability of equivalence problems, in: T. Lepisto, A. Salomaa (Eds.), Automata, Languages and Programming, Springer, Berlin, 1988, pp. 162–175. [2] A. Ehrenfeucht, K.P. Lee, G. Rozenberg, On the number of subwords of everywhere growing DT0L languages, Discrete Math. 15 (1976) 223–234. [3] S. Ginsburg, The Mathematical Theory of Context-Free Languages, McGraw-Hill, New York, 1966. [4] T. Harju, J. Karhumaki, The equivalence problem of multitape nite automata, Theoret. Comput. Sci. 78 (2) (1991) 347–355. [5] J. Honkala, On generalized DT0L systems and their xed points, Theoret. Comput. Sci. 127 (1994) 269–286. [6] M. Latteux, G. Thierrin, On bounded context-free languages, J. Inform. Process. Cybernet. 20 (1984) 3–8. [7] G. Rozenberg, A. Salomaa, The Mathematical Theory of L Systems, Academic Press, New York, 1980. [8] G. Rozenberg, A. Salomaa (Eds.), Handbook of Formal Languages, Vols. 1–3, Springer, Berlin, 1997. [9] A. Salomaa, Comparative decision problems between sequential and parallel rewriting, Proceedings of the Symposium Uniformly Structured Automata and Logic, 1975, pp. 62– 66. [10] A. Salomaa, On sentential forms of context-free grammars, Acta Inform. 2 (1973) 40–49.