EXAMPLE 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
|
|
- Richard Anderson
- 6 years ago
- Views:
Transcription
1 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 1S00 S 1S L = { ww R : w { a, b}*} L = { ww R : w { a, b} } asa bsb S S asa bsb aa bb n m k L { a b c : n 0, m 0, k 0} C A aa B bb C cc L { a b : n 0} { b a : n 0} S S S S S as b 1 bs 2 2 a L { a b b : n 0} S Ab L = { a n b n c k : n, k 0 } S AC C cc L = {a n b n c i : n 1, i 0} A aab ab B cb
2 L = {a j b n c n : n 1, j 0} A aa B bbc bc L = {a n b n+m c m n, m 0} L = {a n b n+m c m n, m 1} A aab ab B bbc B bbc bc L = {a n ba n : n 0} S asa B B b L = {a n b m c n : n, m 0} L = {a n b m c n : n, m 1} S asc A S asc aac A ba A ba b L { ab cd f : n 0} S aaf A bad c L={a i b j c k d l a l b k c j d i i, j, k, l 0} S asd A A bac B B cbb C C dca L = {a n b m c 2n+m : n, m > 0} Here a n b m c 2n+m = a n b m c m c 2n S ascc A A bac bc L = { (ab} i (cd )j (ba) j (dc) i i, j 0 } S absdc A A cdaba L = {a n b m a m b n : n, m 0} S asb A A baa L = {a n b m a m b n : n, m 1} S asb aab A baa ba
3 R L = { wc * w : w { a, b}*} S C asa bsb C Cc L = {a i b j c k i = j+k } a i b j c k = a j+k b j c k = a k a j b j c k S asc A L = {a i b j c k j = i+k } a i b j c k = a i b i+k c k = a i b i b k c k B bac L = {a i b j c k k = i+j } a i b j c k = a i b j c i+j = a i b j c j c i S asc A A bac L = {a i b j c k j=i or j=k} Here the language is union of two language L 1 = {a i b j c k j=i} and L 2 = {a i b j c k j=k} L 1 = {a i b j c k j=i} a i b j c k = a i b i c k A CD D cd L 1 = {a i b j c k j=k} a i b j c k = a i b k c k B EF E ae F bfc The grammar for L is S A B A CD D cd B EF E ae F bfc L = {a i b j c k i=j or i=k} Here the language is union of two language L 1 = {a i b j c k i=j} and L 2 = {a i b j c k i=k}
4 L 1 = {a i b j c k i=j} a i b j c k = a j b j c k A CD D cd L 1 = {a i b j c k i=k} a i b j c k = a k b j c k B abc E E be The grammar for L is S A B A CD D cd B abc E E be L = {a i b j c k k=i or k=j} Here the language is union of two language L 1 = {a i b j c k k=i } and L 2 = {a i b j c k k=j } L 1 = {a i b j c k k=i } a i b j c k = a i b j c i A aac C C bc L 1 = {a i b j c k k=j} a i b j c k = a i b j c j B EF E ae F bfc The grammar for L is S A B A aac C C bc B EF E ae F bfc L = {0 i 1 j 0 k j > i+k, i. k 0} Let j = i+k+m where m > 0 0 i 1 j 0 k = 0 i 1 i+m+k 0 k = 0 i 1 i 1 m 1 k 0 k L = L 1 L 2 L 3 L 1 = {0 i 1 i : i 0 } L 2 = {1 m : m > 0 } L 3 = {1 k 0 k : k 0 } C A 0A1 B 1B 1 C 1C0
5 L = {a i b j c k i < j or i> k} Here the language is union of two language L 1 = {a i b j c k i<j} and L 2 = {a i b j c k i>k} L 1 = {a i b j c k i < j} Let j = i+m where m 1 a i b j c k = a i b i+m c i = a i b i b m c k A CDE D bd b E ce L 1 = {a i b j c k i>k } Let i= k+m where where m 1 a i b j c k = a k+m b j c k = a m a k b j c k B FG F af a G agc H H bh The grammar is S A B A CDE D bd b E ce B FG F af a G agc H H bh L = {a n b m 2n m 3n} S asbb asbbb L = {a n b m : n 2, m 3} S asb as Sb aabbb i j L { a b : i j} S X Y ( L = L(x) L(y)) X axb ax a ( L(x)= { a i b j ; i>j }) Y ayb Yb b ( L(y)= { a i b j ; i<j }) m n L { 0 1 : m n, n, m 1} S 0A1 0B1 A 0A1 0A 0 B 0B1 1B 1 n m L { a b : m n, m, n 1} S asb aa bb a b A aa a B bb b n m p L { a b c : n m p} S Sc asc Ac aac A Ab aab
6 L = { a n b m : n m+3 } S asb A B A a aa aaa B bb L = { a n b m : n m-1 } S asb A B A aa B bb bb L = {0 n 1 m 0 n : n+m 2} case I: case II: case III: n a = n b in L 3 n a - n b 0 in L n a < n b in L Here L is union of 111*, 011*0 and L= {0 n 1*0 n : n 1} S S 1 S 2 S 3 S 1 1 S 1 11 A 1A S 2 01A0 S 3 0 S 3 0 0A0 The set of all string over alphabet {a,b} with exactly twice as many a s as b s S SaSbSaS SaSaSbS SbSaSaS The set of all string over alphabet {a,b} not of the form WW for some string W. S aba bab as bs A ba b B ab a The set of all string over alphabet {0,1} with at least three 1s S A1A1A1A A 0A 1A 0 1 The set of all string over alphabet {0,1} which starts and ends with same symbol S 0A0 1A1 A 0A 1A 0 1 The set of all string over alphabet {0,1} which length is odd RE = ((0+1) (0+1))*(0+1) The grammar is S CA A 0 1 (RE : (0+1) ) B AA (RE : (0+1)(0+1)) C BC (RE: ((0+1)(0+1))*) The set of odd length strings in {a,b}* with middle symbol a. S asa bsb asb bsa a
7 The set of even length strings in {a,b}* with two middle symbols equal S asa bsb asb bsa aa bb The set of odd length strings in {a,b}* whose first, middle and last symbols are all the same. S aaa bbb A aaa bab aab baa a B aba bbb abb bba b Construct grammar which generates all integers S DS D D Construct grammar which generates all even integers up to 998 S AS 1 AAS 1 A S L = { a i b j c k d l i+k=j+l } S asd ABC A aab B bbc C ccd L = { a i b j c k d l i+j=k+l } S asd B C B abc A C bcd A A bac A represent {b j c j j > 0} B represent {a i b j c k i+j = k & i,j,k > 0} a i b j c j c i C represent {b j c k d l k+l=j & i,j,k > 0} b l b k c k d l L = {a i b j c k : i j or i k or j k } Here given language is union of following three languages L = {a i b j c k : i j, k 0 } {a i b j c k : i k, j 0 } {a i b j c k : j k, i 0 } The first language {a i b j c k : i j, k 0 } is the concatenation of {a i b j : i j } with {c k : k 0 } S 1 S 11 S 12 S 11 X Y ( L = L(x) L(y)) X axb ax a ( L(x)= { a i b j ; i>j }) Y ayb Yb b ( L(y)= { a i b j ; i<j }) S 12 cs 12
8 The third language {a i b j c k : j k, k 0 } is the concatenation of {a i : i 0 } with {b j c k : j k } S 3 S 31 S 32 S 31 as 31 S 32 W Z ( L = L(w) L(z)) W bwc bw b ( L(w)= { b j c k ; j>k }) Z bzc Zc c ( L(z)= { b j c k j<k}) The second language {a i b j c k : i k, j 0 }, may be written as: L 1 L 2 L 2 L 3 where L 1 = {a n : n 1}, L 2 = {a n b m c n : n, m 0 }, and L 3 = {c n : n 1}. S 2 S 21 S 22 S 21 AB A aa a B abc B B bb S 22 BC C cc c The CFG of the language {a i b j c k : i j, k 0 } {a i b j c k : i k, j 0 } {a i b j c k : j k, i 0 } is S S 1 S 2 S 3 S 1 S 11 S 12 S 11 X Y ( L = L(x) L(y)) X axb ax a ( L(x)= { a i b j ; i>j }) Y ayb Yb b ( L(y)= { a i b j ; i<j }) S 12 cs 12 S 2 S 21 S 22 S 21 AB A aa a B abc B B bb S 22 BC C cc c S 3 S 31 S 32 S 31 as 31 S 32 W Z ( L = L(w) L(z)) W bwc bw b ( L(w)= { b j c k ; j>k }) Z bzc Zc c ( L(z)= { b j c k j<k})
5.A Examples of Context-Free Grammars 3.1 and 3.2 of Du & Ko s book(pp )
5.A Examples of Context-Free Grammars 3.1 and 3.2 of Du & Ko s book(pp. 91-108) Example 3.1 Consider S ε asb. What is L(S)? Solution S asb aasbb a n Sb n a n b n. L(S) = {a n b n n 0} Example 3.2 Consider
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 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 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 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 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 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 informationProblem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y.
CSE2001, Fall 2006 1 Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y. S 00S1 A - xay, where x = 2 y.
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 informationTheory of Computer Science
Theory of Computer Science C1. Formal Languages and Grammars Malte Helmert University of Basel March 14, 2016 Introduction Example: Propositional Formulas from the logic part: Definition (Syntax of Propositional
More informationRecitation 4: Converting Grammars to Chomsky Normal Form, Simulation of Context Free Languages with Push-Down Automata, Semirings
Recitation 4: Converting Grammars to Chomsky Normal Form, Simulation of Context Free Languages with Push-Down Automata, Semirings 11-711: Algorithms for NLP October 10, 2014 Conversion to CNF Example grammar
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 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 informationCS 133 : Automata Theory and Computability
CS 133 : Automata Theory and Computability Lecture Slides 1 Regular Languages and Finite Automata Nestine Hope S. Hernandez Algorithms and Complexity Laboratory Department of Computer Science University
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 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 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 informationCFG Simplification. (simplify) 1. Eliminate useless symbols 2. Eliminate -productions 3. Eliminate unit productions
CFG Simplification (simplify) 1. Eliminate useless symbols 2. Eliminate -productions 3. Eliminate unit productions 1 Eliminating useless symbols 1. A symbol X is generating if there exists: X * w, for
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 informationC1.1 Introduction. Theory of Computer Science. Theory of Computer Science. C1.1 Introduction. C1.2 Alphabets and Formal Languages. C1.
Theory of Computer Science March 20, 2017 C1. Formal Languages and Grammars Theory of Computer Science C1. Formal Languages and Grammars Malte Helmert University of Basel March 20, 2017 C1.1 Introduction
More informationCSEP 590 Data Compression Autumn Arithmetic Coding
CSEP 590 Data Compression Autumn 2007 Arithmetic Coding Reals in Binary Any real number x in the interval [0,1) can be represented in binary as.b 1 b 2... where b i is a bit. x 0 0 1 0 1... binary representation
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 informationSolutions to Problem Set 3
V22.0453-001 Theory of Computation October 8, 2003 TA: Nelly Fazio Solutions to Problem Set 3 Problem 1 We have seen that a grammar where all productions are of the form: A ab, A c (where A, B non-terminals,
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 informationA Universal Turing Machine
A Universal Turing Machine A limitation of Turing Machines: Turing Machines are hardwired they execute only one program Real Computers are re-programmable Solution: Universal Turing Machine Attributes:
More informationAutomata Theory Final Exam Solution 08:10-10:00 am Friday, June 13, 2008
Automata Theory Final Exam Solution 08:10-10:00 am Friday, June 13, 2008 Name: ID #: This is a Close Book examination. Only an A4 cheating sheet belonging to you is acceptable. You can write your answers
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 informationVTU QUESTION BANK. Unit 1. Introduction to Finite Automata. 1. Obtain DFAs to accept strings of a s and b s having exactly one a.
VTU QUESTION BANK Unit 1 Introduction to Finite Automata 1. Obtain DFAs to accept strings of a s and b s having exactly one a.(5m )( Dec-2014) 2. Obtain a DFA to accept strings of a s and b s having even
More informationSolution. 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 informationCSCI 340: Computational Models. Regular Expressions. Department of Computer Science
CSCI 340: Computational Models Regular Expressions Chapter 4 Department of Computer Science Yet Another New Method for Defining Languages Given the Language: L 1 = {x n for n = 1 2 3...} We could easily
More informationINTRO TO I & CT. (Boolean Algebra and Logic Simplification.) Lecture # By: Department of CS & IT.
INTRO TO I & CT. (Boolean Algebra and Logic Simplification.) Lecture # 13-14 By: M.Nadeem Akhtar. Department of CS & IT. URL: https://sites.google.com/site/nadeemcsuoliict/home/lectures 1 Boolean Algebra
More informationCOSE212: Programming Languages. Lecture 1 Inductive Definitions (1)
COSE212: Programming Languages Lecture 1 Inductive Definitions (1) Hakjoo Oh 2017 Fall Hakjoo Oh COSE212 2017 Fall, Lecture 1 September 4, 2017 1 / 9 Inductive Definitions Inductive definition (induction)
More informationLecture 11 Context-Free Languages
Lecture 11 Context-Free Languages COT 4420 Theory of Computation Chapter 5 Context-Free Languages n { a b : n n { ww } 0} R Regular Languages a *b* ( a + b) * Example 1 G = ({S}, {a, b}, S, P) Derivations:
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 informationREGular and Context-Free Grammars
REGular and Context-Free Grammars Nicholas Mainardi 1 Dipartimento di Elettronica e Informazione Politecnico di Milano nicholas.mainardi@polimi.it March 26, 2018 1 Partly Based on Alessandro Barenghi s
More informationFABER Formal Languages, Automata. Lecture 2. Mälardalen University
CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2010 1 Content Languages, g Alphabets and Strings Strings & String Operations Languages & Language Operations
More informationSemigroup presentations via boundaries in Cayley graphs 1
Semigroup presentations via boundaries in Cayley graphs 1 Robert Gray University of Leeds BMC, Newcastle 2006 1 (Research conducted while I was a research student at the University of St Andrews, under
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 informationProperties of Context Free Languages
1 Properties of Context Free Languages Pallab Dasgupta, Professor, Dept. of Computer Sc & Engg 2 Theorem: CFLs are closed under concatenation If L 1 and L 2 are CFLs, then L 1 L 2 is a CFL. Proof: 1. Let
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 informationCOSE212: Programming Languages. Lecture 1 Inductive Definitions (1)
COSE212: Programming Languages Lecture 1 Inductive Definitions (1) Hakjoo Oh 2018 Fall Hakjoo Oh COSE212 2018 Fall, Lecture 1 September 5, 2018 1 / 10 Inductive Definitions Inductive definition (induction)
More informationAuthor: Vivek Kulkarni ( )
Author: Vivek Kulkarni ( vivek_kulkarni@yahoo.com ) Chapter-3: Regular Expressions Solutions for Review Questions @ Oxford University Press 2013. All rights reserved. 1 Q.1 Define the following and give
More information1 Alphabets and Languages
1 Alphabets and Languages Look at handout 1 (inference rules for sets) and use the rules on some examples like {a} {{a}} {a} {a, b}, {a} {{a}}, {a} {{a}}, {a} {a, b}, a {{a}}, a {a, b}, a {{a}}, a {a,
More informationLinear conjunctive languages are closed under complement
Linear conjunctive languages are closed under complement Alexander Okhotin okhotin@cs.queensu.ca Technical report 2002-455 Department of Computing and Information Science, Queen s University, Kingston,
More informationA B CDE F B FD D A C AF DC A F
International Journal of Arts & Sciences, CD-ROM. ISSN: 1944-6934 :: 4(20):121 131 (2011) Copyright c 2011 by InternationalJournal.org A B CDE F B FD D A C A BC D EF C CE C A D ABC DEF B B C A E E C A
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 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 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 informationPlease give details of your answer. A direct answer without explanation is not counted.
Please give details of your answer. A direct answer without explanation is not counted. Your answers must be in English. Please carefully read problem statements. During the exam you are not allowed to
More informationTheory of Computation
Theory of Computation Lecture #2 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 1 Lecture 2: Overview Recall some basic definitions from Automata Theory.
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 informationcse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska
cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 11 CHAPTER 3 CONTEXT-FREE LANGUAGES 1. Context Free Grammars 2. Pushdown Automata 3. Pushdown automata and context -free
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 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 information60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor
60-354, Theory of Computation Fall 2013 Asish Mukhopadhyay School of Computer Science University of Windsor Pushdown Automata (PDA) PDA = ε-nfa + stack Acceptance ε-nfa enters a final state or Stack is
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Regular Expressions and Finite Automata CMSC 330 Spring 2017 1 How do regular expressions work? What we ve learned What regular expressions are What they
More informationHarvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries
Harvard CS121 and CSCI E-121 Lecture 2: Mathematical Preliminaries Harry Lewis September 5, 2013 Reading: Sipser, Chapter 0 Sets Sets are defined by their members A = B means that for every x, x A iff
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 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 informationChapter 1. Introduction
Chapter Introduction.0 BASICS.0. Sets A set is a collection of objects. For example, the collection of four letters a, b, c and d is a set, which is written as L ={a, b, c, d } The objects comprising a
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 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 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 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 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 informationChapter 4. Regular Expressions. 4.1 Some Definitions
Chapter 4 Regular Expressions 4.1 Some Definitions Definition: If S and T are sets of strings of letters (whether they are finite or infinite sets), we define the product set of strings of letters to be
More informationSection 1.3 Ordered Structures
Section 1.3 Ordered Structures Tuples Have order and can have repetitions. (6,7,6) is a 3-tuple () is the empty tuple A 2-tuple is called a pair and a 3-tuple is called a triple. We write (x 1,, x n )
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 informationCMSC 330: Organization of Programming Languages. Regular Expressions and Finite Automata
CMSC 330: Organization of Programming Languages Regular Expressions and Finite Automata CMSC330 Spring 2018 1 How do regular expressions work? What we ve learned What regular expressions are What they
More informationDeveloping a Distributed Java-based Speech Recognition Engine
The ITB Journal Volume 5 Issue 1 Article 2 2004 Developing a Distributed Java-based Speech Recognition Engine Tony Ayers Institute of Technology Blanchardstown, tony.ayers@itb.ie Brian Nolan Institute
More informationIn English, there are at least three different types of entities: letters, words, sentences.
Chapter 2 Languages 2.1 Introduction In English, there are at least three different types of entities: letters, words, sentences. letters are from a finite alphabet { a, b, c,..., z } words are made up
More informationRecursive descent for grammars with contexts
39th International Conference on Current Trends in Theory and Practice of Computer Science Špindleruv Mlýn, Czech Republic Recursive descent parsing for grammars with contexts Ph.D. student, Department
More informationFundamentele Informatica II
Fundamentele Informatica II Answer to selected exercises 5 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 5.1.a (q 0, ab, Z 0 ) (q 1, b,
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 information5/10/16. Grammar. Automata and Languages. Today s Topics. Grammars Definition A grammar G is defined as G = (V, T, P, S) where:
Grammar Automata and Languages Grammar Prof. Mohamed Hamada oftware Engineering Lab. The University of Aizu Japan Regular Grammar Context-free Grammar Context-sensitive Grammar Left-linear Grammar right-linear
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 informationBasic Principles of Lossless Coding. Universal Lossless coding. Lempel-Ziv Coding. 2. Exploit dependences between successive symbols.
Universal Lossless coding Lempel-Ziv Coding Basic principles of lossless compression Historical review Variable-length-to-block coding Lempel-Ziv coding 1 Basic Principles of Lossless Coding 1. Exploit
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 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 information1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,
1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u, v, x, y, z as per the pumping theorem. 3. Prove that
More informationLecture 7 Properties of regular languages
Lecture 7 Properties of regular languages COT 4420 Theory of Computation Section 4.1 Closure properties of regular languages If L 1 and L 2 are regular languages, then we prove that: Union: L 1 L 2 Concatenation:
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 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 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 informationTriangles. 3.In the following fig. AB = AC and BD = DC, then ADC = (A) 60 (B) 120 (C) 90 (D) none 4.In the Fig. given below, find Z.
Triangles 1.Two sides of a triangle are 7 cm and 10 cm. Which of the following length can be the length of the third side? (A) 19 cm. (B) 17 cm. (C) 23 cm. of these. 2.Can 80, 75 and 20 form a triangle?
More informationPentagonal quasigroups. 1. Introduction
Quasigroups and Related Systems 22 (2014), 147 158 Pentagonal quasigroups Stipe Vidak Abstract. The concept of pentagonal quasigroup is introduced as IM-quasigroup satisfying the additional property of
More informationRegular Expressions [1] Regular Expressions. Regular expressions can be seen as a system of notations for denoting ɛ-nfa
Regular Expressions [1] Regular Expressions Regular expressions can be seen as a system of notations for denoting ɛ-nfa They form an algebraic representation of ɛ-nfa algebraic : expressions with equations
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 informationThe Probability of Winning a Series. Gregory Quenell
The Probability of Winning a Series Gregory Quenell Exercise: Team A and Team B play a series of n + games. The first team to win n + games wins the series. All games are independent, and Team A wins any
More informationDynamic Programming. Shuang Zhao. Microsoft Research Asia September 5, Dynamic Programming. Shuang Zhao. Outline. Introduction.
Microsoft Research Asia September 5, 2005 1 2 3 4 Section I What is? Definition is a technique for efficiently recurrence computing by storing partial results. In this slides, I will NOT use too many formal
More informationTheory of Computation (Classroom Practice Booklet Solutions)
Theory of Computation (Classroom Practice Booklet Solutions) 1. Finite Automata & Regular Sets 01. Ans: (a) & (c) Sol: (a) The reversal of a regular set is regular as the reversal of a regular expression
More informationThe state numbers of a knot
ILDT2014 RIMS, Kyoto University 21 May 2014 The state numbers of a knot Takuji NAKAMURA (Osaka Electro-Communication University) Joint work with Y. NAKANISHI, S. Satoh and Y. Tomiyama (Kobe University)
More informationIsolation and Contentment in Segregation Games with Three Types
Student Projects Isolation and Contentment in Segregation Games with Three Types Mark Burek, Brian McDonough, Spencer Roach Mark Burek is finishing up his undergraduate work in mathematics at Valparaiso
More informationD EFB B E B EAB ABC DEF C A F C D C DEF C AD C AEC D D E C D EF B ABC AB CD A EFD AD D E
D EFB B E BEAB ABC DEF C A F C D C DEF C AD C AEC D D E A B C D EF B ABC AB CD A EFD AD D E FFF A B FBC AE BC D AD A D F D F D F D D B D A D A ED D D DD F D D D D A A DA ADD D F AD AD C A DD D D F D A
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 informationRegularity-preserving letter selections
Regularity-preserving letter selections Armando B. Matos LIACC, Universidade do Porto Rua do Campo Alegre 823, 4150 Porto, Portugal 1 Introduction and definitions Seiferas and McNaughton gave in [SM76]
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 informationCSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.
CSE 5 Homework Due: Monday October 9, 7 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 in this
More informationCS 341 Homework 16 Languages that Are and Are Not Context-Free
CS 341 Homework 16 Languages that Are and Are Not Context-Free 1. Show that the following languages are context-free. You can do this by writing a context free grammar or a PDA, or you can use the closure
More information