0% found this document useful (0 votes)
58 views10 pages

Lecture 21

The document discusses regular expressions and finite automata. It covers constructing finite automata from regular expressions, equivalence of finite automata, right and left linear grammars, constructing regular grammars from DFAs, and constructing finite automata from regular grammars. Examples are provided to illustrate each concept.

Uploaded by

ad.lusifar0007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views10 pages

Lecture 21

The document discusses regular expressions and finite automata. It covers constructing finite automata from regular expressions, equivalence of finite automata, right and left linear grammars, constructing regular grammars from DFAs, and constructing finite automata from regular grammars. Examples are provided to illustrate each concept.

Uploaded by

ad.lusifar0007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Theory of Automata and Formal Language

Lecture-21

Dharmendra Kumar
(Associate Professor)
Department of Computer Science and Engineering
United College of Engineering and Research, Prayagraj
May 6, 2021
Regular Expression

Construction of finite automata


from regular expression

Example: Construct finite automata for the following regular


expressions:-

1. r = (a + b)∗ (aa + bb)(a + b)∗


2. r = 10 + (0 + 11)0∗ 1
3. r = (a + b)∗ b(a + bb)∗
4. r = aa∗ + aba∗ b ∗

1
Regular Expression

Equivalence of two finite automata

Example: Consider two DFA M and M 0 :

Determine whether M and M 0 are equivalent. 2


Regular Expression

Example: Show that following automata M1 and M2 are not


equivalent.

3
Regular Expression

Right and Left linear grammars

A grammar is said to be right linear grammar if all production rules


are of the following form:-
A → xB or A → x, where A,B ∈ V and x∈ Σ∗
A grammar is said to be left linear grammar if all production rules
are of the following form:-
A → Bx or A → x, where A,B ∈ V and x∈ Σ∗
A regular grammar is one that is either right linear or left linear.

4
Regular Expression

Construction of regular grammar


from the given DFA

Suppose the given DFA is


M = ({q0 , q1 , ........, qn }, Σ, δ, q0 , F )
Now we construct the grammar G for M as
G = ({Q0 , Q1 , ............, Qn }, Σ, Q0 , P)
Where P is defined as
(i) Qi → aQj ∈ P if δ(qi , a) = qj ∈
/F
(ii) Qi → aQj and Qi → a ∈ P if δ(qi , a) = qj ∈ F

5
Regular Expression

Example: Find the regular grammar for the following DFA

Solution: Since the number of states are 2, therefore number of variables


in the grammar will be 2. Let these variables are Q0 and Q1 corresponding
to states q0 and q1 . The starting symbol will be Q0 .
The production rules of the grammar are the following:-
Q0 → aQ0
Q0 → b/bQ1
Q1 → a/b/aQ1 /bQ1
6
Regular Expression

Construction of a FA from given


regular grammar

G = ({A0 , A1 , ............, An }, Σ, A0 , P)
We construct finite automata M as
M = ({q0 , q1 , ........, qn , qf }, Σ, δ, q0 , {qf })
and δ is defined as
(i) If Ai → aAj then δ(qi , a) = qj
(i) If Ai → a then δ(qi , a) = qf

7
Regular Expression

Example: Let G = ({A0 , A1 }, {a, b}, A0 , P)


Where P is
A0 → aA1 , A1 → bA1 , A1 → a, A1 → bA0 ,
Construct finite automata accepting L(G).
Solution:

8
Regular Expression

Example: Let G = ({A0 , A1 , A2 , A3 }, {a, b}, A0 , P)


Where P is
A0 → aA0 /bA1 , A1 → aA2 /aA3 , A2 → a/bA1 /bA3 ,
A3 → b/bA0 ,
Construct finite automata accepting L(G).
Solution:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy