Sunteți pe pagina 1din 48

Let’s settle them once and for All !

Can I visit you other than class Yes


timings?
Can I ask question. A lot of them? Appreciated
Can I have some guesses before the No
paper?
Can my marks be increased for grade Yes. Upto two (2) marks
or passing marks?
If I fall sick or have an unavoidable No
issue, will I get any grace marks as
compensation?
Attendance If you are absent, you are
absent.
Can I pass the paper with good grades? Yes
Handouts # 1

Theory of Automata
Material / Resources

 Text & Reference Books


1. Introduction to Computer Theory, by Daniel I.
Cohen, John Wiley and Sons, Inc., 2005, Second
Edition
2. Introduction to Languages and Theory of
Computation, by J. C. Martin, McGraw Hill Book
Co., 2003, Third Edition.
3. Introduction to Automata Theory, Languages,
and Computation by HOPCROFT, MOTWANI,
ULLMAN
4. www, Any other book on Automata Theory
What does automata mean?

 It is the plural of automaton, and it means


“something that works automatically” .

 Automata play a major role in theory of


computation, compiler design, artificial
intelligence, parsing and hardware design etc.
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?".
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


(1) compute, (2) how fast and (3) how much
space does it take to do so.
Theory of Automata

 Automata theory uses mathematical wisdom


(logic) to compute. Automata helps us to make
abstract machines or idealized machines or soft
machines. These abstract machines are actually
logical models.
 Compliers/interpreters/assemblers are kind of
abstract machines since they take input in a user
friendly way and process it into machine form.
 Every executer is an example of abstract machine.
Models of Computation

 FSM: Finite State


Machine.
 CFL: Context Free
Language.
 Turning Machine.
 Undecidable.
Finite State Machine

 A finite-state machine (FSM)


or finite-state automaton , finite
automaton, or simply a state
machine, is a mathematical model of
computation.
 It is an abstract machine that can be
in exactly one of a finite number
of states at any given time. The FSM
can change from one state to another
in response to some external inputs;
the change from one state to another
is called a transition. An FSM is
defined by a list of its states, its
initial state, and the conditions for
each transition.
Finite State Machine

 The behavior of state machines can be observed in


many devices. They perform a predetermined
sequence of actions.
 Examples are vending machines, which dispense
products when the proper combination of coins is
deposited, elevators, whose sequence of stops is
determined by the floors requested by
riders, traffic lights, which change sequence when
cars are waiting, and combination locks, which
require the input of combination numbers in the
proper order.
Finite State Machine

 Deterministic Finite Automata (DFA)

 Non-Deterministic Finite Automata (NDFA)


The Language

 Why a representative language is needed in


automata?
 Because we need to derive standard solutions which are
understandable globally.
 Why structured definition of a language is
needed?
 Because it leads us to the decision that creating larger
strings are based on properly stated rules.
Importance of The Language

 It is important that there be rules for recognizing


an input for its validity.
 Syntax should be in accordance with the
structured definition.
Formal Language

 Formal refers to, “All the rules of the language are


clearly stated in term of what symbols can be to
used to cerate larger string.”
 No liberations are tolerated in formal language.
 Language is a game of symbols on the paper. It
concerns syntax, not semantics.
Alphabets

 Definition:
“A finite non-empty set of symbols (letters)”.
 It is denoted by Σ ( Greek letter sigma).
 Example:
 Σ={A….Z, a…z} // alphabets for English language.
 Σ={0,1} // Binary language alphabets.
 Σ={Aa…..Zz, 0…9, -+%&*….}
Word / String

 Definition:
 “Sequence of symbols chosen from some alphabet” or
simply, “Set of words” or “Concatenation of finite symbols
(letters) from alphabets”.
Denoted by Σ+
 Example:
 Strings of English words are:
 Σ+ = {any words found in English dictionary}
 Strings for C++
 Σ+ = {all allowable variables}
EMPTY STRING or NULL STRING

 Sometimes a string with no symbol at all is used,


denoted by (Small Greek letter Lambda) λ or
(Capital Greek letter Lambda) Λ or є, is called an
empty string or null string.
 The capital lambda will mostly be used to denote
the empty string, in further discussion.
 Empty string is multiplicative identity just like
the number “1”.
 Λa = a
aλ=a
Power of an Alphabet
Strings Example

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


L={x, xx, xxx,….}

Suppose we call the word xx as ‘a’ and xxx as ‘b’ then by


