0% found this document useful (0 votes)
19 views57 pages

Deterministic: Finite Automata

This document discusses deterministic finite automata (DFAs) and regular languages. It contains the following key points in 3 sentences: A DFA is defined by a finite set of states, input alphabet, transition function, initial state, and set of accepting states. It scans an input string according to the transition function and accepts or rejects the string based on whether the final state is accepting. The languages accepted by DFAs are called regular languages, which have certain properties that allow them to be recognized by finite state machines.

Uploaded by

sat258
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views57 pages

Deterministic: Finite Automata

This document discusses deterministic finite automata (DFAs) and regular languages. It contains the following key points in 3 sentences: A DFA is defined by a finite set of states, input alphabet, transition function, initial state, and set of accepting states. It scans an input string according to the transition function and accepts or rejects the string based on whether the final state is accepting. The languages accepted by DFAs are called regular languages, which have certain properties that allow them to be recognized by finite state machines.

Uploaded by

sat258
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 57

Prof.

Busch - LSU 1
Deterministic
Finite Automata

And Regular Languages
Prof. Busch - LSU 2
Deterministic Finite Automaton (DFA)

Input Tape
Accept
or
Reject
String
Finite
Automaton
Output
Prof. Busch - LSU 3
Transition Graph

initial
state
accepting
state
state
transition
0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
Prof. Busch - LSU 4

