Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)

Similar documents
Formal Languages and Automata

Regular expressions, Finite Automata, transition graphs are all the same!!

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Theory of Computation Regular Languages

Regular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15

Convert the NFA into DFA

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Lecture 08: Feb. 08, 2019

Lecture 09: Myhill-Nerode Theorem

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

Lecture 6 Regular Grammars

Thoery of Automata CS402

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

Harvard University Computer Science 121 Midterm October 23, 2012

Some Theory of Computation Exercises Week 1

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

Minimal DFA. minimal DFA for L starting from any other

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Fundamentals of Computer Science

Chapter 1, Part 1. Regular Languages. CSC527, Chapter 1, Part 1 c 2012 Mitsunori Ogihara 1

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

CS375: Logic and Theory of Computing

Formal languages, automata, and theory of computation

Closure Properties of Regular Languages

CS 275 Automata and Formal Language Theory

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

First Midterm Examination

FABER Formal Languages, Automata and Models of Computation

Worked out examples Finite Automata

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Automata and Languages

1 Nondeterministic Finite Automata

Finite Automata-cont d

1.4 Nonregular Languages

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

1 From NFA to regular expression

CHAPTER 1 Regular Languages. Contents

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

Solutions Problem Set 2. Problem (a) Let M denote the DFA constructed by swapping the accept and non-accepting state in M.

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

Homework 3 Solutions

Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15

CMSC 330: Organization of Programming Languages

Designing finite automata II

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

CS375: Logic and Theory of Computing

CISC 4090 Theory of Computation

Chapter 2 Finite Automata

For convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

State Minimization for DFAs

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS

First Midterm Examination

Non-Deterministic Finite Automata

Non-deterministic Finite Automata

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

Formal Methods in Software Engineering

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Lecture 9: LTL and Büchi Automata

Overview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch.

1.3 Regular Expressions

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Nondeterminism and Nodeterministic Automata

Homework Solution - Set 5 Due: Friday 10/03/08

CS 330 Formal Methods and Models

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

Formal Language and Automata Theory (CS21004)

CS 330 Formal Methods and Models

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

Coalgebra, Lecture 15: Equations for Deterministic Automata

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

NON-DETERMINISTIC FSA

Name Ima Sample ASU ID

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

NFAs continued, Closure Properties of Regular Languages

On Determinisation of History-Deterministic Automata.

CS 275 Automata and Formal Language Theory

I. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines

Context-Free Grammars and Languages

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

Deterministic Finite Automata

Revision Sheet. (a) Give a regular expression for each of the following languages:

Running an NFA & the subset algorithm (NFA->DFA) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Non-deterministic Finite Automata

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

Let's start with an example:

Transcription:

C K Ngpl Forml Lnguges nd utomt Theory Chpter 4 Regulr Grmmr nd Regulr ets (olutions / Hints) ol. (),,,,,,,,,,,,,,,,,,,,,,,,,, (),, (c) c c, c c, c, c, c c, c, c, c, c, c, c, c c,c, c, c, c, c, c, c, c, c, c, c, c, c, c, c (d) c, c, c, c (e ) c, c, c, c

C K Ngpl Forml Lnguges nd utomt Theory ol. () 11*2 () 0+1 (c) ()* (d) ** (e ) (+)* (f) (+)* (g) (+)*c(+)* (h) ()*+()* (i) (+)*(+)* (j) 0(0+1)*11 (k) 0(10)*1+0(10)*+1(01)*0+1(01)* (l) (00+01+10+11)*(0+1) (m) (00+01+10+11)* ol. (),, c () C d D c (c)

C K Ngpl Forml Lnguges nd utomt Theory k k D c d, e d,e F Cution: O ne my construct the F s shown elow. uch n utomton will ccept ll the vlid strings in the lnguge ut it will lso ccept some strings tht re not vlid in the lnguge. For exmple, repetition of k re llowed only fter repetitions of or c re over. Once k is reched repetitions of or c re not llowed. ut this utomton llows repetitions of, c nd k in ny order which is not llowed. Hence, the ove finite utomton. k d, e D c (d) c c F ol. Let L e regulr lnguge with its corresponding finite utomton hving m numer of sttes. Let w=0 k 1 k e the string in the lnguge L such tht w =2k > m. To use pumping lemm tke w = xyz w ith xy m nd y 0.

C K Ngpl Forml Lnguges nd utomt Theory Now, the next step is to prove tht the string xy i z does not elong to L for ll i 0. Let us tke three possile cses. Cse I: y hs only 0s. Let y=0 t for some t > 0. Now, xz=0 k-t 1 k. ince t > 0 therefore k-t < k nd the string xz does not elong to L. ince t i=0, w=xyz=xz does not elong to L, hence L is not regulr. Cse II: y hs only 1s. Proof is similr to cse I. Cse III : Let y contin oth 0 nd 1. Let y=0 p 1 s. Now x=0 k-p nd z=1 k-s. t i=4, xy 4 z= 0 k-p 0 p 1 s 0 p 1 s 0 p 1 s 0 p 1 s 1 k-s. This string does not elong to L. Hence L is not regulr. ol. () elongs to R 1 ut not to R 2. elongs to R 1 ut not to R 2. ϵ elongs to R1 ut not to R2. () elongs to R 2 ut not to R 1. elongs to R 2 ut not to R 1. (c) elongs to othr 1 nd R 2. elongs to othr1 nd R2. (d) elongs to neither R 1 nor R 2. elongs to neither R 1 nor R 2.

C K Ngpl Forml Lnguges nd utomt Theory ol. () 1 1 1 0 D 0 0 E () 0, 1 0 1 0 (c) 1 1 0 0 0 0 C D F 1 (d) 0 0, 1 0 1 F 1 0 1 1

