Compiler Design CA1
Compiler Design CA1
Presented By
1.) Union :
If R and S are two regular languages, their union R U S is also a Regular Language.
R U S = {a | a is in R or a is in S}
2.) Intersection :
If R and S are two regular languages, their intersection is also a Regular Language.
L ⋂ M = {ab | a is in R and b is in S}
Example 1 Example 2
Consider the languages L1 = ∅ and L2 = Which one of the following languages over the alphabet
{x}. Which one of the following {a,b} is described by the regular expression:
represents (a+b)*a(a+b)*a(a+b)*?
L1 L2* U L1*. a.) Set of all strings containing the substring aa.
a.) {ε} b.) Set of all strings containing at least two a’s.
b.) x* c.) Set of all strings that begin and end with either a or b.
c.) ∅ d.) Set of all strings containing at most two a’s
d.) {ε,x} Ans. b.) Set of all strings containing at least two a’s.
Ans. a.) {ε} Explanation: The regular expression has two a′s
Explanation: L1 L2* U L1* Result of L1 surrounded by (a+b)*, which means accepted strings must
L2* is ∅, {∅} indicates an empty language. have at least two a′s. The least possible string is ε a ε a ε =
Concatenation of ∅ with any other language aa The set of strings accepted is = { aa, aaa, baa, aaba, bbbb,
is ∅. aabaa, baabaab,.....}. Thus, we can see from the set of
L1* = ∅* which is {ε}. Union of ∅ and {ε} accepted strings that all have at least two a’s, the least
is {ε}. possible string.
What is Deterministic Finite Automata(DFA) :
Step 1: Step 5:
Step 2 :
Now we have got NFA without ε. Now we will convert it into required DFA for
that, we will first write a transition table for this NFA.
Step 3:
State 0 1
→[q0] [q3] [q1, q2]
[q1] [qf] ϕ
Step 4:
[q2] ϕ [q3]
[q3] [q3] [qf]
[q1, q2] [qf] [qf]
*[qf] ϕ ϕ
THANK
YOU