1 Decision Properties of Regular Languages General Discussion of “Properties” The Pumping Lemma Minimizing DFA.

Slides:



Advertisements
Similar presentations
&& Department of nskinfo-i educationwww.nsksofttch.com CS2303-THEORY OF COMPUTATION uChapter: Closure.
Advertisements

Properties of Regular Sets
The Pumping Lemma for CFL’s
Chapter Three: Closure Properties for Regular Languages
CSE 311 Foundations of Computing I
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:
CSC 361NFA vs. DFA1. CSC 361NFA vs. DFA2 NFAs vs. DFAs NFAs can be constructed from DFAs using transitions: Called NFA- Suppose M 1 accepts L 1, M 2 accepts.
Lecture 24 MAS 714 Hartmut Klauck
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
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 Midterm I review Reading: Chapters Test Details In class, Wednesday, Feb. 25, :10pm-4pm Comprehensive Closed book, closed notes.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Normal Forms for CFG’s Eliminating Useless Variables Removing Epsilon
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
Courtesy Costas Busch - RPI1 Non-regular languages.
Nondeterministic Finite Automata
Homework 4 Solutions.
Normal forms for Context-Free Grammars
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
Definitions Equivalence to Finite Automata
CS 503 Spring semester 2015 WPI Most of the slides below are due to Jeffrey Ullman (one of our textbok’s authors). They are slides from a course he gave.
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
Theory of Computing Lecture 22 MAS 714 Hartmut Klauck.
Decision Properties of Regular Languages
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism.
Properties of Context-Free Languages
What Are They? Who Needs ‘em? An Example: Scoring in Tennis Finite Automata 11.
Extra on Regular Languages and Non-Regular Languages
Properties of Regular Languages
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
Introduction to CS Theory
Decidable Questions About Regular languages 1)Membership problem: “Given a specification of known type and a string w, is w in the language specified?”
CHAPTER 1 Regular Languages
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.
Closure Properties Lemma: Let A 1 and A 2 be two CF languages, then the union A 1  A 2 is context free as well. Proof: Assume that the two grammars are.
Chapter 4 Properties of Regular Languages
Conversions & Pumping Lemma CPSC 388 Fall 2001 Ellen Walker Hiram College.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
Introduction to Finite Automata
1 Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism.
Deterministic Finite Automata
Algorithms for hard problems Automata and tree automata Juris Viksna, 2015.
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.
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
General Discussion of “Properties” The Pumping Lemma Membership, Emptiness, Etc.
Standard Representations of Regular Languages
PROPERTIES OF REGULAR LANGUAGES
CSE 3813 Introduction to Formal Languages and Automata
Intro to Theory of Computation
Decision Properties of Regular Languages
CS 154, Lecture 4: Limitations on DFAs (I),
Infiniteness Test The Pumping Lemma Nonregular Languages
4. Properties of Regular Languages
Introduction to Finite Automata
Elementary Questions about Regular Languages
Chapter 1 Regular Language - 02
Regular Language Equivalence and DFA Minimization
CHAPTER 1 Regular Languages
Presentation transcript:

1 Decision Properties of Regular Languages General Discussion of “Properties” The Pumping Lemma Minimizing DFA

2 Properties of Language Classes uA language class is a set of languages. wExample: the regular languages. uLanguage classes have two important kinds of properties: 1.Decision properties. 2.Closure properties.

3 Closure Properties uA closure property of a language class says that given languages in the class, an operation (e.g., union) produces another language in the same class. uExample: the regular languages are obviously closed under union, concatenation, and (Kleene) closure. wUse the RE representation of languages.

4 Representation of Languages uRepresentations can be formal or informal. uExample (formal): represent a language by a RE or FA defining it. uExample: (informal): a logical or prose statement about its strings: w{0 n 1 n | n is a nonnegative integer} w“The set of strings consisting of some number of 0’s followed by the same number of 1’s.”

5 Decision Properties uA decision property for a class of languages is an algorithm that takes a formal description of a language (e.g., a DFA) and tells whether or not some property holds. uExample: Is language L empty?

6 Why Decision Properties? uThink about DFA’s representing protocols. uExample: “Does the protocol terminate?” = “Is the language finite?” uExample: “Can the protocol fail?” = “Is the language nonempty?” wMake the final state be the “error” state.

7 Why Decision Properties – (2) uWe might want a “smallest” representation for a language, e.g., a minimum-state DFA or a shortest RE. uIf you can’t decide “Are these two languages the same?” wI.e., do two DFA’s define the same language? You can’t find a “smallest.”

8 The Membership Problem uOur first decision property for regular languages is the question: “is string w in regular language L?” uAssume L is represented by a DFA A. uSimulate the action of A on the sequence of input symbols forming w.

9 Example: Testing Membership Start 1 0 ACB 1 0 0, Next symbol Current state

10 Example: Testing Membership Start 1 0 ACB 1 0 0, Next symbol Current state

11 Example: Testing Membership Start 1 0 ACB 1 0 0, Next symbol Current state

12 Example: Testing Membership Start 1 0 ACB 1 0 0, Next symbol Current state

13 Example: Testing Membership Start 1 0 ACB 1 0 0, Next symbol Current state

14 Example: Testing Membership Start 1 0 ACB 1 0 0, Next symbol Current state

15 What if We Have the Wrong Representation? uThere is a circle of conversions from one form to another: RE DFA NFA ε -NFA

16 The Emptiness Problem uGiven a regular language, does the language contain any string at all? uAssume representation is DFA. uCompute the set of states reachable from the start state. uIf at least one final state is reachable, then yes, else no.

17 The Infiniteness Problem uIs a given regular language infinite? uStart with a DFA for the language. uKey idea: if the DFA has n states, and the language contains any string of length n or more, then the language is infinite. uOtherwise, the language is surely finite. wLimited to strings of length n or less.

