0% found this document useful (0 votes)
12 views28 pages

2 Deterministic Finite Automata

The document provides an overview of Deterministic Finite Automata (DFA), including its formal definition, components such as states and transition functions, and examples of how it processes input strings. It explains the concept of accepting and rejecting languages based on the transitions defined in the DFA. Additionally, it introduces a simulation tool called jFAST for experimenting with finite automata.

Uploaded by

Muhammad Junaid
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)
12 views28 pages

2 Deterministic Finite Automata

The document provides an overview of Deterministic Finite Automata (DFA), including its formal definition, components such as states and transition functions, and examples of how it processes input strings. It explains the concept of accepting and rejecting languages based on the transitions defined in the DFA. Additionally, it introduces a simulation tool called jFAST for experimenting with finite automata.

Uploaded by

Muhammad Junaid
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/ 28

CS-3613 TAFL

Deterministic Finite Automata

Instructor: Hashim Ayub

Book: Prof. Sipser-MIT


Slides: Prof. Busch - LSU

1
Deterministic Finite Automata
(DFA)
• In DFA, given current state, we know what
next state will be
• In other words, the exact state to which the
machine moves can be determined.
• It has only one unique state, no choices and
randomness 1
–A B

• Easy and simple to design 1


0 0 0 0
1
C D+
1
2
Formal Definition
Deterministic Finite Automaton (DFA)
𝑀 =( 𝑄 , Σ , 𝛿 ,𝑞 0 , 𝐹 )

𝑄 : set of states
Σ : input alphabet 𝜆∉Σ
𝛿 : transition function
𝑞 0 : initial state
𝐹 : set of accepting states
3
Deterministic Finite Automaton (DFA)

Input Tape
String
Output
“Accept”
Finite or
Automaton “Reject”

4
Transition Graph

𝑄= {𝑞 0 ,𝑞 1 ,𝑞 2 , 𝑞 3 , 𝑞 4 , 𝑞5 }
𝑎,𝑏
Σ ={ 𝑎 , 𝑏 }
𝑞5
𝑏
𝑎,𝑏
𝑎 𝑎 𝑏
𝑞0 𝑎 𝑞1 𝑏 𝑞 2 𝑏 𝑞 3 𝑎 𝑞4

initial accepting
state state
transition
state
5
Simulator to try other Examples
at Home: jFAST
jFAST is a simple finite automata (FA)
graphical simulation utility; it is
designed to feature simple mechanisms
for creating, editing, and simulating FA.
jFAST is ideal for use by students,
instructors, and self-guided explorers
alike.
https://sourceforge.net/projects/jfast-fsm
-sim/

Prof. Busch - LSU 6


Simulator to try other Examples
at Home: jFAST

Prof. Busch - LSU 7


Input Alphabet Σ

𝜆 ∉ Σ:the input alphabet never contains𝜆

Example
Σ ={ 𝑎 ,𝑏 } 𝑎,𝑏

𝑞5
𝑏 𝑎,𝑏
𝑎 𝑎 𝑏
𝑞0 𝑎 𝑞1 𝑏 𝑞 2 𝑏 𝑞 3 𝑎 𝑞4

8
Initial State 𝑞 0

Example
𝑎,𝑏

𝑞5
𝑏
𝑎,𝑏
𝑎 𝑎 𝑏
𝑞0 𝑎 𝑞1 𝑏 𝑞 2 𝑏 𝑞 3 𝑎 𝑞4

9
Set of Accepting States 𝐹 ⊆𝑄

Example
𝐹 = { 𝑞4 } 𝑎,𝑏

𝑞5
𝑏
𝑎,𝑏
𝑎 𝑎 𝑏
𝑞0 𝑎 𝑞1 𝑏 𝑞 2 𝑏 𝑞 3 𝑎 𝑞4

10
Transition Function 𝛿: 𝑄 × Σ→ 𝑄


𝛿(𝑞 , 𝑥)=𝑞
𝑥 ′
𝑞 𝑞

Describes the result of a transition


from state 𝑞 with symbol 𝑥

11
Example:
𝛿 ( 𝑞0 , 𝑎 )=𝑞 1

𝑎,𝑏

𝑞5
𝑏 𝑎,𝑏
𝑎 𝑎 𝑏
𝑞0 𝑎 𝑞1 𝑏 𝑞 2 𝑏 𝑞 3 𝑎 𝑞4

12
𝛿 ( 𝑞0 , 𝑏 ) =𝑞5

𝑎,𝑏

𝑞5
𝑏 𝑎,𝑏
𝑎 𝑎 𝑏
𝑞0 𝑎 𝑞1 𝑏 𝑞 2 𝑏 𝑞 3 𝑎 𝑞4

13
𝛿 ( 𝑞2 , 𝑏 ) =𝑞3

𝑎,𝑏

