500 likes | 583 Views
Finite Automata. Irum Feroz Irum.feroz@superior.edu.pk. Why FAs ?. • Recognition Is string x in language L?. Deterministic Finite Automaton (DFA). Input Tape. String. Output. “Accept” or “Reject”. Finite Automaton. 11. 1. 0. 0,1. 1. 0111. 111. 1. 0. 0. 1.
E N D
Finite Automata Irum Feroz Irum.feroz@superior.edu.pk
Why FAs ? • • Recognition • Is string x in language L?
Deterministic Finite Automaton (DFA) Input Tape String Output “Accept” or “Reject” Finite Automaton
11 1 0 0,1 1 0111 111 1 0 0 1 The machine accepts a string if the process ends in a double circle Steven Rudich: www.cs.cmu.edu/~rudich rudich0123456789
1 0 0,1 accept states (F) states 1 0 0 1 states Anatomy of a Deterministic Finite Automaton q1 q0 q2 The machine accepts a string if the process ends in a double circle start state (q0) q3 Steven Rudich: www.cs.cmu.edu/~rudich rudich0123456789
1 0 0,1 1 q1 0 0 1 q0 q2 q3 Anatomy of a Deterministic Finite Automaton The alphabet of a finite automaton is the set where the symbols come from: {0,1} The language of a finite automaton is the set of strings that it accepts Steven Rudich: www.cs.cmu.edu/~rudich rudich0123456789
0,1 q0 All strings of 0s and 1s L(M) = The Language of Machine M Steven Rudich: www.cs.cmu.edu/~rudich rudich0123456789
Transition Graph initial state accepting state transition state Costas Busch - RPI
Alphabet For every state, there is a transition for every symbol in the alphabet
Initial Configuration head Input Tape Input String Initial state Costas Busch - RPI
Scanning the Input Costas Busch - RPI
Input finished accept Costas Busch - RPI
A Rejection Case Input String Costas Busch - RPI
Input finished reject Costas Busch - RPI
Another Rejection Case Tape is empty Input Finished reject Costas Busch - RPI
Language Accepted: Costas Busch - RPI
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 Costas Busch - RPI
Another Example Accept state Accept state Accept state Costas Busch - RPI
Empty Tape Input Finished accept Costas Busch - RPI
Another Example trap state Accept state Costas Busch - RPI
Input String Costas Busch - RPI
Input finished accept Costas Busch - RPI
A rejection case Input String Costas Busch - RPI
Input finished reject
Another Example Alphabet: Language Accepted:
Transition Table for symbols states
Identify following DFA?? 0 0 0 1 1 1 1 0 00(0+1)*
(0+1)*00(0+1)* 1 0 0 0 1 1
(0+1)*00 0 1 0 0 1 1
(0+1)*(00+01) 0 1 0 0 1 1 0 1
Exercise • ab(a+b)* • a(a+b)* • (a+b)*a • (a+b)*aa (a+b)* • Exactly two strings baa and ab • (a+b)*(aa+bb) (a+b)* • (a+b) (a+b)b(a+b)* • all words containing aaa or bbb • (a*ba*ba*ba*)*
ab(a+b)* accept