0% found this document useful (0 votes)
4 views

Chapter 2. Finite Automata

Chapter 2 discusses Finite Automata, including Deterministic Finite Automata (DFA) and Nondeterministic Finite Automata (NFA), detailing their structures, transition functions, and examples of automata for specific string patterns. It also covers the conversion between NFA with ε-transitions and NFA without ε-transitions, along with DFA minimization techniques. Additionally, it introduces Moore and Mealy machines, which are finite automata with outputs based on states and transitions, respectively.

Uploaded by

rogmagnusff
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Chapter 2. Finite Automata

Chapter 2 discusses Finite Automata, including Deterministic Finite Automata (DFA) and Nondeterministic Finite Automata (NFA), detailing their structures, transition functions, and examples of automata for specific string patterns. It also covers the conversion between NFA with ε-transitions and NFA without ε-transitions, along with DFA minimization techniques. Additionally, it introduces Moore and Mealy machines, which are finite automata with outputs based on states and transitions, respectively.

Uploaded by

rogmagnusff
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

Chapter 2.

Finite Automata
Reena Lokare
Deterministic Finite Automata (DFA)
M = { Q, Σ, δ,q0, F}
Q = Finite set of states
Σ = Finite set of Input symbols
δ = Transition functions maps from Q * Σ = Q
q0 = Initial / Start state
F = Set of final or accepting states
DFA
Language = Regular Language
Input = String = Set of input symbols
Output =Accept / Reject
DFA to accept strings ending with 0
r = (0+1) *. 0 M = { Q, Σ, δ,q0, F}

Q = { q0,q1 }

Σ = { 0,1 }

δ = Transition Table

Q0 = {q0}

F = {q1}

q0= strings ending with 1, q1= strings ending with 0


DFA to accept strings beginning with 01
r = 01. (0+1)* M = { Q, Σ, δ,q0, F}

Q = { q0,q1,q2 }

Σ = { 0,1 }

δ = Transition Table

Q0 = {q0}

F = {q2}

q0= Initial state q1= strings end with 0 q2= strings end with 01
DFA to accept Numbers divisible by 4 (0100)

Q\Σ 0 1

q0(rem=0) 0100 01000 (8) q0 01001(9) q1

q1 (rem=1)0101 01010(10) q2 01011(11) q3

q2 (rem=2)0110 01100(12) q0 01101(13) q1

q3(rem=3) 0111 01110 (14) q2 01111 (15) q3


DFA to accept strings with even no of 0’s and even no of 1’s
States:

q0: even 0,even 1},0 -> odd 0, even 1 =q2


q0: even 0,even 1},1 -> even 0, odd 1 = q1
q1: even 0, odd 1 },0 -> odd 0, odd 1 = q3
q1: even 0, odd 1 },1 ->even 0, even 1 =q0
q2 :odd 0, even 1 },0 -> even 0, even 1 = q0
q2 :odd 0, even 1 }, 1 ->odd 0, odd 1 =q2
q3: odd 0,odd 1 },0 -> even 0, odd 1 = q1
q3: odd 0,odd 1 }, 1 -> odd 0, even 1 = q2
Nondeterministic Finite Automata (NFA) types:

1. NFA without έ transition


2. NFA with έ transition
1. NFA without έ transition

M = { Q, Σ, δ,q0, F}
Q = Finite set of states
Σ = Finite set of Input symbols
δ = Transition functions maps from Q * Σ = 2Q
q0 = Initial / Start state
F = Set of final or accepting states
NFA to accept strings having at least 2 consecutive 0’s or 1’s
r= (0+1)*00 (0+1)*+ (0+1)*11 (0+1)*
NFA to accept strings with substring 101
r = (0+1)*101(0+1)*
Regular Expression to Finite Automata
r = a ( a + b )* bb
r1 = a
r2 = (a + b)*
r3 =bb
r1 = a
r2 = (a + b)*
r3 =bb
Final Automata
NFA with ε-transitions to NFA without ε-transitions
Algorithm to convert NFA with ε-transitions to NFA
without ε-transitions
Note: Number of states will remain same.

Step 1. Find ε-closure of states.


Step 2. Find transitions of new states.
Step 3. Construct NFA without ε-transitions.
Example: r = a* b* c* ε-closure:
ε-closure(q0)={q0,q1,q2}
ε-closure(q1)={q1,q2}
ε-closure(q2)={q2}

Q\∑ a b c

qo qo - -
q1 - q1 -
q2 - - q2
Transitions of new states:
New States:
Q\∑ a b c
[{q0,q1,q2}]
[{q1,q2}] [{q0,q1,q2}] [{q0,q1,q2}] [{q1,q2}] [{q2}]

[{q2}]
-
[{q1,q2}] [{q1,q2}] [{q2}]

- -
[{q2}] [{q2}]
NFA without ε-transitions
NFA to DFA

NFA
Equivalent DFA
DFA Minimization/Optimization
● Method of detecting those states of a DFA whose presence or absence in a
DFA does not affect the language accepted by the automata.
● States to remove:
○ Unreachable states
○ Dead states
○ Non-distinguishable states
Finite Automata with Output
FAs where output can be chosen from some other alphabet.
Moore Machine = Output labelled with state
M = { Q, Σ, δ,q0, λ, Δ }

Q = Finite set of states

Σ = Finite set of Input symbols

δ = Transition functions maps from Q * Σ = Q

q0 = Initial / Start state

Δ = Output alphabet

λ = Output function mapping Q into Δ


Moore machine: One’s complement
Moore machine: count the occurrence of substring aab
Mealy Machine = Output labelled with transition
M = { Q, Σ, δ,q0, λ, Δ }

Q = Finite set of states

Σ = Finite set of Input symbols

δ = Transition functions maps from Q * Σ = Q

q0 = Initial / Start state

Δ = Output alphabet

λ = Output function mapping Q * Σ into Δ


Mealy machine: one’s complement
Mealy machine: Count the occurrence of substring 001
Moore to Mealy
Moore to Mealy
Mealy to Moore

You might also like