FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA.

Slides:



Advertisements
Similar presentations
CSE 311 Foundations of Computing I
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:
Lecture 24 MAS 714 Hartmut Klauck
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
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Fall 2006Costas Busch - RPI1 Regular Expressions.
Transparency No Formal Language and Automata Theory Chapter 10 The Myhill-Nerode Theorem (lecture 15,16 and B)
Fall 2006Costas Busch - RPI1 Deterministic Finite Automata And Regular Languages.
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 Regular.
Regular Expression (EXTRA)
CS 310 – Fall 2006 Pacific University CS310 Decidability Section 4.1/4.2 November 10, 2006.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
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.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
1 Non-Deterministic Automata Regular Expressions.
Finite Automata Costas Busch - RPI.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY For next time: Read 2.1 & 2.2.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Transparency No. 8-1 Formal Language and Automata Theory Chapter 8 DFA state minimization (lecture 13, 14)
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA minimization.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
Introduction to CS Theory
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?”
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.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
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.
Language: Set of Strings
Decidable languages Section 4.1 CSC 4170 Theory of Computation.
Complexity and Computability Theory I Lecture #8 Instructor: Rina Zviel-Girshin Lea Epstein.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Cs3102: Theory of Computation Class 5: Non-Regular Languages Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint.
CSCI 2670 Introduction to Theory of Computing September 13.
Regular Expressions Costas Busch - LSU.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA minimization.
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 4 Decidability Some slides are in courtesy.
Algorithms for hard problems Automata and tree automata Juris Viksna, 2015.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY * Read chapter 4 of the book for next time * Lecture9x.ppt.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Chapter 2 Regular Languages & Finite Automata. Regular Expressions A finitary denotation of a regular language over . ØL Ø = Ø aL a = {a} where a ∈ 
Non Deterministic Automata
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Hierarchy of languages
CS 154, Lecture 4: Limitations on DFAs (I),
More on DFA minimization and DFA equivalence
Non-Deterministic Finite Automata
Chapter 1 Regular Language - 02
Instructor: Aaron Roth
Chapter 1 Regular Language
Regular Language Equivalence and DFA Minimization
Presentation transcript:

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA

MINIMIZING DFAs THURSDAY Jan 24

IS THIS MINIMAL? NO

IS THIS MINIMAL?

THEOREM For every regular language L, there exists a UNIQUE (up to re-labeling of the states) minimal DFA M such that L = L(M)

NOT TRUE FOR NFAs

EXTENDING  Given DFA M = (Q, Σ, , q 0, F) extend  to  : Q  Σ* → Q as follows:  (q, ε) =  (q,  ) =  (q,  1 …  k+1 ) =  (  (q,  1 …  k ),  k+1 ) ^ ^ ^ ^ ^ String w  Σ* distinguishes states q 1 and q 2 iff  (q 1, w)  F   (q 2, w)  F ^ ^ q  (q,  ) ^ Note:  (q 0, w)  F  M accepts w

EXTENDING  Given DFA M = (Q, Σ, , q 0, F) extend  to  : Q  Σ* → Q as follows:  (q, ε) =  (q,  ) =  (q,  1 …  k+1 ) =  (  (q,  1 …  k ),  k+1 ) ^ ^ ^ ^ ^ String w  Σ* distinguishes states q 1 and q 2 iff q  (q,  ) ^ Note:  (q 0, w)  F  M accepts w exactly ONE of  (q 1, w),  (q 2, w) is a final state ^ ^

Fix M = (Q, Σ, , q 0, F) and let p, q  Q DEFINITION: p is distinguishable from q iff there is a w  Σ* that distinguishes p and q p is indistinguishable from q iff p is not distinguishable from q iff for all w  Σ*,  (p, w)  F   (q, w)  F ^ ^

0 0, q0q0 q1q1 q2q2 q3q3 ε distinguishes accept from non-accept states

Fix M = (Q, Σ, , q 0, F) and let p, q, r  Q Define relation ~ : p ~ q iff p is indistinguishable from q p ~ q iff p is distinguishable from q / Proposition: ~ is an equivalence relation p ~ p (reflexive) p ~ q  q ~ p (symmetric) p ~ q and q ~ r  p ~ r (transitive) Proof (of transitivity): for all w, we have:  (p, w)  F   (q, w)  F   (r, w)  F ^ ^ ^

