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

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

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

Theory of Computation Regular Languages

Today s Topics Automata and Languages

Automata and Languages

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

CHAPTER 1 Regular Languages. Contents

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

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

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

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

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

Non-deterministic Finite Automata

Lecture 08: Feb. 08, 2019

Non-deterministic Finite Automata

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

CS375: Logic and Theory of Computing

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

Chapter 2 Finite Automata

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

GNFA GNFA GNFA GNFA GNFA

Deterministic Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Non-Deterministic Finite Automata

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

Lecture 6 Regular Grammars

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

1.4 Nonregular Languages

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

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

1.3 Regular Expressions

NFAs continued, Closure Properties of Regular Languages

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Fundamentals of Computer Science

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

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

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

Harvard University Computer Science 121 Midterm October 23, 2012

Minimal DFA. minimal DFA for L starting from any other

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

Formal Language and Automata Theory (CS21004)

Probabilistic Model Checking Michaelmas Term Dr. Dave Parker. Department of Computer Science University of Oxford

Lexical Analysis Finite Automate

CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

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

Java II Finite Automata I

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

Introduction to ω-autamata

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

1 Nondeterministic Finite Automata

Let's start with an example:

CS 330 Formal Methods and Models

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

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

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

Worked out examples Finite Automata

CISC 4090 Theory of Computation

Finite-State Automata: Recap

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

Nondeterminism and Nodeterministic Automata

Designing finite automata II

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

State Minimization for DFAs

1 From NFA to regular expression

Convert the NFA into DFA

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.

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

Turing Machines Part One

Deterministic Finite-State Automata

Languages & Automata

This lecture covers Chapter 8 of HMU: Properties of CFLs

Regular languages refresher

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

Lecture 09: Myhill-Nerode Theorem

Finite Automata-cont d

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

FABER Formal Languages, Automata and Models of Computation

Section: Other Models of Turing Machines. Definition: Two automata are equivalent if they accept the same language.

Lecture 4: More on Regexps, Non-Regular Languages

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

Homework 3 Solutions

CS 275 Automata and Formal Language Theory

Exercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v.

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

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

CS375: Logic and Theory of Computing

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

E 1 (n) = E 0 (n-1) E 0 (n) = E 0 (n-1)+e 0 (n-2) T(n -1)=2E 0 (n-2) + E 0 (n-3)

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

Intro to Theory of Computation

CMSC 330: Organization of Programming Languages

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

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

Formal Languages and Automata

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

Formal languages, automata, and theory of computation

NFAs continued, Closure Properties of Regular Languages

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

Nondeterministic Biautomata and Their Descriptional Complexity

Transcription:

CS:4330 Theory of Computtion Spring 208 Regulr Lnguges Equivlences between Finite utomt nd REs Hniel Brbos

Redings for this lecture Chpter of [Sipser 996], 3rd edition. Section.3.

Finite utomt nd regulr expressions re equivlent Theorem A lnguge is regulr if nd only if some regulr expression describes it. Proof ides. If lnguge A is described by regulr expression R then A is recognized by n NFA, therefore A is regulr There is n NFA N such tht N recognizes L (R) 2. If lnguge A is regulr, it mens tht it is recognized by DFA. Then we cn lwys deduce regulr expression from it. Turn DFA into equivlent regulr expression / 0

Prt : From regulr expressions to NFAs By induction on the length of R: Bse cses (R hs length ): R = {} R = R = 2 / 0

Prt : From regulr expressions to NFAs By induction on the length of R: Bse cses (R hs length ): R = {} R = R = Inductive cse: let R hve length k >. Assume tht for ny smller regulr expression, there is n NFA. R my be one of the following cses: R = R R 2 R = R R 2 R = (R ) 2 / 0

Prt 2: From DFAs to regulr expressions. Define Generlized Nondeterministic Finite Automton (GNFA in short). Insted of δ : Q Σ Q, we use δ : Q RE Q Arrows lbelled with regulr expressions Blocks of symbols insted of one symbol t time One strt nd one ccept stte 2. How to convert ny DFA to n equivlent GNFA 3. Algorithm to convert ny GNFA to n equivlent GNFA with 2 sttes 4. Convert 2-stte GNFA to n equivlent RE. 3 / 0

