CS375: Logic and Theory of Computing
|
|
- Andrew Berry
- 5 years ago
- Views:
Transcription
1 CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1
2 Table of Contents: Week 1: Preliminaries (set algebra, relations, functions) (read Chapters 1-4) Weeks 3-6: Regular Languages, Finite Automata (Chapter 11) Weeks 7-9: Context-Free Languages, Pushdown Automata (Chapters 12) Weeks 10-12: Turing Machines (Chapter 13) 2
3 Table of Contents (conti): Weeks 13-14: Propositional Logic (Chapter 6), Predicate Logic (Chapter 7), Computational Logic (Chapter 9), Algebraic Structures (Chapter 10) 3
4 Context-Free Language Topics Algorithm. Remove Λ-productions from grammars for languages without Λ. 1. Find nonterminals that derive Λ. 2. For each production A w construct all productions A w where w is obtained from w by removing one or more occurrences of the nonterminals from Step Combine the original productions with those of step 2 and eliminate any Λ-productions. 4
5 Context-Free Language Topics Algorithm. Remove Λ-productions from grammars for languages without Λ. Two questions: To avoid violating the length increasing property 1. Why do we want to remove Ʌ-productions from a given grammar? 2. why do we need step 2 in the above algorithm? To avoid the creation of a path that leads to a Ʌ-production 5
6 Remove Λ-productions Language generated by this grammar does not contain Ʌ Example. Remove Λ-productions from the grammar: Solution: S ABc A aa Λ B bb Λ. 1. The nonterminals A and B derive Λ. 2. From S ABc we construct S Bc Ac c From A aa we construct A a From B bb we construct B b 3. S ABc Bc Ac c A aa a B bb b. 6
7 Remove Λ-productions Quiz. Remove Λ-productions from the grammar: S ABc Ab c A ABa Λ B Bbc Λ. Solution: 1. The nonterminals A and B derive Λ. 2. From S ABc we construct S Bc Ac c From S Ab we construct A b From A ABa we construct A Ba Aa a From B Bbc we construct B bc 3. S ABc Ab c Bc Ac b A ABa Ba Aa a B Bbc bc. 7
8 Chomsky Normal Form (CNF) Definition. Productions have one of the following forms: A a (terminal) A BC (non-terminals) S Λ (forbid S on RHS) No need if Ʌ is not in the language Example: S AS a A SA b Language of this grammar = { a, ba, bba, aba, baba, bbaba, ababa, bababa, bbababa, abababa, } 8 = { a(ba) n, (ba) m, b(ba) m n ϵ N, m ϵ N + } True?
9 Chomsky Normal Form (CNF) Definition. Productions have one of the following forms: Advantages: A a (terminal) A BC (non-terminals) S Λ (forbid S on RHS) 1. Parse trees are binary, easy to represent No need if Ʌ is not in the language 2. Any string of length n > 0 can be derived in exactly 2n 1 steps. (Thus: one can determine if a string is in the language by exhaustive search of all derivations.) 9
10 Chomsky Normal Form (CNF) Definition. Productions have one of the following forms: A a (terminal) A BC (non-terminals) S Λ (forbid S on RHS) No need if Ʌ is not in the language Example: S AS a A SA b Consider: a, ba, aba S a S AS bs ba S AS SAS aas abs aba 10
11 Any string of length n > 0 can be derived in exactly 2n 1 steps. Input string: x x x x x x x x n terminals (n 2) Derivation: S A B C D B E F D B S T W X Y Z D B n-1 steps n non-terminals Then 4/18/2017 replace each of the non-terminals University of Kentucky with a terminal (n steps) 11 So, totally, n-1 + n = 2n-1 steps.
12 Transform to Chomsky Normal Form (CFL contains Ʌ) Algorithm: (no start symbol occurs on right side of production) 1. If start symbol S occurs on some right side, create new start symbol S and new production S S. 2. Remove A Λ (if A S) by previous algorithm. (If S Λ is removed, add it back.) 3. Remove unit productions (i.e., A B): If A B or A + B, then construct productions A w where B w is not a unit production. Now remove all unit productions. 12 e.g., IF A B but B ac then conctruct A ac
13 Transform to Chomsky Normal Form (CFL contains Ʌ) Algorithm (conti): 4. For each production whose right side has 2 or more symbols, replace all occurrrences of each terminal a with a new nonterminal A and also add the new production A a. e.g., IF A ab then change it to A CB and create C a 5. Replace each production B C1 Cn where n > 2 with B C1D where D C2 Cn. Repeat this step until all right sides have length 2. 13
14 Transform to Chomsky Normal Form (CFL contains Ʌ) Example. Construct a Chomsky normal form for: S asb D D Dc Λ. Solution: 1. Add the production S S. S S S asb D D Dc Ʌ 2. S S Λ S asb ab D D Dc c. Why? 14
15 Transform to Chomsky Normal Form (CFL contains Ʌ) S S S asb D D Dc Ʌ Why? 2-1. The non-terminals D and S derive Ʌ 2-2. For D Dc we construct D c For S asb we construct S ab Construct S Ʌ 2. S S Λ S asb ab D D Dc c. 15
16 Transform to Chomsky Normal Form (CFL contains Ʌ) Example. Construct a Chomsky normal form for: Solution: S asb D D Dc Λ. 2. S S Λ S asb ab D D Dc c. Remove unit productions How? 3. S asb ab Dc c Λ S asb ab Dc c D Dc c. 16
17 Transform to Chomsky Normal Form (CFL contains Ʌ) How? S S S D 2. S S Λ S asb ab D D Dc c. asb ab Dc c Dc c S asb S ab S Dc S c S Dc S c 3. S asb ab Dc c Λ S asb ab Dc c D Dc c. 17
18 Transform to Chomsky Normal Form (CFL contains Ʌ) How? 3. S asb ab Dc c Λ S asb ab Dc c D Dc c. S ab S AB A a B b S Dc S DC C c 4. S ASB AB DC c Λ S ASB AB DC c D DC c A a B b 18 C c.
19 Transform to Chomsky Normal Form (CFL contains Ʌ) Example. Construct a Chomsky normal form for: S asb D D Dc Λ. Solution(conti): 4. S ASB AB DC c Λ S ASB AB DC c D DC c A a B b C c. 5. Replace S ASB and S ASB with S AE, S AE, and E SB. 19
20 Greibach Normal Form (GNF) Definition. Productions have one of the following forms: A b (terminal) A bd1 Dk S Λ. If Ʌ is in the language Example: S aas a A bsa b 20
21 Greibach Normal Form (GNF) Definition. Productions have one of the following forms: A b (terminal) A bd1 Dk S Λ. If Ʌ is in the language Advantage: Any string of length n > 0 can be derived in n steps. 21
22 Greibach Normal Form (GNF) Definition. Productions have one of the following forms: A b (terminal) A bd1 Dk S Λ. Example: Consider: a, aba, ababa S aas a A bsa b If Ʌ is in the language S a S aas abs aba S aas absas abaas ababs 22 ababa
23 Transform CFG to Greibach Normal Form Algorithm: 1. Perform steps 1, 2, 3 of the Chomsky algorithm. 2. Remove all left-recursion, including indirect, without adding Λ. 3. Make substitutions to transform the grammar into the proper form. 23
24 Transform CFG to Greibach Normal Form Example. Construct a Greibach normal form for: S AB Ac d A aa a B Ab c. Solution: Steps 1 (Chomsky steps 1, 2, 3) and 2 are not needed. Why? Chomsky: 1. create S S 2. remove A Ʌ 3. remove unit productions Greibach: 2. remove all left-recursion No need None None 24 None
25 Transform CFG to Greibach Normal Form Example. Construct a Greibach normal form for: S AB Ac d A aa a B Ab c. Solution (conti.) : 3. Replace A in S AB Ac d with aa a to obtain S aab ab aac ac d. Replace A in B Ab c with the right side of A aa a to obtain B aab ab c. S aab ab aac ac d B aab ab c A aa a 25
26 Example. Construct a Greibach normal form for: S AB Ac d A aa a B Ab c. Solution (conti.) : S aab ab aac ac d B aab ab c A aa a Now add the new productions C c and D b and make appropriate replacements to obtain the proper form: S aab ab aac ac d A aa a B aad ad c C c 26 D b
27 Properties of Context-Free Languages When we know some properties of context-free languages they can help us argue, BWOC, that certain languages are not context-free. 27
28 The Pumping Lemma intuition (1) Recall the pumping lemma for regular languages. It told us that if there was a string long enough to cause a cycle in the DFA for the language, then we could pump the cycle and discover an infinite sequence of strings that had to be in the language. xy k z L for all k 28
29 recursive Terminating mechanism The Pumping Lemma intuition (2) If L is an infinite context-free language, then any grammar for L must be recursive, so there must be derivations of the following form where u, v, w, x, and y are terminal strings. S + uny N + vnx (where v and x are not both Λ) N + w. These derivations lead to derivations like S + uny + uvnxy + uv 2 Nx 2 y + uv k Nx k y + uv k wx k y L 29 for all k N. Basis for the Pumping Lemma
30 The Pumping Lemma For every infinite context-free language L There is an integer m > 0 such that if z L and z m, then z has the form such that 1. vx 1 2. vwx m z = uvwxy 3. uv k wx k y L for all k N. m depends on the grammar 30
31 The Pumping Lemma 1. vx 1 v and x cannot both be Ʌ 2. vx vwx w could be an empty string 3. m =? 4. Why is vwx m? Start with a CNF grammar for L {Ʌ} Let the grammar have n nonterminals Pick m = 2 n 31
32 Proof of The Pumping Lemma Start with a CNF grammar for L {Ʌ} Let the grammar have n non-terminals Pick m = 2 n Let z > m We claim ( Lemma 1 ) that a parse tree with yield z must have a path of length n+2 or more 32
33 Proof of Lemma 1 If all paths in the parse tree of a CNF grammar are of length n+1, then the longest yield has length 2 n 1, as in: n nonterminals one terminal n+1 n terminals 2 n 1 terminals 33
34 Back to the Proof of the Pumping Lemma Now we know that the parse tree for z has a path with at least n+1 non-terminals (and one terminal) Consider some longest path There are only n different non-terminals, so among the lowest n+1 we can find two nodes with the same label, say A. The parse tree thus looks like: 34
35 Parse Tree in The Pumping Lemma Proof Can t both be Ʌ S 2 n = m because height of the first A can be assumed to be at most n+2. Why? 35
36 Back to the Proof of the Pumping Lemma S Longest path : non- terminal : terminal n+1 Consider the lowest n+1 non-terminals in the longest path 36
37 Back to the Proof of the Pumping Lemma S Longest path : non- terminal : terminal n+1 A A By Pigeon Hole Principle, two of the variables must have the same label, say A. 37
38 Back to the Proof of the Pumping Lemma S Longest path : non- terminal : terminal n+1 A A As a node in the lowest n+1 non-terminals, the height of the first A is at most n+2 38
39 Pump Zero Times 39
40 Pump Twice 40
41 Pump Thrice, Etc., Etc. 41
42 Using The Pumping Lemma Example. The language L = { a n b n c n+k k, n N} is not context-free. Proof: Assume, BWOC, that L is context-free. L is infinite, so pumping lemma applies. Choose z = a m b m c m from the lemma. Then z = a m b m c m = uvwxy where m is the positive integer where 1 vx vwx m and uv k wx k y L for all k N. 42
43 Example. The language L = { a n b n c n+k k, n N} is not context-free. Proof (conti.) : Observe neither v nor x can contain distinct letters. For example, if v = a b, then v 2 = a b a b, which cannot appear as a substring of any string in L. So v and x must be strings of repeated occurrences 43 of a single letter.
44 Example. The language L = { a n b n c n+k k, n N} is not context-free. Proof (conti.) : Note that since vwx m, vwx cannot extends from a m into c m. For, otherwise, as the following figure shows, the length of vwx would be m+2, a contradiction. 44
45 Example. The language L = { a n b n c n+k k, n N} is not context-free. Proof (conti.) : So we have only 5 situations to consider: (1) v and x both occur in a m (2) v and x occur in a m and b m, respectively. (3) v and x both occur in b m (4) v and x occur in b m and c m, respectively. (5) v and x both occur in c m 45
46 (1) v and x both occur in a m Let u = a p p 0 v = a i i 0 w = a q q 0 x = a j j 0; i+j > 0 y = a m p i q j b m c m But then for k=0, we have uwy = uv 0 wx 0 y = a m i j b m c m L a contradiction! 46
47 (2) v and x occur in a m and b m, respectively. Let v = a i i 0 x = b j j 0; i+j > 0 y = b q c m q 0 w = a p b m j q p 0 u = a m i p Then uv 2 wx 2 y = a m i p a 2i a p b m j q b 2j b q c m = a m+i b m+j c m L 47 a contradiction!
48 Example. The language L = { a n b n c n+k k, n N} is not context-free. Proof (conti.) : The other three cases can be proved similarly. (3) v and x both occur in b m (4) v and x occur in b m and c m, respectively. (5) v and x both occur in c m In either case, we will get a contradiction again. Hence, L is not a context-free language. 48
49 End of Context-Free Language and Pushdown Automata V * Information on several Stanford InfoLab s slides is used here 49
Solution. S ABc Ab c Bc Ac b A ABa Ba Aa a B Bbc bc.
Section 12.4 Context-Free Language Topics Algorithm. Remove Λ-productions from grammars for langauges without Λ. 1. Find nonterminals that derive Λ. 2. For each production A w construct all productions
More informationSolution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017
Solution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017 1. Find a Greibach normal form for the following given grammar. (10 points) S bab A BAa a B bb Ʌ Solution: (1) Since S does not
More informationThe Pumping Lemma for Context Free Grammars
The Pumping Lemma for Context Free Grammars Chomsky Normal Form Chomsky Normal Form (CNF) is a simple and useful form of a CFG Every rule of a CNF grammar is in the form A BC A a Where a is any terminal
More informationAC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014
Q.2 a. Show by using Mathematical Induction that n i= 1 i 2 n = ( n + 1) ( 2 n + 1) 6 b. Define language. Let = {0; 1} denote an alphabet. Enumerate five elements of the following languages: (i) Even binary
More informationBefore We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?
Before We Start The Pumping Lemma Any questions? The Lemma & Decision/ Languages Future Exam Question What is a language? What is a class of languages? Context Free Languages Context Free Languages(CFL)
More informationTheory of Computation - Module 3
Theory of Computation - Module 3 Syllabus Context Free Grammar Simplification of CFG- Normal forms-chomsky Normal form and Greibach Normal formpumping lemma for Context free languages- Applications of
More informationLecture 12 Simplification of Context-Free Grammars and Normal Forms
Lecture 12 Simplification of Context-Free Grammars and Normal Forms COT 4420 Theory of Computation Chapter 6 Normal Forms for CFGs 1. Chomsky Normal Form CNF Productions of form A BC A, B, C V A a a T
More informationProperties of Context-free Languages. Reading: Chapter 7
Properties of Context-free Languages Reading: Chapter 7 1 Topics 1) Simplifying CFGs, Normal forms 2) Pumping lemma for CFLs 3) Closure and decision properties of CFLs 2 How to simplify CFGs? 3 Three ways
More informationFinite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018
Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 14 Ana Bove May 14th 2018 Recap: Context-free Grammars Simplification of grammars: Elimination of ǫ-productions; Elimination of
More informationProperties of Context-Free Languages
Properties of Context-Free Languages Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr
More informationCS375: Logic and Theory of Computing
CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1 Tale of Contents: Week 1: Preliminaries (set algera, relations, functions) (read Chapters
More informationThe Chomsky Hierarchy(review)
The Chomsky Hierarchy(review) Languages Machines Other Moels Recursively Enumerable Sets Turing Machines Post System Markov Algorithms, µ-recursive Functions Context-sensitive Languages Context-free Languages
More informationSection 1 (closed-book) Total points 30
CS 454 Theory of Computation Fall 2011 Section 1 (closed-book) Total points 30 1. Which of the following are true? (a) a PDA can always be converted to an equivalent PDA that at each step pops or pushes
More informationThis lecture covers Chapter 7 of HMU: Properties of CFLs
This lecture covers Chapter 7 of HMU: Properties of CFLs Chomsky Normal Form Pumping Lemma for CFs Closure Properties of CFLs Decision Properties of CFLs Additional Reading: Chapter 7 of HMU. Chomsky Normal
More informationCS375 Midterm Exam Solution Set (Fall 2017)
CS375 Midterm Exam Solution Set (Fall 2017) Closed book & closed notes October 17, 2017 Name sample 1. (10 points) (a) Put in the following blank the number of strings of length 5 over A={a, b, c} that
More informationContext-Free Grammar
Context-Free Grammar CFGs are more powerful than regular expressions. They are more powerful in the sense that whatever can be expressed using regular expressions can be expressed using context-free grammars,
More informationCS311 Computational Structures More about PDAs & Context-Free Languages. Lecture 9. Andrew P. Black Andrew Tolmach
CS311 Computational Structures More about PDAs & Context-Free Languages Lecture 9 Andrew P. Black Andrew Tolmach 1 Three important results 1. Any CFG can be simulated by a PDA 2. Any PDA can be simulated
More informationCS375: Logic and Theory of Computing
CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1 Tale of Contents: Week 1: Preliminaries (set alger relations, functions) (read Chapters
More informationTAFL 1 (ECS-403) Unit- III. 3.1 Definition of CFG (Context Free Grammar) and problems. 3.2 Derivation. 3.3 Ambiguity in Grammar
TAFL 1 (ECS-403) Unit- III 3.1 Definition of CFG (Context Free Grammar) and problems 3.2 Derivation 3.3 Ambiguity in Grammar 3.3.1 Inherent Ambiguity 3.3.2 Ambiguous to Unambiguous CFG 3.4 Simplification
More informationTheory of Computation Turing Machine and Pushdown Automata
Theory of Computation Turing Machine and Pushdown Automata 1. What is a Turing Machine? A Turing Machine is an accepting device which accepts the languages (recursively enumerable set) generated by type
More informationProperties of context-free Languages
Properties of context-free Languages We simplify CFL s. Greibach Normal Form Chomsky Normal Form We prove pumping lemma for CFL s. We study closure properties and decision properties. Some of them remain,
More informationCS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL) Objectives Introduce Pumping Lemma for CFL Apply Pumping Lemma to show that some languages are non-cfl Pumping Lemma
More informationCS375: Logic and Theory of Computing
CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1 Table of Contents: Week 1: Preliminaries (set algebra, relations, functions) (read Chapters
More informationParsing. Context-Free Grammars (CFG) Laura Kallmeyer. Winter 2017/18. Heinrich-Heine-Universität Düsseldorf 1 / 26
Parsing Context-Free Grammars (CFG) Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Winter 2017/18 1 / 26 Table of contents 1 Context-Free Grammars 2 Simplifying CFGs Removing useless symbols Eliminating
More informationChapter 6. Properties of Regular Languages
Chapter 6 Properties of Regular Languages Regular Sets and Languages Claim(1). The family of languages accepted by FSAs consists of precisely the regular sets over a given alphabet. Every regular set is
More informationSimplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University
Simplification of CFG and Normal Forms Wen-Guey Tzeng Computer Science Department National Chiao Tung University Normal Forms We want a cfg with either Chomsky or Greibach normal form Chomsky normal form
More informationSimplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University
Simplification of CFG and Normal Forms Wen-Guey Tzeng Computer Science Department National Chiao Tung University Normal Forms We want a cfg with either Chomsky or Greibach normal form Chomsky normal form
More informationChapter 16: Non-Context-Free Languages
Chapter 16: Non-Context-Free Languages Peter Cappello Department of Computer Science University of California, Santa Barbara Santa Barbara, CA 93106 cappello@cs.ucsb.edu Please read the corresponding chapter
More informationIntroduction to Theory of Computing
CSCI 2670, Fall 2012 Introduction to Theory of Computing Department of Computer Science University of Georgia Athens, GA 30602 Instructor: Liming Cai www.cs.uga.edu/ cai 0 Lecture Note 3 Context-Free Languages
More informationComputational Models - Lecture 5 1
Computational Models - Lecture 5 1 Handout Mode Iftach Haitner. Tel Aviv University. November 28, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.
More informationCS20a: summary (Oct 24, 2002)
CS20a: summary (Oct 24, 2002) Context-free languages Grammars G = (V, T, P, S) Pushdown automata N-PDA = CFG D-PDA < CFG Today What languages are context-free? Pumping lemma (similar to pumping lemma for
More informationComputability Theory
CS:4330 Theory of Computation Spring 2018 Computability Theory Decidable Problems of CFLs and beyond Haniel Barbosa Readings for this lecture Chapter 4 of [Sipser 1996], 3rd edition. Section 4.1. Decidable
More informationChomsky and Greibach Normal Forms
Chomsky and Greibach Normal Forms Teodor Rus rus@cs.uiowa.edu The University of Iowa, Department of Computer Science Computation Theory p.1/25 Simplifying a CFG It is often convenient to simplify CFG One
More informationContext-Free Grammars: Normal Forms
Context-Free Grammars: Normal Forms Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr
More informationContext Free Language Properties
Context Free Language Properties Knowing that the context free languages are exactly those sets accepted by nondeterministic pushdown automata provides us a bit of information about them. We know that
More informationFinite Automata and Formal Languages TMV026/DIT321 LP Useful, Useless, Generating and Reachable Symbols
Finite Automata and Formal Languages TMV026/DIT321 LP4 2012 Lecture 13 Ana Bove May 7th 2012 Overview of today s lecture: Normal Forms for Context-Free Languages Pumping Lemma for Context-Free Languages
More informationEinführung in die Computerlinguistik
Einführung in die Computerlinguistik Context-Free Grammars formal properties Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Summer 2018 1 / 20 Normal forms (1) Hopcroft and Ullman (1979) A normal
More informationCPS 220 Theory of Computation
CPS 22 Theory of Computation Review - Regular Languages RL - a simple class of languages that can be represented in two ways: 1 Machine description: Finite Automata are machines with a finite number of
More informationÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 17 april Classrum Edition
ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK 7 april 23 Classrum Edition CONTEXT FREE LANGUAGES & PUSH-DOWN AUTOMATA CONTEXT-FREE GRAMMARS, CFG Problems Sudkamp Problem. (3.2.) Which language generates the
More informationCS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA)
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA) Objectives Introduce the Pumping Lemma for CFL Show that some languages are non- CFL Discuss the DPDA, which
More information1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.
Code No: R09220504 R09 Set No. 2 II B.Tech II Semester Examinations,December-January, 2011-2012 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 75 Answer
More informationCS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)
CS5371 Theory of Computation Lecture 7: Automata Theory V (CFG, CFL, CNF) Announcement Homework 2 will be given soon (before Tue) Due date: Oct 31 (Tue), before class Midterm: Nov 3, (Fri), first hour
More informationFoundations of Informatics: a Bridging Course
Foundations of Informatics: a Bridging Course Week 3: Formal Languages and Semantics Thomas Noll Lehrstuhl für Informatik 2 RWTH Aachen University noll@cs.rwth-aachen.de http://www.b-it-center.de/wob/en/view/class211_id948.html
More informationComputational Models - Lecture 4 1
Computational Models - Lecture 4 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 3/8, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationConcordia University Department of Computer Science & Software Engineering
Concordia University Department of Computer Science & Software Engineering COMP 335/4 Theoretical Computer Science Winter 2015 Assignment 3 1. In each case, what language is generated by CFG s below. Justify
More informationTheory of Computation
Fall 2002 (YEN) Theory of Computation Midterm Exam. Name:... I.D.#:... 1. (30 pts) True or false (mark O for true ; X for false ). (Score=Max{0, Right- 1 2 Wrong}.) (1) X... If L 1 is regular and L 2 L
More informationHomework 4. Chapter 7. CS A Term 2009: Foundations of Computer Science. By Li Feng, Shweta Srivastava, and Carolina Ruiz
CS3133 - A Term 2009: Foundations of Computer Science Prof. Carolina Ruiz Homework 4 WPI By Li Feng, Shweta Srivastava, and Carolina Ruiz Chapter 7 Problem: Chap 7.1 part a This PDA accepts the language
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be
More informationHarvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition
Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition Salil Vadhan October 11, 2012 Reading: Sipser, Section 2.3 and Section 2.1 (material on Chomsky Normal Form). Pumping Lemma for
More informationCS500 Homework #2 Solutions
CS500 Homework #2 Solutions 1. Consider the two languages Show that L 1 is context-free but L 2 is not. L 1 = {a i b j c k d l i = j k = l} L 2 = {a i b j c k d l i = k j = l} Answer. L 1 is the concatenation
More informationChap. 7 Properties of Context-free Languages
Chap. 7 Properties of Context-free Languages 7.1 Normal Forms for Context-free Grammars Context-free grammars A where A N, (N T). 0. Chomsky Normal Form A BC or A a except S where A, B, C N, a T. 1. Eliminating
More informationHarvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs
Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harry Lewis October 8, 2013 Reading: Sipser, pp. 119-128. Pushdown Automata (review) Pushdown Automata = Finite automaton
More informationThe View Over The Horizon
The View Over The Horizon enumerable decidable context free regular Context-Free Grammars An example of a context free grammar, G 1 : A 0A1 A B B # Terminology: Each line is a substitution rule or production.
More informationNotes for Comp 497 (Comp 454) Week 10 4/5/05
Notes for Comp 497 (Comp 454) Week 10 4/5/05 Today look at the last two chapters in Part II. Cohen presents some results concerning context-free languages (CFL) and regular languages (RL) also some decidability
More informationINSTITUTE OF AERONAUTICAL ENGINEERING
INSTITUTE OF AERONAUTICAL ENGINEERING DUNDIGAL 500 043, HYDERABAD COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : FORMAL LANGUAGES AND AUTOMATA THEORY Course Code : A40509 Class :
More informationNon-context-Free Languages. CS215, Lecture 5 c
Non-context-Free Languages CS215, Lecture 5 c 2007 1 The Pumping Lemma Theorem. (Pumping Lemma) Let be context-free. There exists a positive integer divided into five pieces, Proof for for each, and..
More informationOgden s Lemma. and Formal Languages. Automata Theory CS 573. The proof is similar but more fussy. than the proof of the PL4CFL.
CS 573 Automata Theory and Formal Languages Professor Leslie Lander Lecture # 24 December 4, 2000 Ogden s Lemma (6.2) Let L be a CFL, then there is a constant n such that if z is a word in L with z > n
More information(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},
Code No: 07A50501 R07 Set No. 2 III B.Tech I Semester Examinations,MAY 2011 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 80 Answer any FIVE Questions All
More informationdownload instant at Assume that (w R ) R = w for all strings w Σ of length n or less.
Chapter 2 Languages 3. We prove, by induction on the length of the string, that w = (w R ) R for every string w Σ. Basis: The basis consists of the null string. In this case, (λ R ) R = (λ) R = λ as desired.
More informationComputational Models - Lecture 4
Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push
More informationNPDA, CFG equivalence
NPDA, CFG equivalence Theorem A language L is recognized by a NPDA iff L is described by a CFG. Must prove two directions: ( ) L is recognized by a NPDA implies L is described by a CFG. ( ) L is described
More informationNote: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules).
Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules). 1a) G = ({R, S, T}, {0,1}, P, S) where P is: S R0R R R0R1R R1R0R T T 0T ε (S generates the first 0. R generates
More informationEXAMPLE CFG. L = {a 2n : n 1 } L = {a 2n : n 0 } S asa aa. L = {a n b : n 0 } L = {a n b : n 1 } S asb ab S 1S00 S 1S00 100
EXAMPLE CFG L = {a 2n : n 1 } L = {a 2n : n 0 } S asa aa S asa L = {a n b : n 0 } L = {a n b : n 1 } S as b S as ab L { a b : n 0} L { a b : n 1} S asb S asb ab n 2n n 2n L {1 0 : n 0} L {1 0 : n 1} S
More informationSt.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad
St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad-500 014 Subject: FORMAL LANGUAGES AND AUTOMATA THEORY Class : CSE II PART A (SHORT ANSWER QUESTIONS) UNIT- I 1 Explain transition diagram, transition
More informationPart 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX
Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu Part 4 out of 5 ETH Zürich (D-ITET) October, 12 2017 Last week, we showed the equivalence of DFA, NFA and REX
More informationCS 373: Theory of Computation. Fall 2010
CS 373: Theory of Computation Gul Agha Mahesh Viswanathan Fall 2010 1 1 Normal Forms for CFG Normal Forms for Grammars It is typically easier to work with a context free language if given a CFG in a normal
More informationQuestion Bank UNIT I
Siddhivinayak Technical Campus School of Engineering & Research Technology Department of computer science and Engineering Session 2016-2017 Subject Name- Theory of Computation Subject Code-4KS05 Sr No.
More informationContext-Free Languages
CS:4330 Theory of Computation Spring 2018 Context-Free Languages Non-Context-Free Languages Haniel Barbosa Readings for this lecture Chapter 2 of [Sipser 1996], 3rd edition. Section 2.3. Proving context-freeness
More informationContext Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages
Context Free Languages Automata Theory and Formal Grammars: Lecture 6 Context Free Languages Last Time Decision procedures for FAs Minimum-state DFAs Today The Myhill-Nerode Theorem The Pumping Lemma Context-free
More informationContext-Free Languages (Pre Lecture)
Context-Free Languages (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Context-Free Languages (Pre Lecture) Fall 2017 1 / 34 Outline Pumping Lemma
More informationAC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013
Q.2 a. Prove by mathematical induction n 4 4n 2 is divisible by 3 for n 0. Basic step: For n = 0, n 3 n = 0 which is divisible by 3. Induction hypothesis: Let p(n) = n 3 n is divisible by 3. Induction
More informationNotes for Comp 497 (454) Week 10
Notes for Comp 497 (454) Week 10 Today we look at the last two chapters in Part II. Cohen presents some results concerning the two categories of language we have seen so far: Regular languages (RL). Context-free
More informationHomework 4 Solutions. 2. Find context-free grammars for the language L = {a n b m c k : k n + m}. (with n 0,
Introduction to Formal Language, Fall 2016 Due: 21-Apr-2016 (Thursday) Instructor: Prof. Wen-Guey Tzeng Homework 4 Solutions Scribe: Yi-Ruei Chen 1. Find context-free grammars for the language L = {a n
More informationAutomata Theory CS F-08 Context-Free Grammars
Automata Theory CS411-2015F-08 Context-Free Grammars David Galles Department of Computer Science University of San Francisco 08-0: Context-Free Grammars Set of Terminals (Σ) Set of Non-Terminals Set of
More informationPlan for 2 nd half. Just when you thought it was safe. Just when you thought it was safe. Theory Hall of Fame. Chomsky Normal Form
Plan for 2 nd half Pumping Lemma for CFLs The Return of the Pumping Lemma Just when you thought it was safe Return of the Pumping Lemma Recall: With Regular Languages The Pumping Lemma showed that if a
More information6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs
CSC4510/6510 AUTOMATA 6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs The Pumping Lemma for Context Free Languages One way to prove AnBn is not regular is to use the pumping lemma
More informationCS A Term 2009: Foundations of Computer Science. Homework 2. By Li Feng, Shweta Srivastava, and Carolina Ruiz.
CS3133 - A Term 2009: Foundations of Computer Science Prof. Carolina Ruiz Homework 2 WPI By Li Feng, Shweta Srivastava, and Carolina Ruiz Chapter 4 Problem 1: (10 Points) Exercise 4.3 Solution 1: S is
More informationSheet 1-8 Dr. Mostafa Aref Format By : Mostafa Sayed
Sheet -8 Dr. Mostafa Aref Format By : Mostafa Sayed 09 Introduction Assignment. For = {a, } a) Write 0 strings of the following languages i) All strings with no more than one a,,, a, a, a, a, a, a, a ii)
More informationSFWR ENG 2FA3. Solution to the Assignment #4
SFWR ENG 2FA3. Solution to the Assignment #4 Total = 131, 100%= 115 The solutions below are often very detailed on purpose. Such level of details is not required from students solutions. Some questions
More informationContext Free Languages and Grammars
Algorithms & Models of Computation CS/ECE 374, Fall 2017 Context Free Languages and Grammars Lecture 7 Tuesday, September 19, 2017 Sariel Har-Peled (UIUC) CS374 1 Fall 2017 1 / 36 What stack got to do
More informationV Honors Theory of Computation
V22.0453-001 Honors Theory of Computation Problem Set 3 Solutions Problem 1 Solution: The class of languages recognized by these machines is the exactly the class of regular languages, thus this TM variant
More informationFall 1999 Formal Language Theory Dr. R. Boyer. Theorem. For any context free grammar G; if there is a derivation of w 2 from the
Fall 1999 Formal Language Theory Dr. R. Boyer Week Seven: Chomsky Normal Form; Pumping Lemma 1. Universality of Leftmost Derivations. Theorem. For any context free grammar ; if there is a derivation of
More informationCISC4090: Theory of Computation
CISC4090: Theory of Computation Chapter 2 Context-Free Languages Courtesy of Prof. Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 Overview In Chapter
More informationAutomata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,
Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) October, 5 2017 Part 3 out of 5 Last week, we learned about closure and equivalence of regular
More informationPart 3 out of 5. Automata & languages. A primer on the Theory of Computation. Last week, we learned about closure and equivalence of regular languages
Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu Part 3 out of 5 ETH Zürich (D-ITET) October, 5 2017 Last week, we learned about closure and equivalence of regular
More informationDefinition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where
Recitation 11 Notes Context Free Grammars Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x A V, and x (V T)*. Examples Problem 1. Given the
More informationMA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation Bottom-up parsing Pumping Theorem for CFLs Recap: Going One Way Lemma: Each context-free language is accepted by some PDA. Proof (by construction): The idea: Let the stack
More informationComputational Models - Lecture 3
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models - Lecture 3 Equivalence of regular expressions and regular languages (lukewarm leftover
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Chomsky Normal Form and TURING MACHINES TUESDAY Feb 4 CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form:
More informationPushdown Automata. Reading: Chapter 6
Pushdown Automata Reading: Chapter 6 1 Pushdown Automata (PDA) Informally: A PDA is an NFA-ε with a infinite stack. Transitions are modified to accommodate stack operations. Questions: What is a stack?
More informationHW 3 Solutions. Tommy November 27, 2012
HW 3 Solutions Tommy November 27, 2012 5.1.1 (a) Online solution: S 0S1 ɛ. (b) Similar to online solution: S AY XC A aa ɛ b ɛ C cc ɛ X axb aa b Y by c b cc (c) S X A A A V AV a V V b V a b X V V X V (d)
More informationLanguages, regular languages, finite automata
Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,
More informationAn automaton with a finite number of states is called a Finite Automaton (FA) or Finite State Machine (FSM).
Automata The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled computing device which follows a predetermined
More informationAutomata Theory. CS F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages. David Galles
Automata Theory CS411-2015F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages David Galles Department of Computer Science University of San Francisco 10-0: Fun with CFGs Create
More informationTalen en Compilers. Johan Jeuring , period 2. October 29, Department of Information and Computing Sciences Utrecht University
Talen en Compilers 2015-2016, period 2 Johan Jeuring Department of Information and Computing Sciences Utrecht University October 29, 2015 12. LL parsing 12-1 This lecture LL parsing Motivation Stack-based
More informationCSE 105 Homework 5 Due: Monday November 13, Instructions. should be on each page of the submission.
CSE 05 Homework 5 Due: Monday November 3, 207 Instructions Upload a single file to Gradescope for each group. should be on each page of the submission. All group members names and PIDs Your assignments
More informationOgden s Lemma for CFLs
Ogden s Lemma for CFLs Theorem If L is a context-free language, then there exists an integer l such that for any u L with at least l positions marked, u can be written as u = vwxyz such that 1 x and at
More informationTheory Of Computation UNIT-II
Regular Expressions and Context Free Grammars: Regular expression formalism- equivalence with finite automata-regular sets and closure properties- pumping lemma for regular languages- decision algorithms
More informationCPSC 313 Introduction to Computability
CPSC 313 Introduction to Computability Grammars in Chomsky Normal Form (Cont d) (Sipser, pages 109-111 (3 rd ed) and 107-109 (2 nd ed)) Renate Scheidler Fall 2018 Chomsky Normal Form A context-free grammar
More informationDD2371 Automata Theory
KTH CSC VT 2008 DD2371 Automata Theory Dilian Gurov Lecture Outline 1. The lecturer 2. Introduction to automata theory 3. Course syllabus 4. Course objectives 5. Course organization 6. First definitions
More information