+ All Categories
Home > Engineering > Finite Automata

Finite Automata

Date post: 14-Apr-2017
Category:
Upload: shiraz316
View: 39 times
Download: 0 times
Share this document with a friend
25
1 Finite Automata What Are They? An Example: Scoring in Tennis Courtesy: Jeff Ullman
Transcript
Page 1: Finite Automata

Courtesy: Jeff Ullman 1

Finite Automata

What Are They?An Example: Scoring in Tennis

Page 2: Finite Automata

Courtesy: Jeff Ullman 2

What is a Finite Automaton?

A formal system. Remembers only a finite amount of

information. Information represented by its

state. State changes in response to

inputs. Rules that tell how the state

changes in response to inputs are called transitions.

Page 3: Finite Automata

Courtesy: Jeff Ullman 3

Informal Explanation Finite automata are finite

collections of states with transition rules that take you from one state to another.

Original application was sequential switching circuits, where the “state” was the settings of internal bits.

Today, several kinds of software can be modeled by FA.

Page 4: Finite Automata

Courtesy: Jeff Ullman 4

Representing FA Simplest representation is often a

graph. Nodes = states. Arcs indicate state transitions. Labels on arcs tell what causes the

transition.

Page 5: Finite Automata

Courtesy: Jeff Ullman 5

Tennis Like ping-pong, except you are

very tiny and stand on the table. Match = 3-5 sets. Set = 6 or more games.

Page 6: Finite Automata

Courtesy: Jeff Ullman 6

Scoring a Game One person serves throughout. To win, you must score at least 4

points. You also must win by at least 2

points. Inputs are s = “server wins point”

and o = “opponent wins point.”

Page 7: Finite Automata

Courtesy: Jeff Ullman 7

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

oAd-out

Ad-in

s

os

o

s

o

Page 8: Finite Automata

Courtesy: Jeff Ullman 8

Acceptance of Inputs Given a sequence of inputs (input

string ), start in the start state and follow the transition from each symbol in turn.

Input is accepted if you wind up in a final (accepting) state after all inputs have been read.

Page 9: Finite Automata

Courtesy: Jeff Ullman 9

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 10: Finite Automata

Courtesy: Jeff Ullman 10

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 11: Finite Automata

Courtesy: Jeff Ullman 11

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 12: Finite Automata

Courtesy: Jeff Ullman 12

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 13: Finite Automata

Courtesy: Jeff Ullman 13

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 14: Finite Automata

Courtesy: Jeff Ullman 14

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 15: Finite Automata

Courtesy: Jeff Ullman 15

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 16: Finite Automata

Courtesy: Jeff Ullman 16

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 17: Finite Automata

Courtesy: Jeff Ullman 17

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 18: Finite Automata

Courtesy: Jeff Ullman 18

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 19: Finite Automata

Courtesy: Jeff Ullman 19

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 20: Finite Automata

Courtesy: Jeff Ullman 20

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s

*

Page 21: Finite Automata

Courtesy: Jeff Ullman 21

Example: Processing a String

Love

Start

Love-15

15-Loves

o

Love-30

15-all

30-Love

s

s

o

o

Love-40

15-30

30-15

40-Love

s

s

s

o

o

o

ServerWins

Opp’ntWins

s

o

40-15

15-40

30-all

s

s

s

o

o

o

30-40

40-30

s

s

s

o

o

o

deuces

s

o

o Ad-out

Ad-in

s

o s

o

s

o

s o s o s o s o s o s s *

Page 22: Finite Automata

Courtesy: Jeff Ullman 22

Example: Recognizing Strings Ending in “ing”

nothing Saw ii

Not i

Saw ingg

i

Not i or g

Saw inn

i

Not i or n

Start

Page 23: Finite Automata

Courtesy: Jeff Ullman 23

Automata to Code In C/C++, make a piece of code

for each state. This code:1. Reads the next input.2. Decides on the next state.3. Jumps to the beginning of the code

for that state.

Page 24: Finite Automata

Courtesy: Jeff Ullman 24

Example: Automata to Code

2: /* i seen */c = getNextInput();if (c == ’n’) goto 3;else if (c == ’i’) goto 2;else goto 1;

3: /* ”in” seen */. . .

Page 25: Finite Automata

Courtesy: Jeff Ullman 25

Language of an Automaton

The set of strings accepted by an automaton A is the language of A.

Denoted L(A). Different sets of final states ->

different languages. Example: As designed, L(Tennis) =

strings that determine the winner.


Recommended