𝑞5
𝑏 𝑎,𝑏
𝑎 𝑎 𝑏
𝑞0 𝑎 𝑞1 𝑏 𝑞 2 𝑏 𝑞 3 𝑎 𝑞4

14
Transition Table for 𝛿

symbols
𝛿 𝑎 𝑏
𝑞0 𝑞1 𝑞5
𝑞1 𝑞5 𝑞2
states

𝑞2 𝑞5 𝑞3
𝑎,𝑏
𝑞3 𝑞4 𝑞5
𝑞4 𝑞5 𝑞5
𝑞5
𝑞5 𝑞5 𝑞5 𝑎,𝑏
𝑏 𝑎 𝑎 𝑏
𝑞0 𝑎 𝑞1 𝑏 𝑞 2 𝑏 𝑞 3 𝑎 𝑞4
15
Extended Transition Function
∗ ∗
𝛿 :𝑄 × Σ → 𝑄

∗ ′
𝛿 (𝑞 ,𝑤)=𝑞

Describes the resulting state


after scanning string 𝑤 from state𝑞

16

Example: 𝛿 ( 𝑞 0 ,𝑎𝑏 ) =𝑞 2

𝑎,𝑏

𝑞5
𝑏 𝑎,𝑏
𝑎 𝑎 𝑏
𝑞0 𝑎 𝑞1 𝑏 𝑞 2 𝑏 𝑞 3 𝑎 𝑞4
17

𝛿 ( 𝑞 0 ,𝑎𝑏𝑏𝑏𝑎𝑎 ) =𝑞5

𝑎,𝑏

𝑞5
𝑏 𝑎,𝑏
𝑎 𝑎 𝑏
𝑞0 𝑎 𝑞1 𝑏 𝑞 2 𝑏 𝑞 3 𝑎 𝑞4

18

𝛿 ( 𝑞 1 , 𝑏𝑏𝑎 ) =𝑞 4

𝑎,𝑏

𝑞5
𝑏 𝑎,𝑏
𝑎 𝑎 𝑏
𝑞0 𝑎 𝑞1 𝑏 𝑞 2 𝑏 𝑞 3 𝑎 𝑞4

19
Special case:

for any state 𝑞


𝛿 ( 𝑞, 𝜆 ) =𝑞

20
∗ ′
In general: 𝛿 ( 𝑞, 𝑤 )=𝑞
implies that there is a walk of transitions

𝑤=𝜎 1 𝜎 2 ⋯ 𝜎 𝑘
𝜎1 𝜎2 𝜎𝑘

𝑞 𝑞
states may be repeated

𝑤 ′
𝑞 𝑞
21
Language Accepted by DFA
Language L accepted by DFA machine M
is denoted as 𝐿 ( 𝑀 ) and contains all the strings
accepted by
𝑀
We also say that 𝑀 recognizes𝐿 ( 𝑀 )
𝑀 =( 𝑄 , Σ , 𝛿 ,𝑞 0 , 𝐹 )

• A word w is a string of letters from alphabets () in a linear


sequence. eg. 0110 that is taken from .
• w denotes the length of word w.

22
For a DFA 𝑀 =( 𝑄 , Σ , 𝛿 ,𝑞 0 , 𝐹 )

𝑀
Language accepted by :

𝐿 ( 𝑀 ) = {𝑤 ∈ Σ : 𝛿 ( 𝑞 0 , 𝑤 ) ∈ 𝐹 }
∗ ∗

𝑤
𝑞0 ′
𝑞 ′
𝑞 ∈𝐹

23
Language rejected by𝑀 :

𝐿 ( 𝑀 ) = {𝑤 ∈ Σ : 𝛿 ( 𝑞 0 , 𝑤 ) ∉ 𝐹 }
∗ ∗

𝑤
𝑞0 𝑞
′ ′
𝑞 ∉𝐹

24
DFA Examples
Σ={𝑎, 𝑏}
𝑎,𝑏
𝑎,𝑏

𝑞0 𝑞0


𝐿(𝑀)={} 𝐿(𝑀)=Σ
Empty language All strings
25
Σ={𝑎, 𝑏}
𝐿 ( 𝑀=) { all strings with prefix 𝑎𝑏 }
𝑎,𝑏

𝑞0 𝑎 𝑞1 𝑏 𝑞2

𝑏 𝑎 accept

𝑞3 𝑎,𝑏

26
𝐿 ( 𝑀=
) { all binary strings containing
substring 001 }

1 0
0 ,1

𝜆 0 1
0 00 001

27
𝐿(𝑀)={ 𝑎𝑤𝑎:𝑤 ∈ { 𝑎 ,𝑏 } }

𝑎
𝑏

𝑞0 𝑎 𝑞2 𝑞3

𝑏 𝑎

𝑞4

𝑎,𝑏
28

You might also like