0% found this document useful (0 votes)
5 views23 pages

Lecture 01

Uploaded by

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

Lecture 01

Uploaded by

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

Theory of Automata

Lecture # 01
What does Theory of automata mean?

• The word “Theory” means that this subject is a more mathematical


subject and less practical.

• It is not like your other courses such as programming. However, this


subject is the foundation for many other practical subjects.

• Automata is the plural of the word Automaton which means “self-


acting”

• In general, this subject focuses on the theoretical aspects of computer


science.

SAIFULLAH JAN INU-Peshawar


Where does Theory of Automata come from?

 Theory of automata is a part of Theory of Computation.

 Theory of Computation is about how efficiently problems can be

solved using an algorithm.

 Theory of Computation is divided into three major branches:

Automata theory, Computability theory, and Complexity theory,

which are linked by the question: "What are the fundamental

capabilities and limitations of computers?”

SAIFULLAH JAN INU-Peshawar


Theory of Automata
 Automata theory is the study of abstract machines and automata,
as well as the computational problems that can be solved using
them.

Why study Theory of Automata


 Mainly, to know what kind of things can you really
 Compute
 how fast
 how much space does it take to do so.

SAIFULLAH JAN INU-Peshawar


What are Strings

• A String is formed by combining various symbols from an alphabet.

• Example:

If Σ = { 1, 0 } then

0, 1, 110011, …..

Similarly, If Σ = { a, b } then

a, b, abbbbbb, aaaabbbbb, …..

SAIFULLAH JAN INU-Peshawar


What is an EMPTY or NULL String

• A string with no symbol is denoted by (Small Greek letter Lambda) λ


or (Capital Greek letter Lambda) Λ. It is called an empty string or null
string.

• We will prefer Λ in this course. Please don’t confuse it with logical


operator ‘and’.

• One important thing to note is that we never allow Λ to be part of


alphabet of a language

SAIFULLAH JAN INU-Peshawar


What are Words

• Words are strings that belong to some specific language.

Thus, all words are strings, but vice versa is not true.

Example:

If Σ = { a } then a language L can be defined as

L = { a, aa, aaa,….} where L is a set of words of the language.

Also a, aa,… are the words of L but not ab.

SAIFULLAH JAN INU-Peshawar


Defining Alphabets – Guidelines

The following are three important rules for defining Alphabets for a

language:

• Should not contain empty symbol Λ

• Should be finite. Thus, the number of symbols are finite

• Should not be ambiguous

• Example: an alphabet may contain letters consisting of group of

symbols for example Σ1= {A, aA, bab, d}.

SAIFULLAH JAN INU-Peshawar


• Now consider an alphabet

Σ2= {A, Aa, bab, d} and a string AababA.

• This string can be factored in two different ways

– (Aa), (bab), (A)

– (A), (abab), (A)

Which shows that the second group cannot be identified as a string,

defined over Σ = {a, b}.

• This is due to ambiguity in the defined alphabet Σ2

SAIFULLAH JAN INU-Peshawar


Why Ambiguity comes: A computer program first scans A as a letter belonging
to Σ2, while for the second letter; the computer program would not be able to
identify the symbols correctly.
• Ambiguity Rule:- The Alphabets should be defined in a way that letters
consisting of more than one symbols should not start with a letter, already
being used by some other letter.

Ambiguity Examples
• Σ1= {A, aA, bab, d}

• Σ2= {A, Aa, bab, d}

Σ1 is a valid alphabet while Σ2 is an in-valid alphabet.

Similarly,
• Σ1= {a, ab, ac}

• Σ2= {a, ba, ca}

In this case, Σ1 is a invalid alphabet while Σ2 is a valid alphabet.


SAIFULLAH JAN INU-Peshawar
Length of Strings
• Definition:
The length of string s, denoted by |s|, is the number of letters/symbols in the
string.
• Example:
Σ={a,b}
s=aaabb
|s|=5
Word Length Example
Σ= {A, aA, bab, d}
s=AaAbabAd
Factoring=(A), (aA), (bab), (A), (d)
|s|=5
• One important point to note here is that aA has a length 1 and not 2.
SAIFULLAH JAN INU-Peshawar
Length of strings over n alphabets

• Formula: Number of strings of length ‘m’ defined over alphabet of ‘n’

