L3 DFA Introduction

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

L3 - Theory of Computation -

DFA Introduction

Course Instructors:
Div 1: Praveen Pawar (Div 1)
Div 2: Jibi Abraham (Div 2)

1
Finite Automata

2
Example of a Finite Automaton
f
off on
f
 There are states off and on, the automaton
starts in off and tries to reach the “good state”
on
 What sequences of f’s lead to the final state?
 Answer: {f, fff, fffff, …} = {f n: n is odd}
 This is an example of a deterministic finite
automaton over alphabet {f}
Deterministic finite automata
 A deterministic finite automaton (DFA) is a 5-
tuple (Q, S, d, q0, F) where
 Q is a finite set of states
 S is an alphabet
 d: Q × S → Q is a transition function
 q0  Q is the initial state
 F  Q is a set of accepting states (or final states).
Representation of d
 Transition Function, d, can be represented in
2-ways
 Transition Diagram
 Transition Table

5
Example - 1
0 1 0,1
q0 1 q1 0 q2

alphabet S = {0, 1} transition function d:


states Q = {q0, q1, q2} inputs
initial state q0 0 1
accepting states F = {q0, q1} q0 q0 q1

states
q1 q2 q1
q2 q2 q2

In Transition diagrams, the accepting states will be denoted by


double loops
Polling - 1
 Is the below FA a DFA?
A. Yes

B. No

7
Block Diagram of FA

0 1 1 0 0 .. .. Input Tape
Header
Finite
Control

 One-way, infinite tape, broken into cells


 One-way, read-only tape head.
 Finite control, i.e.,
 finite number of states, and
 transition rules between them, i.e.,
 a program, containing the position of the read head, current symbol
being scanned, and the current “state.” 8
Acceptance of DFA
 A string is placed on the tape, read head is
positioned at the left end, and the DFA will read the
string one symbol at a time until all symbols have
been read.
 The DFA will then either accept or reject the string.
 Let ‘w’ be any string defined over alphabet Σ
corresponding to ‘w’ if their exist a transition path
which start at initial state and end in any one of the
final states then string ‘w’ is accepted by DFA.
 The set of all string’s which are accepted by DFA is
called as Language of DFA

9
Example -2
The language of a DFA (Q, S, d, q0, F) is the set of
all strings over S that, starting from q0 and
following the transitions as the string is read left
to right, will reach some accepting state.

f
M: off on
f

 Language of M is {f, fff, fffff, …} = {f n: n is


odd}
Example - 3
 Modeling recognition of the word “then”

Start state Transition Intermediate Final state


state
11
Example - 4
1

0
q0 q1 1
0

State q0 q0 q1 q0 q0 q0
Input 1 0 0 1 1

• One state is final/accepting, all others are


rejecting.
• The above DFA accepts those strings that
contain an even number of 0’s, including the
null string, over {0,1}
L = {all strings with even number of 0’s} 12
Polling - 2
 Does the language of the below DFA include ԑ?
A. Yes

B. No

0
q0 q1 1
0

13
Construction of DFA – Example 5
Construct the FA that accept all the strings on {0,1}
where every string start with 10.
Step 1 : ∑ = {0,1}
Step 2 : L = {10, 100, 101, 1000, 1001, 1010, 1011, ….}
Step 3: Transition Diagram
0,1
q3
Step 4: Q = {q0, q1, q2, q3} 0 0,1
1
Step 5: F = {q2} q0 q1 q2
1 0
Start

14
Construction of DFA – Example 6
Construct the FA that accept all the string of {0,1}
where every string contain the substring 10.
Step 1 : ∑ = {0,1}
Step 2 : L = {10, 010, 110, 100, 101, 1010, 1011, ….}
Step 3: Transition Diagram

Step 4: Q = {q0, q1, q2} 1 0,1


0
Step 5: F = {q2} q0 q1 q2
1 0
Start
15
Home Work
 Construct a DFA that accept all the string of
{0,1}
1. where every string end with 10

2. where every string Start and end with 0

3. where every string Start and end with same

symbol where every string


4. Start and end with different symbol

5. where number of 0 in the string is exactly 2

6. where number of 0 in the string is at most 2

16
?
17

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