0% found this document useful (0 votes)
50 views44 pages

Theory of Automata

The document discusses theory of automata and finite automata. It defines an automaton as a system that transforms energy, materials and information without direct human participation. Examples include automatic machines. An automaton in computer science refers to a discrete automaton, which is an abstract model with inputs, outputs, states, state relations and output relations. Examples of finite state machines like a candy vending machine are provided to illustrate states and state transitions. Characteristics of discrete automata like inputs, outputs, states and relations are explained. Languages recognized by finite automata are also discussed.

Uploaded by

Ahsan Arshad
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)
50 views44 pages

Theory of Automata

The document discusses theory of automata and finite automata. It defines an automaton as a system that transforms energy, materials and information without direct human participation. Examples include automatic machines. An automaton in computer science refers to a discrete automaton, which is an abstract model with inputs, outputs, states, state relations and output relations. Examples of finite state machines like a candy vending machine are provided to illustrate states and state transitions. Characteristics of discrete automata like inputs, outputs, states and relations are explained. Languages recognized by finite automata are also discussed.

Uploaded by

Ahsan Arshad
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/ 44

Theory of Automata

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.
Automaton

 In Computer Science the term ‘automaton’


means “discrete automaton” and is defined in
a more abstract way as shown in the figure:

I1 Automaton O1
I2 O2
I3 O3
q1, q2, …..qn
Ip Oq
The model of a discrete automaton
Characteristics of Discrete Automaton
 Input
 At each discrete instance of time t1, t2,…. Input values I1, I2,…. Each of which
can take a finite number of fixed values from the input alphabet Σ, are applied
to the input side of the model.
 Output
 O1, O2,…. Are the outputs of the model, each of which can take finite number
of fixed values from an output O.
 States
 At any instant of time the automaton can be in one of the states q 1, q2, q3….
 State relation
 The next state of an automaton at any instant of time is determined by the
present state and the present input.
 Output relation
 Output is related to either state only or to both the input and the state. It
should be noted that at any instant of time the automaton is in some state.
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.
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.
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
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
Defining Languages (continued)…
 Method 4 (Finite Automaton)
Definition:
A Finite automaton (FA), is a collection of the
followings
1) Finite number of states, having one initial and
some (maybe none) final states.
2) Finite set of input letters (Σ) from which input
strings are formed.
3) Finite set of transitions i.e. for each state and
for each input letter there is a transition
showing how to move from one state to
another.
Example

 Σ = {a,b}
 States: x, y, z where x is an initial state and z is final
state.
 Transitions:
1. At state x reading a go to state z,
2. At state x reading b go to state y,
3. At state y reading a, b go to state y
4. At state z reading a, b go to state z
Example Continued …

 These transitions can be expressed by the


following table called transition table

Old States New States

Reading a Reading b
x- z y
y y y
z+ z z
Note

 It may be noted that the information of an FA,


given in the previous table, can also be depicted
by the following diagram, called the transition
diagram, of the given FA
a,b

y
b

x–
a,b
a
Z+
Remark

 The previous transition diagram is an FA


accepting the language of strings, defined over
Σ={a, b}, starting with a. It may be noted
that this language may be expressed by the
regular expression
a (a + b)*
Deterministic Finite Automata
 A deterministic finite
automaton is a simple Input tape
language recognition a b a a b b a b
device. It is called
deterministic because Reading head
their operation is
completely determined
by their input.
 Strings are fed into the q0
q1
device by means of an Finite q5
input tape, which is control
q4 q2
divided into squares, with q3
one symbol inscribed in
each tape square.
Formal Definition of Deterministic Finite
Automata (DFA)
 A deterministic finite automaton is quintuple
A= (Q, Σ, δ, s, F) where
Q is a finite set of states,
Σ is an alphabet,
s Є Q is the initial state,
F Q is the set of final states, and
δ the transition function, is a function from Q X Σ to Q .
If the symbol read from tape is σ Є Σ, then δ(q, σ) Є Q.

Note: δ – delta…. σ small sigma


A DFA
 M = (Q, Σ, δ, s, F), where
Q = {q0, q1}
Σ = {a, b}
s = q0
F = {q0}

q σ δ(q,σ)
q0 a q0
q0 b q1
q1 a q1
q1 b q0
The Language of DFA
 M passes from state q0 to q1 or from q1 back to
q0 when a b is read, but M essentially ignores a’s,
always remaining in its current state when an a
is read. Thus M accepts a string if and only if the
number of b’s is even.
 Then L(M) is the set of all strings in {a,b}* that
have an even number of b’s.
L(M) = { w | w Є { a, b }* and w contains
even number of b’s }
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 a
q0, labeled start. a
b
4. Nodes corresponding to accepting
states (those in F) are marked by a q0 q1
double circle.
b
How a DFA Processes Strings?

Let the input string is aabba.


δ(q0, a) = q0
δ(q0, a) = q0
δ(q0, b) = q1
δ(q1, b) = q0
δ(q0, a) = q0
Since q0 belong to F therefore the string is accepted.
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}

 To decide whether 01 is a substring of the input, M needs to