letters is nm

Examples:

– The language of strings of length 2, defined over Σ={a,b}is L={aa,

ab, ba, bb} i.e. number of strings = 22

– The language of strings of length 3, defined over Σ={a,b} is

L={aaa, aab, aba, baa, abb, bab, bba, bbb} i.e. number of strings =

23

SAIFULLAH JAN INU-Peshawar


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
• Example:
Σ= {A, aA, bab, d}
s=AaAbabAd
Rev(s)=dAbabaAA or
Rev(s)= dAbabAaA
Which one is correct?

SAIFULLAH JAN INU-Peshawar


How to form a Palindrome String?
• For strings of length =1:
– Take rev(s) where s is a string

– Example: if s = a then Rev(a) = a

– If s=b then Rev(b) = b

– Similarly, if Σ= {A, aA, bab, d} and

s=aA then rev(aA) = aA


• For strings of length >1:
– Take s Rev(s) where s is string

– Example: if s = ab then s Rev(s) = ab ba is a palindrome

– Similarly, if Σ= {A, abab, d}

s=Aabab then s Rev(s) = A abab abab A which is a palindrome

SAIFULLAH JAN INU-Peshawar


Length of Palindrome

• If the length of Palindrome is even then:

– s Rev(s) means length of string s is n and thus, there will be 2 n

strings.

– As we know that string is of length n and number of symbols in

the alphabet is 2, which shows that there are as many

palindromes of length 2n as there are the strings of length n i.e.

the required number of palindromes are 2n.

SAIFULLAH JAN INU-Peshawar


– If the length of Palindrome is odd then:

• How an odd length palindrome looks like:

• abc a cba

• Formula: s (symbol from alphabet) Rev(s)

• For odd length palindrome, string is of length n and symbol


from the alphabet which appears in the middle and has a
length 1 which is subtracted, plus the Rev(s) which is again of
length n.

• Thus it is 2n-1. For example: we have a palindrome abcacba.


So it is formed from string: s = abc a Rev(abc)
thus: n-1 +n = 2n -1

SAIFULLAH JAN INU-Peshawar


• The no of palindromes in the odd case depends on the alphabets/symbols

in the Sigma. Suppose if number is 2 that is Σ= {a, b} then number of

palindromes of length 2n-1 with ‘a’ as a middle letter, will be 2 n-1.

• Similarly the number of palindromes of length 2n-1, with ‘ b ’ as middle

letter, will be 2n-1 as well. Hence the total number of palindromes of length

2n-1 will be 2n-1 + 2n-1 = 2 (2n-1)= 2n .

SAIFULLAH JAN INU-Peshawar


Defining Languages
 The languages can be defined in different ways , such as

Descriptive definition,

Recursive definition,

using Regular Expressions(RE) and

using Finite Automaton(FA) etc.


 Descriptive definition of language:

The language is defined, describing the conditions imposed on its words


 Example:

The language L of strings of odd length, defined over Σ={a}, can be written as

 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, …}

SAIFULLAH JAN INU-Peshawar


 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,…}
 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, …}

SAIFULLAH JAN INU-Peshawar


 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, aabb, abab, abba, baab, baba, bbaa…}
 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,…}

SAIFULLAH JAN INU-Peshawar


 Example:

The language FACTORIAL, of strings defined over Σ={a}, as {an! :


n=1,2,3,…}, can be written as
{a, aa, aaa,aaaa,…}
It is to be noted that the language FACTORIAL can be defined over any
single letter alphabet.
 Example:

The language DOUBLEFACTORIAL, of strings defined over Σ={a, b},


as {an! bn! : n=1,2,3,…}, can be written as
{ab, aabb, aaabbb, aaaaaabbbbbb,…}
 Example:

The language SQUARE, of strings defined over Σ={a}, as {an2 :


n=1,2,3,…}, can be written as
{a, aaaa, aaaaaaaaa,…}

SAIFULLAH JAN INU-Peshawar


 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…}

SAIFULLAH JAN INU-Peshawar


Lecture 1 Summary
• Definition of the word Automata
• Types of languages, empty/Null String, Alphabets, words, length
of strings, Palindromes
• How to form palindromes of even and odd length.

SAIFULLAH JAN INU-Peshawar

You might also like