Theory Automata
Theory Automata
THEORY OF AUTOMATA
• Why we need Automata theory
• How to make a Finite State Automaton
• Real life examples of Automata
2
Computation
• Computation can be defined as finding a solution
to a problem from given inputs by means of an
algorithm.
• Model of Computation
• A formal or an abstract computer
• Types of Computation Models
• Serial Models
• Parallel Models
1.3
Computation Devices
• In this study we consider a mathematical
model of computing.
• Such a model strips the computational
machinery down to the bare minimum, so
that it’s easy to manipulate these
theoretical machines mathematically to
prove things about their capabilities.
1.4
Applications
• Finite state machines are a useful model
for many important kinds of hardware and
software. e.g.
• Software for designing digital circuits
• Lexical analyzer of a compiler
• Searching for keywords in a file or on the Web
• Software for verifying finite state systems, such
as communication protocols
• Operating System (UNIX grep)
• Text Editors
• Markup Languages (HTML, XML)
• Natural Language Processing
1.5
Central Concepts
• Symbol
• A symbol is a single object and is an
abstract entity that has no meaning by
itself.
• It can be alphabet, character or special
character
1.6
Central Concepts
• Alphabet
• An alphabet is a finite, nonempty set of
symbols, Σ (sigma) is used for an
alphabet.
• For example
{0, 1} is an alphabet with two symbols
{a, b} is another alphabet with two
symbols, and
English alphabet is also an alphabet
• Σ = {0,1}, or Σ = the binary alphabet
• Σ = {a,b,…..z}, or Σ=the set of all lower-case letters
1.7
Central Concepts
• String
• A string is a finite sequence of symbols
chosen from some alphabet. e.g. 01101 is
a string from the binary alphabet Σ = {0,1}.
• The number of symbols in a string is
called the length of a string. e.g. 011101
has length 5 and the number of symbols
are 2. The standard notation for the length
of a string w is |w|. e.g. |011| = 3 and | ε |
=0
Central Concepts
• Strings
• Concatenation of Strings: Let x and y
be strings. Then xy denotes the string
obtained by concatenating x with y, that
is, xy is the string obtained by appending
the sequence os symbols of y to that of x.
e.g. if x = aab and y = bbab, then xy =
aabbbab. Note that xy ≠ yx.
1.8
Central Concepts
Languages
• A language is a set of strings over an
alphabet. Thus {a, ab, baa} is a language
(over alphabet {a, b}).
• A set of strings all of which are chosen from
some Σ*, where Σ is a particular alphabet,
is
called a language. If Σ is an alphabet, and L
Σ* , then L is a language over Σ.
• An example is English, where the collection of legal English words is
a set of strings over the alphabet that consists of all the letters.
1.9
1.10
Examples of Languages
• The language of all strings consisting of n 0’s
followed by n 1’s, for some n ≥ 0:
• {ε, 01, 0011, 000111,…..}
• The set of strings of 0’s and 1’s with an equal
number of each:
• {ε, 01,10,0011,0101,1001,…..}
• The set of binary numbers whose value is a
prime:
• {10, 11, 101,111,1011…..}
Note: The only important constraint on what can
be a language is that all alphabets are finite,
although they can have an infinite number of
strings.
1.11
Set Notation
• It is common to describe a language using a “set-
notation”:
{w | something about w }
It is read “the set of strings w such that
(whatever is said about w to the right of the
vertical bar)”
Examples:
• { w | w consists of an equal number of 0’s and 1’s }
• { w | w is a binary integer that is prime }
• { w | w is a syntactically correct C++ program }
1.12
Finite Automata
• Definition of an Automaton
“An automaton is defined as a system where energy, materials and
information are transformed, transmitted and used for performing
some functions without direct participation of man.”
• Examples are
• Automatic machine tools, automatic packing machines, and automatic
photo printing machines.
15
Example 1
• A vending machine dispense piece of candy that cost
Rs. 20 each. The machine accepts coins of Rs. 5 and
Rs. 10 only and does not return change.
As soon as the amount deposited equal or exceeds
Rs. 20, the machine releases a piece of candy.
16
Example 1 (contd:)
10 Rs. 15
Rs. 5
deposited deposited
5 5
Rs. 0 5 5 10
deposited
5
10
Rs. 10 10 Rs. 20 or
deposited more deposited
10
• Each circle represents a state of the machine
• Unlabelled arrow indicates the initial state of the machine
• Double circle indicates that candy is released, called
accepting state.
17
Example 1 (contd:)
Next State Table
Inputs
State 5 10
Rs. 0 deposited Rs. 5 deposited Rs. 10 deposited
Rs. 5 deposited Rs. 10 deposited Rs. 15 deposited
Rs. 10 deposited Rs. 15 deposited Rs. 20 or more
deposited
Rs. 15 deposited Rs. 20 or more Rs. 20 or more
deposited deposited
Rs. 20 deposited Rs. 5 deposited Rs. 10 deposited
18
Example 2
• A story of man with wolf, goat and cabbage to cross the
river.
G M
MWGC - Φ WC-MG MWC-G
G M
W C
W C
C-MWG W-MCG
G G G G
MGC-W MWG-C
C W
C W
G M
Φ - MWGC MG-WC G-MWC
G M
19
Transition Diagram
• A transition diagram for a DFA M = (Q, Σ, δ, s, F) is
a graph defined as follows:
1. For each state in Q there is a node (vertex).
2. For each state q in Q and each input symbol a in
Σ, let δ(q, a) = p. Then the transition diagram has
an arc (edge) from node q to node p, labeled a.
3. There is an arrow into the start state q0, labeled
start. a
4. Nodes corresponding to accepting states (those in
F) are marked aby a double circle.
b
q0 q1
b
21
Example-2
• Let us design a DFA M that accepts the language
L(M) = { w | w Є {0,1}* and w is of the form x01y
for some strings x and y consisting of 0’s and 1’s
only}
Example (continued)
• These three conditions
can each be represented
by three states q0, q1, q2.
The transition functions
are:
δ(q0, 0) = q2 1 0 0,1
δ(q0, 1) = q0
δ(q2, 0) = q2
0
δ(q2, 1) = q1 q0 q2
1
q1
δ(q1, 0) = q1
δ(q1, 1) = q1
Transition Tables
• A transition table is a
conventional, tabular
representation of a function 0 1
like δ that takes two
arguments and returns a q0 q2 q0
value.
• The rows of the table *q1 q1 q1
correspond to the states,
and the columns q2 q2 q1
correspond to the inputs. Transition table for the DFA
24
25
1 0 0,1
Exercise # 1
0 1
q0 q2 q1
Exercise # 2
• Design a DFA to accept the language:
L = { w | w Є {English language letters}* and w
has “the” as a substring}
- What are the states of M?
- What are the input symbols of M?
- What is the initial state of M?
- What are the accepting states of M?
- Find δ(q1, brothers).
- Find the transition state table for M.
- Draw the transition diagram.
1.27
Recommended Book(s)
• Text Book(s):
– Nasir S.F.B and P.K. Srimani, “A Textbook on
Automata Theory”, Cambridge University Press,
India, 2008
– Sikander H. Khiyal, “Theory of Automata and
Computation”, National Book Foundation, 2004
• Reference Book(s):
– John E. Hopcroft, Rajeev Motvani, and Jeffrey D.
Ullman, “Introduction to Automata theory,
Languages and Computation”, Second Edition,
Addison-Wesley, New York, 2001.
– Daniel I. A. Cohen, “Introduction to Computer
Theory”, Second Edition.
– K.L.P. Mishra, N. Chandrasekaran, “Theory of
Computer Science (Automata, Languages and
Computation)”, Prentice-Hall of India, 2002.