Part One : Deterministic Finite Automata
Terminology singular = automaton plural = automata Very Simple Computer: 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 IoT 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 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 s q r zero or more a's followed by one or more b's accepted: rejected: aaabb abab ab ba bbb a b a b a s q r b a b text figure 2.2
DFA Example 2 recognizes even number of a's and odd number of b's q b a a b s r t text figure 2.7
DFA Example 3 q r Q: What does this DFA accept? A: all strings of a's and b's with even number of b's q r a b
DFA Example 3 continued How would we program this DFA? q r a b Alternate Representation a b > q q r r r q How would we program this DFA?
DFA Example 4 q r s t Q: What language does this accept? A: strings of 0 and 1 that does not contain 3 consecutive 1s q r s t 1 1 1 1
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 Cloudy 1-5 8-10 Sunny 1-5 6,7 10 7,8 Raining 9,10 1-6
Exercise Design a car cruise control system. Input Alphabet = { on, off, too slow, too fast, okay speed }