MINIMIZATION May 12, 2009 1. Agenda 2  These slides are not mine www1.cs.solumbia.edu/~zeph/3261/L9/L9.ppt www1.cs.solumbia.edu/~zeph/3261/L9/L9.ppt.

Slides:



Advertisements
Similar presentations
Theory of Computing Lecture 23 MAS 714 Hartmut Klauck.
Advertisements

Lexical Analysis IV : NFA to DFA DFA Minimization
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
Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
Regular Expressions and DFAs COP 3402 (Summer 2014)
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Finite Automata CPSC 388 Ellen Walker Hiram College.
Summary Showing regular Showing non-regular construct DFA, NFA
Automata and Formal Languages Tim Sheard 1 Lecture 9 Reasoning with DFAs.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Complexity 11-1 Complexity Andrei Bulatov Space Complexity.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
61 Nondeterminism and Nodeterministic Automata. 62 The computational machine models that we learned in the class are deterministic in the sense that the.
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
1 Finite Automata. 2 Finite Automaton Input “Accept” or “Reject” String Finite Automaton Output.
1 Minimization; Pumping Lemma. October 2, Agenda Minimization Algorithm Guarantees smallest possible DFA for a given regular language Proof of.
Regular Expression (EXTRA)
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
Automating Construction of Lexers. Example in javacc TOKEN: { ( | | "_")* > | ( )* > | } SKIP: { " " | "\n" | "\t" } --> get automatically generated code.
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
Theory of Computing Lecture 22 MAS 714 Hartmut Klauck.
Finite Automata Costas Busch - RPI.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY For next time: Read 2.1 & 2.2.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA minimization.
Nondeterminism (Deterministic) FA required for every state q and every symbol  of the alphabet to have exactly one arrow out of q labeled . What happens.
Extra on Regular Languages and Non-Regular Languages
Regular Expressions. Notation to specify a language –Declarative –Sort of like a programming language. Fundamental in some languages like perl and applications.
 Computability Theory Turing Machines Professor MSc. Ivan A. Escobar
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
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.
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
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.
Lexical Analysis: DFA Minimization Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice.
Inferring Finite Automata from queries and counter-examples Eggert Jón Magnússon.
Lecture # 12. Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label.
Complexity and Computability Theory I Lecture #8 Instructor: Rina Zviel-Girshin Lea Epstein.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
CS 203: Introduction to Formal Languages and Automata
Regular Expressions Fundamental Data Structures and Algorithms Peter Lee March 13, 2003.
Formal Languages Finite Automata Dr.Hamed Alrjoub 1FA1.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA.
98 Nondeterministic Automata vs Deterministic Automata We learned that NFA is a convenient model for showing the relationships among regular grammars,
CS 154 Formal Languages and Computability February 11 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
LECTURE 5 Scanning. SYNTAX ANALYSIS We know from our previous lectures that the process of verifying the syntax of the program is performed in two stages:
Lecture 09: Theory of Automata:2014 Asif NawazUIIT, PMAS-Arid Agriclture University Rawalpindi. Kleene’s Theorem and NFA.
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
Lecture 06: Theory of Automata:08 Finite Automata with Output.
Lecture 15: Theory of Automata:2014 Finite Automata with Output.
An investigation into FA minimization through Regex Hashing Wikus Coetser Prof. Dr. D.G. Kourie Prof. Dr. B.W. Watson.
Department of Software & Media Technology
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Regular Expression (EXTRA)
Languages.
Copyright © Cengage Learning. All rights reserved.
Chapter 2 FINITE AUTOMATA.
CSE322 Finite Automata Lecture #2.
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
DFA Equivalence & Minimization
Chapter Nine: Advanced Topics in Regular Languages
CSE322 Minimization of finite Automaton & REGULAR LANGUAGES
Principles of Computing – UFCFA3-30-1
Instructor: Aaron Roth
Presentation transcript:

MINIMIZATION May 12,

Agenda 2  These slides are not mine www1.cs.solumbia.edu/~zeph/3261/L9/L9.ppt www1.cs.solumbia.edu/~zeph/3261/L9/L9.ppt  The given minimization algorithm differs from the algorithm given in the previous set of slides on minimization and provides a first step in understanding the 1971 Hopcroft algorithm.  Minimization Algorithm  Guarantees smallest possible DFA for a given regular language

Equivalent States. Example 3 Consider the accept states c and g. They are both sinks meaning that any string which ever reaches them is guaranteed to be accepted later. Q: Do we need both states? a b 1 d 0,1 e 1 c g f