concatenation of ab we will get what ????
Finite vs Infinite Languages

Finite Languages
In these languages the number of strings are finite such as:

L1= {a ab bab}
L2= {a b}
L3= {b}
L4= {ab}
L5= {} // Ø
L6= {є ab abb}
L7= {є}
Finite vs Infinite Languages

Infinite Languages
In these languages the number of strings are infinite such as:

L1= {Language of all those string which begins with b}


L2= {Language of all those string whose length is even}
L3= {Language of all those string whose length is odd}
L4= {Language of all those string whose length is less than 5}
L6= {ab abb abbb ………….} etc
Key points: Valid/In-valid alphabets

 While defining an alphabet, an alphabet may contain


letters consisting of group of symbols for
example
Σ1= {B, aB, bab, d}

 Now consider an alphabet


Σ2= {B, Ba, bab, d}
How to avoid ambiguity problem ?

 While defining an alphabet of letters consisting


of more than one symbols, no letter should be
started with the letter of the same alphabet i.e. one
letter should not be the prefix of another. However,
a letter may be ended in the letter of same alphabet
i.e. one letter may be the suffix of another.

 Why ? So that we can avoid ambiguity problem


Conclusion

 Σ1= {B, aB, bab, d}


 Σ2= {B, Ba, bab, d}

 Σ1 is a valid alphabet while


Σ2 is an in-valid alphabet.
Length of Strings

 Definition:
The length of string s, denoted by |s| or length(s)
or sometimes as |w|, is the number of letters in
the string.

 Example:
Σ={a,b}
s=ababa
|s|=5
Length of Strings

 In any language that includes the empty string λ


we have:

 length(λ) = 0
Reverse of a String

 Definition:
The reverse of a string s in a language L denoted by
Rev(s) or sr , is obtained by writing the letters of s
in reverse order even if this backward string is not
a word in L.
 Example:
If s = abc is a string defined over
Σ={a,b,c} then
Rev(s) or sr = cba
Same Words

 Definition:
The words or strings are said to be same if they are
made up of the same alphabets in the same order.
E.g. book (kitab) and book (reserve).
Null Language

 Definition:
A language with no words or strings. It is denoted
by ∅.
Dictionary

 Definition:
An all inclusive list of words or strings created over
fixed alphabets.
Lexicographic

 Definition:
When the words are arranged as per their length
i.e. shortest word first. This is a computable
arrangement.
Palindrome

 Definition:
A string whose reverse is equal to itself. E.g.
reverse (eye) = eye
reverse (abba) = abba
reverse (……..) = ?
From Computability point of view, a palindrome has
same first and last alphabets and what lies in
between is a palindrome too.
Every single letter is always a ……………..?
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.

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


 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, …}
 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,…}
 Example:
The language FACTORIAL, of strings defined
over Σ={a}, as {an! : n=1,2,3,…}, can be written as

It is to be noted that the language FACTORIAL


can be defined over any single letter alphabet.

{a, aa, aaa,aaaa,…}


 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,…}
 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…}
Kleene Star Closure / Kleene Closure

 Set over an alphabet that contains all possible


strings and also a null (Λ).
 Denoted by Σ*.
 E.g. Σ = {a}, Σ* = {Λ, a, aa, aaa, aaaa, ….}
 Σ = {a,b,c}, Σ* = {Λ, a, b, c, aa, ab, ac, ….}

 Difference between dictionary and kleene closure


is only the presence of Λ in kleene closure.
Examples

 If Σ = {x}
Then Σ* = {Λ, x, xx, xxx, xxxx, ….}
Lexicographic
 If Σ = {0,1} Order
Then Σ* = {Λ, 0, 1, 00, 01, 10, 11, ….}

 If Σ = {a,b}
Then Σ* = {Λ, a, b, aa, ab,
ba,bb,aaa,aab,aba,abb,aab,baa,bab,bba,bbb}

 If Σ = {aaB, c}
Then Σ* = {Λ, aaB, c, aaBaaB, aaBc, caaB, cc, ….}
Note

 Languages generated by Kleene Star Closure of set of


strings, are infinite languages.

 (By infinite language, it is supposed that the


language contains infinite many words, each of finite
length).
PLUS Operation (+)

 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, ….}
 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 strings defined over
{a}, which shows that a+ generates
a, aa, aaa, aaaa, …

S-ar putea să vă placă și