Minimal DFA. minimal DFA for L starting from any other

Similar documents
Convert the NFA into DFA

Finite Automata-cont d

State Minimization for DFAs

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Formal Languages and Automata

Myhill-Nerode Theorem

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

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

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

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

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

CMSC 330: Organization of Programming Languages

Lecture 08: Feb. 08, 2019

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

Designing finite automata II

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

Lecture 09: Myhill-Nerode Theorem

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Java II Finite Automata I

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

Harvard University Computer Science 121 Midterm October 23, 2012

1 Nondeterministic Finite Automata

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

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.

Non-deterministic Finite Automata

Non-deterministic Finite Automata

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

DFA minimisation using the Myhill-Nerode theorem

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

GNFA GNFA GNFA GNFA GNFA

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

Lexical Analysis Finite Automate

Homework 3 Solutions

First Midterm Examination

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

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.

Coalgebra, Lecture 15: Equations for Deterministic Automata

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

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

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

Deterministic Finite Automata

Fundamentals of Computer Science

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

Finite-State Automata: Recap

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

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

Worked out examples Finite Automata

Formal Language and Automata Theory (CS21004)

Theory of Computation Regular Languages

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

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

Formal languages, automata, and theory of computation

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

CHAPTER 1 Regular Languages. Contents

Thoery of Automata CS402

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

Nondeterminism and Nodeterministic Automata

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

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

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

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

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

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

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

Let's start with an example:

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

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

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

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

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

Languages & Automata

Model Reduction of Finite State Machines by Contraction

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

First Midterm Examination

378 Relations Solutions for Chapter 16. Section 16.1 Exercises. 3. Let A = {0,1,2,3,4,5}. Write out the relation R that expresses on A.

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.

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

ɛ-closure, Kleene s Theorem,

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

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

NFAs continued, Closure Properties of Regular Languages

Tutorial Automata and formal Languages

DFA Minimization and Applications

NON-DETERMINISTIC FSA

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

1.4 Nonregular Languages

Closure Properties of Regular Languages

Lecture 9: LTL and Büchi Automata

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

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

SWEN 224 Formal Foundations of Programming WITH ANSWERS

CISC 4090 Theory of Computation

Some Theory of Computation Exercises Week 1

Regular Languages and Applications

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

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

FABER Formal Languages, Automata and Models of Computation

3 Regular expressions

Chapter 2 Finite Automata

Free groups, Lecture 2, part 1

Transcription:

Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA for L strting from ny other y the Stte Minimiztion Algorithm.

Deciding Equivlence of DFAs With this lgorithm: We cn check whether two DFAs A nd B represent the sme regulr lnguge. Just minimize oth A nd B nd see if the otined utomt re isomorphic (equl up to stte renming).

Two lgorithms In this lecture we will see two lgorithms for minimizing DFAs. They oth work y prtitioning the sttes of the DFA into equivlence clsses. The lgorithms differ y how they do the prtitioning Top Down From lrge prtitions to smller ones Bottom up From unit prtitions to lrger ones

Equivlence Reltions nd Prtitions A prtition of set A is set {C 1,C 2,,C k } of susets of A such tht: C i C i C j = for i j C 1 C 2 C k = A C 1 C 2... C 3 C k

Now if we define reltion ~ on A y: x ~ y iff x nd y elong to the sme prtition set; then this reltion will stisfy the properties of n equivlence reltion: x ~ x (reflexivity) x ~ y y ~ x (symmetry) x ~ y nd y ~ z x ~ z (trnsitivity) The correspondence etween prtitions nd equivlence reltions goes oth wys. If we hve n equivlence reltion on A then there is n ssocited prtition of the set A. Its clsses re clled equivlence clsses of. The clss contining x is [x] = { y A y x}.

Equivlence of Sttes Definition. Two sttes p nd q of DFA re equivlent (nottion: p q) when, for every string w: w leds from p to finl stte if nd only if w leds from q to finl stte. Non-equivlent sttes re clled distinguishle. To show tht two sttes re distinguishle, we need to find only one string tht leds from one of them to finl stte, nd leds from the other to non-finl stte. The empty string distinguishes every finl stte from every non-finl stte. Thus, if p q, then p nd q re either oth finl or oth non-finl.

