Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cs466(Prasad)L14Equiv1 Equivalence of Regular Language Representations.

Similar presentations


Presentation on theme: "Cs466(Prasad)L14Equiv1 Equivalence of Regular Language Representations."— Presentation transcript:

1 cs466(Prasad)L14Equiv1 Equivalence of Regular Language Representations

2 cs466(Prasad)L14Equiv2 Grand Unification Regular Languages: Grand Unification (Parallel Simulation) (Rabin and Scott’s work) (Collapsing graphs; Structural Induction) (S. Kleene’s work) (Construction) (Solving linear equations)

3 cs466(Prasad)L14Equiv3 Role of various representations for Regular Languages Closure under complemention. (DFAs) Closure under union, concatenation, and Kleene star. (NFA- s, Regular expression.) Consequence: Closure under intersection by De Morgan’s Laws. Relationship to context-free languages. (Regular Grammars.) Ease of specification. (Regular expression.) Building tokenizers/lexical analyzers. (DFAs)

4 cs466(Prasad)L14Equiv4 Application to Scanner (Lexer, Tokenizer) High-level view Regular expressions NFA DFA Lexical Specification Table-driven Implementation of a minimal DFA

5 cs466(Prasad)L14Equiv5 M(a) Construction of Finite Automata from Regular Expressions Show that there are FA for basis elements and there exist constructions on FA for capturing union, concatenation, and Kleene star operations. Basis Case

6 cs466(Prasad)L14Equiv6 Constructions on NFA- s M(R1) M(R2) M M(R1 U R2) M M(R1 R2) M M(R*) M(R2) M(R)

7 cs466(Prasad)L14Equiv7 Construction of Regular Expression from Finite Automaton Expression Graph is a labeled directed graph in which the arcs are labeled by regular expressions. An expression graph, like a state diagram, contains a distinguished start node and a set of accepting nodes.

8 cs466(Prasad)L14Equiv8 Examples ab L(M) = (ab)*

9 cs466(Prasad)L14Equiv9 Examples ba L(M) = (b+ a)* (a u b) (ba)* b+ a a u b

10 cs466(Prasad)L14Equiv10 Examples bb L(M) = (b a)* b*( bb u (a+(ba)*b*) )* ba b*b* a+a+

11 cs466(Prasad)L14Equiv11 Main Idea To associate an RE with an FA, –reduce an arbitrary expression graph to one containing at most two nodes, –by repeatedly removing nodes from the graph and relabeling the arcs to preserve the language. Without loss of generality, we can assume one accepting state (because of the presence of the union operation).

12 cs466(Prasad)L14Equiv12 Example qj qk qj qi qk Wj,i Wj,i Wi,k Wi,k

13 cs466(Prasad)L14Equiv13 qj qk qj qi qk Wj,i Wj,i (Wi,i)* Wi,k Wi,k Wi,i

14 cs466(Prasad)L14Equiv14 Final Graph : Alternative 1 u L(M) = (u)*

15 cs466(Prasad)L14Equiv15 Final Graph : Alternative 2 w L(M) = (u)* v( w u (x (u)* v) )* u v x

16 cs466(Prasad)L14Equiv16 Detailed Example b a b a a b b q0 q1q2q3

17 cs466(Prasad)L14Equiv17 Delete node q1 b a b a a b b q0 q1q2q3bb ab

18 cs466(Prasad)L14Equiv18 Delete node q2 b a a b u bb q0 q2q3 ab ab*ab

19 cs466(Prasad)L14Equiv19 Finally a b u bb q0 q3 ab*ab (ab*ab)*a ((bubb) (ab*ab)*a)*

20 cs466(Prasad)L14Equiv20 For precise details, see Algorithm 6.2.2 on Page 194 in Sudkamp’s Languages and Machines, 3 rd Edition.

21 cs466(Prasad)L14Equiv21 From Regular Expression to NFA to DFA to Regular Grammars Via Examples

22 cs466(Prasad)L14Equiv22 Exercise Construct a DFA for a+b+ q0 b q1q2 a a b

23 cs466(Prasad)L14Equiv23 Equivalent DFA {q0} {q1,q2} {q0,q1} {} a a a a,b b b b

24 cs466(Prasad)L14Equiv24 Two Equivalent (Right-linear) Regular Grammars -> a | a -> b | b -> λ -> a -> a | b -> λ | b All productions involving can be deleted, as does not derive any terminal strings.

25 cs466(Prasad)L14Equiv25 Two Equivalent (Left-linear) Regular Grammars -> λ | a -> b | a -> b -> λ -> a | a -> | b

26 cs466(Prasad)L14Equiv26 From Grammars to Finite Automata S -> aA | c A -> bB | bA B -> λ S -> aA | cF A -> bB | bA B -> λ F -> λ S A B F a b b c

27 cs466(Prasad)L14Equiv27 From Grammars to Finite Automata S -> aA | c A -> bB | bA B -> λ S -> λ A -> Sa | Ab B -> Ab F -> Sc Z Z -> B | F S A B F a b b c


Download ppt "Cs466(Prasad)L14Equiv1 Equivalence of Regular Language Representations."

Similar presentations


Ads by Google