Download Chapter 10: Nonregular Languages

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Chapter 10: Nonregular Languages
A language that cannot be defined by a regular expression is
called a nonregular language.
Example:
● L = {Λ,ab,aabb,aaabbb,aaaabbbb,…}
● L = {anbn | n=0,1,2,3,4,…}
● L = {anbn}
● L ⊂ language(a*b*)
1
a9b9
b
6
3
1–
a
a
a
a
a
a
7
a
a
2
4
5
9
+
b
8
b
bbbbbb
10
a
2
a13b9
b
6
3
1–
7
aa
a
aaa
9
+
b
aaa
a
5
2
4
8
b
bbbbbb
10
aaa
a5(a4)*b9
3
The pumping lemma:
Let L be any regular language that has infinitely many words.
Then there exist three words x,y,z (where y is not the empty
word) such that all words of the form:
xynz n=1,2,3,4,…
are in L.
4
y
z
x
x
y
z
first state that is visited more than once
xyz ∈L, xyyz ∈L, xyyyz ∈L, …,
xz ∈L
xynz ∈L.
5
Example
a
1–
b
2+
a
a
a,b
4
b
5
b
b
a
3
b
a
6+
w = bbbababa
1
b
x
2
b
a
b a
3b 5
2
3
6 b 3a 6
y
z
6
Theorem: L = {anbn | n=0,1,2,3,4,…} is not regular.
Theorem:
EQUAL = all words with the same number of a’s and b’s.
EQUAL =
{Λ, ab, ba, aabb, abab, abba, baab, baba, bbaa, aaabbb, …}.
EQUAL is not regular.
Theorem: L = {anban | n=0,1,2,3,4,…} = {b, aba, aabaa, …} is
not regular.
7
Pumping Lemma: (version 2)
Let L be any regular language that has infinitely many words
that is accepted by a finite automaton with N states. All
words w in L that have more than N letters can be
decomposed into words x,y,z such that:
1. y is not the empty word
2. length(x) + length(y) ≤ N
3. w = xyz
4. for all n ≥1, xynz is in L.
Theorem: PALINDROME is not regular.
Theorem: PRIME = {ap | p is a prime number} =
{aa, aaa, aaaaa, aaaaaaa, …} is not regular.
8
Related documents