1 Minimization; Pumping Lemma. October 2, 2001. 2 Agenda Minimization Algorithm Guarantees smallest possible DFA for a given regular language Proof of.

Slides:



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

Lecture 24 MAS 714 Hartmut Klauck
Theory Of Automata By Dr. MM Alam
Lecture 9,10 Theory of AUTOMATA
Regular Expressions and DFAs COP 3402 (Summer 2014)
Summary Showing regular Showing non-regular construct DFA, NFA
Fall 2006Costas Busch - RPI1 Non-regular languages (Pumping Lemma)
3.2 Pumping Lemma for Regular Languages Given a language L, how do we know whether it is regular or not? If we can construct an FA to accept the language.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Mount Holyoke College 2 Nonregular languages? We now know: –Regular languages may be specified either.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Fall Nonregular languages? We now know: –Regular languages may be specified either by regular.
Automata and Formal Languages Tim Sheard 1 Lecture 8 Pumping Lemma & Distinguishability Jim Hook Tim Sheard Portland State University.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (more on Section 1.4) David Martin This work is licensed under.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Regular Expression (EXTRA)
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Limitations.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Context Free Pumping Lemma Zeph Grunschlag. Agenda Context Free Pumping Motivation Theorem Proof Proving non-Context Freeness Examples on slides Examples.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
Theory of Computing Lecture 22 MAS 714 Hartmut Klauck.
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.4: Nonregular Languages) David Martin With some.
1 Non-regular languages. 2 Regular languages Non-regular languages.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA minimization.
Extra on Regular Languages and Non-Regular Languages
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
Tutorial CSC3130 : Formal Languages and Automata Theory Haifeng Wan ( )
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
Introduction to CS Theory
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.
Lines in the plane, slopes, and Euler’s formula by Tal Harel
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
CS 3240 – Chapter 4.  Closure Properties  Algorithms for Elementary Questions:  Is a given word, w, in L?  Is L empty, finite or infinite?  Are L.
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
Chapter 6 Properties of Regular Languages. 2 Regular Sets and Languages  Claim(1). The family of languages accepted by FSAs consists of precisely the.
Conversions & Pumping Lemma CPSC 388 Fall 2001 Ellen Walker Hiram College.
CS 203: Introduction to Formal Languages and Automata
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
CSCI 3130: Formal languages and automata theory Tutorial 3 Chin.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
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.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
1 Recap lecture 28 Examples of Myhill Nerode theorem, Quotient of a language, examples, Pseudo theorem: Quotient of a language is regular, prefixes of.
COMP3190: Principle of Programming Languages DFA and its equivalent, scanner.
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
1 Advanced Theory of Computation Finite Automata with output Pumping Lemma Theorem.
Lecture 15: Theory of Automata:2014 Finite Automata with Output.
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
Complexity and Computability Theory I
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
PROPERTIES OF REGULAR LANGUAGES
CSE 3813 Introduction to Formal Languages and Automata
Infiniteness Test The Pumping Lemma Nonregular Languages
Alternating tree Automata and Parity games
Principles of Computing – UFCFA3-30-1
Elementary Questions about Regular Languages
Non-regular languages
Pumping Lemma.
Chapter 4 Properties of Regular Languages
Nonregular languages & the pumping lemma
Non-Regular Languages
Instructor: Aaron Roth
Recap lecture 25 Intersection of two regular languages is regular, examples, non regular languages, example.
CHAPTER 1 Regular Languages
Presentation transcript:

1 Minimization; Pumping Lemma. October 2, 2001

2 Agenda Minimization Algorithm Guarantees smallest possible DFA for a given regular language Proof of this fact (Time allowing ) Pumping Lemma Gives a way of determining when certain languages are non-regular A direct consequence of applying pigeonhole principle to automata (Time allowing )

3 Equivalent States. Example 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

4 Equivalent States. Example 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

5 Equivalent States. Example 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

6 Equivalent States. Example 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

7 Equivalent States. Definition 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.

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

9 Useless States 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

10 Minimization Algorithm. Goals 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. Later: remarkably, the algorithm actually produces smallest possible DFA for the given language, hence the name “minimization”. The minimization algorithm reverses previous example. Start with least possible number of states, and create new states when forced to. Explain with a game:

11 The Game of MINIMIZE 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.

12 The Game of MINIMIZE a b 1 d 0,1 e 1 c g f

13 Minimization Algorithm. (Partition Refinement) Code 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 )

14 Minimization Algorithm. (Partition Refinement) Code 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’ )

15 Minimization Example Start with a DFA

16 Minimization Example Miniature version 

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

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

19 Minimization Example 1-label splits up REJECT's

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

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

22 Minimization Example. Compare

23 Minimization Example. Compare

24 Minimization Example. Compare

25 Minimization Example. Compare

26 Minimization Example. Compare

27 Minimization Example. Compare

28 Minimization Example. Compare

29 Minimization Example. Compare

30 Minimization Example. Compare

31 Minimization Example. Compare ACCEPTED.

32 Minimization Example. Compare 10000

33 Minimization Example. Compare 10000

34 Minimization Example. Compare 10000

35 Minimization Example. Compare 10000

36 Minimization Example. Compare 10000

37 Minimization Example. Compare REJECT.

38 Proof of Minimal Automaton Previous algorithm guaranteed to produce an irreducible FA. Why should that FA be the smallest possible FA for its accepted language? Analogous question in calculus: Why should a local minimum be a global minimum? Usually not the case!