C K Ngpl Forml Lnguges nd utomt Theory ol. Q1={,, } Q2={P, Q, R} Q1 X Q2= { (, P), (, Q), (, R), (, P), (, Q), (, R), (F, P), (F, Q), (F, R)} Trnsition Tle Current tte Input ymol {, P } {, P} {, Q} {,Q} {,P} {, R} {, R} {, R} {,R} {, P } {, P} {F, Q} {,Q} {,P} {F, R} {, R} {, R} {F,R} {F, P } {, P} {, Q} {F,Q} {,P} {, R} {F, R} {, R} {,R} fter removing the sttes tht re not generted tht is {, Q} nd {F, P}. Current tte Input ymol {, P } {, P} {, Q} {, P } {, P} {F, Q} {,Q} {,P} {, R}

C K Ngpl Forml Lnguges nd utomt Theory {F,Q} {,P} {, R} {, R} {, R} {,R} {, R} {, R} {F,R} {F, R} {, R} {,R} utomt for the lnguge L1 U L2. Current tte Input ymol {, P } {, P} {, Q} {, P } {, P} {F, Q} {,Q} {,P} {, R} *{F,Q} {,P} {, R} *{, R} {, R} {,R} *{, R} {, R} {F,R} *{F, R} {, R} {,R} utomt for the lnguge L1 L2 Current tte Input ymol {, P } {, P} {, Q} {, P } {, P} {F, Q} {,Q} {,P} {, R} {F,Q} {,P} {, R} {, R} {, R} {,R} {, R} {, R} {F,R} *{F, R} {, R} {,R}

C K Ngpl Forml Lnguges nd utomt Theory utomt for the lnguge L1 - L2 Current tte Input ymol {, P } {, P} {, Q} {, P } {, P} {F, Q} {,Q} {,P} {, R} *{F,Q} {,P} {, R} {, R} {, R} {,R} {, R} {, R} {F,R} {F, R} {, R} {,R} utomt for the lnguge L2 L1 Current tte Input ymol {, P } {, P} {, Q} {, P } {, P} {F, Q} {,Q} {,P} {, R} {F,Q} {,P} {, R} *{, R} {, R} {,R} *{, R} {, R} {F,R} {F, R} {, R} {,R} ol. ()

C K Ngpl Forml Lnguges nd utomt Theory = ϵ + 1= ϵ1* = 1* F=0 =0+ 1+ F1 =1*0 + 1+01=1*0+(1+01)=1*0(1+01)* F=0= 1*0(1+01)*0 Required regulr expression: 1*0(1+01)*0 () = ϵ =0+ 1+ 0 F=1+F0=1(0*)*=10* =0 +F1= 0+10*1=0(10*1)* =0+1+0= ϵ0+ 1+ 0(10*1)*0=0+1+ 0(10*1)*0= 0+ (1+ 0(10*1)*0) =0(1+ 0(10*1)*0)* = 0(10*1)*= 0(1+ 0(10*1)*0)*0(10*1)* F=10*=0(1+ 0(10*1)*0)*0(10*1)*10* Required regulr expression: 0(1+ 0(10*1)*0)*0(10*1)*10* + 0(1+ 0(10*1)*0)*0(10*1)* ol. = ϵ == ϵ= F= += ϵ+=+ = +(+)+F=+(+)+F=+F+(+)=+(+)+(+) =++(++)=(+)(++)* F=+(+)(++)* Required regulr expression: +(+)(++)* + ol. F = ϵ+= ϵ*=* =+=*+=**

C K Ngpl Forml Lnguges nd utomt Theory F==** Required regulr expression: ** ol. F = ϵ =+= ϵ+=+=* = += ϵ+=+=* F=+=*+* Required regulr expression: *+* ol. () **** () ****(+)* (c) 0011(0011)*(00)*+1100(1100)*(11)* (d) ** (e) 00(0+1)*00 ol. It is DF

C K Ngpl Forml Lnguges nd utomt Theory 1 0 F 1 0 1 C 0 ol. NF corresponding to (0+1)*(00+11)(0+1)* 0, 1 0 0 0, 1 F 1 1 DF corresponding to NF tte Input ymol 0 1 {} {,} {,} {,} {,,F} {,} {,} {,} {,,F} {,,F} {,,F} {,,F} {,,F} {,,F} {,,F} ol. = ϵ =++= ϵ+ ϵ+=++=(+)*

C K Ngpl Forml Lnguges nd utomt Theory F=+F(+)=(+)*+F(+)*=(+)*(+)* Required regulr expression: (+)*(+)* ol. = ϵ =+++F= ϵ+ ϵ++f=+++f F=+F=* =+++*=++(+*)=(+)(+*)* F=(+)(+*)** Required regulr expression: (+)(+*)** ol. = ϵ =+c= ϵ+c=+c == ϵ= =+c F=++F=(+c)++F=((+c)+)* Required regulr expression: ((+c)+)* ol.

C K Ngpl Forml Lnguges nd utomt Theory ϵ C D,, ϵ K ϵ ϵ E F G H I J L,, C L E F G H I () C E, ϵ ϵ D F fter removl of null moves, we hve C E, F ove finite utomton will ccept ll vlid strings in the lnguge, ut it my lso ccept some other strings tht re not in the lnguge. For exmple, it will ccept the repetitions of even fter repetitions of which is not desirle. For exmple, will e vlid string which is not desirle. Hence in the ctul utomton

C K Ngpl Forml Lnguges nd utomt Theory pth is so creted tht there is no wy ck once is reched. Hence, the ove utomton is modified s given elow: C D F E