1 / 12

Examples for Finite Automata

Learn about DFA, NFA, regular expressions, conversion techniques, and construction of DFAs for specific language patterns. Explore common prefix/suffix strings and practical examples with detailed explanations.

ellefson
Download Presentation

Examples for Finite Automata

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fall 2009 Examples for Finite Automata Xiao Linfu CSC3130 Tutorial One lfxiao@cse.cuhk.edu.hk Department of Computer Science & Engineering

  2. Outline • DFA example • NFA example • NFA to DFA conversion • Regular Expressions

  3. DFA • For every string x, there is a uniquepath from initial state and associated with x. • x is accepted if and only if this path ends at a accept state. x

  4. NFA • For any string x, there may exist none or morethan onepath from initial state and associated with x. • x is accepted if there is some path that ends at a accept state.

  5. 0,1 1 0 1 q0 q1 q2 q3 start 0 1 0 q4 0,1 Strings With Common Prefix • Construct a DFA that accepts a language L over  = {0, 1} such that L is the set of all strings starting with “101”. absorbing state dead state

  6. 0 0 0 1 q0 q1 q10 q101 start 1 0 1 1 Strings With Common Suffix • Construct a DFA that accepts a language L over  = {0, 1} such that L is the set of all strings ending with “101”.

  7. 1,0 1 0 1 start q0 0 q1 q2 q3 0 0 1 1 q0 q0q1 q0q2 q0q1q3 start 1 0 1 NFA for Common Suffix • We can have a simpler representation for common suffix language using NFA: • Use subset construction to convert it to a DFA. compare with previous DFA

  8. all all e a t start q0 q1 q2 q3 s y q4 s e a q5 q6 NFA Example • Construct NFAs for the following languages over the alphabet {a, b, …, z}: • All strings that contain eatorseaoreasy

  9. ‘f’ not ‘f’ ‘f’ ‘f’ ‘f’ ‘o’ ‘l’ start q0 q1 q2 q3 q2 ‘o’ not ‘f’,‘o’ not ‘f’,‘l’ not ‘f’,‘o’ NFA Example • Construct NFA for the language over the alphabet {a, b, …, z} such that every string doesn’t contain “fool”. deadstate

  10. Regular Expressions - Alphabet X = {a, b, c, d} • (a + b)* all strings containing only a and b • c(a + b + c)*c2 all strings containing only a, b, and c that begin with c and end with cc 3) all strings containing only one b (a+c+d)*b(a+c+d)*

  11. Regular Expressions - Alphabet X = {0, 1} • (0 + 1)* the set of all binary strings • 031*04 all strings consisting of three 0’s, followed by any number of 1’s, followed by four 0’s • 0*1001* all strings starting with any number of 0’s, followed by 100, followed by and number of 1’s

  12. Thank you!

More Related