39 Proof of Minimal Automaton THM (Myhill-Nerode): 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, the path from their paths from the start state must have different endpoints.

40 Proof of Minimal Automaton Consequently, the number of states in any DFA for L must be as great as the number of mutually distinguishable strings for L. But an irreducible DFA has the property that every state gives rise to another mutually distinguishable string! Therefore, any other DFA must have at least as many states as the irreducible DFA  Let’s see how the proof works on a previous example:

41 Proof of Minimal Automaton. Example The “spanning tree of strings” { ,0,01,00} is a mutually distinguishable set (otherwise redundancy would occur and hence DFA would be reducible). Any other DFA for L has  4 states. a 0,1 e cg bf 0 1

42 The Pumping Lemma Motivation Consider the language L 1 = 01* = {0, 01, 011, 0111, … } The string 011 is said to be pumpable in L 1 because can take the underlined portion, and pump it up (i.e. repeat) as much as desired while always getting elements in L 1. Q: Which of the following are pumpable?

43 The Pumping Lemma Motivation Pumpable: 01111, 01111, 01111, 01111, etc. 2. Pumpable: not pumpable because most of 0* not in L 1 Define L 2 by the following automaton: Q: Is pumpable?

44 The Pumping Lemma Motivation A: Pumpable: 01010, Underlined substrings correspond to cycles in the FA! Cycles in the FA can be repeated arbitrarily often, hence pumpable. Let L 3 = {011,11010,000,  Q: Which strings are pumpable?

45 The Pumping Lemma Motivation A : None! When pumping any string non- trivially, always result in infinitely many possible strings. So no pumping can go on inside a finite set. Pumping Lemma give a criterion for when strings can be pumped:

46 Pumping Lemma THM: Given a regular language L, there is a number p (called the pumping number) such that any string in L of length  p is pumpable within its first p letters. In other words, for all u  L with |u |  p we we can write: u = xyz(x is a prefix, z is a suffix) |y |  1(mid-portion y is non-empty) |xy|  p(pumping occurs in first p letters) xy i z  L for all i  0(can pump y-portion)

47 Pumping Lemma Proof EX: Show that pal={x  *|x =x R } isn’t regular. 1. Assume pal were regular 2. Therefore it has a pumping no. p 3. But… consider the string 0 p 10 p. Can this string be pumped in its first p letters? The answer is NO because any augmenting of the first 0 p -portion results in a non- palindrome 4. (2)  (3) Therefore our assumption (1) was wrong and conclude that pal is not a regular language

48 Pumping Lemma Template In general, to prove that L isn’t regular: 1. Assume L were regular 2. Therefore it has a pumping no. p 3. Find a string pattern involving the length p in some clever way, and which cannot be pumped. This is the hard part. 4. (2)  (3) Therefore our assumption (1) was wrong and conclude that L is not a regular language

49 Pumping Lemma Examples Since parts 1, 2 and 4 are identical for any pumping lemma proof, following examples will only show part 3 of the proof.

50 Pumping Lemma Examples EX: Show that {a n b n | n = 0,1,2, … } is not regular. Part 3) Consider a p b p. By assumption, we can pump up within the first p letters of this string. Thus we get more a’s than b’s in the resulting string, which breaks the pattern.

51 Pumping Lemma Examples Pumping Down Sometimes it is useful to pump-down instead of up. In pumping down we simply erase the y portion of the pattern string. This is allowed by setting i = 0 in the pumping lemma: EX: Show that {a m b n | m > n} is not regular. Part 3) Consider a p+1 b p. By assumption, we can pump down within the first p letters of this string. As by assumption y is non-empty, we must decrease the number of a’s in the pattern, meaning that the number of a’s is less than or equal to the number of b’s, which breaks the pattern!

52 Pumping Lemma Examples Numerical Arguments Sometimes we have to look at the resulting pump-ups more carefully: EX: Show that {1 n | n is a prime number} is not regular. Part 3) Given p, choose a prime number n bigger than p. Consider 1 n. By assumption, we can pump within the first p letters of this string so we can pump 1 n. Let m be the length of the pumped portion x. Pumping i times (i = 0 means we pump-down) results in the string 1 (n-m)+im =1 n+(i-1)m. Q: Find an i making the exponent non-prime.

53 Pumping Lemma Examples Numerical Arguments A: Set i = n + 1. Then the pumped- up string is 1 n+(i-1)m =1 n+(n+1-1)m =1 n+nm =1 n(1+m) Therefore the resulting exponent is not a prime, which breaks the pattern.

54 Proof of Pumping Lemma Consider a graph with n vertices. Suppose you tour around visiting a certain number of nodes. Q: How many vertices can you visit before you are forced to see some vertex twice?

55 Proof of Pumping Lemma A: If you visit n+1 vertices, you must have seen some vertex twice. Q: Why?

56 Proof of Pumping Lemma. Pigeonhole Principle A: The pigeonhole principle. More precisely. Your visiting n+1 vertices defines the following function: f : {1, 2, 3, …, n+1}  {size-n set} f (i ) = i ‘th vertex visited Since domain is bigger than codomain, cannot be one-to-one.

57 Proof of Pumping Lemma Now consider an accepted string u. By assumption L is regular so let M be the FA accepting it. Let p = |Q | = no. of states in M. Suppose |u|  p. The path labeled by u visits p+1 states in its first p letters. Thus u must visit some state twice. The sub-path of u connecting the first and second visit of the vertex is a loop, and gives the claimed string y that can be pumped within the first p letters.