0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
} , { b a = E
For every state, there is a transition
for every symbol in the alphabet
Alphabet
Prof. Busch - LSU 5
Initial Configuration

1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
Input String
a
b b
a
b a,
0
q
Initial state
Input Tape
head
Prof. Busch - LSU 6
Scanning the Input

0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
a
b b
a
b a,
Prof. Busch - LSU 7

0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
a
b b
a
b a,
Prof. Busch - LSU 8

0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
a
b b
a
b a,
Prof. Busch - LSU 9
0
q
1
q
2
q
3
q
4
q
a
b b
a
accept
5
q
a
a
b
b
b a,
a
b b
a
b a,
Input finished
Last state determines the outcome
Prof. Busch - LSU 10

1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
a
b
a
b a,
0
q
A Rejection Case
Input String
Prof. Busch - LSU 11

0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
a
b
a
b a,
Prof. Busch - LSU 12

0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
a
b
a
b a,
Prof. Busch - LSU 13
0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
reject
a
b
a
b a,
Input finished
Last state determines the outcome
Prof. Busch - LSU 14

1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
0
q
) (
Another Rejection Case
Tape is empty
reject
Input Finished (no symbol read)
Prof. Busch - LSU 15
Language Accepted: { } abba L =
0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
This automaton accepts only one string
Prof. Busch - LSU 16
To accept a string:
all the input string is scanned
and the last state is accepting
To reject a string:
all the input string is scanned
and the last state is non-accepting
Prof. Busch - LSU 17
Another Example
0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
{ } abba ab L , , =
Accept
state
Accept
state
Accept
state

Prof. Busch - LSU 18
) (
Empty Tape
0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
accept
Input Finished
Prof. Busch - LSU 19
Another Example
a
b
b a,
b a,
0
q
1
q
2
q
Accept
state
trap state
Prof. Busch - LSU 20
a
b
b a,
b a,
0
q
1
q
2
q
a
b
a
Input String
Prof. Busch - LSU 21
a
b
b a,
b a,
0
q
1
q
2
q
a
b
a
Prof. Busch - LSU 22
a
b
b a,
b a,
0
q
1
q
2
q
a
b
a
Prof. Busch - LSU 23
a
b
b a,
b a,
0
q
1
q
2
q
a
b
a
accept
Input finished
Prof. Busch - LSU 24
a
b
b a,
b a,
0
q
1
q
2
q
a
b b
A rejection case
Input String
Prof. Busch - LSU 25
a
b
b a,
b a,
0
q
1
q
2
q
a
b b
Prof. Busch - LSU 26
a
b
b a,
b a,
0
q
1
q
2
q
a
b b
Prof. Busch - LSU 27
a
b
b a,
b a,
0
q
1
q
2
q
a
b b
reject
Input finished
Prof. Busch - LSU 28
Language Accepted:
} 0 : { > = n b a L
n
a
b
b a,
b a,
0
q
1
q
2
q
Prof. Busch - LSU 29
Another Example
0
q
1
q
1
1
} 1 { = E
Alphabet:
Language Accepted:
even} is and : {
*
x x x EVEN E e =
} , 111111 , 1111 , 11 , { =
Prof. Busch - LSU 30
Formal Definition
Deterministic Finite Automaton (DFA)
( ) F q Q M , , , ,
0
o E =
Q
E
o
0
q
F
: set of states
: input alphabet
: transition function
: initial state
: set of accepting states
E e
Prof. Busch - LSU 31
Set of States

Q
0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
{ }
5 4 3 2 1 0
, , , , , q q q q q q Q=
b a,
Example
Prof. Busch - LSU 32
Input Alphabet

E
0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
{ } b a, = E
b a,
:the input alphabet never contains
E e
Example
Prof. Busch - LSU 33
Initial State

0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
0
q
Example
Prof. Busch - LSU 34
Set of Accepting States

Q F _
0
q
1
q
2
q
3
q
a
b b
a
5
q
a
a
b
b
b a,
{ }
4
q F =
b a,
4
q
Example
Prof. Busch - LSU 35
Transition Function

Q Q E : o
q
q
'
x
q x q
'
= ) , ( o
Describes the result of a transition
from state with symbol
q x
Prof. Busch - LSU 36

2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
0
q
1
q
( )
1 0
, q a q = o
Example:
Prof. Busch - LSU 37

( )
5 0
, q b q = o
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
0
q
Prof. Busch - LSU 38
0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
( )
3 2
, q b q = o
Prof. Busch - LSU 39

o
a
b
0
q
1
q
2
q
3
q
4
q
5
q
1
q
5
q
5
q
2
q
5
q
3
q
4
q
5
q
0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
5
q
5
q
5
q
5
q
Transition Table for
s
t
a
t
e
s

symbols
o
Prof. Busch - LSU 40
Extended Transition Function

Q Q E
* *
: o
q w q
'
= ) , (
*
o
Describes the resulting state
after scanning string from state
w
q
Prof. Busch - LSU 41

( )
2 0
*
, q ab q = o
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
0
q
1
q
2
q
Example:
Prof. Busch - LSU 42
( )
5 0
*
, q abbbaa q = o
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
0
q
Prof. Busch - LSU 43
( )
4 1
*
, q bba q = o
0
q
1
q
2
q
3
q
4
q
a
b b
a
5
q
a
a
b
b
b a,
b a,
Prof. Busch - LSU 44
Special case:
( ) q q = o ,
*
for any state
q
Prof. Busch - LSU 45
( ) q w q
'
= ,
*
o
q
q
'
w
q
q
'
k
w o o o
2 1
=
1
o
2
o
k
o
states may be repeated
In general:
implies that there is a walk of transitions
Prof. Busch - LSU 46
Language accepted by DFA :
Language Accepted by DFA
it is denoted as and contains
all the strings accepted by
( ) M L
M
M
( ) M L We also say that recognizes
M
Prof. Busch - LSU 47

For a DFA

Language accepted by :



( ) F q Q M , , , ,
0
o E =
M
( ) ( ) { } F w q w M L e E e = , :
0
* *
o
0
q q
'
w
F q e
'
Prof. Busch - LSU 48
Language rejected by :
( ) ( ) { } F w q w M L e E e = , :
0
* *
o
M
0
q q
'
w
F q e
'
Prof. Busch - LSU 49
0
q
More DFA Examples
b a,
} , { b a = E
*
) ( E = M L
0
q
b a,
} { ) ( = M L
Empty language All strings
Prof. Busch - LSU 50
0
q
b a,
} , { b a = E
0
q
b a,
} { ) ( = M L
Language of the empty string
Prof. Busch - LSU 51

( ) M L = { all strings with prefix }
ab
a
b
b a,
0
q
1
q
2
q
accept
b a,
3
q
a
b
} , { b a = E
Prof. Busch - LSU 52

( ) M L
= { all binary strings containing
substring } 001

0 00 001
1
0
1
1 0
0
1 , 0
Prof. Busch - LSU 53

( ) M L
= { all binary strings without
substring } 001

0 00 001
1
0
1
1 0
0
1 , 0
Prof. Busch - LSU 54


{ } { }
*
, : ) ( b a w awa M L e =
a
b
b a,
a
b
b
a
0
q
2
q
3
q
4
q
Prof. Busch - LSU 55
Regular Languages
Definition:
A language is regular if there is
a DFA that accepts it ( )



The languages accepted by all DFAs
form the family of regular languages

L
M
L M L = ) (
Prof. Busch - LSU 56
{ } abba { } abba ab, ,
} 0 : { > n b a
n
{ all strings in {a,b}* with prefix }
ab
{ all binary strings without substring } 001
Example regular languages:
There exist DFAs that accept these
languages (see previous slides).
{ } { }
*
, : b a w awa e
even} is and } 1 { : {
*
x x x e
} {
} {
*
} , { b a
Prof. Busch - LSU 57
There exist languages which are not Regular:
} 0 : { > = n b a L
n n
There are no DFAs that accept these languages
(we will prove this in a later class)
} n
, 1 z , 1 y , 1 x : {
m n
k m
z y x ADDITION
k
= +
= = = = + =

You might also like