Presentation is loading. Please wait.

Presentation is loading. Please wait.

FORMAL LANGUAGES AND AUTOMATA THEORY

Similar presentations


Presentation on theme: "FORMAL LANGUAGES AND AUTOMATA THEORY"— Presentation transcript:

1 FORMAL LANGUAGES AND AUTOMATA THEORY
C K Nagpal M.Tech. Ph.D. Associate Professor Computer Engg. YMCA University of Science & Technology

2 Chapter 4 Regular Grammar and Regular Sets
In these slides, we will cover the following topics: • Definition of regular expression and regular sets • Basic identities related to regular expressions • Kleene’s theorem • Finding a finite automaton corresponding to a regular expression and vice versa Conditions for Application of Arden’s Theorem Algorithm to Find Regular Expression Corresponding to a Finite Automaton Closure Properties of Regular Sets Finite Automata for Union, Intersection, and Difference • Using pumping lemma to prove that a language is not regular • Production system associated with regular languages Myhill Nerode Theorem Decision Problems Related to Finite Automata and Regular Languages Regular Languages and Current Programming Scenario

3 Regular Expression All alphabets ϵ If R then R*
If R1 and R2 then R1+R2 If R1 and R2 then R1R2 If R then (R) Combination of all the above Φ if L= { }

4 Regular Expressions and Regular Sets

5 Identities Related to Regular Expressions

6 Kleene’s Theorem Every regular language is accepted by some finite automaton. The language accepted by a finite automaton is regular.

7 Finite Automaton Corresponding to Regular Expression

8 Finite Automaton Corresponding to Regular Expression ( Contd.)

9 Regular Expression Corresponding to Finite Automaton

10 Conditions for Application of Arden’s Theorem
The FA should not contain ϵ moves There should be exactly one initial state There is an assumption while using the Arden’s theorem a state in Finite automaton is used like a regular expression

11 Algorithm to Find Regular Expression Corresponding to a Finite Automaton
1. Simplify M by eliminating unreachable states and dead-states. Because these are the states from where, it is not possible to reach to final state. 2. If all states are eliminated then the regular expression is Ф. 3. For each final-state qi in M, let Mi be the DFA which is same as M except that qi is the only final-state. Simplify Mi by eliminating unreachable states, if any, and then reduce Mi to a transition diagram. Let Ri be the corresponding regular expression. 4. The final regular expression for M is R1+R Rn where n = number of final-states in M

12 Closure Properties of Regular Sets
Union Concatenation Transpose Intersection Complement Difference Kleene’s Star

13 Finite Automata for Union, Intersection, and Difference
Let M1 be defined as M1(Q1, ∑, q1, δ1, F1) and M2 be defined as M2(Q2, ∑, q2, δ2, F2) where all the entities have the usual meaning. The finite automaton M (Q, ∑, q0, δ, F) for union, intersection and difference can be obtained as follow: Q=Q1 X Q2 q0 = (q1, q2) δ((p, q), a)= (δ1(p, a), δ2(q, a)) For union, F= (p, q) if p F1 or q F2. For intersection, F= (p, q) if p F1 and q F2. For difference, F= (p, q) if p F1 and q F2.

14 Pumping Lemma for Regular Languages
Let L be a regular language. Then there exists a constant n (whose value depends upon L) such that for every string w belonging to the language L and |w| ≥ n, w can be broken into three parts xyz such that y≠ϵ and |xy| ≤ n. Then for all i ≥ 0 the string xyiz also belongs to L. Application of Pumping Lemma L={0s| s is a perfect square} is not regular. L={0p| p is prime} is not regular L={w| w is palindrome} is not regular Suitability Pumping lemma is not necessary and sufficient condition to prove that a language L is not regular. It is not possible in all cases to apply pumping lemma to conclusively prove that a language is not regular. It is a one way mechanism. It can be used to prove that a language is not regular but vice versa is not possible.

15 Production System Associated with Regular Grammar
A→a A→aB

16 Myhill Nerode Theorem If number of equivalent classes over a language L is finite then the language L is regular Examples A language L over {0,1} such that every string ends with 0 can be divided into two equivalent classes. A language L over {0,1} such that every string ends with 00 can be divided into four two equivalent classes. A positive mechanism to prove that a language is regular.

17 Decision Problems Related to Finite Automata and Regular Languages
1. Given an arbitrary string x and a regular expression R, does x belong to the language L(R). Given a finite automaton M, is L(M)=Ф? Given a finite automaton M, is L(M) infinite. 4. Given two automata M1 and M2, if L1(M1)=L2(M2). 5. Given two automata M1 and M2, if L1(M1) is subset of L2(M2). 6. Given two automata M1 and M2, if L2(M1) ∩ L2(M2)=Ф. 7. Given two regular expressions R1 and R2, do they generate same language.

18 Regular Languages and Current Programming Scenario


Download ppt "FORMAL LANGUAGES AND AUTOMATA THEORY"

Similar presentations


Ads by Google