CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA minimization.

Slides:



Advertisements
Similar presentations
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Properties.
Advertisements

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:
Finite Automata CPSC 388 Ellen Walker Hiram College.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Summary Showing regular Showing non-regular construct DFA, NFA
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
CS5371 Theory of Computation
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Fall 2008.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
CS 310 – Fall 2006 Pacific University CS310 Decidability Section 4.1/4.2 November 10, 2006.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Limitations.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
1 CSCI 3130: Formal Languages and Automata Theory Tutorial 4 Hung Chun Ho Office: SHB 1026 Department of Computer Science & Engineering.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Finite Automata Costas Busch - RPI.
CS Chapter 2. LanguageMachineGrammar RegularFinite AutomatonRegular Expression, Regular Grammar Context-FreePushdown AutomatonContext-Free Grammar.
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.
Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Fall 2011.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA to regular.
Tutorial CSC3130 : Formal Languages and Automata Theory Haifeng Wan ( )
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Closure.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong NFA to DFA.
Decidable Questions About Regular languages 1)Membership problem: “Given a specification of known type and a string w, is w in the language specified?”
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Text search.
Transition Diagrams Lecture 3 Wed, Jan 21, Building Transition Diagrams from Regular Expressions A regular expression consists of symbols a, b,
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Decidable languages Section 4.1 CSC 4170 Theory of Computation.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Turing Machines.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong NFA to.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Undecidable.
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
CSCI 3130: Formal languages and automata theory Tutorial 7 Chin.
CS 154 Formal Languages and Computability February 11 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong NP-complete.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Decidable.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Undecidable.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Nondeterminism The Chinese University of Hong Kong Fall 2011
More variants of Turing Machines
Undecidable problems for CFGs
Nondeterministic Finite Automata
Reducibility The Chinese University of Hong Kong Fall 2010
More on DFA minimization and DFA equivalence
Non-Deterministic Finite Automata
NFAs, DFAs, and regular expressions
Decidable and undecidable languages
More undecidable languages
NFA to DFA conversion and regular expressions
Non-regular languages
Non-regular languages
Regular Language Equivalence and DFA Minimization
Pushdown automata The Chinese University of Hong Kong Fall 2011
More undecidable languages
Text search and closure properties
Chapter # 5 by Cohen (Cont…)
DFA minimization The Chinese University of Hong Kong Fall 2011
Non Deterministic Automata
Nondeterminism The Chinese University of Hong Kong Fall 2010
Presentation transcript:

CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA minimization Fall 2009

Example Construct a DFA over alphabet {0, 1} that accepts those strings that end in 111 This is big, isn’t there a smaller DFA for this? 0 1 … … … … qq qq qq q  q  q  q  q  q  q  q 

Smaller DFA qq qq qq qq 11 Can we do it with 3 states?

Even smaller DFA? Suppose we had a 3 state DFA M for L … let’s imagine what happens when: By the pigeonhole principle, on two of these inputs M ends in the same state M inputs: , 1, 11, 111

Pigeonhole principle Here, balls are inputs, bins are states: Suppose you are tossing m balls into n bins, and m > n. Then two balls end up in the same bin. If you have a DFA with n states and you run it on m inputs, and m > n, then two inputs end up in same state.

A smaller DFA Suppose M ends up in the same state after reading inputs x = 1 and y = 11 Then after reading one more 1 –The state of x1 = 11 should be rejecting –The state of y1 = 111 should be accepting … but they are both the same state! M inputs: , 1, 11, 111 1, 11 11, 111 “ends in 111”

A smaller DFA Suppose M ends up in the same state after reading inputs x =  and y = 1 Then after reading 11 –The state of x1 = 11 should be rejecting –The state of y1 = 111 should be accepting … but they are both the same state! M inputs: , 1, 11, 111 , 1 11, 111 “ends in 111”

No smaller DFA! After looking at all possible pairs for x, y, x ≠ y we conclude that So, this DFA is minimal There is no DFA with 3 states for L 1 qq qq qq qq ( , 1)( , 11)( , 111) (1, 11)(1, 111)(11, 111)