Fix M = (Q, Σ, , q 0, F) and let p, q, r  Q Proposition: ~ is an equivalence relation so ~ partitions the set of states of M into disjoint equivalence classes q0q0 Q q [q] = { p | p ~ q }

p ~ q iff p is indistinguishable from q p ~ q iff p is distinguishable from q / Proposition: ~ is an equivalence relation p ~ p (reflexive) p ~ q  q ~ p (symmetric) p ~ q and q ~ r  p ~ r (transitive) so ~ partitions the set of states of M into disjoint equivalence classes q0q0 Q q [q] = { p | p ~ q }

Algorithm MINIMIZE Input: DFA M Output: DFA M MIN such that: M  M MIN (that is, L(M) = L(M MIN )) M MIN has no inaccessible states M MIN is irreducible all states of M MIN are pairwise distinguishable || Theorem: M MIN is the unique minimum DFA

Idea: States of M MIN will be blocks of equivalent states of M Theorem: M MIN is the unique minimum Must show: Suppose M’  M, then 1. # states in M’  # states in M MIN 2. If # states in M’ = # states in M MIN then M’ is isomorphic to M MIN (i.e. same up to re-labeling of states)

Intuition: States of M MIN will be blocks of equivalent states of M We’ll find these equivalent states with a “Table-Filling” Algorithm

TABLE-FILLING ALGORITHM Input: DFA M = (Q, Σ, , q 0, F) Output: (2) E M = { [q] | q  Q } (1) D M = { (p,q) | p,q  Q and p ~ q } / q0q0 q1q1 qiqi qnqn q0q0 q1q1 qiqi qnqn Base Case: p accepts and q rejects  p ~ q / Recursion: ddd d d p p q q ~/    p ~ q /

TABLE-FILLING ALGORITHM Input: DFA M = (Q, Σ, , q 0, F) (2) E M = { [q] | q  Q } (1) D M = { (p,q) | p,q  Q and p ~ q } / We know how to find those pairs of states that ε distinguishes… Use this and recursion to find those pairs distinguishable with longer strings Pairs left over will be indistinguishable IDEA: Output:

TABLE-FILLING ALGORITHM Input: DFA M = (Q, Σ, , q 0, F) Output: (2) E M = { [q] | q  Q } (1) D M = { (p,q) | p,q  Q and p ~ q } / q0q0 q1q1 qiqi qnqn q0q0 q1q1 qiqi qnqn Base Case: p accepts and q rejects  p ~ q /

TABLE-FILLING ALGORITHM Input: DFA M = (Q, Σ, , q 0, F) Output: (2) E M = { [q] | q  Q } (1) D M = { (p,q) | p,q  Q and p ~ q } / q0q0 q1q1 qiqi qnqn q0q0 q1q1 qiqi qnqn Recursion: if there is σ  Σ and states p, q satisfying DD D  (p,  ) = p  (q,  ) = q ~/  p ~ q / Base Case: p accepts and q rejects  p ~ q / Repeat until no more new D’s

,1 0 q0q0 q0q0 q1q1 q1q1 q2q2 q2q2 q3q3 q3q3 q0q0 q1q1 q2q2 q3q3 DDD D D D

q0q0 q0q0 q1q1 q1q1 q2q2 q2q2 q3q3 q3q3 DD D D q0q0 q1q1 q2q2 q3q3

Claim: If p, q are distinguished by Table- Filling algorithm, then p ~ q Proof: By induction on the length of the string distinguishing them. If (p, q) is marked D at the start, then one’s in F and one isn’t, so ε distinguishes p and q Then there are states p, q, and string w such that:  (p, w)  F and  (q, w)  F ^^ 2. p =  (p,  ) and q =  (q,  ), where   Σ The string  w distinguishes p and q! / Suppose (p, q) is marked D at a later point. 1. (p, q) are marked D  p ~ q (by induction)  /

Claim: If p, q are not distinguished by Table- Filling algorithm, then p ~ q Proof (by contradiction): Suppose the pair (p, q) is not marked D by the algorithm, yet p ~ q (a “bad pair”) / Then there is a string w such that:  (p, w)  F and  (q, w)  F ^^ Of all such bad pairs, let p, q be a pair with the shortest w So, w =  w, where   Σ Let p =  (p,  ) and q =  (q,  ) Then (p, q) is also a bad pair, but with a SHORTER w ! (Why is |w| >0 ?)

