+ All Categories
Home > Engineering > Deterministic Finite Automata

Deterministic Finite Automata

Date post: 11-Apr-2017
Category:
Upload: shiraz316
View: 66 times
Download: 0 times
Share this document with a friend
57
Costas Busch - LSU 1 Deterministic Finite Automata And Regular Languages
Transcript
Page 1: Deterministic Finite Automata

Costas Busch - LSU 1

Deterministic Finite Automata

And Regular Languages

Page 2: Deterministic Finite Automata

Costas Busch - LSU 2

Deterministic Finite Automaton (DFA)

Input Tape

“Accept” or“Reject”

String

FiniteAutomaton

Output

Page 3: Deterministic Finite Automata

Costas Busch - LSU 3

Transition Graph

initialstate

accepting state

statetransition

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

Page 4: Deterministic Finite Automata

Costas Busch - LSU 4

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

},{ ba

For every state, there is a transitionfor every symbol in the alphabet

Alphabet

Page 5: Deterministic Finite Automata

Costas Busch - LSU 5

Initial Configuration

1q 2q 3q 4qa b b a

5q

a a bb

ba,Input Stringa b b a

ba,0q

Initial state

Input Tapehead

Page 6: Deterministic Finite Automata

Costas Busch - LSU 6

Scanning the Input

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b b a

ba,

Page 7: Deterministic Finite Automata

Costas Busch - LSU 7

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b b a

ba,

Page 8: Deterministic Finite Automata

Costas Busch - LSU 8

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b b a

ba,

Page 9: Deterministic Finite Automata

Costas Busch - LSU 9

0q 1q 2q 3q 4qa b b a accept

5q

a a bb

ba,

a b b a

ba,

Input finished

Last state determines the outcome

Page 10: Deterministic Finite Automata

Costas Busch - LSU 10

1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b a

ba,0q

A Rejection Case

Input String

Page 11: Deterministic Finite Automata

Costas Busch - LSU 11

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b a

ba,

Page 12: Deterministic Finite Automata

Costas Busch - LSU 12

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

a b a

ba,

Page 13: Deterministic Finite Automata

Costas Busch - LSU 13

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

reject

a b a

ba,

Input finished

Last state determines the outcome

Page 14: Deterministic Finite Automata

Costas Busch - LSU 14

1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,0q

)(

Another Rejection CaseTape is empty

reject

Input Finished (no symbol read)

Page 15: Deterministic Finite Automata

Costas Busch - LSU 15

Language Accepted: abbaL

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

This automaton accepts only one string

Page 16: Deterministic Finite Automata

Costas 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

Page 17: Deterministic Finite Automata

Costas Busch - LSU 17

Another Example

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

abbaabL ,,

Acceptstate

Acceptstate

Acceptstate

Page 18: Deterministic Finite Automata

Costas Busch - LSU 18

)(Empty Tape

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

accept

Input Finished

Page 19: Deterministic Finite Automata

Costas Busch - LSU 19

Another Example

a

b ba,

ba,

0q 1q 2q

Accept state

trap state

Page 20: Deterministic Finite Automata

Costas Busch - LSU 20

a

b ba,

ba,

0q 1q 2q

a ba

Input String

Page 21: Deterministic Finite Automata

Costas Busch - LSU 21

a

b ba,

ba,

0q 1q 2q

a ba

Page 22: Deterministic Finite Automata

Costas Busch - LSU 22

a

b ba,

ba,

0q 1q 2q

a ba

Page 23: Deterministic Finite Automata

Costas Busch - LSU 23

a

b ba,

ba,

0q 1q 2q

a ba

accept

Input finished

Page 24: Deterministic Finite Automata

Costas Busch - LSU 24

a

b ba,

ba,

0q 1q 2q

ab b

A rejection case

Input String

Page 25: Deterministic Finite Automata

Costas Busch - LSU 25

a

b ba,

ba,

0q 1q 2q

ab b

Page 26: Deterministic Finite Automata

Costas Busch - LSU 26

a

b ba,

ba,

0q 1q 2q

ab b

Page 27: Deterministic Finite Automata

Costas Busch - LSU 27

a

b ba,

ba,

0q 1q 2q

ab b

reject

Input finished

Page 28: Deterministic Finite Automata

Costas Busch - LSU 28

Language Accepted: }0:{ nbaL n

a

b ba,

ba,

0q 1q 2q

Page 29: Deterministic Finite Automata

Costas Busch - LSU 29

Another Example

0q 1q

1

1

}1{Alphabet:

Language Accepted:even} is and :{ * xxxEVEN

},111111,1111,11,{

Page 30: Deterministic Finite Automata

Costas Busch - LSU 30

Formal Definition Deterministic Finite Automaton (DFA)

FqQM ,,,, 0

Q

0q

F

: set of states: input alphabet: transition function: initial state: set of accepting states

Page 31: Deterministic Finite Automata

Costas Busch - LSU 31

Set of States

Q

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba, 543210 ,,,,, qqqqqqQ

ba,

Example

Page 32: Deterministic Finite Automata

Costas Busch - LSU 32

Input Alphabet

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba, ba,

ba,

:the input alphabet never contains

Example

Page 33: Deterministic Finite Automata

Costas Busch - LSU 33

Initial State

0q

1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,0q

Example

Page 34: Deterministic Finite Automata

Costas Busch - LSU 34

Set of Accepting States

QF

0q 1q 2q 3qa b b a

5q

a a bb

ba, 4qF

ba,

4q

Example

Page 35: Deterministic Finite Automata

Costas Busch - LSU 35

Transition Function

QQ :

q qx

qxq ),(

Describes the result of a transitionfrom state with symbolq x

Page 36: Deterministic Finite Automata

Costas Busch - LSU 36

2q 3q 4qa b b a

5q

a a bb

ba,

ba,0q 1q

10 , qaq Example:

Page 37: Deterministic Finite Automata

Costas Busch - LSU 37

50 , qbq

1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,0q

Page 38: Deterministic Finite Automata

Costas Busch - LSU 38

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

32 , qbq

Page 39: Deterministic Finite Automata

Costas Busch - LSU 39

a b

0q

1q

2q

3q

4q

5q

1q 5q

5q 2q5q 3q

4q 5q

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,5q5q5q5q

Transition Table for st

ates

symbols

Page 40: Deterministic Finite Automata

Costas Busch - LSU 40

Extended Transition Function QQ ** :

qwq ),(*

Describes the resulting state after scanning string from statew q

Page 41: Deterministic Finite Automata

Costas Busch - LSU 41

20

* , qabq

3q 4qa b b a

5q

a a bb

ba,

ba,0q 1q 2q

Example:

Page 42: Deterministic Finite Automata

Costas Busch - LSU 42

50* , qabbbaaq

1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,0q

Page 43: Deterministic Finite Automata

Costas Busch - LSU 43

41* , qbbaq

0q 1q 2q 3q 4qa b b a

5q

a a bb

ba,

ba,

Page 44: Deterministic Finite Automata

Costas Busch - LSU 44

Special case:

qq ,*

for any state q

Page 45: Deterministic Finite Automata

Costas Busch - LSU 45

qwq ,*

q qw

q qkw 21

1 2 k

states may be repeated

In general:

implies that there is a walk of transitions

Page 46: Deterministic Finite Automata

Costas Busch - LSU 46

Language accepted by DFA :

Language Accepted by DFA

it is denoted as and containsall the strings accepted by

MLM

M

MLWe also say that recognizesM

Page 47: Deterministic Finite Automata

Costas Busch - LSU 47

For a DFA

Language accepted by :

FqQM ,,,, 0

M FwqwML ,: 0

**

0q qw Fq

Page 48: Deterministic Finite Automata

Costas Busch - LSU 48

Language rejected by :

FwqwML ,: 0**

M

0q qw Fq

Page 49: Deterministic Finite Automata

Costas Busch - LSU 49

0q

More DFA Examples

ba,},{ ba

*)( ML

0q

ba,

}{)( MLEmpty language All strings

Page 50: Deterministic Finite Automata

Costas Busch - LSU 50

1q

ba,

},{ ba

0q ba,

}{)( MLLanguage of the empty string

Page 51: Deterministic Finite Automata

Costas Busch - LSU 51

ML = { all strings with prefix }ab

a b

ba,

0q 1q 2q

accept

ba,3q

ab

},{ ba

Page 52: Deterministic Finite Automata

Costas Busch - LSU 52

ML = { all binary strings containing substring }001

0 00 001

1

0

110

0 1,0

Page 53: Deterministic Finite Automata

Costas Busch - LSU 53

ML = { all binary strings without substring }001

0 00 001

1

0

110

0 1,0

Page 54: Deterministic Finite Automata

Costas Busch - LSU 54

*,:)( bawawaML

a

b

ba,

a

b

ba

0q 2q 3q

1q

Page 55: Deterministic Finite Automata

Costas Busch - LSU 55

Regular LanguagesDefinition:A language is regular if there is a DFA that accepts it ( )

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

LM LML )(

Page 56: Deterministic Finite Automata

Costas Busch - LSU 56

abba abbaab,,}0:{ nban

{ all strings in {a,b}* with prefix }ab{ all binary strings without substring }001

Example regular languages:

There exist DFAs that accept theselanguages (see previous slides).

*,: bawawa

even} is and }1{:{ * xxx

}{ }{ *},{ ba

Page 57: Deterministic Finite Automata

Costas Busch - LSU 57

There exist languages which are not Regular:

}0:{ nbaL nn

There are no DFAs that accept these languages

(we will prove this in a later class)

}n ,1z,1y,1x :{ mn

kmzyxADDITION k


Recommended