Scattered Context Grammars Alexander Meduna Faculty of Information Technology Brno University of Technology Brno, Czech Republic, Europe.

Slides:



Advertisements
Similar presentations
Context free languages 1. Equivalence of context free grammars 2. Normal forms.
Advertisements

4.5 Inherently Ambiguous Context-free Language For some context-free languages, such as arithmetic expressions, may have many different CFG’s to generate.
Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
The CYK Algorithm David Rodriguez-Velazquez CS – 6800 Summer I
CS5371 Theory of Computation
127 The Chomsky Hierarchy(review) Recursively Enumerable Sets Turing Machines Post System Markov Algorithms,  -recursive Functions Regular Expression.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.1: Context-Free Grammars) David Martin With some.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
Normal forms for Context-Free Grammars
Lecture 9UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 9.
Context-Free Grammars Chapter 3. 2 Context-Free Grammars and Languages n Defn A context-free grammar is a quadruple (V, , P, S), where  V is.
Context-free Grammars
CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)
Final Exam Review Cummulative Chapters 0, 1, 2, 3, 4, 5 and 7.
1 Introduction to Parsing Lecture 5. 2 Outline Regular languages revisited Parser overview Context-free grammars (CFG’s) Derivations.
Formal Grammars Denning, Sections 3.3 to 3.6. Formal Grammar, Defined A formal grammar G is a four-tuple G = (N,T,P,  ), where N is a finite nonempty.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
DIPLOMA THESIS Peter Černo Clearing Restarting Automata Supervised by RNDr. František Mráz, CSc.
CSE 3813 Introduction to Formal Languages and Automata Chapter 8 Properties of Context-free Languages These class notes are based on material from our.
Pushdown Automata (PDA) Intro
Context-Free Grammars Normal Forms Chapter 11. Normal Forms A normal form F for a set C of data objects is a form, i.e., a set of syntactically valid.
Normal Forms for Context-Free Grammars Definition: A symbol X in V  T is useless in a CFG G=(V, T, P, S) if there does not exist a derivation of the form.
Context Free Grammars CIS 361. Introduction Finite Automata accept all regular languages and only regular languages Many simple languages are non regular:
Lecture # 9 Chap 4: Ambiguous Grammar. 2 Chomsky Hierarchy: Language Classification A grammar G is said to be – Regular if it is right linear where each.
CS 3240: Languages and Computation Context-Free Languages.
Regulated Pushdown Automata Alexander Meduna 1/22 Faculty of Information Technology Brno University of Technology Brno, Czech Republic, Europe.
Random Context and Programmed Grammars of Finite Index Have The Same Generative Power Doc. RNDr. Alexander Meduna, CSc. Ing. Zbyněk Křivka DIFS, FIT, Brno.
Part VII. Models for Context-Free Languages 1/50.
Phrase-structure grammar A phrase-structure grammar is a quadruple G = (V, T, P, S) where V is a finite set of symbols called nonterminals, T is a set.
Midterm 1 Breakdown >79 3 >29 7 >69 5 >19 5 >59 7 >49 9 >39 7.
Context Free Grammars.
Deep Pushdown Automata Alexander Meduna Brno University of Technology, Czech Republic  Based on Meduna, A.: Deep Pushdown Automata,
Context-Free and Noncontext-Free Languages Chapter 13 1.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
1 Simplification of Context-Free Grammars Some useful substitution rules. Removing useless productions. Removing -productions. Removing unit-productions.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Grammars Hopcroft, Motawi, Ullman, Chap 5. Grammars Describes underlying rules (syntax) of programming languages Compilers (parsers) are based on such.
Grammars CS 130: Theory of Computation HMU textbook, Chap 5.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
Pumping Lemma for CFLs. Theorem 7.17: Let G be a CFG in CNF and w a string in L(G). Suppose we have a parse tree for w. If the length of the longest path.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
Introduction Finite Automata accept all regular languages and only regular languages Even very simple languages are non regular (  = {a,b}): - {a n b.
Classifications LanguageGrammarAutomaton Regular, right- linear Right-linear, left-linear DFA, NFA Context-free PDA Context- sensitive LBA Recursively.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Discrete Structures ICS252 Chapter 5 Lecture 2. Languages and Grammars prepared By sabiha begum.
1/44 #-Rewriting Systems Based upon Brno University of Technology, Czech Republic  Křivka, Z., Meduna, A., Schönecker, R.: Generation.
Lecture # 31 Theory Of Automata By Dr. MM Alam 1.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Refining the Nonterminal Complexity of Graph-controlled Grammars Faculty of Informatics TU Wien, Wien, Austria Rudolf FREUND Wilhelm-Schickard-Institut.
Chomsky Normal Form.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
CS 461 – Sept. 23 Context-free grammars Derivations Ambiguity Proving correctness.
Complexity and Computability Theory I Lecture #12 Instructor: Rina Zviel-Girshin Lea Epstein.
CSCI 2670 Introduction to Theory of Computing September 16, 2004.
Lecture 17: Theory of Automata:2014 Context Free Grammars.
Chapter 2. Formal Languages Dept. of Computer Engineering, Hansung University, Sung-Dong Kim.
Introduction to Automata Theory
Formal Language & Automata Theory
L-systems L-systems are grammatical systems introduced by Lyndenmayer to describe biological developments such as the growth of plants and cellular organisms.
Complexity and Computability Theory I
Context free grammar.
Introduction to Automata Theory
Finite Automata and Formal Languages
Presentation transcript:

Scattered Context Grammars Alexander Meduna Faculty of Information Technology Brno University of Technology Brno, Czech Republic, Europe

2 Based on these Papers Meduna, A.: Coincidental Extention of Scattered Context Languages, Acta Informatica 39, , 2003 Meduna, A. and Fernau, H.: On the Degree of Scattered Context-Sensitivity. Theoretical Computer Science 290, , 2003 Meduna, A.: Descriptional Complexity of Scattered Rewriting and Multirewriting: An Overview. Journal of Automata, Languages and Combinatorics, , 2002 Meduna, A. and Fernau, H.: A Simultaneous Reduction of Several Measures of Descriptional Complexity in Scattered Context Grammars. Information Processing Letters, , 2003

3 Classification of Parallel Grammars I. Totally parallel grammars, such as L systems, rewrite all symbols of the sentential form during a single derivation step (not discussed in this talk). II. Partially parallel grammars rewrite some symbols while leaving the other symbols unrewritten. Scattered Context Grammars work in a partially parallel way. These grammars are central to this talk.

4 Scattered Context Grammars (SCGs) Essence semi-parallel grammars application of several context-free productions during a single derivation step stronger than CFGs Main Topics under Discussion reduction of the grammatical size new language operations

5 Concept sequences of context-free productions several nonterminals are rewritten in parallel while the rest of the sentential form remains unchanged

6 Definition Scattered context grammar : G = (N, T, P, S) N, T, and S as in a CFG P is a finite set of productions of the form (A 1, A 2,..., A n )  (x 1, x 2,..., x n ) where A i  N and x i  V* with V = N  T Direct derivation: u 1 A 1 u 2 A 2 u 3... u n A n u n+1  u 1 x 1 u 2 x 2 u 3... u n x n u n+1 if (A 1, A 2,..., A n )  (x 1, x 2,..., x n ) Generated language: L(G) = {w: S  * w and w  T*}

7 Example Productions: (S)  (AA), (A, A)  (aA, bAc), (A, A)  ( ,  ) Derivation: S  AA  aAbAc  aaAbbAcc  aabbcc Generated Language: L(G) = {a i b i c i : i  0}

8 Language Families CS - Context Sensitive Languages RE - Recursively Enumerable Languages SC = {L(G): G is a SCG} for every n  1, SC(n) = {L(G): G is a SCG with no more than n nonterminals}

9 Reduction of SCGs (A) reduction of the number of nonterminals (B) reduction of the number of context (non-context-free) productions (C) simultaneous reduction of (A) and (B)

10 Reduction (A) 1/2 Reduction of the Number of Nonterminals Theorem 1: RE = SC (3) Theorem 2: CS  SC (1) Proof (Sketch): Let L = {a h : h = 2 n, n  1}. Assume that L = L(G), where G = ({S}, {a}, P, S) is a SCG. In G, S  * a i Sa j  * a i a k a j for some i, j  0 such that i + j, k  1. Thus, S  * a in Sa jn  * a in a k a jn for every n  0. As a i a k a j  L, |a i a k a j | = i + k + j = 2 m. Consider v = a 2i a k a 2j  L. Then, 2 m < |v| = 2 m + i + j < 2 m+1, so v  L—a contradiction.

11 Reduction (A) 2/2 Corollary: SC(1)  SC (3) = RE Open Problem: RE = SC (2)?

12 Reduction (B) Reduction of SCGs (A) reduction of the number of nonterminals (B) reduction of the number of context (non-context-free) productions (C) reduction of (A) and (B)

13 Reduction (B) 1/5 Reduction of the Number of Context Productions A context production means a non-context-free production (A 1, A 2,..., A n )  (x 1, x 2,..., x n ) with n  2 Theorem 4: Every language in RE is generated by a scattered context grammar with only these two context productions: ($, 0, 0, $)  ( , $, $,  ) ($, 1, 1, $)  ( , $, $,  )

14 Reduction (B) 2/5 I. Left-Extended Queue Grammar Q = (V, T, W, F, s, R) R - finite set of productions of the form (a, q, z, r). Every generation of h  L(Q) has this form #a 0 q 0  a 0 #a 1 x 0 q 1 [(a 0, q 0, z 0, q 1 )]  a 0 a 1 #a 2 x 1 q 2 [(a 1, q 1, z 1, q 2 )]  a 0 a 1  a k #a k+1 x k q k+1  a 0 a 1  a k a k+1 #a k+2 x k+1 y 1 q k+2 [(a k+1, q k+1, y 1, q k+2 )]  a 0 a 1  a k a k+1  a k+m-1 # a k+m y 1  y m-1 q k+m [(a k+m-1, q k+m-1, y m-1, q k+m )]  a 0 a 1  a k a k+1  a k+m #y 1  y m q k+m+1 [(a k+m, q k+m, y m, q k+m+1 )] where h = y 1  y m with q k+m+1  F

15 Reduction (B) 3/5 II. Substitutions g: binary code of symbols from V h: binary code of states from W III. Introduction of SCG G = (N, T, CF  Context, S) Context = {($, 0, 0, $)  ( , $, $,  ), ($, 1, 1, $)  ( , $, $,  ) } IV. CF used to generate $g(a 0 a 1  a k a k+1  ak +m )y 1  y m h(q k+m  q k+1 q k  q 1 q 0 )$

16 Reduction (B) 4/5 V. Context used to verify g(a 0 a 1  a k a k+1  a k+m ) = h(q 0 q 1  q k q k+1  q k+m ) let g(a 0 a 1  a k a k+1  a k+m ) = c 0 c 1  c (k+m)2n let h(q 0 q 1  q k q k+1  q k+m ) = d 0 d 1  d (k+m)2n where each c i, d i  {0, 1} By using ($, 0, 0, $)  ( , $, $,  ) and ($, 1, 1, $)  ( , $, $,  ), G makes $c 0 c 1 c 2  c (k+m)2n y 1  y m d (k+m)2n  d 2 d 1 d 0 $ $c 1 c 2  c (k+m)2n y 1  y m d (k+m)2n  d 2 d 1 $ $c 2  c (k+m)2n y 1  y m d (k+m)2n  d 2 $ $y 1  y m $ y 1  y m

17 Reduction (B) 5/5 Corollary 5: The SCGs with two context productions characterize RE. Open Problem: What is the power of the SCGs with a single context production?

18 Reduction of SCGs (A) reduction of the number of nonterminals (B) reduction of the number of context (non-context-free) productions (C) reduction of (A) and (B)

19 Simultaneous Reduction (A) & (B) Simultaneous Reduction of the Number of Nonterminals and the Number of Context Productions Note: Next two theorems were proved in cooperation with H. Fernau (Germany). Theorem: Every type-0 language is generated by a SCG with no more than seven context productions and no more than five nonterminals Theorem: Every type-0 language is generated by a SCG with no more than six context productions and no more than six nonterminals Open Problem: Can we improve the above theorems?

20 New Operations  -free SCGs  -free SCG: each production (A 1, …, A n )  (x 1, …, x n ) satisfies x i    -free SC = {L(G): G is an  -free SCG }  -free SC  CS  SC = RE Objective: Increase of  -free SC to RE by a simple language operation over  -free SC

21 Coincidental Extension 1/6 Coincidental Extension For a symbol, #, and a string, x = a 1 a 2  a n-1 a n, any string of the form # i a 1 # i a 2 # i  # i a n-1 # i a n # i, where i  0, is a coincidental #-extension of x. A language, K, is a coincidental #-extension of L if every string of K represents a coincidental extension of a string in L and the deletion of all #s in K results in L, symbolically written as L #  K If L #  K and there are an infinitely many coincidental extensions of x in K for every x  L, we write L #   K

22 Coincidental Extension 2/6 Examples: For X = {# i a# i b# i : i  5}  {# i c n # i d n # i : n, i  0} and Y = {ab}  {c n d n : n  0}, Y #   X, so Y #  X. For A = {#a#b#}  {# i c n # i d n # i : n, i  0}, Y #  A holds, but Y #   A does not hold. B = {# i a# i b# i : i  5}  {# i c n # i d n # i+1 : n, i  0} is not the coincidental #-extension of any language.

23 Coincidental Extension 3/6 Theorem: Let K  RE. Then, there exists a  -free SCG, G, such that K #   L(G). Proof (Sketch): Let K  RE. There exists a SCG, G, such that L = L(G). Construct a  -free SCG, G = (V, P, S, {#}  T ), so that L #   L(G). Homomorphism h : h(A) = A for every nonterminal A h(a) = a for every terminal a h(  ) = Y

24 Coincidental Extension 4/6 P constructed by performing the next six steps: I.add (Z)  (YS$) to P II.for every (A 1, …, A n )  (x 1, …, x n )  P, add (A 1, …, A n, $)  (h(x 1 ), …, h(x n ), $) to P III.add (Y, $)  (YY, $) to P IV.for every a, b, c  T, add (  a ,  b ,  c , $)  (  0a ,  0b ,  0c , §) to P V.for every a, b, c, d  T, add (Y,  0a , Y,  0b , Y,  0c , §)  (#,  0a , X,  0b , Y,  0c , §), (  0a ,  0b ,  0c , §)  (  4a ,  1b ,  2c , §), (  4a , X,  1b , Y,  2c , §)  (  4a , #,  1b , X,  2c , §), (  4a ,  1b ,  2c ,  d , §)  (a,  4b ,  1c ,  2d , §), (  4a ,  1b ,  2c , §)  (a,  1b ,  3c , §), (  1a , X,  3b , Y, §)  (  1a , #,  3b , #, §) to P

25 Coincidental Extension 5/6 VI.for every a, b  T, add (  1a , X,  3b , §)  (a, #, b, #) to P. G generates every y  L(G) in this way Z  YS$  + x$  v§  + z§  y where v  (T{Y} + ) + {$}. In addition, v = u 0  0a 1  u 1  0a 2  u 2  0a 3  u n-1  a n  u n § if and only if a 1 a 2 a 3  a n  L(G)

26 Coincidental Extension 6/6 In greater detail, v§  + z§  y can be expressed as Y i  0a 1  Y i  0a 2  Y i  0a 3  Y i  a n  Y i-1 §  i # i  0a 1  X i  0a 2  Y i  0a 3  Y i  a 4  Y i  a n  Y i-1 §  # i  4a 1  X i  1a 2  Y i  2a 3  Y i  a 4  Y i  a n  Y i-1 §  i # i  4a 1  # i  1a 2  X i  2a 3  Y i  a 4  Y i  a n  Y i-1 §  # i a 1 # i  4a 2  X i  1a 3  Y i  2a 4  Y i  a n  Y i-1 §  i # i a 1 # i  4a 2  # i  1a 3  X i  2a 4  Y i  a n  Y i-1 §  # i a 1 # i a 2 # i  4a 3  X i  1a 4  Y i  2a 5  Y i  a n  Y i-1 § : # i a 1 # i a 2 # i a 3   4a n-2  # i  1a n-1  X i  2a n  Y i-1 §  # i a 1 # i a 2 # i a 3  a n-2 # i  1a n-1  X i  3a n  Y i-1 §  i-1 # i a 1 # i a 2 # i a 3  # i a n-2 # i  1a n-1  # j X# k  3a n  # i-1 §  # i a 1 # i a 2 # i a 3  # i a n-2 # i a n-1 # i a n # i Corollary: Let K  RE. Then, there exists a  -free SCG, G, such that K #  L(G).

27 Use in Theoretical Computer Science Corollary: For every language K  RE, there exists a homomorphism h and a language H   -free SC such that K = h(H). In a complex way, this result was proved on page 245 in [Greibach, S. A. and Hopcroft, J. E.: Scattered Context Grammars. J. Comput. Syst. Sci. 3, (1969)]

28 Future Investigation Future Investigation: k-limited coincidental extension Let k be a non-negative integer. For a symbol, #, and a string, x = a 1 a 2  a n-1 a n, any string of the form # i a 1 # i a 2 # i  # i a n-1 # i a n # i, where k  i  0, is a k-limited coincidental #-extension of x. A language, K, is a coincidental a k-limited #-extension of L if every string of K represents a k-limited coincidental extension of a string in L and the deletion of all #s in K results in L, symbolically written as L k  #  K Example For X = {# i a# i b# i : 2  i  0}  {# i c n # i d n # i : n  0, 4  i  0} and Y = {ab}  {c n d n : n  0}, Y 4  #  X

29 Very Important Open Problem Important Open Problem:  -free SC = CS ? Does there exist a non-negative integer k, such that for every L  CS, L k  #  L(H) for some  -free SCG, H? If so, I know how to prove  -free SC = CS. END