18 Proof of Key Idea uIf an n-state DFA accepts a string w of length n or more, then there must be a state that appears twice on the path labeled w from the start state to a final state. uBecause there are at least n+1 states along the path.

19 Proof – (2) w = xyz q x y z Then xy i z is in the language for all i > 0. Since y is not ε, we see an infinite number of strings in L.

20 The Pumping Lemma uRegular languages wAccepted by DFA, NFA, ε-NFA, RE wSome languages are not regular upumping lemma for regular languages is used to show a language is NOT regular

21 Statement of the Pumping Lemma For every regular language L There is an integer n, such that For every string w in L of length > n We can write w = xyz such that: 1.|xy| < n. 2.|y| > 0. 3.For all i > 0, xy i z is in L. Number of states of DFA for L Labels along first cycle on path labeled w

Pumping lemma uWe can find a nonempty string y not far from the beginning and can be pumped (repeated) as many times as you like and the result should still be in the language L 1.|xy| < n. 2.|y| > 0. 3.For all i > 0, xy i z is in L 22 q x y z

Adversarial Game uProver (P) vs. Adversary (A) wProver wants to prove L is not regular 1.P picks language L to prove nonregular 2.A picks n but not reveal it 3.P picks w > n, usually w depends on n ww L 4.A divides w into w = xyz without showing how but |xy| 0 5.P wins by picking k s.t. xy k z is NOT in L 23

24 Example: Use of Pumping Lemma uWe have claimed {0 k 1 k | k > 1} is not a regular language. 1.P picks L = {0 k 1 k | k > 1} 2.A picks n wWe don’t know what n is, some fixed value 3.P picks w = 0 n 1 n 4.A write w = xyz, |xy| < n, and y  ε. wxy must be all 0’s 5.xyyz NOT in L so proved L is not regular

Another Example uL pr consists of 1’s with length prime uP picks L pr and A picks n uP picks w = 1 p s.t. p > n+2  A picks w = xyz, |xy| < n, and y  ε wLet |y|=m and |xz|= p-m uP pumps y (p-m) times w|xy p-m z|=|xz|+(p-m)|y| = (p-m)(m+1) wThis is not prime so not in L 25

26 Efficient State Minimization uConstruct a table with all pairs of states. uIf you find a string that distinguishes two states (takes exactly one to an accepting state), mark that pair.

27 Love Start Love Love s o Love all 30-Love s s o o Love Love s s s o o o Server Wins Opp’nt Wins s o all s s s o o o s s s o o o deuce s s o o Ad-out Ad-in s o s o s o

28 State Minimization – (2) uBasis: Mark pairs with exactly one final state.  Induction: mark [q, r] if for some input symbol a, [ δ (q,a), δ (r,a)] is marked. uAfter no more marks are possible, the unmarked pairs are equivalent and can be merged into one state.

29 Transitivity of “Indistinguishable” uIf state p is indistinguishable from q, and q is indistinguishable from r, then p is indistinguishable from r. uProof: The outcome (accept or don’t) of p and q on input w is the same, and the outcome of q and r on w is the same, then likewise the outcome of p and r.

30 Constructing the Minimum- State DFA uSuppose q 1,…,q k are indistinguishable states. uReplace them by one representative state q.  Then δ (q 1, a),…, δ (q k, a) are all indistinguishable states. wKey point: otherwise, we should have marked at least one more pair.  Let δ (q, a) = the representative state for that group.

31 Example: State Minimization r b {1} * {1,3,5,7,9}{2,4,6,8} {1,3,5,7,9} * {1,3,7,9}{2,4,6,8} {5} {2,4,6,8} {1,3,5,7,9}{2,4,6,8} {2,4,6,8} {1,3,7,9}{5} {2,4}{2,4,6,8} {1,3,5,7} {1,3,5,7} {2,4} {5} {2,4,6,8} {1,3,5,7,9} Remember this DFA? It was constructed for the chessboard NFA by the subset construction. r b A B C B D E C D F D D G E D G F D C G D G * * Here it is with more convenient state names

32 Example – Continued r b A B C B D E C D F D D G E D G F D C G D G * * G F E D C B A B C D E F x x x x x x x x x x Start with marks for the pairs with one of the final states F or G.

33 Example – Continued r b A B C B D E C D F D D G E D G F D C G D G * * G F E D C B A B C D E F x x x x x x x x x x Input r gives no help, because the pair [B, D] is not marked.

34 Example – Continued r b A B C B D E C D F D D G E D G F D C G D G * * G F E D C B A B C D E F x x x x x x x x x x But input b distinguishes {A,B,F} from {C,D,E,G}. For example, [A, C] gets marked because [C, F] is marked. x xx x x xx

35 Example – Continued r b A B C B D E C D F D D G E D G F D C G D G * * G F E D C B A B C D E F x x x x x x x x x x [C, D] and [C, E] are marked because of transitions on b to marked pair [F, G]. x xx x x xx xx

36 Example – Continued r b A B C B D E C D F D D G E D G F D C G D G * * G F E D C B A B C D E F x x x x x x x x x x [A, B] is marked because of transitions on r to marked pair [B, D]. x xx x x xx xx x [D, E] can never be marked, because on both inputs they go to the same state.

37 Example – Concluded r b A B C B D E C D F D D G E D G F D C G D G * * G F E D C B A B C D E F x x x x x x x x x x x xx x x xx xx x r b A B C B H H C H F H H G F H C G H G * * Replace D and E by H. Result is the minimum-state DFA.

38 Eliminating Unreachable States uUnfortunately, combining indistinguishable states could leave us with unreachable states in the “minimum-state” DFA. uThus, before or after, remove states that are not reachable from the start state.