remember:
1. Has it already seen 01? If so, then it accepts every sequence of
further inputs.
2. Has it never seen 01, but its most recent input was 0, so if it now
sees a 1, it will have seen 01.
3. Has it never seen 01, but its last input was either nonexistent or
it last saw a 1?
Example (continued)

 These three conditions


can each be represented
by three states q0, q1, q2.
The transition functions
are:
δ(q0, 0) = q2
δ(q0, 1) = q0 1 0 0,1
δ(q2, 0) = q2
δ(q2, 1) = q1 0 1
q0 q2 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 correspond to the
inputs. q2 tableqfor
Transition q1
2 the DFA
Extending the Transition Function to
String
 Design a DFA to accept the language:
L = { w | w Є {0, 1}* and w has an even
number of 0’s and even number of 1’s}

0 1
*->q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Extending the Transition Function to
String

 We want to use it to illustrate the construction


of δ from its transition function δ. Suppose
^

the input is 110101. Since this string has even


number of 0’s and 1’s both, we expect it is in
the language. Thus, we expect the
δ(q0,110101) = q0, since q0 is the only
accepting state. Let us now verify that claim.
^
 δ(q
^
0, ε) = q0.

 δ(q
^
0 , 1) = (δ(δ(q
^
0, ε ), 1) = δ(q0,1)=q1.

 δ(q
^
0, 11) = (δ(δ(q0, 1), 1) = δ(q1,1)=q0.
^

 δ(q
^
0, 110) = (δ(δ(q0, 11), 0) = δ(q0,0)=q2.
^

 δ(q
^
0, 1101) = (δ(δ(q0, 110), 1) = δ(q2,1)=q3.
^

 δ(q
^ 0, 11010) = (δ(δ(q^ 0, 1101), 0) = δ(q 3,0)=q1.

 δ(q
^ 0, 110101) = (δ(δ(q ^ 0
, 11010), 1) = δ(q1,1)=q0.
Example
 Build an FA accepting the Language L of Strings,
defined over Σ = {a, b}, beginning with and
ending in same letters.
Solution:The language L may be expressed by
the following regular expression
(a+b)+a(a + b)*a + b(a + b)*b
This language L may be accepted by the
following FA
Solution continued …

a b a
a
b 6+
a
2+ 4
b
1– b a b
b
b
a 7+
3+ 5
a
Example

Consider the Language L of Strings , defined


over Σ = {a, b}, beginning with and ending
in different letters.
The language L may be expressed by the
following regular expression
a (a + b)* b + b (a + b)* a
This language may be accepted by the following
FA
Example Continued …

a b b

2 4+
a a
1–
b a
a
b
3 5+
b
Example

 Consider the Language L , defined over Σ=


{a, b} of all strings including Λ, The
language L may be accepted by the following FA
a,b

a,b
1  2+

 The language L may also be accepted by the


following FA
Example Continued …
a,b

 The language L may be expressed by the


following regular expression

(a + b)*
Example

 Consider the Language L , defined over Σ=


{a, b} of all non empty strings. The language
L may be accepted by the following FA

a,b

a,b
– +

The above language may be expressed by the


following regular expression (a + b)+
Example

 Consider the following FA, defined over Σ=


{a, b}
a,b
a,b
– +

 It is to be noted that the above FA does not


accept any string. Even it does not accept the
null string. As there is no path starting from
initial state and ending in final state.
Equivalent FAs

 It is to be noted that two FAs are said to


be equivalent, if they accept the same
language, as shown in the following FAs.
Equivalent FAs Continued …
a,b
FA1 –
a,b
+
a,b

FA2 a,b
1 – 2

a,b a,b

a,b
FA3 1– 2 3
+
Note (Equivalent FAs)

 FA1 has already been discussed, while in FA2,


there is no final state and in FA3, there is a final
state but FA3 is disconnected as the states 2 and
3 are disconnected.
It may also be noted that the language of
strings accepted by FA1, FA2 and FA3 is denoted
by the empty set i.e.
{ } OR Ø
Example

Consider the Language L of strings ,


defined over Σ = {a, b}, containing
double a.
The language L may be expressed by the
following regular expression
(a+b)* (aa) (a+b)*. This
language may be accepted by the
following FA
Example Continued …

b a,b
a
a
1- 2 3+
b
Example
Consider the language L of strings, defined over
Σ={0, 1}, having double 0’s or double 1’s,
The language L may be expressed by the
regular expression (0+1)*
(00 + 11) (0+1)*
This language may be accepted by the following
FA
Example Continued …

0
0
0,1

- 0 1 +

1
1

y
Example

Consider the language L of strings, defined over


Σ={a, b}, having triple a’s or triple b’s.
The language L may be expressed by RE

(a+b)* (aaa + bbb) (a+b)*


This language may be accepted by the following
FA
Example Continued …
2 a
4

a
a
b a,b

1–– a b 6+

b a
b

3 b 5
Example

 Consider the EVEN-EVEN language, defined


over Σ={a, b}. As discussed earlier that
EVEN-EVEN language can be expressed by
the regular expression (aa+bb+(ab+ba)
(aa+bb)*(ab+ba))*
EVEN-EVEN language may be accepted by the
following FA
Example Continued …

1 3
b

a a a a

2 4
b

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy