Download presentation
Presentation is loading. Please wait.
Published byReynold Wells Modified over 6 years ago
1
Course 2 Introduction to Formal Languages and Automata Theory (part 2)
Cpt S 317: Spring 2009 Course 2 Introduction to Formal Languages and Automata Theory (part 2) The structure and the content of the lecture is based on School of EECS, WSU
2
The Chomsky Hierarchy β 0 β 1 β 2 β 3 Recursively- enumerable
Context- sensitive Context- free Regular Grammar Languages Automaton Production Rules Type-0 Recursively enumerable Turing machine πΌβπ½ Type-1 Context sensitive Linear-bounded non-deterministic Turing machine πΌπ΄π½βπΌπΎπ½ Type-2 Context-free Non-deterministicΒ pushdown automaton π΄βπΎ Type-3 Regular Finite state automaton π΄βπ and π΄βππ΅ β 0 β 1 β 2 β 3
3
The Chomsky Hierarchy (contβd)
Cpt S 317: Spring 2009 The Chomsky Hierarchy (contβd) Classification using the structure of their rules: Type-0 grammars: there are no restriction on the rules; Type-1 grammars/Context sensitive grammars: the rules for this type have the next form: π’π΄π£βπ’ππ£, π’,π,π£β π πΊ β , πβ π, Aβ π π Type-2 grammars/Context free grammars: the rules for this type are of the form: π΄βπ, πβ π πΊ β , Aβ π π Type-3 grammars/regular grammars: the rules for this type have one of the next two forms: Cat. I rules π΄βπ΅π Cβπ or A,π΅,πΆβ π π , π,πβ π π β π΄βππ΅ Cat. II rules Examples: see whiteboard School of EECS, WSU
4
The Chomsky Hierarchy (contβd)
Cpt S 317: Spring 2009 The Chomsky Hierarchy (contβd) Localization lemma for context-free languages (CFL) Let πΊ be a context free grammar and the derivation π₯ 1 β¦ π₯ π β π, where π₯ π β π πΊ , πβ π πΊ β . Then there exists π 1 β¦ π π β π πΊ β such that π= π 1 β¦ π π and π₯ π β π π . School of EECS, WSU
5
The Chomsky Hierarchy (contβd)
Cpt S 317: Spring 2009 The Chomsky Hierarchy (contβd) On the previos slide: what do you observe on the right-hand side (RHS) of the production rules? School of EECS, WSU
6
The Chomsky Hierarchy (contβd)
Cpt S 317: Spring 2009 The Chomsky Hierarchy (contβd) It is convenient to have on the RHS of a derivation only terminal or nonterminal symbols! This can be achieved without changing the type of grammar. Lemma π΄βπ Let system πΊ=( π π , π π ,π,π) be a context free grammar. There exists an equivalent context free grammar πΊ β² with the property: if one rule contains terminals then the rule is of the form π΄βπ, Aβ π π , π βπ π . School of EECS, WSU
7
The Chomsky Hierarchy (contβd)
Cpt S 317: Spring 2009 The Chomsky Hierarchy (contβd) Lemma π΄βπ Let system πΊ=( π π , π π ,π,π) be a context free grammar. There exists an equivalent context free grammar πΊ β² with the property: if one rule contains terminals then the rule is of the form π΄βπ, Aβ π π , π βπ π . Proof. Let πΊ β² = π π β² , π π β² , π β² , π β² , where π π β π π β² and π β² contains all βconvenientβ rules from π. Let the following incoveninent rule: π’β π£ 1 π 1 π£ 2 π 2 β¦ π π π£ π+1 , π π βπ π , π£ π βπ π β We add to π β² the following rules: Observation: For type-0 grammars, all terminals from both sides of the rules are replaced. π’β π£ 1 π π1 π£ 2 π π2 β¦ π ππ π£ π+1 π ππ β π π π=1..π, π ππ β π π β² School of EECS, WSU
8
The Chomsky Hierarchy (contβd)
Cpt S 317: Spring 2009 The Chomsky Hierarchy (contβd) What is the relationship between β 0 , β 1 , β 2 , β 3 ? School of EECS, WSU
9
The Chomsky Hierarchy (contβd)
Cpt S 317: Spring 2009 The Chomsky Hierarchy (contβd) We have β 0 β β 1 , β 2 β β 3 . Apparently, a type-2 rule π΄βπ is a particular case of type-1 rule π’π΄π£βπ’ππ£, in which the context is empty word: π’=π£=π. This is not correct because of the restriction πβ π imposed for context free grammars. School of EECS, WSU
10
Closure properties of Chomsky families
Cpt S 317: Spring 2009 Closure properties of Chomsky families Definition. Let β be a binary operation on a family of languages πΏ. We say that the family πΏ is closed on the operation β if πΏ 1 , πΏ 2 βπΏ then πΏ 1 , πΏ 2 βπΏ. Closure of Chomsky families under union The families β 0 , β 1 , β 2 , β 3 are closed under union. Key idea in the proof πΊ= π π 1 βͺ π 2 βͺπ , π π 1 βͺ π 2 , π 1 βͺ π 2 βͺ πβ π 1 | π 2 Examples: see whiteboard School of EECS, WSU
11
Closure properties of Chomsky families
Cpt S 317: Spring 2009 Closure properties of Chomsky families Closure of Chomsky families under product The families β 0 , β 1 , β 2 , β 3 are closed under product. Key ideas in the proof For β 0 , β 1 , β 2 πΊ= π π 1 βͺ π 2 βͺπ , π π 1 βͺ π 2 , π 1 βͺ π 2 βͺ πβ π 1 π 2 For β 3 πΊ= π π 1 βͺ π 2 , π π 1 βͺ π 2 , π 1 , π 1 β²βͺ π 2 where π 1 β² is obtained from π 1 by replacing the rules π΄βπ with π΄βπ π 2 Examples: see whiteboard School of EECS, WSU
12
Closure properties of Chomsky families
Cpt S 317: Spring 2009 Closure properties of Chomsky families Closure of Chomsky families under Kleene closure The families β 0 , β 1 , β 2 , β 3 are closed under Kleene closure operation. Key ideas in the proof For β 0 , β 1 πΊ β = π π βͺ π β ,π , π π , π β ,πβͺ π β βπ π ππ, ππβππ|πππ, πβ π π The new introduced rules are of type 1, so πΊ β does not modify the type of πΊ. For β 2 πΊ β = π π βͺ π β , π π , π β ,πβͺ π β β π β π|π For β 3 πΊ β = π π βͺ π β , π π , π β ,πβͺ π β² βͺ π β βπ|π where π β² is obtained with category II rules, from π, namely if π΄βπ β π then π΄βππ β π. Examples: see whiteboard School of EECS, WSU
13
Closure properties of Chomsky families
Cpt S 317: Spring 2009 Closure properties of Chomsky families Observation. Union, product and Kleene closure are called regular operations. Hence, the language families from the Chomsky classification are closed under regular operations. School of EECS, WSU
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.