DFA minimization We will show how to turn any DFA for L into the minimal DFA for L 0 1 … … … … qq qq qq q  q  q  q  q  q  q  q  qq qq qq qq

Minimal DFAs and distinguishable states First, we have to understand minimal DFAs: qq qq qq qq 11 rejectaccept minimal DFA every pair of states is distinguishable

Distinguishable states Two states q and q’ are distinguishable if q q’ w1w1 w1w1 w2w2 w2w2 wkwk wkwk w k-1 … … on the same continuation string w 1 w 2...w k, one accepts, but the other rejects reject accept

Examples of distinguishable states distinguishable by 01 (q 0, q 2 ) (q 0, q 3 ) (q 0, q 1 ) (q 1, q 3 ) (q 2, q 3 ) (q 1, q 2 ) distinguishable by 1 distinguishable by  distinguishable by 1 distinguishable by  qq qq qq qq DFA is minimal

Examples of distinguishable states distinguishable by  qq qq qq qq , 1 q0q0 qq qq 0 1 (q 1, q 3 ) (q 2, q 3 ) (q 0, q 3 ) (q 0, q 2 ) (q 0, q 1 ) (q 1, q 2 ) distinguishable by  distinguishable by 0 indistinguishable indistinguishable pairs can be merged

Examples of distinguishable states distinguishable by  (q 1, q 2 ) (q 0, q 3 ) (q 0, q 2 ) (q 0, q 1 ) (q 2, q 3 ) (q 1, q 3 ) distinguishable by  indistinguishable qq qq qq qq 1 0, 1 0 q  q  0, 1

Finding (in)distinguishable states Rule 1: Rule 2: q q’ If q is accepting and q’ is rejecting Mark (q, q’) as distinguishable (x) x q1q1 q1’q1’ x x q2q2 q2’q2’ aa If (q 1, q 1 ’) are marked, Mark (q 2, q 2 ’) as distinguishable (x) Rule 3: Unmarked pairs are indistinguishable Merge them together

Example of DFA minimization 0 1 qq qq qq q  q  q  q  qq qq q  q  q  q  qq qq qq q  q 

Example of DFA minimization 0 1 qq qq qq q  q  q  q  xxxxxx qq qq q  q  q  q  qq qq qq q  q   q 11 is distinguishable from all other states

Example of DFA minimization 0 1 qq qq qq q  q  q  q  x x x x x x xxxx qq qq q  q  q  q  qq qq qq q  q   q 1 is distinguishable from q , q 0, q 00, q 10 On transition 1, they go to distinguishable states

Example of DFA minimization 0 1 qq qq qq q  q  q  q  x x x x x x x x x x x x xx qq qq q  q  q  q  qq qq qq q  q   q 01 is distinguishable from q , q 0, q 00, q 10 On transition 1, they go to distinguishable states

Example of DFA minimization 0 1 qq qq qq q  q  q  q  A x A x A x x A x A x x B x x x A x x xx qq qq q  q  q  q  qq qq qq q  q   Merge states not marked distinguishable q , q 0, q 00, q 10 are equivalent → group A q 1, q 01 are equivalent → group B q 11 cannot be merged → group C A B C

Example of DFA minimization 0 1 qq qq qq q  q  q  q  A x A x A x x A x A x x B x x x A x x xx qq qq q  q  q  q  qq qq qq q  q  1 qq qq qCqC minimized DFA: A B C

Food for thought Why does method find all distinguishable pairs? q q’ w1w1 w1w1 w2w2 w2w2 wkwk wkwk w k-1 … … x xxx Because we work backwards

Food for thought Why are there no inconsistencies when we merge? A q3q3 q7q7 q1q1 B q5q5 q2q2 C q6q6 a a Because we only merge indistinguishable states w w

Food for thought Why is there no smaller DFA? M q q’ v v’v’ smaller DFA M’ q’’ v, v’ Suppose there is By the pigeonhole principle this must happen:

Food for thought Why is there no smaller DFA? But then M smaller DFA M’ q q’ v v’v’ q’’ v, v’ w w ? w Every pair of states is distinguishable q’’ cannot exist!