0% found this document useful (0 votes)
13 views11 pages

4-DFA To RE Conversion-24-01-2025

The document discusses the properties of regular languages, categorizing them into closure properties (such as complementation, union, intersection, concatenation, Kleene star, difference, and reversal) and decision properties (including membership, emptiness, equivalence, subset, and infinite questions). It also introduces the pumping lemma, which provides a method to prove that certain languages are not regular by demonstrating that they do not satisfy the pumping property. The document concludes with an example of a non-regular language and a proof using the pumping lemma.

Uploaded by

easelearnai
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)
13 views11 pages

4-DFA To RE Conversion-24-01-2025

The document discusses the properties of regular languages, categorizing them into closure properties (such as complementation, union, intersection, concatenation, Kleene star, difference, and reversal) and decision properties (including membership, emptiness, equivalence, subset, and infinite questions). It also introduces the pumping lemma, which provides a method to prove that certain languages are not regular by demonstrating that they do not satisfy the pumping property. The document concludes with an example of a non-regular language and a proof using the pumping lemma.

Uploaded by

easelearnai
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/ 11

Properties of Regular Languages

So far we have seen different ways of specifying regular language: DFA, NFA, ε-NFA, regular
expressions and regular grammar. Noted that all these different expressions are equal in power
by showing the equivalences. Regular expressions and grammars are considered as generators
of regular language while the machines (DFA, NFA, ε-NFA) are considered as acceptors of
the language.

Now will look at the properties of regular language. The properties can be broadly classified
as two parts: (A) Closure properties and (B) Decision properties

(A) Closure Properties


1. Complementation

If a language L is regular its complement L' is regular.

