Regular and Nonregular Languages
Regular and Nonregular Languages
Languages
Chapter 8
Languages: Regular or Not?
a*b* is regular.
{anbn: n 0} is not.
Proof:
● Upper bound: number of FSMs (or regular exp.)
● Lower bound on number of regular languages:
{a},{aa},{aaa},{aaaa},{aaaaa},{aaaaaa},…
• L = L1 L2, where:
L1 = {anbn, n 0}, and
L2 = {bnan, n 0}
L=
● Concatenation
● Kleene star
● Complement
● Intersection
● Difference
● Reverse
Closure of Regular Languages
Under Complement ()
L1 L2 =
(L1 L2)
L1 L2
● Union
● Concatenation
● Kleenestar
● Complementation
Closure of Regular Languages
Under Difference
L1 - L2 = L1 L2
Use operations - Example
Let L = {w {a, b}* : w contains an even number of a’s
and an odd number of b’s and all a’s come in runs of
three}.
L = L1 L2, where:
• L1 = {w {a, b}* : w contains an even number of a’s
and an odd number of b’s}, and
L = L1 L2
L = L1 L2
Don’t Try to Use Closure Backwards
One Closure Theorem:
L = L1 L2
L = L1 L2
L = L1 L2
L = L1 L2
Example:
{anbn, n 0} is not regular
Showing that a Language is Not Regular
The only way to generate/accept an infinite language with
a finite description is to use:
• Kleene star (in regular expressions), or
• cycles (in automata).
x z
Example
L= {anbn: n 0} is not regular
1 2
aaaaa…aaaaabbbb …bbbbbb
x y z
● To choose q:
● Try letting q be either 0 or 2.
● If that doesn’t work, analyze L to see if there is some
other specific value that will work.
Using the Closure Properties
• Intersection
• Complement
L = L _______
An easier way:
An easier way: