Lecture 1 27022023 011941pm
Lecture 1 27022023 011941pm
Lecture 1 27022023 011941pm
1
Introduction
Amna Iftikhar
2 What is theory of automata?
3
Grading
4
5 What does automata mean?
Software for scanning large bodies of text (e.g., web pages) for pattern finding
Software for verifying systems of all types that have a finite number of states (e.g., stock market
transaction, communication/network protocol)
In which we are not allowed to divert from the strict and predefined grammatical rules
We must make and consider all the possible strings/subsets according to predefined rules
Definition:
A finite non-empty set of symbols (letters), is called an alphabet. It is denoted by Σ ( Greek letter sigma).
Example:
Σ={a,b}
Σ={0,1} //important as this is the language //which the computer understands.
Σ={i,j,k}
Strings
Definition:
Concatenation of finite symbols from the alphabet is called a string.
Example:
If Σ= {a,b} then
a, abab, aaabb, ababababababababab
14
NOTE:
15
16 Words
Definition:
Words are strings belonging to some language.
Example:
If Σ= {x} then a language L can be defined as
L={xn : n=1,2,3,…..} or L={x,xx,xxx,….}
Here x,xx,… are the words of L
17 NOTE:
All words are strings, but not all strings are words.
18 Length of Strings
Definition:
The length of string s, denoted by |s|, is the number of
letters in the string.
Example:
Σ={a,b}
s=ababa
|s|=5
19
Example:
Σ= {B, aB, bab, d}
s=BaBbabBd
Tokenizing=(B), (aB), (bab), (d)
|s|=4
20 Reverse of a String
Definition:
The reverse of a string s denoted by Rev(s) or sr, is
obtained by writing the letters of s in reverse order.
Example:
If s=abc is a string defined over Σ={a,b,c}
then Rev(s) or sr = cba
21
Example:
Σ= {B, aB, bab, d}
s=BaBbabBd
Rev(s)=dBbabaBB
22 Defining Languages
Example:
The language L of strings of odd length, defined over Σ={a}, can be written as
L={a, aaa, aaaaa,…..}
Example:
The language L of strings that does not start with a, defined over Σ={a,b,c}, can be written
as
L={b, c, ba, bb, bc, ca, cb, cc, …}
24
Example:
The language L of strings of length 2, defined over
Σ={0,1,2}, can be written as
L={00, 01, 02,10, 11,12,20,21,22}
Example:
The language L of strings ending in 0, defined over Σ
={0,1}, can be written as
L={0,00,10,000,010,100,110,…}
25
Example: The language EQUAL, of strings with number of a’s equal to number of b’s,
defined over Σ={a,b}, can be written as
{Λ ,ab,aabb,abab,baba,abba,…}
Example: The language EVEN-EVEN, of strings with even number of a’s and even
number of b’s, defined over Σ={a,b}, can be written as
{Λ, aa, bb, aaaa,aabb,abab, abba, baab, baba, bbaa, bbbb,…}
26
An Important language
PALINDROME:
The language consisting of Λ and the strings s
defined over Σ such that Rev(s)=s.
It is to be denoted that the words of PALINDROME
are called palindromes.
Example:For Σ={a,b},
PALINDROME={Λ , a, b, aa, bb, aaa, aba, bab,
bbb, ...}
33 Note
over Σ, including Λ.
It is to be noted that Kleene Star Closure can be
defined over any set of strings.
35 Examples
If Σ = {x}
Then Σ* = {Λ, x, xx, xxx, xxxx, ….}
If Σ = {0,1}
Then Σ* = {Λ, 0, 1, 00, 01, 10, 11, ….}
If Σ = {aaB, c} d
Then Σ* = {Λ, aaB, c, aaBaaB, aaBc, caaB, cc,
….}
36 Note
Plus Operation is same as Kleene Star Closure except that it does not generate Λ (null
string), automatically.
Example:
If Σ = {0,1}
Then Σ+ = {0, 1, 00, 01, 10, 11, ….}
If Σ = {aab, c}
Then Σ+ = {aab, c, aabaab, aabc, caab, cc, ….}
39 TASK
i. (S+)*=(S*)*
ii. (S+)+=S+
iii. Is (S*)+=(S+)*
40 Remark
It is to be noted that Kleene Star can also be operated on any string i.e. a* can be considered
to be all possible strings defined over {a}, which shows that a* generates
Λ, a, aa, aaa, …
It may also be noted that a can be considered to be all possible non empty
+
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
49
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
51
Summing Up