Finite Automata Part One Deterministic Finite Automata Terminology

  • Slides: 11
Download presentation
Finite Automata Part One : Deterministic Finite Automata

Finite Automata Part One : Deterministic Finite Automata

Terminology singular = automaton plural = automata Very Simple Computer: v v No external

Terminology singular = automaton plural = automata Very Simple Computer: v v No external memory Reads one character at a time Knows only its current state and the last character read Next state is the result of only the current state and the next character Big O = O (n)

Uses Ø lexical analysis Ø game systems Ø Io. T Ø Web and Mobile

Uses Ø lexical analysis Ø game systems Ø Io. T Ø Web and Mobile Apps Ø Network Communications, eg TCP Ø hardware components ØCannot do : Lots of things! Ø for example, sorting requires storing the entire list

Formal Definition A = ( Q, Σ, δ, s, F ) A Deterministic Finite

Formal Definition A = ( Q, Σ, δ, s, F ) A Deterministic Finite Automaton Q finite set of states Σ input alphabet δ transition function s ∈ Q initial state, exactly one F ⊆ Q set of favorable states

DFA Example 1 zero or more a's followed by one or more b's accepted:

DFA Example 1 zero or more a's followed by one or more b's accepted: aaabb ab bbb b rejected: abab ba a a b s b a q r a b text figure 2. 2

DFA Example 2 recognizes even number of a's and odd number of b's a

DFA Example 2 recognizes even number of a's and odd number of b's a s q b a b b b a t r a text figure 2. 7

DFA Example 3 Q: What does this DFA accept? A: all strings of a's

DFA Example 3 Q: What does this DFA accept? A: all strings of a's and b's with even number of b's a b q r b a

a DFA Example 3 continued b q Alternate Representation a b >q q r

a DFA Example 3 continued b q Alternate Representation a b >q q r r r q Ø How would we program this DFA? r b a

DFA Example 4 Q: What language does this accept? A: strings of 0 and

DFA Example 4 Q: What language does this accept? A: strings of 0 and 1 that does not contain 3 consecutive 1 s 0 q 0 1 0 0 r 1 s 1 t 1

Game Example Markov Chain Suppose we are programming a game and we want the

Game Example Markov Chain Suppose we are programming a game and we want the weather to change randomly. The changes need to be somewhat realistic. Rarely does the sky go straight from sunny to rainy. Clouds don't always lead to rain. etc. Every 30 seconds generate a random number from 1 to 10. 6 -9 1 -5 8 -10 Sunny Cloudy 6, 7 10 7, 8 9, 10 Raining 1 -6 1 -5

Exercise Design a car cruise control system. Input Alphabet = { on, off, too

Exercise Design a car cruise control system. Input Alphabet = { on, off, too slow, too fast, okay speed }