Let DFA(L) denote the DFA for the language L. Modify the DFA as follows to obtain
DFA(L').

1. Change the final states to non-final states.


2. Change the non-final states to final states.

Since there exists a DFA(L') now, L' is regular.

This can be shown by an example using a DFA. Let L denote the language containing strings
that begins and ends with a. Σ = {a, b}. The DFA for L is given below.

Note: q3 denotes the


dead state.
Once you enter q3,
you remain in it
forever.

L' denotes the language that does not contain strings that begin and end with a. This implies
L' contains strings that

• begins with a and ends with b


• begins with b and ends with a
• begins with b and ends with b

The DFA for L' is obtained by flipping the final states of DFA(L) to non-final states and vice-
versa. The DFA for L' is given below.

• q0 ensures ε is
accepted

• q1 ensures all
strings that begin
with a and end with
b are accepted.

• q3 ensures all
strings that begin
with b (ending with
either a or b) are
accepted.

Important Note: While specifying the DFA for L, we have also included the dead state q3. It
is important to include the dead state(s) if we are going to derive the complement DFA since,
the dead state(s) too would become final in the complementation. If we didn't add the dead
state(s) originally, the complement will not accept all strings supposed to be accepted.

In the above example, if we didn't include q3 originally, the complement will not accept
strings starting with b. It will only accept strings that begin with a and end with b which is
only a subset of the complement.

CONCLUSION: REGULAR LANGUAGES ARE CLOSED UNDER


COMPLEMENTATION.

2. Union

If L1 and L2 are regular, then L1 ∪ L2 is regular.

This is easier proved using regular expressions. If L1 is regular, there exists a regular
expression R1 to describe it. Similarly, if L2 is regular, there exists a regular expression R2 to
describe it. R1 + R2 denotes the regular expression that describe L1 ∪ L2. Therefore, L1 ∪ L2
is regular.

This again can be shown using an example. If L1 is a language that contains strings that begin
with a and L2 is a language that contain strings that end with a, then L1 ∪ L2 denotes the
language the contain strings that either begin with a or end with a.
- a(a+b)* is the regular expression that denotes L1.

- (a+b)*a is the regular expression that denotes L2.

- L1 ∪ L2 is denoted by the regular expression a(a+b)* + (a+b)*a. Therefore, L1 ∪ L2


is regular.

In terms of DFA, we can say that a DFA(L1 ∪ L2) accepts those strings that are accepted by
either DFA(L1) or DFA(L2) or both.

• DFA(L1 ∪ L2) can be constructed by adding a new start state and new final state.
• The new start state connects to the two start states of DFA(L1) and DFA(L2) by
εtransitions.
• Similarly, two ε transitions are added from the final states of DFA(L1) and DFA(L2)
to the new final state.
• Convert this resulting NFA to its equivalent DFA.

As an exercise you can try this approach of DFA construction for union for the given
example.

CONCLUSION: REGULAR LANGUAGES ARE CLOSED UNDER UNION.

3. Intersection

If L1 and L2 are regular, then L1 ∩ L2 is regular.

Since a language denotes a set of (possibly infinite) strings and we have shown above that
regular languages are closed under union and complementation, by De Morgan's law can be
applied to show that regular languages are closed under intersection too.

L1 and L2 are regular ⇒ L1' and L2' are regular (by Complementation property)
L1' ∪ L2' is regular (by Union property)
L1 ∩ L2 is regular (by De Morgan's law)

In terms of DFA, we can say that a DFA(L1 ∩ L2) accepts those strings that are accepted by
both DFA(L1) and DFA(L2).

CONCLUSION: REGULAR LANGUAGES ARE CLOSED UNDER


INTERSECTION.

4. Concatenation

If L1 and L2 are regular, then L1 . L2 is regular.

This can be easily proved by regular expressions. If R1 is a regular expression denoting L1


and R2 is a regular expression denoting L2, then we R1 . R2 denotes the regular expression
denoting L1 . L2. Therefore, L1 . L2 is regular.
In terms of DFA, we can say that a DFA(L1 . L2) can be constructed by adding an ε-trainstion
from the final state of DFA(L1) - which now ceases to be the final state - to the start state of
DFA(L2). You can try showing this using an example.

CONCLUSION: REGULAR LANGUAGES ARE CLOSED UNDER


CONCATENATION.

5. Kleene star

If L is regular, then L* is regular.

This can be easily proved by regular expression. If L is regular, then there exists a regular
expression R. We know that if R is a regular expression, R* is a regular expression too. R*
denotes the language L*. Therefore L* is regular.

In terms of DFA, in the DFA(L) we add two ε transitions, one from start state to final state
and another from final state to start state. This denotes DFA(L*). You can try showing this
for an example.

CONCLUSION: REGULAR LANGUAGES ARE CLOSED UNDER KLEENE STAR.

6. Difference

If L1 and L2 are regular, then L1 - L2 is regular.

We know that L1 - L2 = L1 ∩ L2'

L1 and L2 are regular ⇒ L1 and L2' are regular (by Complementation property)
L1 ∩ L2' is regular (by Intersection property)
L1 - L2 is regular (by De Morgan's law)

In terms of DFA, we can say that a DFA(L1 - L2) accepts those strings that are accepted by
both DFA(L1) and not accepted by DFA(L2). You can try showing this for an example.

CONCLUSION: REGULAR LANGUAGES ARE CLOSED UNDER DIFFERENCE.

7. Reverse

If L is regular, then LR is regular.

Let DFA(L) denote the DFA of L. Make the following modifications to construct DFA(LR).

1. Change the start state of DFA(L) to the final state.


2. Change the final state of DFA(L) to the start state.

In case there are more than one final state in DFA(L), first add a new final state and
add ε- transitions from the final states (which now cease to be final states any more)
and perform this step.
3. Reverse the direction of the arrows.

You can try showing this using an example.

CONCLUSION: REGULAR LANGUAGES ARE CLOSED UNDER REVERSAL.

(B) Decision Properties


1. Membership question

Does a string w belong to L? i.e. Is w ∈ L?

This can be validated as follows.

• Construct DFA(L).
• Run w on DFA(L).
• If DFA(L) accepts w, then w ∈ L. Else w ∉ L.

CONCLUSION: MEMBERSHIP QUESTION IN REGULAR LANGUAGES IS


DECIDABLE.

2. Emptiness question

Is L = φ?

This can be validated as follows.

• Construct DFA(L).
• If there exists no path from start state to final state, L = φ. Else L ≠ φ.

CONCLUSION: EMPTINESS OF REGULAR LANGUAGES IS DECIDABLE.

3. Equivalence question

Is L1 = L2?

This can be validated as follows.

• Construct DFA(L1) and DFA(L2).


• Reduce them to their minimal DFAs: MinDFA(L1) and MinDFA(L2).
• If MinDFA(L1) = MinDFA(L2) then L1 = L2. Else L1 ≠ L2.

CONCLUSION: EQUIVALENCE OF REGULAR LANGUAGES IS DECIDABLE.

4. Subset question

Is L1 ⊂ L2?

This can be validated as follows.


• If (L1 - L2) = φ and (L2 - L1) ≠ φ then L1 ⊂ L2. Else L1 ⊄ L2.

CONCLUSION: SUBSET PROPERTY OF REGULAR LANGUAGES IS


DECIDABLE.

5. Infinite question

Is L infinite?

This can be validated as follows.

• Construct DFA(L).
• If DFA(L) has at least one loop, then L is infinite. Else L finite.

CONCLUSION: INFINITE PROPERTY OF REGULAR LANGUAGES IS


DECIDABLE.

Pumping lemma and its applications


Not all languages are regular. For example, the language L = {anbn : n ≥ 0} is not regular.
Similarly, the language {ap : p is a prime number} is not regular. A pertinent question
therefore is how do we know if a language is not regular.

Question: Can we conclude that a language is not regular if no one could come up with a
DFA, NFA, ε-NFA, regular expression or regular grammar so far?
- No. Since, someone may very well come up with any of these in future.

We need a property that just holds for regular languages and so we can prove that any
language without that property is not regular. Let's recall some of the properties.

• We have seen that a regular language can be expressed by a finite state automaton. Be
it deterministic or non-deterministic, the automaton consists of a finite set of states.

• Since the states are finite, if the automaton has no loop, the language would be finite.

- Any finite language is indeed a regular language since we can express the language
using the regular
expression: S1 + S2 + ... + SN, where N is the total number of strings accepted by
the automaton.

• However, if the automaton has a loop, it is capable of accepting infinite number of


strings.
- Because, we can loop around any number of times and keep producing more and
more strings.
- This property is called the pumping property (elaborated below).

The pumping property of regular languages

Any finite automaton with a loop can be divided into parts three.

• Part 1: The transitions it takes before the loop.


• Part 2: The transitions it takes during the loop.
• Part 3: The transitions it takes after the loop.

For example consider the following DFA. It accepts all strings that start with aba followed by
any number of baa's and finally ending with ba.

1. What strings are accepted by this DFA?


ababaaba, ababaabaaba, ababaabaabaaba, .... so on and so forth. Thus the strings
accepted by the above DFA can be divided into three parts: aba, (baa)i and ba. Here, i > 0.

Investigating this further, we can say that any string w accepted by this DFA can be written
as w = x yi z
where y represents the part that can be pumped again and again to generate more and more
valid strings. This is shown below for the given example.

Before we generalize further, let's investigate this example a little more.

2. What if the loop was at the beginning? Say a self-loop at q0 instead of at q2.
Then x = ε or |x| = 0. In such a special case, w = yz.
3. What is the loop was at the end. Say a self loop at q6 instead of at q2.
Then z = ε or |z| = 0. In such a special case, w = xy.

4. Can y be equal to ε ever?


No. It is impossible. If y = ε, it implies there is no loop which implies the language is
finite. We have already seen that a finite language is always regular. So, we are now
concerned only with infinite regular language. Hence, y can never be ε. Or |y| > 0.

5. What is the shortest string that is accepted by the DFA?


ababa. Obviously, a string obtained without going through the loop.
There is a catch however. See the next question.

6. What is the shortest string accepted if there are more final states? Say q2 is final.
ab of length 2.

7. What is the longest string accepted by the DFA without going through the loop even once?
ababa (= xz). So, any string of length > 5 accepted by DFA must go through the loop at
least once.

8. What is the longest string accepted by the DFA by going through the loop exactly once?
ababaaba (= xyz) of length 8. We call this pumping length.

More precisely, pumping length is an integer p denoting the length of the string w such that w
is obtained by going through the loop exactly once. In other words, |w| = |xyz| = p.

9. Of what use is this pumping length p?


We can be sure that |xy| ≤ p. This can be used to prove a language non-regular.

Now, let's define a regular language based on the pumping property.

Pumping Lemma: If L is a regular language, then there exists a constant p such that every
string w ∈ L, of length p or more can be written as w = xyz, where

1. |y| > 0
2. |xy| ≤ p
3. xyiz ∈ L for all i

Proving languages non-regular


1. The language L = { anbn : n ≠ 0 } is not regular.

Before proving L is not regular using pumping property, let's see why we can't come up with
a DFA or regular expression for L.

L = { ε, ab, aabb, aaabbb, .... }

It may be tempting to use the regular expression a*b* to describe L. No doubt, a*b*
generates these strings. However, it is not appropriate since it generates other strings not in L
such as a, b, aa, ab, aaa, aab, abb, ...
Let's try to come up with a DFA. Since it has to accept ε, start state has to be final. The
following DFA can accept anbn for n ≤ 3. i.e. {ε, a, b, ab, aabb, aaabbb}

The basic problem is DFA does not have any memory. A transition just depends on the
current state. So it cannot keep count of how many a's it has seen. So, it has no way to match
the number of a's and b's. So, only way to accept all the strings of L is to keep adding newer
and newer states which makes automaton to infinite states since n is unbounded.

Now, let's prove that L does not have the pumping property.

Lets assume L is regular. Let p be the pumping length.

Consider a string w = aa....abb....b such that |w| = p.

⇒ w = ap/2bp/2

We know that w can be broken into three terms xyz such that y ≠ ε and xyiz ∈ L.

There are three cases to consider.

• Case 1: y is made up of only a's

Then xy2z has more a's than b's and does not belong to L.

• Case 2: y is made up of only b's


Then xy2z has more b's than a's and does not belong to L.

• Case 3: y is made up of a's and b's

Then xy2z has a's and b's out of order and does not belong to L.

Since none of the 3 cases hold, the pumping property does not hold for L. And therefore L is
not regular.

2. The language L = { uuR : u ∈ {a,b}*} is not regular.

Lets assume L is regular. Let p be the pumping length.

Consider a string w = apbbap.

|w| = 2p + 2 ≥ p

Since, xy ≤ p, xy will consist of only a's.

⇒ y is made of only a's


⇒ y2 is made of more number of a's than y since |y| > 0
(Let's say y2 has m a's more than y where m > 1)
⇒ xy2z = ap+mbbap where m ≥ 1
⇒ xy2z = ap+mbbap cannot belong to L.

Therefore, pumping property does not hold for L. Hence, L is not regular.

3. The language L = { an : n is prime } is not regular.

Lets assume L is regular. Let p be the pumping length. Let q ≥ p be a prime number (since we
cannot assume that pumping length p will be prime).

Consider the string w = aa....a such that |w| = q ≥ p.

We know that w can be broken into three terms xyz such that y ≠ ε and xyiz ∈ L

⇒ xyq+1z must belong to L


⇒ |xyq+1z| must be prime
|xyq+1z| = |xyzyq|
= |xyz| + |yq|
= q + q.|y|
= q(1 + |y|) which is a composite number.

Therefore, xyq+1z cannot belong to L. Hence, L is not regular.

Exercises
Show that the following languages are not regular.
4. L = { anbm : n ≠ m }

5. L = { anbm : n > m }

6. L = { w : na(w) = nb(w) }

7. L = { ww : w ∈ {a,b}* }

8. L = { an2 : n > 0 }

IMPORTANT NOTE

Never use pumping lemma to prove a language regular. Pumping property is necessary but
not sufficient for regularity.

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