1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 For next time: Read 2.1 & 2.2.

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
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
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.
CS 310 – Fall 2006 Pacific University CS310 Converting NFA to DFA Sections:1.2 Page 54 September 15, 2006.
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.
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
1 Finite Automata. 2 Finite Automaton Input “Accept” or “Reject” String Finite Automaton Output.
Regular Expression (EXTRA)
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.
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.
Language: Set of Strings
Decidable languages Section 4.1 CSC 4170 Theory of Computation.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Complexity and Computability Theory I Lecture #8 Instructor: Rina Zviel-Girshin Lea Epstein.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
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.
The decidability of Presburger Arithmetic By Guillermo Guillen 04/13/05 Dr. Smith COT 6421 FIU Spring 2005.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA.
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.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Decidable.
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.
Busch Complexity Lectures: Reductions
Reductions Costas Busch - LSU.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
CS 154, Lecture 4: Limitations on DFAs (I),
More on DFA minimization and DFA equivalence
Non-Deterministic Finite Automata
Non-Deterministic Finite Automata
Chapter 1 Regular Language - 02
Instructor: Aaron Roth
Chapter 1 Regular Language
Regular Language Equivalence and DFA Minimization
Presentation transcript:

1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY For next time: Read 2.1 & 2.2

2 MINIMIZING DFAs

3 IS THIS MINIMAL? NO

4 IS THIS MINIMAL?

5 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)

6 NOT TRUE FOR NFAs

7 EXTENDING  Given DFA M = (Q, Σ, , q 0, F) extend  to  : Q  Σ* → Q as follows:  (q, ε) =  (q,  ) =  (q, w 1 …w k+1 ) =  (  (q, w 1 …w k ), w k+1 ) ^ ^ ^ ^^ A string w  Σ* distinguishes states q 1 from q 2 if  (q 1, w)  F   (q 2, w)  F ^^ q  (q,  )

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

9 Fix M = (Q, Σ, , q 0, F) and let p, q, r  Q Definition: p is distinguishable from q iff there is a w  Σ* that distinguishes p from q p is indistinguishable from q iff p is not distinguishable from q

10 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) p q r ww Suppose not:

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

13 Algorithm MINIMIZE Input: DFA M Output: DFA M MIN such that: M  M MIN M MIN has no inaccessible states M MIN is irreducible states of M MIN are pairwise distinguishable || Theorem: M MIN is the unique minimum

14 Idea: States of M MIN will be blocks of equivalent states of M Theorem: M MIN is the unique minimum Must show 2 things: Suppose M’ is a DFA equiv 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)

15 Idea: States of M MIN will be blocks of equivalent states of M

16 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 /

17 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 } / Make best effort to find pairs of states that are distinguishable. Pairs left over will be indistinguishable. IDEA! Output:

18 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 /

19 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 /

,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

22 If 2 states are not distinguished by table- filling algorithm, then they are equivalent Proof (by contradiction): Suppose there exist states p and q that aren’t distinguished by the T-F algorithm, but p ~ q / Then there exists w such that:  (p, w)  F and  (q, w)  F ^^ Of all such bad pairs, let (p, q) be a pair with the smallest |w| So, w =  w, where   Σ Let p =  (p,  ) and q =  (q,  ) Then (p, q) is also a bad pair (Why is |w| >0 ?)

23 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 } 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,  ) ] Must show  MIN is well defined!

24 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 } 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

,1 0 q0q0 q1q1 q3q3 q5q5 q4q4 0 1 q0q0 q0q0 q1q1 q1q1 q3q3 q3q3 q4q4 q4q4 d dd d dd q5q5 q5q5 d d d

28 *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

29 *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

30 *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 NB: If M is minimal, then M has no inaccessible states and is irreducible. (So claim implies * ) This Claim is also implying the converse, ie if M has no inaccessible states and is irreducible, then M is minimal. Proof. Let M min (  M  M MIN ) be minimal. Then M min  M MIN So, by Claim, both M min and M are isomorphic to M MIN NOT TRUE for NFAs !

31 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 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

32 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

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

34 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 

35 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 not indistinguishable w Accept w Reject w w Accept

36 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) ^

37 M MIN M Suppose there exist 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 not indistinguishable w Accept w Reject w w Accept The map is 1-1

38 How do we prove two regular expressions are equivalent?

39

40

41 Finish Reviewing Chapter 1 of the book and Read 2.1 & 2.2 for next time