Step : DFA to GNFA q strt strt DFA q ccept Add unique nd distinct strt nd ccept sttes Edges with multiple lbels become regexp lbels If internl sttes (q, q 2 ) don t hve n edge between them, dd one lbeled with This should be such tht q strt hs no incoming edges nd q ccept hs no outgoing edges. 4 / 0

Step 2: Eliminte sttes from GNFA While mchine hs more thn 2 sttes: Pick nd internl stte, rip it out Re-lbel the rrows with regulr expressions to ccount for the missing stte 5 / 0

Step 2: Eliminte sttes from GNFA While mchine hs more thn 2 sttes: Pick nd internl stte, rip it out Re-lbel the rrows with regulr expressions to ccount for the missing stte strt b 2,b 5 / 0

Step 2: Eliminte sttes from GNFA While mchine hs more thn 2 sttes: Pick nd internl stte, rip it out Re-lbel the rrows with regulr expressions to ccount for the missing stte strt strt s b b 2,b f 2 b 5 / 0

Step 2: Eliminte sttes from GNFA While mchine hs more thn 2 sttes: Pick nd internl stte, rip it out Re-lbel the rrows with regulr expressions to ccount for the missing stte strt strt s b b 2,b f 2 b strt s b( b) f 5 / 0

Step 2: Eliminte sttes from GNFA While mchine hs more thn 2 sttes: Pick nd internl stte, rip it out Re-lbel the rrows with regulr expressions to ccount for the missing stte strt strt s b b 2,b f 2 b strt s strt s b( b) b( b) f f 5 / 0

GNFA: definition nd cceptnce A GNFA is tuple (Q, Σ, δ, q strt,qccept ) Q is the set of sttes, Σ is the finite lphbet (not regexps) q strt : initil stte (unique, no incoming edges) q ccept : ccepting stte (unique, no outgoing edges) δ : (Q \ {q ccept }) (Q \ {q strt }) R R is the set of ll regexps over Σ A GNFA ccepts string w Σ if w = w,..., w k, with ech w i Σ nd sequence of sttes q 0,..., q k exists such tht: q 0 = q strt is the strt stte q k = q ccept is the ccept stte for ech i, we hve w i L (R i ), where R i = δ(q i,q i ), i.e. R i is the expression on the rrow from q i to q i 6 / 0

CONVERT Given DFA M, let G be its GNFA. CONVERT(G) yields the equivlent regexp.. Let k be the number of sttes of G 2. If k = 2, then G, return the regexp lbeling its single trnsition 3. Select ny stte q rip Q \ {q strt,q ccept } nd let G be the GNFA (Q, Σ, δ, q strt,qccept ) such tht Q = Q \ {q rip } nd for ny q i Q \ {q ccept } nd ny q j Q \ {q strt }, let δ (q i,q j ) = (R )(R 2 ) (R 3 ) (R 4 ) for R = δ(q i,q rip ), R 2 = δ(q rip,q rip ), R 3 = δ(q rip,q j ) nd R 4 = δ(q i,q j ) 4. Return CONVERT(G ) 7 / 0

Is CONVERT correct? Theorem Given ny GNFA G, CONVERT(G) is equivlent to G. Proof ide By induction on k, the number of sttes of G. Bse step: k = 2 Show tht the regexp lbeling its single rrow describe ll ccepting strings of G Inductive step: ssume it holds for k. Show tht G nd G re equivlent (i.e. ccept the sme words), then by the induction hypothesis so it will be for CONVERT(G ). 8 / 0

The Complete Picture DFA NFA Reg. Lnguge Reg. Expression 9 / 0

Limits of finite utomt Are the following lnguges regulr? L = {w w hs equl number of s nd 0s} L 2 = {w w hs equl number of occurrences of 0 nd 0} 0 / 0