unit2
unit2
(v) (a + b)* denotes {a, b}*. The set represented by R is denoted by L(R),
Questions
(c) As {01, 10} is the union of {01} and {10}, we have {01, 10}
represented by 01 + 10
(g) Any element in {1, 11, 111, ... } can be obtained by concatenating
1 and any element of {1}*. Hence 1(1)* represents {1, 11, 111, ... }
Example 1:
Write the regular expression for the language accepting all combinations of
a's, over the set ∑ = {a}
Example 1:
Write the regular expression for the language accepting all combinations of
a's, over the set ∑ = {a}
Solution:
All combinations of a's means a may be zero, single, double and so on. If a is
appearing zero times, that means a null string. That is we expect the set of
{ε, a, aa, aaa, ....}. So we give a regular expression for this as:
R = a*
That is Kleen closure of a.
Example 2:
• Write the regular expression for the language accepting all combinations
of a's except the null string, over the set ∑ = {a}
Example 2:
• Write the regular expression for the language accepting all combinations
of a's except the null string, over the set ∑ = {a}
• Solution:
The regular expression has to be built for the language
L = {a, aa, aaa, ....}
This set indicates that there is no null string. So we can denote regular
expression as:
R = a+
Example 3:
Write the regular expression for the language accepting all the
string containing any number of a's and b's.
Example 3:
Write the regular expression for the language accepting all the
string containing any number of a's and b's.
Solution:
The regular expression will be:
r.e. = (a + b)*
This will give the set as L = {ε, a, aa, b, bb, ab, ba, aba, bab, .....}, any
combination of a and b.
The (a + b)* shows any combination with a and b even a null string.
Example 4
• Write the regular expression for the language accepting all
the string which are starting with 1 and ending with 0, over
∑ = {0, 1}.
Example 4
• Write the regular expression for the language accepting all
the string which are starting with 1 and ending with 0, over
∑ = {0, 1}.
Solution:
In a regular expression, the first symbol should be 1, and the last symbol
should be 0. The r.e. is as follows:
R = 1 (0+1)* 0
Example 5
• Write the regular expression for the language
starting and ending with a and having any having any
combination of b's in between.
Example 5
• Write the regular expression for the language
starting and ending with a and having any having any
combination of b's in between.
• Solution:
The regular expression will be:
R = a b* b
Example 6
• Write the regular expression for the language
starting with a but not having consecutive b's.
Example 6
• Write the regular expression for the language
starting with a but not having consecutive b's.
Solution:
The regular expression has to be built for the
language:
L = {a, aba, aab, aba, aaa, abab, .....}
The regular expression for the above language is:
R = {a + ab}*
Example 7
Write the regular expression for the language accepting all the
string in which any number of a's is followed by any number
of b's is followed by any number of c's.
Example 7
Write the regular expression for the language accepting all the
string in which any number of a's is followed by any number
of b's is followed by any number of c's.
• Solution:
As we know, any number of a's means a* any number of b's means b*, any
number of c's means c*. Since as given in problem statement, b's appear
after a's and c's appear after b's. So the regular expression could be:
R = a* b* c*
Example 8
• Write the regular expression for the language over ∑
= {0} having even length of the string.
Example 8
• Write the regular expression for the language over ∑
= {0} having even length of the string.
Solution:
The regular expression has to be built for the language:
L = {ε, 00, 0000, 000000, ......}
The regular expression for the above language is:
R = (00)*
Example 9
• Write the regular expression for the language
having a string which should have atleast one
0 and alteast one 1.
Example 9
• Write the regular expression for the language
having a string which should have atleast one
0 and alteast one 1.
Solution:
The regular expression will be:
R = [(0 + 1)* 0 (0 + 1)* 1 (0 + 1)*] + [(0 + 1)* 1 (0
+ 1)* 0 (0 + 1)*]
• Describe the language denoted by following
regular expression
RE. = (b* (aaa)* b*)*
• Describe the language denoted by following
regular expression
RE. = (b* (aaa)* b*)*
The language can be predicted from the regular expression by
finding the meaning of it. We will first split the regular
expression as:
r.e. = (any combination of b's) (aaa)* (any combination of b's)
L = {The language consists of the string in which a's appear
triples, there is no restriction on the number of b's}
Problem
Solution
IDENTITIES FOR REGULAR
EXPRESSIONS
`
Which among the following are
incorrect regular identities?
a) εR=R
b) ε*=ε
c) Ф*=ε
d) RФ=R
Answer: d
Explanation: I2: There are few
identities over Regular Expressions
which include: RФ=ФR=Ф
(0+ε) (1+ε) represents
a) {0, 1, 01, ε}
b) {0, 1, ε}
c) {0, 1, 01 ,11, 00, 10, ε}
d) {0, 1}
Answer: a
Explanation: The regular expression is
fragmented and the set of the strings
eligible is formed. ‘+’ represents union
while ‘.’ Represents concatenation.
Which of the following is correct?
Statement 1: ε represents a single string in the set.
Theorem :
(Arden' s theorem) Let P and Q be two regular expressions
over ∑. If P does not contain Λ, then the following equation in
R, namely
R = Q + RP
has a unique solution (i.e. one and only one solution) given
by R = QP*.
Ardens Theorem
Example 1: Constructing RE for
NDFA
Example 2: Constructing RE for
DFA
Example 3
Example 4
P, O, R be regular expression over ∑, P
is not ε, then
R=Q + RP has a unique solution:
a) Q*P
b) QP*
c) Q*P*
d) (P*O*) *
Arden’s theorem is true for:
a) More than one initial states
b) Null transitions
c) Non-null transitions
d) None of the mentioned
Answer: c
Explanation: Arden’s theorem strictly
assumes the following;
a) No null transitions in the transition
diagrams
b) True for only single initial state
Closure Properties of Regular
Language
THEORM
Proof
Q + (QP*)P = Q(Λ+ P*P) = QP* by I9
Important justification
PROBLEM
SOLUTION
PROBLEM & SOLUTION
Difference between Null and Ø
TRANSITION SYSTEM CONTAINING Λ -MOVES
Step 2- Duplicate all these edges starting from V1' without changing the edge
labels.
• Q1 as initial state
• (0 + 1(1 + 011)*(00 + 010)*(1(1 + 011)* 01)
Construct FA Equivalent to regular
expression
Construct FA Equivalent to regular
expression
• 10 + (0 + 11)0*1
• (0 +1 )*(00 + 11)(0 + 1)*
Comparison Method
• A language is regular if and only if
a) accepted by DFA
b) accepted by PDA
c) accepted by LBA
d) accepted by Turing machine
• The minimum number of transitions to pass to
reach the final state as per the following
regular expression is:
{a,b}*{baaa}
a) 4
b) 5
c) 6
d) 3
• Which of the following statements is not true?
a) Every language defined by any of the automata is also
defined by a regular expression
b) Every language defined by a regular expression can be
represented using a DFA
c) Every language defined by a regular expression can be
represented using NFA with e moves
d) Regular expression is just another representation for any
automata definition
Equivalence of 2 regular
expression
• Prove (a + b)* =a*(ba*)* by constructing
regular expressions
CONSTRUCTION OF A REGULAR GRAMMAR
GENERATING T(M) FOR A GIVEN DFA M