0% found this document useful (0 votes)
139 views41 pages

Chapter 2 DFA and NFA

The document discusses finite automata and deterministic finite automata (DFAs). It defines a finite automaton as a mathematical model of a system with a finite number of internal states. A DFA is defined as a 5-tuple with a finite set of states, input alphabet, transition function, starting state, and set of accepting states. The transition function for a DFA uniquely determines the next state based on the current state and input. The document provides examples of DFA transition diagrams, tables, and descriptions. It also discusses non-deterministic finite automata (NFAs) which can transition to multiple states from a given state and input.
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)
139 views41 pages

Chapter 2 DFA and NFA

The document discusses finite automata and deterministic finite automata (DFAs). It defines a finite automaton as a mathematical model of a system with a finite number of internal states. A DFA is defined as a 5-tuple with a finite set of states, input alphabet, transition function, starting state, and set of accepting states. The transition function for a DFA uniquely determines the next state based on the current state and input. The document provides examples of DFA transition diagrams, tables, and descriptions. It also discusses non-deterministic finite automata (NFAs) which can transition to multiple states from a given state and input.
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/ 41

Chapter 2

FINITE AUTOMATA

1 Formal language and Automata Theory 06/03/2021


.
Automata
Comes from Greek word autopata meaning “self making”
An automaton is a self-operating machines
is  a  mathematical  model  of  HW and  SW  mostly  used for  compilers

It is an abstract model/machine of a digital computer.


An automaton has a mechanism to read input, which is a string over a given alphabet.
This input is actually written on an “input file”, which can be read by the automaton but

cannot change it.

2 Formal language and Automata Theory 06/03/2021


.
Automata
Input file is divided into cells, each of which can hold one symbol.
The automaton has a temporary “storage” device, which has unlimited number of cells, the contents of which can be altered by the automaton.
Automaton has a control unit, which is said to be in one of a finite number of internal states.
The automaton can change state in a defined way.

Automata  Theory

Study
  of  abstract  computing  devices,  or  “machines”  

Automaton
  =  an  abstract  computing  device

An
 automaton with a finite number of states is called a Finite Automaton.

3 Formal language and Automata Theory 06/03/2021


Finite Automata

 The finite automaton is a mathematical model of a system, with discrete inputs and
outputs.
 The system can be in any one of a finite number of internal configurations or
“states”.
 The state of the system summarizes the information concerning past inputs that is
needed to determine the behavior of the system on subsequent inputs.
 Formal language (L(m))- is a set of strings, each string composed of symbols
from a finite symbol set called alphabet
 For example, the alphabet for the sheep language is the set ∑ = {a,b,!}
 L(m) = {baa!, baaa!......}

4 Formal language and Automata Theory 06/03/2021


