notes07 Converting DFAs to Regular Expressions

# notes07 Converting DFAs to Regular Expressions - CS 373...

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 373: Theory of Computation Gul Agha Mahesh Viswanathan Fall 2010 1 Regular Expressions and Regular Languages Why do they have such similar names? Theorem 1. L is a regular language if and only if there is a regular expression R such that L ( R ) = L i.e., Regular expressions have the same “expressive power” as finite automata. Proof. • Given regular expression R , can construct NFA N such that L ( N ) = L ( R ) • Given DFA M , will construct regular expression R such that L ( M ) = L ( R ) 1 Converting a DFA to an Equivalent Regular Expression DFA to Regular Expression • Given DFA M , will construct regular expression R such that L ( M ) = L ( R ). In two steps: – Construct a “Generalized NFA” (GNFA) G from the DFA M – And then convert G to a regex R 1.1 Generalized NFA Generalized NFA • A GNFA is similar to an NFA, but: – There is a single accept state. – The start state has no incoming transitions, and the accept state has no outgoing tran- sitions. * These are “cosmetic changes”: Any NFA can be converted to an equivalent NFA of this kind. – The transitions are labeled not by characters in the alphabet, but by regular expressions . * For every pair of states ( q 1 ,q 2 ), the transition from q 1 to q 2 is labeled by a regular expression ρ ( q 1 ,q 2 ). – “Generalized NFA” because a normal NFA has transitions labeled by , elements in Σ (a union of elements, if multiple edges between a pair of states) and ∅ (missing edges). Generalized NFA 2 • Transition: GNFA non-deterministically reads a block of characters from the input, chooses an edge from the current state q 1 to another state q 2 , and if the block of symbols matches the regex ρ ( q 1 ,q 2 ), then moves to q 2 . • Acceptance: G accepts w if there exists some sequence of valid transitions such that on starting from the start state, and after finishing the entire input, G is in the accept state. Generalized NFA: Example q q 1 q 2 * 10 * * * 10 * 10 * Figure 1: Example GNFA G Accepting run of G on 11110100 is q 1-→ G q 1 11-→ G q 1 101-→ G q 1 00-→ G q 2 Generalized NFA: Definition Definition 2. A generalized nondeterministic finite automaton (GNFA) is G = ( Q, Σ ,q ,q F ,ρ ), where • Q is the finite set of states • Σ is the finite alphabet • q...
View Full Document

{[ snackBarMessage ]}

### Page1 / 9

notes07 Converting DFAs to Regular Expressions - CS 373...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online