decidability for clark congruential cfgs
play

Decidability for Clark-congruential CFGs Tobias Kapp e Makoto - PowerPoint PPT Presentation

Decidability for Clark-congruential CFGs Tobias Kapp e Makoto Kanazawa NII Logic Seminar, January 10, 2018 Introduction Context Free Grammars are surrounded by undecidable questions: Universality Equivalence Congruence These are


  1. Decidability for Clark-congruential CFGs Tobias Kapp´ e Makoto Kanazawa NII Logic Seminar, January 10, 2018

  2. Introduction Context Free Grammars are surrounded by undecidable questions: ◮ Universality ◮ Equivalence ◮ Congruence These are all decidable for regular languages.

  3. Introduction Idea: restrict CFGs, such that: ◮ Regular languages are contained (and then some) ◮ Some questions become decidable

  4. Preliminaries Let us fix a (finite) alphabet Σ. Σ ∗ denotes the set of words over Σ. The empty word is denoted by ǫ . Σ + denotes the non-empty words over Σ. For w , x ∈ Σ ∗ , wx denotes the concatenation of w and x .

  5. Preliminaries A congruence on Σ ∗ is an equivalence ≡ on Σ ∗ such that w ≡ w ′ x ≡ x ′ wx ≡ w ′ x ′ ≡ is finitely generated if it is the smallest congruence contained in a finite relation. We write [ w ] ≡ for the congruence class of w ∈ Σ ∗ modulo ≡ , i.e., [ w ] ≡ = { x ∈ Σ ∗ : w ≡ x }

  6. Preliminaries Every language L induces a syntactic congruence ≡ L : ∀ u , v ∈ Σ ∗ . uwv ∈ L ⇐ ⇒ uxv ∈ L w ≡ L x

  7. Preliminaries A reduction on Σ ∗ is a reflexive, transitive and Noetherian relation � on Σ ∗ such that w � w ′ x � x ′ wx � w ′ x ′

  8. Preliminaries A Context-Free Grammar ( CFG ) is a tuple G = � V , → , I � , s.t. ◮ V is a finite set of non-terminals ◮ → ⊆ V × ( V ∪ Σ) ∗ is a finite production relation ◮ I ⊆ V is a finite set of initial non-terminals Elements of → are known as productions . We write ˆ Σ for V ∪ Σ. We fix G = � V , → , I � throughout this talk.

  9. Preliminaries Σ ∗ such that ⇒ G is the smallest relation on ˆ α B γ ∈ ˆ Σ ∗ B → β α B γ ⇒ G αβγ We write ⇔ G for the symmetric closure of ⇒ G .

  10. Preliminaries For A ∈ V , we define: Σ ∗ : A ⇒ ∗ ℓ ( G , A ) = { α ∈ ˆ � G α } ℓ ( G ) = ℓ ( G , A ) A ∈ I L ( G , A ) = { w ∈ Σ ∗ : A ⇒ ∗ � G w } L ( G ) = L ( G , A ) A ∈ I Convention If A ∈ V , then L ( G , A ) � = ∅ .

  11. Preliminaries Congruence problem Given a grammar G , and w , x ∈ Σ ∗ , does w ≡ L ( G ) x hold? Equivalence problem Given grammars G 1 and G 2 , does L ( G 1 ) = L ( G 2 ) hold? Equivalence 1 and congruence are undecidable for general CFGs. Recognition problem Given a class of grammars G and a grammar G , does G ∈ G hold? 1 Bar-Hillel, Perles, and Shamir 1961.

  12. Classes of grammars G is NTS 2 when for A ∈ V and α ∈ ˆ Σ ∗ , we have A ⇒ ∗ G α iff A ⇔ ∗ G α . Example Consider the grammars G 1 = �{ S } , { S → SS + a + b } , { S }� G 2 = �{ S } , { S → aS + bS + a + b } , { S }� Here ℓ ( G 1 , S ) = { a , b , S } + = ¯ ℓ ( G 1 , S ), and thus G 1 is NTS. Contrarily, S ⇔ ∗ G 2 SS while S �⇒ ∗ G 2 SS , and thus G 2 is not NTS. 2 Boasson 1980.

  13. Classes of grammars G is pre-NTS 3 when for A ∈ V and w ∈ Σ ∗ , we have A ⇒ ∗ G w iff A ⇔ ∗ G w . Example Consider the grammars G 2 = �{ S } , { S → aS + bS + a + b } , { S }� G 3 = �{ S , T } , { S → SS + a + b , T → b } , { S , T }� Here L ( G 2 , S ) = { a , b } + = ¯ L ( G 2 , S ), and thus G 2 is pre-NTS. Contrarily, T ⇔ ∗ G 3 a while T �⇒ ∗ G 3 a , and thus G 3 is not pre-NTS. 3 Autebert and Boasson 1992.

  14. Classes of grammars G is Clark-congruential 4 when for A ∈ V and w , x ∈ L ( G , A ) it holds that w ≡ L ( G ) x . Example Consider the grammars G 3 = �{ S , T } , { S → SS + a + b , T → b } , { S , T }� G 4 = �{ S , T } , { S → SS + a + b + aT , T → c + cc } , { S }� Here L ( G 3 , S ) , L ( G 4 , T ) ⊆ [ a ] ≡ L ( G 3) , and thus G 3 is Clark-congruential. Contrarily, a , ǫ ∈ L ( G 4 , T ) while c �≡ L ( G 4 ) cc , and thus G 4 is not Clark-congruential. 4 Clark 2010.

  15. Classes of grammars NTS-like G 4 Clark-congruential G 3 Pre-NTS G 2 NTS G 1

  16. Classes of grammars Congruence Equivalence Recognition ✓ 5 ✓ 5 ✓ 5,6 NTS ✓ 7 ✓ 7 ✗ 8 Pre-NTS Clark-congruential † ✓ ✓ 5 S´ enizergues 1985. 6 Engelfriet 1994. 7 Autebert and Boasson 1992. 8 Zhang 1992.

  17. Deciding congruence We assume a total order � on Σ. This order extends to a total order on Σ ∗ : ◮ If w is shorter than x , then w � x . ◮ If w and x are of equal length, compare lexicographically. Σ ∗ with L ( G , α ) � = ∅ , write ϑ G ( α ) for the � -minimal element of L ( G , α ). For α ∈ ˆ

  18. Deciding congruence We mimic an earlier method to decide congruence. 9 Let � G be the smallest reduction such that A → α L ( G , α ) � = ∅ ϑ G ( α ) � G ϑ G ( A ) Lemma If w � G x, then w ≡ L ( G ) x. 9 Autebert and Boasson 1992.

  19. Deciding congruence Lemma w ∈ L ( G ) if and only if w � G ϑ G ( A ) for some A ∈ I. Proof. ( ⇒ ) If w ∈ L ( G ), then w ∈ L ( G , A ) for some A ∈ I . Work “backwards” through the derivation A ⇒ ∗ G w to go from w to ϑ G ( A ). ( ⇐ ) If w � G ϑ G ( A ), then w ≡ L ( G ) ϑ G ( A ), and thus w ∈ L ( G ).

  20. Deciding congruence Example Let G = �{ S } , { S → SS + qSp + ǫ } , { S }� . Then � G is generated by qp � G ǫ , and thus qqpqppqp � G qqppqp � G qpqp � G qp � G ǫ = ϑ G ( S ) and therefore qqpqppqp ∈ L ( G ). From pqpq , we can only “reach” pq , which is irreducible; thus, pqpq �∈ L ( G ).

  21. Deciding congruence Given G , we write I G for the set of words irreducible by � G . Let us fix w , x ∈ Σ ∗ . Lemma We can create a DPDA M w such that L ( M w ) = { u ♯ v : uwv ∈ L ( G ) , u , v ∈ I G } . “I have a truly marvelous proof which this margin is too narrow to contain. . . ”

  22. Deciding congruence Recall: L ( M w ) = { u ♯ v : uwv ∈ L ( G ) , u , v ∈ I G } . Lemma L ( M w ) = L ( M x ) if and only if w ≡ L x. Proof. ( ⇒ ) If uwv ∈ L ( G ), let u ′ , v ′ ∈ I G be such that u � G u ′ and v � G v ′ . Then u ′ ♯ v ′ ∈ L ( M w ) = L ( M x ). But then u ′ xv ′ ∈ L ( G ); since u ′ xv ′ ≡ L ( G ) uxv , also uxv ∈ L ( G ). Analogously, uxv ∈ L ( G ) implies uwv ∈ L ( G ). ( ⇐ ) If y ∈ L ( M w ), then y = u ♯ v such that uwv ∈ L ( G ) and u , v ∈ I G . But then uxv ∈ L ( G ), and so u ♯ v ∈ L ( M x ). Analogously, L ( M x ) ⊆ L ( M w ).

  23. Deciding congruence Since equivalence of DPDAs is decidable, 10 we have Theorem Let w , x ∈ Σ ∗ . We can decide whether w ≡ L ( G ) x. 10 S´ enizergues 1997.

  24. Deciding equivalence Lemma Let ≈ G be the smallest congruence containing � G . Then � L ( G ) = [ ϑ G ( A )] ≈ G A ∈ I Proof. ( ⊆ ) If w ∈ L ( G ), then w � G ϑ G ( A ) for some A ∈ I , and so w ≈ G ϑ G ( A ). ( ⊇ ) If w ≈ G ϑ G ( A ), then w ≡ L ( G ) ϑ G ( A ); but then w ∈ L ( G ). Note: ≈ G is finitely generated.

  25. Deciding equivalence Analogous to a result about NTS grammars, 11 we find Lemma Let G 1 = � V 1 , → 1 , I 1 � and G 2 = � V 2 , → 2 , I 2 � be Clark-congruential. Then L ( G 1 ) = L ( G 2 ) if and only if (i) for all A ∈ I 1 , it holds that ϑ G 1 ( A ) ∈ L ( G 2 ) (ii) for all A ∈ I 2 , it holds that ϑ G 2 ( A ) ∈ L ( G 1 ) (iii) for all pairs u ≈ G 1 v generating ≈ G 1 , also u ≡ L ( G 2 ) v (iv) for all pairs u ≈ G 2 v generating ≈ G 2 , also u ≡ L ( G 1 ) v 11 S´ enizergues 1985.

  26. Deciding equivalence Theorem Let G 1 and G 2 be Clark-congruential. We can decide whether L ( G 1 ) = L ( G 2 ) .

  27. Deciding Clark-congruentiality ≡ on ˆ Given a congruence ≡ , we can extend it a congruence ˆ Σ ∗ , by stipulating ϑ G ( α ) ≡ ϑ G ( β ) α ˆ ≡ β

  28. Deciding Clark-congruentiality Lemma Let ≡ be a congruence on Σ ∗ . The following are equivalent: (i) For all productions A → α , it holds that A ˆ ≡ α (ii) For all A ∈ V and w , x ∈ L ( G , A ) , it holds that w ≡ x. Proof. (i) ⇒ (ii): If β ⇒ ∗ G γ , then β ˆ ≡ γ . Thus, if w , x ∈ L ( G , A ), then A ⇒ ∗ G w , x , and so w ˆ ≡ A ˆ ≡ x . We conclude that w = ϑ G ( w ) ≡ ϑ G ( x ) = x . (ii) ⇒ (i): If A → α , then ϑ G ( A ) , ϑ G ( α ) ∈ L ( G , A ), and so ϑ G ( A ) ≡ ϑ G ( α ). From this, we conclude that A ˆ ≡ α .

  29. Deciding Clark-congruentiality Theorem If ≡ L ( G ) is decidable, then we can decide whether G is Clark-congruential. Proof. For A → α , check whether A ˆ ≡ L ( G ) α , i.e., whether ϑ G ( A ) ≡ L ( G ) ϑ G ( α ). Corollary If L ( G ) is a deterministic CFL, then it is decidable whether G is Clark-congruential.

  30. Further work Many open questions: ◮ Are pre-NTS grammars more expressive than NTS grammars? ◮ Are Clark-congruential grammars more expressive than pre-NTS grammars? ◮ Is the language of every pre-NTS grammar a DCFL? ◮ Is the language of every Clark-congruential grammar a DCFL? ◮ Is it decidable in general whether a given grammar is Clark-congruential? ◮ Is it decidable whether the grammar of a DCFL is pre-NTS?

  31. Bonus: NTS-like grammars G is NTS-like when L ( G , A ) ∩ L ( G , B ) � = ∅ implies that adding A → B and B → A does not change L ( G ). Example Consider the grammars G 5 = �{ S , T } , { S → aS + bT + ǫ, T → bS + aT + ǫ } , { S }� G 6 = �{ S , T } , { S → aS + bT + ǫ, T → aS + a } , { S }� Here L ( G 5 ) = L ( G 5 , A ) = L ( G 5 , T ) = { a , b } ∗ ; thus, G 5 is NTS-like. Contrarily, a ∈ L ( G 6 , S ) ∩ L ( G 6 , T ), but adding T → S changes L ( G 6 ).

Recommend


More recommend