0% found this document useful (0 votes)
14 views21 pages

Lec 2

Uploaded by

huzaifa ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views21 pages

Lec 2

Uploaded by

huzaifa ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

THEORY OF AUTOMATA

DEFINITION: PALINDROME

• Let us define a new language called Palindrome


over the alphabet
∑ = { a, b }
PALINDROME = { Λ, and all strings x such that
reverse(x) = x }
• If we want to list the elements in PALINDROME, we
find
PALINDROME = { Λ, a, b, aa, bb, aaa, aba, bab,
bbb, aaaa, abba, … }
PALINDROME

• Sometimes two words in PALINDROME when


concatenated will produce a word in PALINDROME

• abba concatenated with abbaabba gives


abbaabbaabba (in PALINDROME)

• But more often, the concatenation is not a word in


PALINDROME

• aa concatenated with aba gives aaaba (NOT in


PALINDROME)
KLEENE CLOSURE

• Definition: Given an alphabet ∑, we define a


language in which any string of letters from ∑ is
a word, even the null string Λ. We call this
language the closure of the alphabet ∑, and
denote this language by ∑*.

• Examples:
If ∑ = { x } then ∑* = { Λ, x, xx, xxx, … }
If ∑ = { 0, 1 } then ∑* = { Λ, 0, 1, 00, 01, 10,
11, 000, 001, … }
If ∑ = { a, b, c } then ∑* = { Λ, a, b, c, aa, ab,
ac, ba, bb, bc, ca, cb, cc, aaa,
…}
LEXICOGRAPHIC ORDER
• Note that we listed the words in a language in size
order (i.e., words of shortest length first), and then
listed all the words of the same length
alphabetically.

• This ordering is called lexicographic order, which


we will usually follow.

• The star in the closure notation is known as the


Kleene star.

• We can think of the Kleene star as an operation


that makes, out of an alphabet, an infinite language
(i.e., infinitely many words, each of finite length).
KLEENE CLOSURE

• Let us now generalize the use of the Kleene star


oprator to sets of words, not just sets of alphabet
letters.

• Definition: If S is a set of words, then S* is the set


of all finite strings formed by concatenating words
from S, where any word may be used as often as
we like, and where the null string Λ is also
included.
KLEENE CLOSURE
• Example: If S = { aa, b } then
S* = { Λ plus any word composed of factors of aa
and b }, or

S* = { Λ plus any strings of a’s and b’s in which the


a’s occur in even clumps }, or

S* = { Λ, b, aa, bb, aab, baa, bbb, aaaa, aabb,


baab, bbaa, bbbb, aaaab, aabaa, aabbb, baaaa,
baabb, bbaab, bbbaa, bbbbb, … }

Note that the string aabaaab is not in S* because it


has a clump of a’s of length 3.
KLEENE CLOSURE

• Example: Let S = { a, ab }. Then


S* = { Λ plus any word composed of factors of a and
ab }, or

S* = { Λ plus all strings of a’s and b’s except those


that start with b and those that contain a double b },
or
S* = { Λ, a, aa, ab, aaa, aab, aba, aaaa, aaab, abaa,
abab, aaaaa, aaaab, aaaba, aabaa, aabab, abaaa,
abaab, ababa, … }

• Note that for each word in S*, every b must have an a


immediately to its left, so the double b, that is bb, is
not possible; neither any string starting with b.
How to prove a certain word is in the
closure language S*
• We must show how it can be written as a
concatenation of words from the base set S.

• In the previous example, to show that abaab is in


S*, we can factor it as follows:
abaab = (ab)(a)(ab)
• These three factors are all in the set S, therefore
their concatenation is in S*.
• Note that the parentheses, ( ), are used for the
sole purpose of demarcating the ends of factors.
How to prove a certain word is in the closure
language S*
• Observe that if the alphabet has no letters, then
its closure is the language with the null string as
its only word; that is
if ∑ = ø (the empty set), then ∑* = { Λ }
• Also, observe that if the set S has the null string as
its only word, then the closure language S* also
has the null string as its only word; that is
if S = { Λ }, then S* = { Λ }
because ΛΛ = Λ.
• Hence, the Kleene closure always produces an
infinite language unless the underlying set is one
of the two cases above.
POSITIVE CLOSURE

• If we wish to modify the concept of closure to refer


only the concatenation of some (not zero) strings
from a set S, we use the notation + instead of *.
• This “plus operation” is called positive closure.
Example: if ∑ = { x } then ∑+ = { x, xx, xxx, … }
Observe that:

1. If S is a language that does not contain Λ, then S+


is the language S* without the null word Λ.

2. If S is a language that does contain Λ, then S+ =


S*

3. Likewise, if ∑ is an alphabet, then ∑+ is ∑* without


the word Λ.
S**?
• What happens if we apply the closure operator
twice?
• We start with a set of words S and form its closure S*
• We then start with the set S* and try to form its closure,
which we denote as (S*)* or S**
• Theorem 1:
For any set S of strings, we have S* = S**
• Before we prove the theorem, recall from Set
Theory that
• A = B if A is a subset of B and B is a subset of A
• A is a subset of B if for all x in A, x is also in B
PROOF OF THEOREM 1:

• Let us first prove that S** is a subset of S*:


Every word in S** is made up of factors from S*.
Every factor from S* is made up of factors from S.
Hence, every word from S** is made up of factors
from S. Therefore, every word in S** is also a word in
S*. This implies that S** is a subset of S*.

• Let us now prove that S* is a subset of S**:


In general, it is true that for any set A, we have A is a
subset of A*, because in A* we can choose as a word
any factor from A. So if we consider A to be our set
S* then S* is a subset of S**

• Together, these two inclusions prove that S* = S**.


DEFINING LANGUAGES
CONTINUED…

• Recursive definition of languages


The following three steps are used in
recursive definition
1. Some basic words are specified in the
language.
2. Rules for constructing more words are
defined in the language.
3. No strings except those constructed in above,
are allowed to be in the language.
EXAMPLE

• Defining language of EVEN


Step 1:
2 is in EVEN.
Step 2:
If x is in EVEN then x+2 and x-2 are also in EVEN.
Step 3:
No strings except those constructed in above, are
allowed to be in EVEN.
EXAMPLE

• Defining the language factorial


Step 1:
As 0!=1 so 1 is in factorial.
Step 2:
n!=n*(n-1)! is in factorial.
Step 3:
No strings except those constructed in above, are
allowed to be in factorial.
• Defining the language {anbn }, n=1,2,3,… , of
strings defined over Σ={a,b}
Step 1:
ab is in {anbn}
Step 2:
if x is in {anbn}, then axb is in {anbn}
Step 3:
No strings except those constructed in above,
are allowed to be in {anbn}
• Defining the language L, of strings ending in
a , defined over Σ={a,b}
Step 1:
a is in L
Step 2:
if x is in L then s(x) is also in L, where s belongs to Σ*
Step 3:
No strings except those constructed in above,
are allowed to be in L
• Defining the language L, of strings beginning and
ending in same letters , defined over Σ={a, b}
Step 1:
a and b are in L
Step 2:
(a)s(a) and (b)s(b) are also in L, where s belongs to Σ*
Step 3:
No strings except those constructed in above, are
allowed to be in L
• Defining the language L, of strings containing
exactly aa, defined over Σ={a, b}
Step 1:
aa is in L
Step 2:
s(aa)s is also in L, where s belongs to b*
Step 3:
No strings except those constructed in above,
are allowed to be in L
• Useful Reading

Third chapter of Daniel I. Cohen book.

You might also like