Exmple Sttes 0 nd 1 re distinguishle, since from 0 -> 1 Non-finl from 1 -> 3, Finl Sttes 1 nd 2 re indistinguishle y ny string over the lphet {,} All strings tht led from 1 or 2, tht end up in finl stte from 1, lso led to finl stte from 2!

p 0 0 q 0 1 1 r 1 Testing two finl (or two non-finl) sttes for equivlence is more difficult. In this exmple, q nd r re equivlent. No string eginning with 0 cn distinguish them: the two pths converge fter the first rc. For strings eginning with 1, the two pths will lternte etween q nd r while reding the initil 1's; s soon s the first 0 is red (if ever), the pths will converge t p.

Miniml Automt Definition. A DFA is miniml iff 1. All its sttes re rechle from the strt stte; 2. All its sttes re distinguishle. Theorem. Two miniml utomt for the sme lnguge re isomorphic.

The quotient The Quotient (Stte Collpse) Construction. Stte equivlence reltion hs this fundmentl property: If p q then for every Σ, δ(p,) δ(q,). Indeed, if string w distinguishes δ(p,) from δ(q,), then the string w will distinguish p from q.

The quotient construction Given ny DFA A We cn construct the quotient DFA A 1. Its sttes re the equivlence clsses of the sttes of A 2. Its trnsition reltion is δ (C,) = C where 1. δ(x,)=y 2. C is the clss tht contins x 3. C is the clss tht contins y 3. The strt stte of A is the equivlence clss of the strt stte of A, 4. The finl sttes of A re equivlence clsses of finl sttes of A.

p Quotient Exmple 0 0 q 0 1 1 1 r Here is the quotient of the DFA of our exmple. p 0,1 q,r 1 0 Theorem. For ny DFA, A, in which ll sttes re rechle from the strt stte, the utomton A is miniml.

Minimiztion Algorithm Any minimiztion lgorithm hs two prts: Eliminte sttes of the input DFA tht re not rechle from the strt stte. Do the quotient construction on the resulting DFA. The first step is esy. The second is esy once we mnge to prtition the sttes into equivlence clssses. There re two possile wys to do this 1. Top down - equivlence clsses of re found y n itertive construction tht produces sequence of finer nd finer prtitions. 2. Bottom up we construct smll (size 2) prtitions nd then merge them (Algorithm in the Hein Text ook)

Top Down pproch Define p i q to men p nd q cnnot e distinguished y strings of length i. We cn lwys compute directly 0 ; it hs two clsses: finl sttes nd non-finl sttes. The fct p i+1 q p i q nd δ(p,) i δ(q,) for every Σ is the sis for effectively constructing i+1 when i is known. For ech equivlence clss, try nd rek it into two or more new equivlence clsses y finding some symol which distinguishes two sttes in the current clss.

Structure Bse Cse If n equivlence clss hs only one stte, we re done with tht stte. It cnnot e roken down into finer equivlence. Itertive Step We repet this construction until ( i+1 )= ( i ). Going further on would not chnge the equivlence reltion. At this point we hve our desired. Note the worst we cn do is hve every stte in its own equivlence clss, in which cse the originl DFA ws lredy miniml.

Exmple We wnt the miniml utomton equivlent to the following. 1 2 3 4 5 6 7 8

Automt nd Forml Lnguges 1 2 3 4 5 6 7 8 First remove the unrechle stte 4 1 2 3 5 6 7 8 The trnsition tle is now useful. Lecture 10 1 2 3 5 6 7 8 2 7 1 8 3 7 7 6 3 3 6 7 5 3 Tim Sherd 17

Automt nd Forml Lnguges 1 2 3 5 6 7 8 We strt with 0 ; its two clsses re X= {1,2,5,6,7} nd Y={3} The equivlence clss {3} is done. It cnnot e further roken down into finer equivlences. So concentrte on {1,2,5,6,7} Lecture 10 1 2 3 5 6 7 8 2 7 1 8 3 7 7 6 3 3 6 7 5 3 Focus on the colors, not the sttes 1 2 3 5 6 7 8 X X X X Y X X X Y Y X X X Y Tim Sherd 18

Automt nd Forml Lnguges Now we need to find 1 ; We need to look t the tle for the sttes in X={1,2,5,6,7} without distinguishing etween sttes in the sme 0 clss. We do this y oserving the different colors or symols in ech column of the new trnsition tle. Recll we cn ignore the columns leled y Y= {3} ecuse it is lredy fully refined (s smll s possile). 1 2 3 5 6 7 8 2 7 7 8 3 7 7 6 3 3 6 7 5 3 1 2 3 5 6 7 8 X X X X Y X X X Y Y X X X Y Lecture 10 Tim Sherd 19

