Theory of Automata - Lecture 1
Theory of Automata - Lecture 1
Theory of Automata - Lecture 1
Lecture – 1
Course Information
• Instructor: Arslan Tariq
• Email: [email protected]
• Course information and updates will be posted on Google Classroom
• Schedule
• News and announcements
• Lecture Slides
• Assignments
• etc.
• Class Code is zamvmuh
Textbooks
• Introduction to Computer Theory
by Daniel Cohen
Grading Scheme
• Midterm 30%
• Sessional 30%
• Final 40%
Introduction – Automata Theory
Automata theory is the study of abstract machines and automata, as
well as the computational problems that can be solved using them
• Abstract Machine: Is a theoretical model of a computer hardware or software
• Automata: It comes from the Greek word αὐτόματα meaning "self-acting". So
it refers to a self-operating machine.
BATTERY
input: switch
output: light bulb
actions: flip switch
states: on, off
A simple “computer”
input: switch
output: light bulb
actions: f for “flip switch”
states: on, off
A simple “computer”
input: switch
output: light bulb bulb is on if and only if
there was an odd number
actions: f for “flip switch” of flips
states: on, off
Another “computer”
1
BATTERY
2 2 2 2
BATTERY
1
2
off on
1
2 2 2 2
BATTERY
1
2
off on
1
• Talking language
• Programming language
• Formal Languages
Alphabets
• 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}
• A certain version of language ALGOL has 113 letters.
Strings
• Definition:
Concatenation of finite symbols from the alphabet is called a string.
• Example:
If Σ= {a,b} then a, abab, aaabb, ababababababababab
Words
• Definition:
Words are strings belonging to some language.
• Example:
If Σ= {a} then a language L can be defined as L={an :
n=1,2,3,…..} or L={a,aa,aaa,….}
All words are strings, but not all strings are words
Language
• Definition:
The length of string s, denoted by |s|, is the number
of letters in the string.
• Example:
Σ={a,b}
s=ababa
|s|=5
• Example:
Σ= {B, aB, bab, d}
s=BaBbabBd
Tokenizing=(B), (aB), (bab), (B), (d) |s|=5
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
Reverse of a String
• Example:
Σ= {B, aB, bab, d}
s=BaBbabBd
Tokenizing=(B) (aB) (bab) (B) (d)
Rev(s)=dBbabaBB
Defining Languages
• The languages can be defined in different ways , such
as
1. Descriptive definition,
2. Recursive definition,
3. using Regular Expressions(RE) and
4. using Finite Automaton(FA) etc.
• 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,…}
• 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,…}
• Example:
The language INTEGER, of strings defined over Σ={-
,0,1,2,3,4,5,6,7,8,9}, can be written as
INTEGER = {…,-2,-1,0,1,2,…}
• Example:
The language EVEN, of stings defined over
Σ={-,0,1,2,3,4,5,6,7,8,9}, can be written as
EVEN = { …,-4,-2,0,2,4,…}
• Example:
The language {anbn}, of strings defined over Σ={a,b}, as
{anbn : n=1,2,3,…}, can be written as
{ab, aabb, aaabbb,aaaabbbb,…}
• Example:
The language {anbn an}, of strings defined over Σ={a,b},
as {anbn an : n=1,2,3,…}, can be written as
{aba, aabbaa, aaabbbaaa,aaaabbbbaaaa,…
• Example:
The language factorial, of strings defined over
Σ={0,1,2,3,4,5,6,7,8,9} i.e.
{1,2,6,24,120,…}
• Example:
The language FACTORIAL, of strings defined over Σ={a}, as
{an! : n=1,2,3,…}, can be written as
{a,aa,aaaaaa,…}.
• Example:
The language DOUBLEFACTORIAL, of strings defined
over Σ={a, b}, as {an! bn! : n=1,2,3,…}, can be written
as
{ab, aabb, aaaaaabbbbbb,…}
• Example:
The language SQUARE, of strings defined over Σ={a},
as
{an2 : n=1,2,3,…}, can be written as
{a, aaaa, aaaaaaaaa,…}
• Example:
The language DOUBLESQUARE, of strings defined over Σ={a,b}, as
{an2 bn2 : n=1,2,3,…}, can be written as
{ab, aaaabbbb, aaaaaaaaabbbbbbbbb,…}
• Example:
The language PRIME, of strings defined over Σ={a}, as
{ap : p is prime}, can be written as
{aa,aaa,aaaaa,aaaaaaa,aaaaaaaaaaa…}
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, ...}
Kleene Star Closure
• It is to be noted that Kleene Star Closure can be defined over any set
of strings.
Examples
• If Σ = {x}
Then Σ* = {Λ, x, xx, xxx, xxxx, ….}
• If Σ = {0,1}
Then Σ* = {Λ, 0, 1, 00, 01, 10, 11, ….}
• If Σ = {aaB, c}
Then Σ* = {Λ, aaB, c, aaBaaB, aaBc, caaB,
cc, ….}
Note
• Languages generated by Kleene Star Closure of set of strings, are
infinite languages.
• Step 1: 1 is in INTEGER.
• Step 1: 2 is in EVEN.
• Step 1: ab is in {anbn}
• Step 1: aa is in L