DFA Minimization: The Idea

Slides:



Advertisements
Similar presentations
Lexical Analysis IV : NFA to DFA DFA Minimization
Advertisements

CSE 311 Foundations of Computing I
Reducing DFA’s Section 2.4. Reduction of DFA For any language, there are many DFA’s that accept the language Why would we want to find the smallest? Algorithm:
Lecture 24 MAS 714 Hartmut Klauck
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
Finite Automata CPSC 388 Ellen Walker Hiram College.
CSE 311: Foundations of Computing Fall 2013 Lecture 23: Finite state machines and minimization.
Summary Showing regular Showing non-regular construct DFA, NFA
Simplifying CFGs There are several ways in which context-free grammars can be simplified. One natural way is to eliminate useless symbols those that cannot.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
EECS 20 Lecture 13 (February 14, 2001) Tom Henzinger Minimization.
Transparency No Formal Language and Automata Theory Chapter 10 The Myhill-Nerode Theorem (lecture 15,16 and B)
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY For next time: Read 2.1 & 2.2.
CSCI 3301 Transparency No. 9-1 Chapter #9: Finite State Machine Optimization Contemporary Logic Design.
Transparency No. 8-1 Formal Language and Automata Theory Chapter 8 DFA state minimization (lecture 13, 14)
CSE 311: Foundations of Computing Fall 2014 Lecture 23: State Minimization, NFAs.
Introduction to CS Theory
Decidable Questions About Regular languages 1)Membership problem: “Given a specification of known type and a string w, is w in the language specified?”
DFA Minimization 1 2 Equivalent States Consider the accept states c and g. They are both sinks meaning that any string which ever reaches them is guaranteed.
Lexical Analysis III : NFA to DFA DFA Minimization Lecture 5 CS 4318/5331 Spring 2010 Apan Qasem Texas State University *some slides adopted from Cooper.
Transition Diagrams Lecture 3 Wed, Jan 21, Building Transition Diagrams from Regular Expressions A regular expression consists of symbols a, b,
Minimal NFA Problems are hard Tao Jiang & B. Ravikumar N Andres Parra.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
General Discussion of “Properties” The Pumping Lemma Membership, Emptiness, Etc.
NFAε - NFA - DFA equivalence
Closed book, closed notes
Normal Forms for CFG’s Eliminating Useless Variables Removing Epsilon
CPSC 121: Models of Computation 2008/9 Winter Term 2
PDAs Accept Context-Free Languages
Non Deterministic Automata
CSE 311 Foundations of Computing I
The time complexity for e-closure(T).
PDAs Accept Context-Free Languages
Two issues in lexical analysis
NPDAs Accept Context-Free Languages
Review: NFA Definition NFA is non-deterministic in what sense?
Chapter 2 FINITE AUTOMATA.
Jaya Krishna, M.Tech, Assistant Professor
Hierarchy of languages
Decision Properties of Regular Languages
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
CSE 311 Foundations of Computing I
CS 154, Lecture 4: Limitations on DFAs (I),
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
4. Properties of Regular Languages
Nondeterministic Finite Automata
Minimal DFA Among the many DFAs accepting the same regular language L, there is exactly one (up to renaming of states) which has the smallest possible.
Lecture 4: Lexical Analysis II: From REs to DFAs
Transition Diagrams Lecture 3 Fri, Jan 21, 2005.
DFA Equivalence & Minimization
Chapter Nine: Advanced Topics in Regular Languages
Finite Automata Reading: Chapter 2.
This method is used for converting an
Finite Automata.
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Chapter 1 Regular Language - 02
Instructor: Aaron Roth
Instructor: Aaron Roth
Principles of Computing – UFCFA3-30-1
CSC312 Automata Theory Transition Graphs Lecture # 9
Regular Language Equivalence and DFA Minimization
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Lecture 5 Scanning.
Context-Free Languages
Presentation transcript:

DFA Minimization: The Idea “Minimal”? Minimal number of states. “Unique”? Unique up to renaming of states. I.e., has same shape. Isomorphic. Will show algorithm & detailed example. Will outline why algorithm is correct.

DFA Minimization: Algorithm Idea Equate & collapse states having same behavior. p q z or Build equivalence relation on states: p  q  (zS*, (p,z)F  (q,z)F) I.e., iff for every string z, one of the following is true:

DFA Minimization: Algorithm Build table to compare each unordered pair of distinct states p,q. Each table entry has a “mark” as to whether p & q are known to be not equivalent, and a list of entries, recording dependences: “If this entry is later marked, also mark these.”

DFA Minimization: Algorithm Initialize all entries as unmarked & with no dependences. Mark all pairs of a final & nonfinal state. For each unmarked pair p,q & input symbol a: Let r=d(p,a), s=d(q,a). If (r,s) unmarked, add (p,q) to (r,s)’s dependences, Otherwise mark (p,q), and recursively mark all dependences of newly-marked entries. Coalesce unmarked pairs of states. Delete inaccessible states.

DFA Minimization: Example b f c g d h 1 f b c d e a g h Initialize table entries: Unmarked, empty list

DFA Minimization: Example b f c g d h 1 f b c d e a g h Mark pairs of final & nonfinal states

DFA Minimization: Example b f c g d h 1 f b c d e a g h d(b,0) ? d(a,0) d(b,1) ? d(a,1) For each unmarked pair & symbol, …

DFA Minimization: Example b f c g d h 1 f b c d e a g h Maybe. No! g ? b c ? f For each unmarked pair & symbol, …

DFA Minimization: Example b f c g d h 1 f b c d e a g h For each unmarked pair & symbol, …

DFA Minimization: Example b f c g d h 1 f b c d e a g h d(e,0) ? d(a,0) d(e,1) ? d(a,1) For each unmarked pair & symbol, …

DFA Minimization: Example b f c g d h 1 f b c d e a g h Maybe. Yes. h ? b f ? f For each unmarked pair & symbol, … (a,e)

DFA Minimization: Example b f c g d h 1 f b c d e a g h (a,e) For each unmarked pair & symbol, … (g,a)

DFA Minimization: Example b f c g d h 1 f b c d e a g h (a,e) Need to mark. So, mark (g,a) also. For each unmarked pair & symbol, … (g,a) (g,a)

DFA Minimization: Example b f c g d h 1 f b c d e a g h (g,a) (a,e) For each unmarked pair & symbol, …

DFA Minimization: Example b f c g d h 1 f b c d e a g h (a,e) Coalesce unmarked pairs of states. ae bh df c g 1 a  e b  h d  f

DFA Minimization: Example b f c g d h 1 f b c d e a g h (a,e) Delete unreachable states. ae bh df c g 1 None.

DFA Minimization: Notes Order of selecting state pairs was arbitrary. All orders give same ultimate result. But, may record more or fewer dependences. Choosing states by working backwards from known non-equivalent states produces fewest dependences. Can delete unreachable states initially, instead. This algorithm: O(n2) time; Huffman (1954), Moore (1956). Constant work per entry: initial mark test & possibly later chasing of its dependences. More efficient algorithms exist, e.g., Hopcroft (1971).

DFA Minimization: Correctness Why is new DFA no larger than old DFA? Only removes states, never introduces new states. Obvious. Why is new DFA equivalent to old DFA? Only identify states that provably have same behavior. Could prove xL(M)  xL(M’) by inductions on derivations.

What About NFA Minimization? This algorithm doesn’t find a unique minimal NFA. Is there a (not necessarily unique) minimal NFA? ? ? Of course.

NFA Minimization In general, minimal NFA not unique! Example NFAs for 0+: Both minimal, but not isomorphic.