DFA Equivalence & Minimization

Slides:



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

CSE 311 Foundations of Computing I
Lecture 24 MAS 714 Hartmut Klauck
DFA Minimization Jeremy Mange CS 6800 Summer 2009.
Finite Automata CPSC 388 Ellen Walker Hiram College.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Examples for Finite Automata
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
CS 310 – Fall 2006 Pacific University CS310 Regular Expressions Sections:1.3 page 63 September 18, 2006 September 20, 2006.
1 The scanning process Goal: automate the process Idea: –Start with an RE –Build a DFA How? –We can build a non-deterministic finite automaton (Thompson's.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
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.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
CS 310 – Fall 2006 Pacific University CS310 Converting NFA to DFA Sections:1.2 Page 54 September 13, 2006.
Lecture 8 Sept 29, 2011 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to.
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY For next time: Read 2.1 & 2.2.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)
Regular Expressions (RE) Empty set Φ A RE denotes the empty set Empty string λ A RE denotes the set {λ} Symbol a A RE denotes the set {a} Alternation M.
NFA ε - NFA - DFA equivalence. What is an NFA An NFA is an automaton that its states might have none, one or more outgoing arrows under a specific symbol.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
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,
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA.
Jianguo Lu : Lab 3 Jan 30, Winter 2004.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
 2005 SDU Lecture11 Decidability.  2005 SDU 2 Topics Discuss the power of algorithms to solve problems. Demonstrate that some problems can be solved.
Lecture #5 Advanced Computation Theory Finite Automata.
NFAε - NFA - DFA equivalence
Non Deterministic Automata
Theory of Computation Lecture # 9-10.
Finite Automata & Regular Languages
Review: NFA Definition NFA is non-deterministic in what sense?
Examples for Finite Automata
Jaya Krishna, M.Tech, Assistant Professor
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Non-Determinism 12CS45 Finite Automata.
Non-Deterministic Finite Automata
COSC 3340: Introduction to Theory of Computation
Regular languages, regular expressions, & finite automata (intro)
Non-Deterministic Finite Automata
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.
Non Deterministic Automata
Transition Diagrams Lecture 3 Fri, Jan 21, 2005.
DFA-> Minimum DFA Module 05.4 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
CS 350 — Fall 2018 gilray.org/classes/fall2018/cs350/
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
CS21 Decidability and Tractability
Instructor: Aaron Roth
COP46– Programming Language Translators Dr. Manuel E. Bermudez
Are DFAs and NFAs Equivalent
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Regular Language Equivalence and DFA Minimization
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
Non Deterministic Automata
Lexical Analysis Uses formalism of Regular Languages
CSCI 2670 Introduction to Theory of Computing
Part Two : Nondeterministic Finite Automata
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

DFA Equivalence & Minimization CS 350 — Fall 2018 gilray.org/classes/fall2018/cs350/

Models of regular languages “Converts to” GNFA “Converts to” RE DFA “Minimizes to” NFA “Converts to” “Converts to”

For every regular language, there is a unique minimum-state DFA which accepts it. (Modulo the names of states in Q.) Thus for any given DFA we can compute its minimal equivalent DFA.

The basic idea: we collapse/merge two states in the input DFA whenever those two states are equivalent (i.e., behave exactly the same for identical strings/string-suffixes).

The basic idea: we collapse/merge two states in the input DFA whenever those two states are equivalent (i.e., behave exactly the same for identical strings/string-suffixes). Two states. q0 and q1 are equivalent if for all strings s, q0 accepts on string s exactly when q1 accepts on string s: ∀𝑠∈ Σ ∗ .( 𝑞 0 ,𝑠, 𝑞 0 ′ ).∈ 𝛿 ̂ ∧ 𝑞 0 ′ ∈𝐹⟺( 𝑞 1 ,𝑠, 𝑞 1 ′ )∈ 𝛿 ̂ ∧ 𝑞 1 ′ ∈𝐹

Hopcroft Minimization: starts with a minimal partitioning of accept states from non-accept states (these states cannot be equivalent). Minimization proceeds by iteratively splitting partitions as necessary until the partitioning reaches a fixed point: then each partition represents one state in the minimal DFA (except any unreachable states/partitions)! J. Hopcroft. “An n log n algorithm for minimizing states in a finite automaton”. 1971.

Splitting partitions: there is no need to split a partition (e. g Splitting partitions: there is no need to split a partition (e.g. P1) if all its states transition (on any given input) to the same partition (e.g., P2). This is true even if they do not transition to the same exact state. P1 P2 q0 a q3 a q1 q4 a q2

Splitting partitions: We must split/refine a partition (e. g Splitting partitions: We must split/refine a partition (e.g., P1 into P1 and P4) whenever a subset of its states (here q2) transition to states in a distinct partition (here q5) from those transitioned to (q3,q4 in P2) by other states in the partition (q0,q1). P1 P2 q0 a q3 q4 a q1 P3 b P4 a q5 q2

Hopcroft Minimization Input: DFA (Q, Σ, δQ, q0, FQ) parts = {Q-FQ, FQ} work = {FQ} While ∃ p ∈ work: work -= p For each s ∈ Σ: Let preds = {q | (q,s,q’) ∈ δQ ∧ q’ ∈ p} For part∈parts: If part∩preds≠∅ ∧ part-preds≠∅: parts = parts-part ∪ {part∩preds,part-preds} If part ∈ work: work = work-part ∪ {part∩preds,part-preds} Else If |part∩preds| <= |part-preds|: work = work ∪ {part∩preds} Else: work = work ∪ {part-preds} Each partition is now a state in the minimal DFA!

Try an example: Minimize the following DFA. q1 a c q0 b c q2 q3 dead 10

Try an example: Minimize the following DFA. a,b c q0 q2 q3 dead 11

Try an example: Minimize the following DFA. 1 q1 q3 q0 1 1 q4 q2 dead 12

Try an example: Minimize the following DFA. 1 0,1 q2 q0 q1 dead 13