You are on page 1of 7

Global College

Automata and Complexity Theory


Chapter 3:Regular Expressions and Regular Languages
Bayisa Gutema(MSc)

11/26/2022 Compiled by Bayisa G. 1


Regular Expression
1. Regular Expressions
• The language accepted by finite automata can be easily described by simple
expressions called regular expressions.
• It is most effective way to represent any language.
• The languages accepted by some regular expressions are referred to as regular
languages.
• A regular expressions can also be described as a sequence of pattern that defines a
string.
11/26/2022 Compiled by Bayisa G. 2
Cont..

For instance:
• Regular expression R.E x* means zero or more occurrence of x.
• It can generate {ε, x, xx, xxx, xxxx, …..}
• Regular expression R.E x+ means one or more occurrence of x.
• It can generate {x, xx, xxx, xxxx, …..}
Operations on regular Language
1. union: if L and M are two regular languages their union L U M is also regular language.
L U M = {S | S is in L or S is in M}
2. Intersection: if L and M are two regular languages their intersection L ո M is also regular
L ո M = {ST | S is in L or T is in M}

11/26/2022 Compiled by Bayisa G. 3


Cont..

• Kleen Closure: if L is regular languages then its kleen closure L* also is regular
language.
L* = zero or more occurrences of language L.
• Kleen Plus: if L is regular languages then its kleen plus L+ also is regular
language.
L+ = one or more occurrences of language L.

11/26/2022 Compiled by Bayisa G. 4


Example

1. Write regular expression for the language accepting all strings containing any number of a’s and b’s.
Solution: R.E = (a + b)*
• This will give the set as L= {ε, a, aa, ab, b, aba, ba, bb, …} any combination of a and b.
• The (a + b)* shows any combination with a and b even ε.
2. Write regular expression for the language accepting all strings which starting with 1 and ending
with 0 over ∑ = {0,1}.
Solution: the starting symbol is 1 and ending symbol is 0.
R.E = 1(0+1) * 0
L= {10, 100, 1110, 110, 1010, …..}

11/26/2022 Compiled by Bayisa G. 5


Example..

3.Write regular expression for the language accepting all strings containing any number of
a’s and b’s except empty string.
Solution: R.E = (a + b)+
• This will give the set as L= {a, aa, ab, b, aba, ba, bb, …} any combination of a and b.
• The (a+b)+ shows any combination with a and b except ε.
4.Write regular expression for the language starting with a, but not having consecutive b’s.
Solution L = {a, ab, aab, aba, aaa, abab, ….. }
R.E = (a+ab)*

11/26/2022 Compiled by Bayisa G. 6


Example..

5. Write R.E for the language over ∑ = {0}having Even length of the string
Solution: L={ε, 00, 0000, 000000, ….}
R.E = (00)*
6. Write R.E for the language over ∑ = {0,1}such that all the strings do not contain
the substring 01.
Solution: L={ε, 0, 1,00, 10,100, ….}
R.E = (1*0*)

11/26/2022 Compiled by Bayisa G. 7

You might also like