Algorithm MINIMIZE Input: DFA M Output: DFA M MIN (1) Remove all inaccessible states from M (2) Apply Table-Filling algorithm to get: E M = { [q] | q is an accessible state of M } Q MIN = E M, q 0 MIN = [q 0 ], F MIN = { [q] | q  F }  MIN ( [q],  ) = [  ( q,  ) ] Must show  MIN is well defined! Define: M MIN = (Q MIN, Σ,  MIN, q 0 MIN, F MIN )

Algorithm MINIMIZE Input: DFA M Output: DFA M MIN (1) Remove all inaccessible states from M (2) Apply Table-Filling algorithm to get: E M = { [q] | q is an accessible state of M } Define: M MIN = (Q MIN, Σ,  MIN, q 0 MIN, F MIN ) Q MIN = E M, q 0 MIN = [q 0 ], F MIN = { [q] | q  F }  MIN ( [q],  ) = [  ( q,  ) ] Claim: M MIN  M

q0q0 q1q1 q2q2 MINIMIZE

,1 0 q0q0 q1q1 q3q3 q5q5 q4q4 0 1 q2q2 q0q0 q0q0 q1q1 q1q1 q3q3 q3q3 q4q4 q4q4 D DD D DD q5q5 q5q5 D D D

q0q0 q1q1 q3q3 q5q5 q4q4 0 1 q0q0 q0q0 q1q1 q1q1 q3q3 q3q3 q4q4 q4q4 D DD D DD q5q5 q5q5 D D D

*M MIN is the unique minimal DFA equivalent to M Suppose M  M MIN, and M has no inaccessible states and is irreducible Claim: There exists a 1-1 onto correspondence (preserving transitions) between M and M MIN Proof: We will construct a map recursively Base Case: q 0 MIN → q 0 Recursive Step: If p → p q  q Then q → q

*M MIN is the unique minimal DFA equivalent to M Claim: Suppose M  M MIN, and M has no inaccessible states and is irreducible. Then there is a bijection that preserves transitions between M and M MIN

*M MIN is the unique minimal DFA equivalent to M Claim: Suppose M  M MIN, and M has no inaccessible states and is irreducible. Then there is a bijection that preserves transitions between M and M MIN Note: If M is minimal, then M has no inaccessible states and is irreducible. (So the Claim implies *) Corollary to the Claim: If M has no inaccessible states and is irreducible, then M is minimal. Proof: Let M min  M be minimal. Then M min  M MIN So, by Claim, both M min and M are isomorphic to M MIN NOT TRUE for NFAs !

Proof: We construct a map from M MIN to M recursively Base Case: q 0 MIN → q 0 Recursive Step: If p → p q  q Then q → q *M MIN is the unique minimal DFA equivalent to M Claim: Suppose M  M MIN, and M has no inaccessible states and is irreducible. Then there is a bijection that preserves transitions between M and M MIN

Base Case: q 0 MIN → q 0 Recursive Step: If p → p q  q Then q → q We need to prove: The map is defined everywhere The map is well defined The map is a bijection That is, for all q  M MIN there is a q  M such that q → q If q  M MIN, there is a string w such that  MIN (q 0 MIN,w) = q ^ Let q =  (q 0,w). q will map to q ^

Base Case: q 0 MIN → q 0 Recursive Step: If p → p q  q Then q → q The map is well defined Suppose there exist q and q  such that q → q and q → q  We show that q and q  are indistinguishable, so it must be that q = q 

M MIN M Suppose there exist q and q  such that q → q and q → q  q u q0q0 q  v q0q0 q u q 0 MIN q v Suppose q and q  are distinguishable w Accept w Reject w w Accept Contradiction!

Base Case: q 0 MIN → q 0 Recursive Step: If p → p q  q Then q → q The map is onto For all q  M there is a q  M MIN such that q → q If q  M, there is w such that  (q 0,w) = q ^ Let q =  MIN (q 0 MIN,w) ^

M MIN M Suppose there are distinct p and q such that p → q and q → q q u q0q0 q v q0q0 p u q 0 MIN q v Suppose p and q are distinguishable w Accept w Reject w w Accept The map is 1-1 Contradiction!

How can we prove that two regular expressions are equivalent?

Finish reviewing Chapter 1 of the book and read 2.1 & 2.2 for next time