CHAPTER 1 Regular Languages. Contents

Similar documents
Lecture 08: Feb. 08, 2019

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

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

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

1 Nondeterministic Finite Automata

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

Theory of Computation Regular Languages

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Fundamentals of Computer Science

Finite-State Automata: Recap

Let's start with an example:

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

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

CISC 4090 Theory of Computation

Deterministic Finite Automata

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum

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

Homework 3 Solutions

Non-deterministic Finite Automata

NFAs continued, Closure Properties of Regular Languages

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Finite Automata-cont d

Languages & Automata

Chapter 2 Finite Automata

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

CS375: Logic and Theory of Computing

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

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

Harvard University Computer Science 121 Midterm October 23, 2012

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

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

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

CMSC 330: Organization of Programming Languages

1 From NFA to regular expression

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.

Name Ima Sample ASU ID

Minimal DFA. minimal DFA for L starting from any other

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

Some Theory of Computation Exercises Week 1

Convert the NFA into DFA

3 Regular expressions

Designing finite automata II

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

Java II Finite Automata I

Non-deterministic Finite Automata

Formal Languages and Automata

Automata and Languages

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

Today s Topics Automata and Languages

Automata and Languages

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

ɛ-closure, Kleene s Theorem,

Non-Deterministic Finite Automata

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

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

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Coalgebra, Lecture 15: Equations for Deterministic Automata

1.4 Nonregular Languages

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.

More on automata. Michael George. March 24 April 7, 2014

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

1.3 Regular Expressions

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

Lexical Analysis Finite Automate

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

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

Thoery of Automata CS402

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

NFAs continued, Closure Properties of Regular Languages

Nondeterminism and Nodeterministic Automata

First Midterm Examination

Formal Language and Automata Theory (CS21004)

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

Lecture 09: Myhill-Nerode Theorem

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

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

Deterministic Finite-State Automata

GNFA GNFA GNFA GNFA GNFA

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

Worked out examples Finite Automata

Regular languages refresher

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

Closure Properties of Regular Languages

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research

In-depth introduction to main models, concepts of theory of computation:

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

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

PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

Myhill-Nerode Theorem

A negative answer to a question of Wilke on varieties of!-languages

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

CS375: Logic and Theory of Computing

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

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Lecture 6 Regular Grammars

Hybrid Control and Switched Systems. Lecture #2 How to describe a hybrid system? Formal models for hybrid system

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Lecture 9: LTL and Büchi Automata

Transcription:

Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr opertions egulr expressions definitions, euivlence with finite utomt Non-regulr Lnguges the pumping lemm for regulr lnguges Theory of Computtion, Feodor F. Drgn, Kent Stte University 1

egulr expressions: definition An lgeric euivlent to finite utomt. We cn uild complex lnguges from simple lnguges using opertions on lnguges. Let Σ = { 1,..., n } e n lphet. The simple lnguges over Σ re the empty lnguge, which contins no word. for every symol Σ, the lnguge {}, which contins only the oneletter word. The regulr opertions on lnguges re U (union), o (conctention), nd * (itertion). An expression tht pplies regulr opertions to simple lnguges is clled regulr expression (nd the resulting lnguge is regulr lnguge; we will see lter why ). L(E) is the lnguge defined y the regulr expression E. Formlly, is regulr expression if is 1. for some in the lphet Σ (stnds for lnguge {}), 2., stnding for lnguge { }, 3., stnding for the empty lnguge, 4. ( ) 1U, where, 2 1 2 re regulr expressions, 5. ( ), where, 1o 2 1 2 re regulr expressions, * 6. ( ), where is regulr expression. 1 1 Theory of Computtion, Feodor F. Drgn, Kent Stte University 2

Nottions When writing regulr expressions, we use the following conventions: For simple lnguges of the form {}, we write (omitting rces). Prentheses re omitted ccording to the rule tht itertion inds stronger thn conctention, which inds stronger thn union. The conctention symol is often omitted. We write Σ for... 1 n o. * We write for (which is the lnguge tht contins only the empty word). For exmple, 01* stnds for the expression ({ 0} o ({1}*)) ( *). ( ΣΣ)* (0*10*1)*0* Exmples of expressions Σ *000Σ* the lnguge of ll words tht contin the sustring 000 the lnguge of ll words with n even numer of letters the lnguge of ll words tht contin n even numer of 1 s Note tht conctenting the empty set to ny set yields the empty set; 1* = Theory of Computtion, Feodor F. Drgn, Kent Stte University 3

Euivlence with Finite Automt egulr expressions nd finite utomt re euivlent in their descriptive power. Any regulr expression cn e converted into finite utomton tht recognizes the lnguge it descries, nd vice vers. We will prove the following result Theorem. A lnguge is recognizle y FA if nd only if some regulr expression descries it. This theorem hs two directions. We stte ech direction s seprte lemm. Lemm 1. If lnguge is descried y regulr expression, then it is recognizle y FA. We hve regulr expression descriing some lnguge A. We show how to convert into n NFA recognizing A. We proved efore tht if n NFA recognizes A then DFA recognizes A. To convert into n NFA N, we consider the six cses in the forml definition of regulr expression. Theory of Computtion, Feodor F. Drgn, Kent Stte University 4