.
Types of Finite Automaton
1. Deterministic fine Automata (DFA)
Deterministic means that at each point in processing there is always one unique thing to do (has no choice points.
It always knows that to do for any input
A deterministic Finite automata is one in which each move (transition from one state to another) is unequally determined by the current configuration.
If the internal state, input and contents of the storage are known, it is possible to predict the future behavior of the automaton.
This is said to be deterministic automata otherwise it is nondeterministic automata.

An automaton whose output response is “yes” or “No” is called an “Acceptor”.

5 Formal language and Automata Theory 06/03/2021


Deterministic Finite Automata (DFA)

 DFA—also known as deterministic finite state machine—is a finite state


machine that accepts /rejects finite strings of symbols and only produces a
unique computation (or run) of the automaton for each input string.
 Deterministic refers to the uniqueness of the computation.

6 Formal language and Automata Theory 06/03/2021


Deterministic Finite Automata (DFA)

Definition (DFA)

A DFA is a quintuple (𝑄,Σ,𝛿,𝑞0,𝐹) where

𝑄: A finite set of state

Σ: An alphabet of input symbols

𝛿 ∶ 𝑄 × Σ → 𝑄: A transition function

𝑞0 ∈ 𝑄: A start state

𝐹 ⊆ 𝑄: A set of accepting (or final) states

7 Formal language and Automata Theory 06/03/2021


Deterministic Finite Automaton

 The input mechanism can move only from left to right and reads exactly one
symbol on each step.
 The transition from one internal state to another are governed by the transition
function δ.

 If δ(q0 , a)=q1 , then if the DFA is in state q0 and the current input symbol is a,

the DFA will go into state q1.

8 Formal language and Automata Theory 06/03/2021


Example

Q={q0,q1,q2},

Σ={0,1},

q0=q0,

F={q2},

and δ is given by 6 equalities

• δ(q0,0)=q1,

• δ(q0,1)=q0,
•…
• δ(q2,1)=q2

9 Formal language and Automata Theory 06/03/2021


10 Formal language and Automata Theory 06/03/2021
Con...

11 Formal language and Automata Theory 06/03/2021


DFA Representations

 Transition diagram

 Transition table

 Detailed description

Transition diagram: a diagram consisting of circles to represent

states and directed line segments to represent transitions between

the states.

One or more actions (outputs) may be associated with each

transition.
12 Formal language and Automata Theory 06/03/2021
Transition diagram
If any state q in Q is the starting state then it is represented by
the circle with arrow as
Nodes corresponding to accepting states are marked by a
double circle

Example
The following transition diagram represents a DFA
that accepts the language 𝐿 = {𝑥01𝑦 ∣ 𝑥, 𝑦 ∈ {0, 1}∗}.

13 Formal language and Automata Theory 06/03/2021


DFA

States description:

𝑞0: The automaton has never seen 01, but its last input was either
nonexistent or it last saw a 1.

𝑞1: The automaton has never seen 01, but its most recent input was
0.

𝑞2: The automaton has already seen 01


14 Formal language and Automata Theory 06/03/2021
Transition Tables & Detailed Descriptions
In automata theory and sequential logic, a state transition table is a table
showing what state (or states in the case of a nondeterministic finite
automaton) or finite state machine will move to, based on the current state
and other inputs.

15 Formal language and Automata Theory 06/03/2021


Transition Tables

16 Formal language and Automata Theory 06/03/2021


Transition detailed descriptions
 The description of state transitions by statement(words) is known as
transition detailed descriptions.

17 Formal language and Automata Theory 06/03/2021


DFA
Example
Determine the DFA schematic for M = (Q, Σ, δ ,q ,F ), where
Q = {q1, q2, q3}, Σ = {0,1}, q1 is the start state, F = {q2} and δ
is given by the table below

18 Formal language and Automata Theory 06/03/2021


Solution

 Design a DFA, the language recognized by the Automaton being


L = {an b :n ≥ 0}
 For the given language L = {an b :n ≥ 0}, the strings could be
b, ab, a2b, a3b,....,.
Therefore the DFA accepts all strings consisting of an arbitrary
number of a’s, followed by a single b.
 All other input strings are rejected.

19 Formal language and Automata Theory 06/03/2021


Extension of the Transition Function for DFAs

 Let 𝐷 = (𝑄, Σ, 𝛿, 𝑞0, 𝐹) be a DFA.


 The function

𝛿 ∶ 𝑄 × Σ∗ → 𝑄 is recursively defined by 𝛿 ̂ (𝑞, ) = 𝑞,


𝛿 ̂ (𝑞, 𝑥𝑎) = 𝛿 ̂ (𝛿(𝑞, 𝑥), 𝑎).

Example

𝛿 ̂ (𝑞0, 0101)=𝛿(𝛿 ̂ (𝑞0, 010), 1)


= -----
20 = ----- Formal language and Automata Theory 06/03/2021
Extension of the Transition Function for DFAs

21 Formal language and Automata Theory 06/03/2021


NON-DETERMINISTIC FINITE AUTOMATA (NFA)

For any input symbol, nondeterministic one can transit to more than one
states.

In the automata theory, a nondeterministic finite automaton (NFA) or


nondeterministic finite state machine is a finite state machine where from
each state and a given input symbol the automaton may jump into several
possible next states.

22 Formal language and Automata Theory 06/03/2021


NON-DETERMINISTIC FINITE AUTOMATA (NFA)

A Nondeterministic Finite Automata (NFA) is defined by a 5-tuple M =


(Q, Σ, δ ,q0, F ) where Q, Σ, δ, q0, F are defined as follows:

Q = Finite set of internal states

Σ = Finite set of symbols called “Input alphabet”

δ = Q × (Σ ∪ {λ} ) → 2Q

q0∈ Q is the Initial states

F ⊆ Q is a set of Final states

23 Formal language and Automata Theory 06/03/2021


NFA
The automaton can be in several states at once Facilitates the design of
automata.

- NFA differs from DFA in that, the range of δ in NFA is in the power set 2Q.
 A string is accepted by an NFA if there is some sequence of possible
moves that will put the machine in the final state at the end of the string.

24 Formal language and Automata Theory 06/03/2021


Example:

Please note that this is an NFA as δ(q0 ,0) = q0 and δ(q0,0)=q1


.

25 Formal language and Automata Theory 06/03/2021


 Determine an NFA accepting the language

 Solution

 Solutions

26 Formal language and Automata Theory 06/03/2021


Sketch the NFA state diagram for

Solution

1
27 Formal language and Automata Theory 06/03/2021
EQUIVALENCE OF NFA AND DFA
 Two finite accepters M1 and M2 are equivalent iff
 L(M1) =L(M2) i.e., if both accept the same language.
 Both DFA and NFA recognize the same class of languages.
 It is important to note that every NFA has an equivalent DFA.
 Let us illustrate the conversion of NFA to DFA through an example.

28 Formal language and Automata Theory 06/03/2021


Example

29 Formal language and Automata Theory 06/03/2021


30 Formal language and Automata Theory 06/03/2021
Exercise: Find the equivalence DFA for given NFA

 Answer:

31 Formal language and Automata Theory 06/03/2021


DFA Minimization
 Algorithm.
Step 1: Remove unreachable states.
Step 2: Mark the distinguishable pairs of states.
To achieve this task, we first mark all pairs p; q, where pF and qF as distinguishable.

 Then, we proceed as follows:


repeat
for all non-marked pairs p; q do
for each letter a do
if the pair δ(p; a),δ(q; a) is marked
then mark p; q
until no new pairs are marked
Step 3: Construct the reduced automaton A’.

32 Formal language and Automata Theory 06/03/2021


DFA Minimization
 All involve finding equivalent states:
 States that go to equivalent states under all inputs (sounds recursive)
 We will use the Partitioning Method

1.Start by separating final and non-final states:  


 {1,2}, {0,3,4,5}
2. All of 0,3,4 go to final states by a b transition, 5 does
not (5 is a dead state). So we have 3 groups:
{1,2}, {0,3,4}, {5}
3.An a- transition takes 3 to 5 and 0,4 to 3. So we
split {0,3,4} into two groups, getting:
{1,2}, {0,4}, {3}, {5}

33 Formal language and Automata Theory 06/03/2021


Solution
We cannot make any further sub-partitions and so the minimal DFA is: 

34 Formal language and Automata Theory 06/03/2021


Minimize the following DFA

35 Formal language and Automata Theory 06/03/2021


Example

36 Formal language and Automata Theory 06/03/2021


Answer

37 Formal language and Automata Theory 06/03/2021


Exercise
 Find the minimum DFA

38 Formal language and Automata Theory 06/03/2021


Properties Of Regular Languages
 If L1 and L2 are regular over Σ, then L1 ∪ L2 is regular i.e., union of two
regular sets is also regular. [Regular sets are closed w.r.t. union].
 If L1 and L2 are regular, so is L 1 ∩ L 2 [Regular sets are closed w.r.t.
Intersection]

39 Formal language and Automata Theory 06/03/2021


DFA vs NFA

DFA NFA

For every symbol of the alphabet, there is We donot need to specify how does the
only one state transition in dfa nfa react according to some symbol.
DFA can not use empty string transitions NFA can use empty string transition

DFA can be understood as one machine NFA can be understood as multiple little
machines computing at the same time
Backtracking is allowed in DFA Backtracking is not always allowed in
NFA.
DFA is more difficult to construct NFA is easier to construct.

40 Formal language and Automata Theory 06/03/2021


41 Formal language and Automata Theory 06/03/2021

You might also like