Equivalent States. Example 4 A: No, they can be unified as illustrated below. Q: Can any other states be unified because any subsequent string suffixes produce identical results? a b 1 d 0,1 e 1 cg f

Equivalent States. Example 5 A: Yes, b and f. Notice that if you’re in b or f then: 1. if string ends, reject in both cases 2. if next character is 0, forever accept in both cases 3. if next character is 1, forever reject in both cases So unify b with f. a b 1 d 0,1 e 1 cg f

Equivalent States. Example 6 Intuitively two states are equivalent if all subsequent behavior from those states is the same. Q: Come up with a formal characterization of state equivalence. a 0,1 d e 1 cg bf 0 0 1

Equivalent States. Definition 7 DEF: Two states q and q’ in a DFA M = (Q, , , q 0, F ) are said to be equivalent (or indistinguishable) if for all strings u   *, the states on which u ends on when read from q and q’ are both accept, or both non-accept. Equivalent states may be glued together without affecting M’s behavior.

Finishing the Example 8 Q: Any other ways to simplify the automaton? a 0,1 d e 1 cg bf 0 0 1

Useless States 9 A: Get rid of d. Getting rid of unreachable useless states doesn’t affect the accepted language. a 0,1 e cg bf 0 1

Minimization Algorithm. Goals 10 DEF: An automaton is irreducible if  it contains no useless states, and  no two distinct states are equivalent. The goal of minimization algorithm is to create irreducible automata from arbitrary ones. The minimization algorithm reverses previous example. Start with least possible number of states, and create new states when forced to.

The Game of MINIMIZE 11 0.All useless players are disqualified. 1.Game proceeds in rounds. 2.Start with 2 teams: ACCEPT vs. REJECT. 3.Each round consists of sub-rounds – one sub- round per team. 4.Two members of a team are said to agree if for a given label, they want to pass the buck to same team. Otherwise, disagree. 5.During a sub-round, disagreeing members split off into new maximally agreeing teams. 6.If a round passes with no splits, STOP.

Minimization Algorithm. (Partition Refinement) Code 12 DFA minimize(DFA (Q, , , q 0, F ) ) remove any state q unreachable from q 0 Partition P = {F, Q - F } boolean Consistent = false while( Consistent == false ) Consistent = true for(every Set S  P, char a  , Set T  P ) Set temp = {q  T |  (q,a)  S } if (temp != Ø && temp != T ) Consistent = false P = (P  T )  {temp,T  temp} return defineMinimizor( (Q, , , q 0, F ), P ) – defined on next slide

Minimization Algorithm continue 13 DFA defineMinimizor (DFA (Q, , , q 0, F ), Partition P ) Set Q’ =P State q’ 0 = the set in P which contains q 0 F’ = { S  P | S  F } for (each S  P, a    define  ’ (S,a) = the set T  P which contains the states  ’(S,a) return (Q’, ,  ’, q’ 0, F’ )

Minimization Example 14 Start with a DFA

Minimization Example 15 Miniature version 

Minimization Example 16 Split into two teams. ACCEPT vs. REJECT

Minimization Example 17 0-label doesn’t split up any teams

Minimization Example 18 1-label splits up REJECT's

Minimization Example 19 No further splits. HALT! Start team contains original start

Minimization Example. End Result 20 States of the minimal automata are remaining teams. Edges are consolidated across each team. Accept states are break-offs from original ACCEPT team.

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare ACCEPTED.

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare

Minimization Example. Compare REJECT.

Proof of Minimal Automaton 37 Previous algorithm guaranteed to produce an irreducible FA. Why should that FA be the smallest possible FA for its accepted language?

Proof of Minimal Automaton 38 THM The minimization algorithm produces the smallest possible automaton for its accepted language. Proof. Show that any irreducible automaton is the smallest for its accepted language L: We say that two strings u,v   * are indistinguishable if for all suffixes x, ux is in L exactly when vx is. Notice that if u and v are distinguishable, following u and v from the start state must lead to different endpoints in any DFA for L.

Proof of Minimal Automaton 39 Consequently, the number of states in any DFA for L must be at least as many as the number of mutually distinguishable strings for L. But an irreducible DFA has the property that every indistinguishable string leads to the same state when starting from the initial state. Thus an irreducible automaton has as many states as there are distinguishable strings. Therefore, any other DFA must have at least as many states as the irreducible DFA 