0% found this document useful (0 votes)
42 views5 pages

Unit-2 TOC

The document provides lecture notes on Regular Expressions and Languages, detailing closure properties such as positive closure (L+) and Kleene closure (L*), along with their definitions and examples. It explains regular expressions, their formation rules, and the concept of regular languages, including operations like union, intersection, concatenation, and complement. Additionally, the document includes exercises to create regular expressions for various sets of binary strings and strings from the alphabet (a, b).

Uploaded by

ronak.gadaria
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)
42 views5 pages

Unit-2 TOC

The document provides lecture notes on Regular Expressions and Languages, detailing closure properties such as positive closure (L+) and Kleene closure (L*), along with their definitions and examples. It explains regular expressions, their formation rules, and the concept of regular languages, including operations like union, intersection, concatenation, and complement. Additionally, the document includes exercises to create regular expressions for various sets of binary strings and strings from the alphabet (a, b).

Uploaded by

ronak.gadaria
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/ 5

LECTURE NOTES

Subject: Theory of Computation Unit-2: Regular Expressions and Languages


_______________________________________________________________________________________________

Closure properties:

 L +:
 It is a Positive Closure that represents a set of all strings except Null or ε-strings.
 It represents the occurrence of certain alphabets for given language alphabets from one to infinite
number of times.

Example: Language accepting all combination of a's over Σ= {a} :


L = a+

L= {a, aa, aaa, aaaa, aaaaa, ....}

 L *:
 It is “Kleene Closure “that represents the occurrence of certain alphabets for given language
alphabets from zero to infinite number of times in which ε-string is also included.

Example: Language accepting all combination of a's over Σ= {a} :


L = a*

L= { ε , a, aa, aaa, aaaa, aaaaa,...}

 From the above two statements, it can be concluded that:

L* = εL+

Regular Expression:

 Regular expressions are used for representing certain sets of strings in an algebraic fashion.

 ɸ is a regular expression for regular language ɸ.


 ɛ is a regular expression for regular language {ɛ}.
 If a ∈ Σ (Σ represents the input alphabet), a is regular expression with language {a}.
 If a and b are regular expression, a + b (Union of a and b) is also a regular expression.
 If a and b are regular expression, ab (concatenation of a and b) is also regular.
 If a is regular expression, a* (Kleene Closure) is also regular.

Prepared by: Mr. Dinesh A Mehbubani


(CE/IT Department, LJ University, Ahmedabad)
LECTURE NOTES
Subject: Theory of Computation Unit-2: Regular Expressions and Languages
_______________________________________________________________________________________________

Regular Language:
 A language is regular if it can be expressed in terms of regular expression.

 Closure Properties of Regular Languages

 Union : If L1 and If L2 are two regular languages, their union L1 ∪ L2 will also be regular.

For example, L1 = {𝑎 , n ≥ 0} and L2 = {𝑏 ,n ≥ 0}


 L3 = L1 ∪ L2 = {𝑎 ∪ 𝑏 ,n ≥ 0} is also regular.

 Intersection: If L1 and If L2 are two regular languages, their intersection L1 ∩ L2 will also be
regular.

For example,
 L1= {𝑎 𝑏 , n ≥ 0 and m ≥ 0} and L2= {𝑎 𝑏 ∪ 𝑏 𝑎 ,n ≥ 0 and m ≥ 0}
 L3 = L1 ∩ L2 = {𝑎 𝑏 , n ≥ 0 and m ≥ 0} is also regular.

 Concatenation: If L1 and If L2 are two regular languages, their concatenation L1.L2 will also be
regular.

For example,
 L1 = {𝑎 , n ≥ 0} and L2 = {𝑏 ,n ≥ 0}
 L3 = L1.L2 = {𝑎 𝑏 , m ≥ 0 and n ≥ 0} is also regular.

 Kleene Closure: If L1 is a regular language, its Kleene closure L1* will also be regular.

For example,
 L1 = (a ∪ b)
 L1* = (a ∪ b)*

 Complement: If L(G) is regular language, its complement L’(G) will also be regular. Complement of
a language can be found by subtracting strings which are in L(G) from all possible strings.

For example,
 L(G) = {𝑎 | n > 3}
 L’(G) = {𝑎 | n <= 3}

Prepared by: Mr. Dinesh A Mehbubani


(CE/IT Department, LJ University, Ahmedabad)
LECTURE NOTES
Subject: Theory of Computation Unit-2: Regular Expressions and Languages
_______________________________________________________________________________________________

Exercise :

 Write a regular expression and give the corresponding automata for each of the following sets of
binary strings. Use only the basic operations.

1. 0 or 11 or 101
0 | 11 | 101

2. 0 or 1
0|1

3. only 0s
0*

4. only 1s
1*

5. all binary strings


(0|1)*

6. all binary strings except empty string


(0|1)

7. begins with 1, ends with 1


1 | (0|1)*|1

8. ends with 00
(0|1)*00

9. starts with 10
10(0|1)*

10. contains at least three 1s


(0|1)*1(0|1)*1(0|1)*1(0|1)*

11. contains at least three consecutive 1s


(0|1)*111(0|1)*

12. contains the substring 110


(0|1)*110(0|1)*

13. doesn't contain the substring 110


(0|10)*1*

14. contains at least two 0s but not consecutive 0s


(1|01)* 0 1 0 (1|10)*

Prepared by: Mr. Dinesh A Mehbubani


(CE/IT Department, LJ University, Ahmedabad)
LECTURE NOTES
Subject: Theory of Computation Unit-2: Regular Expressions and Languages
_______________________________________________________________________________________________

15. has at least 3 characters, and the third character is 0


(0|1)(0|1)0(0|1)*

16. number of 0s is a multiple of 3


(1*0 1*0 1*0 1*)*

17. starts and ends with the same character


1(0|1)*1|0 (0|1)*0

18. odd length


(0|1)((0|1) (0|1))*

19. even length


((0|1) (0|1))*

20. starts with 0 and has odd length, or


0((0|1) (0|1))*

21. starts with 1 and has even length


1(0|1) ((0|1) (0|1))*

22. length is at least 1 and at most 3


(0|1)| (0|1)(0|1)|(0|1)(0|1)(0|1)

23. Contains 00 and 11 as substring


(0|1)*00(0|1)*11(0|1)*| (0|1)*11(0|1)*00(0|1)*

24. not ending with 01


Ɛ|0|1|(0|1)*(00|10|11)

25. strings that do not contain the substring 01.


(1* 0*)
26. strings ending with 1 and not containing 00 as substring
(1|01)

 Write a regular expression and give the corresponding automata for each of the following from
alphabet ∑(a,b).

27. Any number of a’s followed by any number of b’s


a*b*

28. starting with a but not having consecutive b's.


(a|ab)
29. Strings having exactly 3 b’s
a*b a*b a*b a*

Prepared by: Mr. Dinesh A Mehbubani


(CE/IT Department, LJ University, Ahmedabad)
LECTURE NOTES
Subject: Theory of Computation Unit-2: Regular Expressions and Languages
_______________________________________________________________________________________________

30. Third character from right end is always a


(a|b)* a (a|b) (a|b)
31. Set of strings consisting of even number of a’s followed by odd number of b’s
(aa)*(bb)*b

Prepared by: Mr. Dinesh A Mehbubani


(CE/IT Department, LJ University, Ahmedabad)

You might also like