Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Finite Automata

Finite Automata

  • Be the first to comment

Finite Automata

  1. 1. Finite Automata Mukesh N. Tekwani Elphinstone College Mumbai, India 2006 Finite Automata Finite Automata
  2. 2. Nondeterministic Finite Automata A nondeterministic finite automata (NFA) is collection of 5 things or 5 tuple: A set of states S. A set of input symbols ∑ (alphabet) A transition function δ that maps state-symbol pairs to sets of states. A state S 0 (sometimes denoted by Q 0 ) called as the start state or initial state . A set of states F called as the accepting states or final states . An accepting state is denoted by a double circle.
  3. 3. <ul><li>Test if a string matches some pattern. </li></ul><ul><li>Scan for virus signatures. </li></ul><ul><li>Process natural language. </li></ul><ul><li>Search for information using Google. </li></ul><ul><li>Search for markers in human genome. </li></ul><ul><li>Access information in digital libraries. </li></ul><ul><li>Search-and-replace in a word processors. </li></ul><ul><li>Filter text (spam, NetNanny). </li></ul><ul><li>Validate data-entry fields (dates, email, URL, credit card). </li></ul>Why study regular expression and DFA?
  4. 4. Deterministic Finite Automata <ul><li>Theoreticians have developed a number of theoretical models to describe &quot;computing&quot; </li></ul><ul><li>Simplest model is known as a DFA </li></ul><ul><li>Deterministic : Machine will be in a state. Upon receipt of a certain symbol, it will go to a known state </li></ul><ul><li>Finite : The machines only have a certain number of states </li></ul><ul><li>Automata : Machine, robot </li></ul>
  5. 5. DFA's <ul><li>DFA's recognize strings. </li></ul><ul><li>If the input ends and the DFA is in an accept state then the string is &quot;recognized&quot; </li></ul><ul><li>A &quot;language&quot; can be described as a set of strings </li></ul><ul><li>A language is called a regular language if some finite automaton recognizes it. </li></ul><ul><li>There is a precise mathematical definition of exactly what is meant by a finite automaton </li></ul>
  6. 6. Parts of a DFA 1 0 1 1 0 accept state transition start state The alphabet for this example is {0, 1}. Each state has a transition for every symbol in the alphabet 2
  7. 7. DFA Examples Example. 1 Accept all strings that end in a 1 q 0 q 1 0 1 1 0 Start
  8. 8. DFA Examples Strings with an odd number of ones. Even Odd 0 0 1 1 Start
  9. 9. DFA Examples Strings containing the substring 001 '001' 0 0 1 1 '0' '00' 0 1 0,1
  10. 10. Finite State Machine (DFA) 0 1 2 3 4 start h e 5 6 8 9 7 ACCEPTED State Machine that recognizes the strings “ he”, “hers”, “his”, and “she”
  11. 11. Finite State Machine (DFA) State Machine that recognizes the strings “ he”, “hers”, “his”, and “she” 0 1 2 3 4 start h e 5 6 8 9 7 ACCEPTED r s
  12. 12. Finite State Machine (DFA) 0 1 2 3 4 start h 5 6 8 9 7 ACCEPTED i s State Machine that recognizes the strings “ he”, “hers”, “his”, and “she”
  13. 13. Finite State Machine (DFA) 0 1 2 3 4 start 5 6 8 9 7 ACCEPTED s h e State Machine that recognizes the strings “ he”, “hers”, “his”, and “she”
  14. 14. Finite State Machine (DFA) 0 1 3 2 start 4 A DFA that recognizes the strings “ and”, & “any” a n d ACCEPTED y
  15. 15. Finite State Machine (DFA) 0 1 3 2 start 4 A DFA that recognizes the strings “ and”, & “any” a n ACCEPTED
  16. 16. Nondeterministic Finite Automata 0 start A NFA that recognizes the strings “and”, & “any” n 1 2 3 4 5 6 d n y a a
  17. 17. Examples <ul><li>Design a DFA to recognize strings that start out with k zeros followed by k ones. </li></ul><ul><li>Design a DFA to recognize strings with an equal number of ones and zeros. </li></ul><ul><li>Design a DFA to recognize strings with an equal number of strings &quot;01&quot; and &quot;10&quot;. Impossible? </li></ul><ul><ul><li>1 yes </li></ul></ul><ul><ul><li>2 No </li></ul></ul>
  18. 18. Actually the third one is regular! DFA to recognize strings with an equal number of strings &quot;01&quot; and &quot;10&quot; 0 0 0 0 0 1 1 1 1 1 1 0 1 0

×