Automt nd Forml Lnguges 1 2 3 5 6 7 8 2 7 8 3 7 7 6 3 6 7 5 3 1 2 3 5 6 7 8 X X X Y X X X Y X X X Y Two elements of the sme 0 clss elong to the sme 1 clss when their corresponding columns re equl (I.e. hve the sme color or symol.) So in this tle we hve three different ptterns X/X, X/Y, nd Y/X, nd thus we rek {1,2,5,7,8} into three different equivlent clsses. X/X {1,5,7} = U {3} = Y X/Y {2,8} = V Rememer to propgte the Y/X {6} = W lredy done sttes {3}. Now identify new color (or symol) to ech of these sets. And redo the tle. 1 2 3 5 6 7 8 2 7 1 8 3 7 7 6 3 3 6 7 5 3 Lecture 10 1 2 3 5 6 7 8 V U U V Y U U W Y Y W U U Y Tim Sherd 20

Automt nd Forml Lnguges 1 2 3 5 6 7 8 2 7 1 8 3 7 7 6 3 3 6 7 5 3 1 2 3 5 6 7 8 V U U V Y U U W Y Y W U U Y Ignoring the two done sttes Y={3} nd W={6} (of size 1). We try nd further refine U= {1,5,7} nd V={2,8}. We note tht V={2,8} cnnot e further refined, ut {1,5} cn e distinguished from {7} ecuse the trnsition on differs. So nming these two sttes {1,5} = T {7} = Z We re led to the finl trnsition digrm, Becuse further distinction Between {1,5}, nd {2,8} Is not possile. Lecture 10 1 = T 2 = V 3 = Y 5 = T 6 = W 7 = Z 8 = v V Z T V Y Z Z W Y Y W Z T Y Tim Sherd 21

Automt nd Forml Lnguges 1 = T 2 = V 3 = Y 5 = T 6 = W 7 = Z 8 = v V Z T V Y Z Z W Y Y W Z T Y 1,5 2,8 3 Redundnt columns T={1,5} V={2,8} Y={3} W={6} Z={7} V={2,8} Z={7} T={1,5} Y={3} Z={7} 6 7 W={6} Y={3} Y={3} Z={7} T={1,5} Lecture 10 Tim Sherd 22

Bottom up (in Text Book) Remove sttes not rechle from the strt stte (4)

Bottom up, strt with smll equivlences Compute ll distinct pirs of sttes Where oth prts of the pir re either Both finl, or oth non-finl [(5,8),(5,7),(5,6),(7,8),(6,8),(6,7), (2,8),(2,5),(2,7),(2,6),(1,8),(1,5), (1,7),(1,6),(1,2)] Note tht 3 is the only finl stte, so It prticiptes in no pir

Keep only good pirs [(5,8),(5,7), (5,6), (7,8),(6,8),(6,7),(2,8),(2,5),(2,7), (2,6),(1,8),(1,5),(1,7),(1,6),(1,2)] [(5,7),(2,8),(1,5),(1,7)] A pir (x,y) is good if 1. Its δ is the sme on ll letters δ(x,) = δ(y,) for ll OR 2. The pir ( δ(x,), δ(y,) ) is lredy in the current set of pirs forll Exmple (5,7) ( δ(5,), δ(7,) ) = (7,8) ( δ(5,b), δ(7,b) ) = (6,5)

Repet Repet until no more pirs cn e removed [(5,8),(5,7), (5,6),(7,8),(6,8),(6,7),(2,8),(2,5), (2,7),(2,6),(1,8),(1,5),(1,7),(1,6),(1,2)] [(5,7),(2,8),(1,5),(1,7)] [(2,8),(1,5)] So the equivlences re {{3},{4},{6},{7},{2,8},{1,5}}

Prtition {{3},{4},{6},{7},{2,8},{1,5}}

New DFA δ({3},) = {1,5} δ({3},) = {3} δ({4},) = δ({4},) = δ({6},) = δ({6},) = δ({7},) = δ({7},) = δ({2,8},) = δ({2,8},) = δ({1,5},) = δ({1,5},) =