Proof of Lemm 1 (6 cses) 1. = for some in Σ. Then L( ) = { }, hence N = ({ 1, 2}, Σ, δ, 1,{ 2}) δ ( 1, ) = { 2} δ ( r, ) = for r or 1. 2. =. Then L( ) = { }, hence N = ({ 1}, Σ, δ, 1,{ 1}) δ ( r, ) = for ny r nd. 3. =. Then L( ) =, hence N = ({ }, Σ, δ,, ) δ ( r, ) = for ny r nd. 4. 5. 6. = = = 1 1 * 1 U 2. o 2.. in these cses we use the constructions given in the proofs tht the clss of regulr lnguges is closed under the regulr opertions. We construct the NFA for from NFAs for 1, 2 nd the pproprite closure construction. Theory of Computtion, Feodor F. Drgn, Kent Stte University 5

Exmple 1 ( )* Building n NFA from the regulr expression ( ) * Theory of Computtion, Feodor F. Drgn, Kent Stte University 6

Exmple 2 ( )* ( ) * Building n NFA from the regulr expression Theory of Computtion, Feodor F. Drgn, Kent Stte University 7 ( ) *

Euivlence with Finite Automt We re working on the proof of the following result Theorem. A lnguge is regulr if nd only if some regulr expression descries it. We hve proved Lemm 1. If lnguge is descried y regulr expression, then it is regulr. For given regulr expression, descriing some lnguge A, we hve shown how to convert into n NFA recognizing A. Now we will prove the other direction Lemm 2. If lnguge is regulr then it is descried y regulr expression. For given regulr lnguge A, we need to write regulr expression, descriing A. Since A is regulr, it is ccepted y DFA. We will descrie procedure for converting DFAs into euivlent regulr expressions. We will define new type of finite utomton, generlized NFA (GNFA). nd show how to convert DFAs into GNFAs nd then GNFAs into regulr expression. Theory of Computtion, Feodor F. Drgn, Kent Stte University 8

Generlized Non-deterministic Finite Automt Generlized non-deterministic finite utomt re simply NFAs wherein the trnsition rrows my hve ny regulr expressions s lels, insted of only memers of the lphet or. strt * * ()* * ccept For convenience we reuire tht GNFAs lwys hve form tht meets the following conditions. the strt stte hs rrows going to every other stte ut no ingoing rrows. there is only one ccepting stte. It hs ingoing rrows from every other stte ut no outgoing rrows. moreover, the strt stte is not the sme s the ccept stte. except for the strt nd ccept sttes, one rrow goes from every stte to every other stte nd lso from ech stte to itself. Theory of Computtion, Feodor F. Drgn, Kent Stte University 9

Forml definition of GNFAs A GNFA is 5-tuple ( Q, Σ,, strt, ccept), where 1. Q is the finite set of sttes, 2. Σ is the input lphet, 3. δ : ( Q { ccept}) ( Q { strt}) 4. strt 5. ccept is the strt stte, nd is the ccept stte. δ is the trnsition function, A GNFA ccepts string w in Σ* if w = w1 w,..., w, where ech is in nd seuence of sttes exists such, 2 w tht n i Σ* r 0, r1, r2,..., r n 1. r 0 = strt, rn = ccept 2. For ech i, we hve w i L( i ), where i = δ ( ri 1, ri ) ; in other words, iis the expression on the rrow from r to r. From DFAs to GNFAs dd new stte with n rrow to the old strt stte, new ccept stte with rrows from the old ccept sttes. if ny rrows hve multiple lels (or if there re multiple rrows going etween the sme two sttes in the sme direction) replce ech with single rrow whose lel is the union of the previous lels. dd rrows leled etween sttes tht hd no rrows. i 1 Theory of Computtion, Feodor F. Drgn, Kent Stte University 10 i

i From GNFAs to egulr Expressions. Convert(G) 1. Let k e the numer of sttes of GNFA G. 2. If k=2, then G must consist of strt stte, n ccept stte, nd single rrow connecting them nd leled with regulr expression. eturn the expression. 3. If k>2, select ny stte r Q different from strt nd ccept sttes nd let G e the GNFA ( Q', Σ, δ ', strt, ), where ccept Q' = Q { r}, And for ny Q' { } nd ny Q' { } let for = δ, ), = δ (, ), = δ (, ), = δ (, ). 1 ( i r 2 r r 3 r 4 i 4. Compute Covert(G ) nd return this vlue. 4 1 3 r i ccept δ '( i, ) = ( 1 )( 2 )*( 3 ) ( 4 ), i Clim. For ny GNFA G, G is euivlent to G. 2 Theory of Computtion, Feodor F. Drgn, Kent Stte University 11 strt ( 1 )( 2 )*( 3 ) ( 4 )

Proof of Clim. Clim. For ny GNFA G, G is euivlent to G. We show tht G nd G recognize the sme lnguge Suppose G ccepts n input w then there exists seuence of sttes s.t. 1 2 strt 1 2 3 4 k 3... ccept, wi L( i ), w = w1 w2... wk if none of them is, then G ccepts w r since ech of the new regulr expressions leling rrows of G contins the old reg. expression s prt of union 1 3 r if does pper, removing ech seuence of consecutive sttes r r forms n ccepting pth in G. i i r So, G ccepts w. Suppose G ccepts w s ech rrow etween ny sttes nd in G descries the collection the sttes nd rcketing seuence hve new regulr expression on the rrow etween them tht descries ll strings tking to vi on G i of strings tking i to in G, either directly or vi, G must lso ccept w. r Theory of Computtion, Feodor F. Drgn, Kent Stte University 12 i i 2 4 ( 1 )( 2 )*( 3 ) ( 4 )

1 2 3 s Exmple 1 2 3 s 3 2 ( )* s ( ) * 3 ( )( ) * ( )( ) * s ( ( )* ) (( )( )* ) *(( )( )* ) ( )* Theory of Computtion, Feodor F. Drgn, Kent Stte University 13