l ecture 9,10 t heory of automata. dfa state minimization

36
LECTURE 9,10 THEORY OF AUTOMATA

Upload: jovany-saker

Post on 14-Dec-2015

226 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

LECTURE 9,10THEORY OF

AUTOMATA

Page 2: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

DFA state minimization

Page 3: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

Any language that can be expressed by a RE is said to be regular language, so if L1 and L2 are regular languages then L1 + L2 , L1L2 and L1* are also regular languages. This fact can be

proved by the following two methods1) By Regular Expressions2) By TGs

Page 4: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

By Regular Expressions As discussed earlier that if r1, r2 are regular

expressions, corresponding to the languages L1 and L2 then the languages

L1 + L2 , L1L2 and L1* generated by r1+ r2, r1r2 and r1*, are also regular languages.

Page 5: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

By TGs If L1 and L2 are regular languages then L1 and

L2 can also be expressed by some REs as well and hence using Kleene’s theorem, L1 and L2 can also be expressed by some TGs. Following are the methods showing that there exist TGs corresponding to L1 + L2, L1L2 and L1*

Page 6: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

By TGs If L1 and L2 are expressed by TG1 and TG2 then

following may be a TG accepting L1 + L2

Page 7: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

By TGs If L1 and L2 are expressed by the following TG1

and TG2

then following may be a TG accepting L1L2

Page 8: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

By TGs also a TG accepting L1* may be as under

Page 9: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

By TGs Example

Consider the following TGs

Page 10: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

By TGs Example

Following may be a TG accepting L1+L2

Page 11: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

By TGs Example

Also a TG accepting L1L2 may be

Page 12: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

By TGs Example

And a TG accepting L2*

Page 13: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

Complement of a language Let L be a language defined over an alphabet Σ,

then the language of strings, defined over Σ, not belonging to L, is called Complement of the language L, denoted by or L’.

Note For a certain language L, the complement of

is the given language L i.e. = L

Page 14: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES Theorem

If L is a regular language then, is also a regular language.

Proof Since L is a regular language, so by Kleene’s

theorem, there exists an FA, say F, accepting the language L.

Converting each of the final states of F to non-final states and old non-final states of F to final states, FA thus obtained will reject every string belonging to L and will accept every string, defined over Σ, not belonging to L.

Which shows that the new FA accepts the language . Hence using Kleene’s theorem can be expressed by some RE. Thus is regular.

Page 15: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

Theorem(cont.) If L is a regular language then, is also a

regular language. Example

Let L be the language over the alphabet Σ = {a, b}, consisting of only two words aba and abb, then the FA accepting L may be

Page 16: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

Example(cont.) Converting final states to non-final states and old

non-final states to final states, then FA accepting may be

Page 17: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

REGULAR LANGUAGES

Theorem Statement

If L1 and L2 are two regular languages, then L1 ∩ L2 is also regular.

Proof Using De-Morgan's law for sets

Since L1and L2 are regular languages, so are and . and being regular provide

that is also regular language and so

being complement of regular language is regular language.

Page 18: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

Following are example of finding an FA accepting the intersection of two regular languages.

Example Consider two regular languages L1 and L2,

defined over the alphabet Σ = {a, b}, where L1= language of words with double a’s. L2= language of words containing even number

of a’s. FAs accepting languages L1 and L2 may be as follows

Page 19: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

FAs accepting languages L1 and L2 may be as follows

FA1

FA2

Their corresponding REs may be r1 = (a+b)*aa(a+b)* r2 = (b+ab*a)*

Page 20: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

Now FAs accepting and , by definition, may be

Now FA accepting , using the method described earlier, may be as follows

Page 21: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

Now FA accepting , using the method described earlier, may be as follows

Page 22: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

Here all the possible combinations of states of and are considered

Page 23: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

An FA that accepts the language may be

Page 24: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

Corresponding RE can be determined as follows The regular expression defining the language L1

∩ L2 can be obtained, converting and reducing the previous FA into a GTG as after eliminating states z2 and z6

Page 25: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

z4 can obviously be eliminated as follows

eliminating the loops at z1 and z5

Thus the required RE may be (b+abb*ab)*a(a+bb*aab*a)(b+ab*a)*

Page 26: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

FA corresponding to intersection of two regular languages (short method) Let FA3 be an FA accepting L1 ∩ L2, then the

initial state of FA3 must correspond to the initial state of FA1 and the initial state of FA2.

Since the language corresponding to L1 ∩ L2 is the intersection of corresponding languages L1 and L2, consists of the strings belonging to both L1and L2, therefore a final state of FA3 must correspond to a final state of FA1 and FA2. Following is an example regarding short method of finding an FA corresponding to the intersection of two regular languages.

Page 27: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

Example Let r1 = (a+b)*aa(a+b)* and FA1 be also r2 = (b+ab*a)* and FA2 be

FA1

FA2

Page 28: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

An FA corresponding to L1 ∩ L2 can be determined as follows

Page 29: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

The corresponding transition diagram may be as follows

Page 30: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

NONREGULAR LANGUAGES

The language that cannot be expressed by any regular expression is called a Nonregular language.

The languages PALINDROME and PRIME are the examples of nonregular languages.

Note: It is to be noted that a nonregular language, by

Kleene’s theorem, can’t be accepted by any FA or TG.

Page 31: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

NONREGULAR LANGUAGES

Example Consider the language L = {Λ, ab, aabb, aaabbb,

…} i.e. {an bn : n=0,1,2,3,…} . Suppose, it is required to prove that this language is nonregular.

Page 32: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

NONREGULAR LANGUAGES

Pumping Lemma Statement

Let L be an infinite language accepted by a finite automaton with N states, then for all words w in L that have langth more than N, there are strings x,y and z (y being non-null string) and length(x) + length(y) ≤ N s.t. w = xyz and all strings of the form xynz are in L for n = 1,2,3, …

Page 33: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

NONREGULAR LANGUAGES

Pumping Lemma Proof The lemma can be proved, considering the

following examples

Page 34: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

NONREGULAR LANGUAGES Pumping Lemma Proof (Example) Consider the language PALINDROME which is

obviously infinite language. let the PALINDROME be a regular language and be

accepted by an FA of 78 states. Consider the word w = Decompose w as xyz, where x,y and z are all

strings belonging to Σ* while y is non-null string, s.t. length(x) + length(y) ≤ 78, which shows that the substring xy is consisting of a’s and xyyz will become , which is not in PALINDROME.

Hence pumping lemma is not satisfied for the language PALINDROME.

Page 35: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

MYHILL NERODE THEOREM

Statement For a language L, defined over an alphabetΣ, L partitions Σ* into distinct classes. If L is regular then, L generates finite number of

classes. If L generates finite number of classes then L is

regular. The proof is obvious from the following examples

Page 36: L ECTURE 9,10 T HEORY OF AUTOMATA. DFA state minimization

MYHILL NERODE THEOREM

Example Consider the language L of strings, defined over

Σ = {a,b}, ending in a. It can be observed that L partitions Σ* into the

following two classes C1 = set of all strings ending in a. C2 = set of all strings not ending in a. Since there are finite many classes generated by

L, so L is regular and hence following is an FA, built with the help of C1 and C2, accepting L.