570 likes | 755 Views
Single Final State for NFA. Any NFA can be converted to an equivalent NFA with a single final state. Example. NFA. Equivalent NFA. In General. NFA. Equivalent NFA. Single final state. Add a final state Without transitions. Extreme Case. NFA without final state.
E N D
Single Final State for NFA COMP 335
Any NFA can be converted • to an equivalent NFA • with a single final state COMP 335
Example NFA Equivalent NFA COMP 335
In General NFA Equivalent NFA Single final state COMP 335
Add a final state Without transitions Extreme Case NFA without final state COMP 335
Properties of Regular Languages COMP 335
Union: Concatenation: Are regular Languages For regular languages and we will prove that: Star: Reversal: Complement: Intersection: COMP 335
Union: Concatenation: We say: Regular languages are closed under Star: Reversal: Complement: Intersection: COMP 335
Regular language Regular language NFA NFA Single final state Single final state COMP 335
Example COMP 335
Union • NFA for COMP 335
Example NFA for COMP 335
Concatenation • NFA for COMP 335
Example • NFA for COMP 335
Star Operation • NFA for COMP 335
Example • NFA for COMP 335
Reverse NFA for 1. Reverse all transitions 2. Make initial state final state and vice versa COMP 335
Example COMP 335
Complement 1. Take the DFA that accepts 2. Make final states non-final, and vice-versa COMP 335
Example COMP 335
regular regular regular regular regular Intersection DeMorgan’s Law: COMP 335
Example regular regular regular COMP 335
Regular Expressions COMP 335
Regular Expressions • Regular expressions • describe regular languages • Example: • describes the language COMP 335
Given regular expressions and Are regular expressions Recursive Definition Primitive regular expressions: COMP 335
Not a regular expression: Examples A regular expression: COMP 335
Languages of Regular Expressions • : language of regular expression • Example: COMP 335
Definition • For primitive regular expressions : COMP 335
Definition (continued) • For regular expressions and COMP 335
Example • Regular expression: COMP 335
Example • Regular expression COMP 335
Example • Regular expression COMP 335
= {all strings with at least two consecutive 0} Example • Regular expression COMP 335
= { all strings without two consecutive 0 } Example • Regular expression COMP 335
Equivalent Regular Expressions • Definition: • Regular expressions and • are equivalent if COMP 335
and are equivalent Reg. expressions Example = { all strings without two consecutive 0 } COMP 335
Theorem Languages Generated by Regular Expressions Regular Languages COMP 335
1. For any regular expression the language is regular Theorem - Part 1 Languages Generated by Regular Expressions Regular Languages COMP 335
2. For any regular language , there is a regular expression with Theorem - Part 2 Languages Generated by Regular Expressions Regular Languages COMP 335
1. For any regular expression the language is regular Proof by induction on the size of Proof - Part 1 COMP 335
NFAs regular languages Induction Basis • Primitive Regular Expressions: COMP 335
Inductive Hypothesis • Assume for regular expressions and • that and are regular languages COMP 335
Inductive Step • We will prove: are regular Languages. COMP 335
We also know: Regular languages are closed under: Union Concatenation Star By inductive hypothesis we know: and are regular languages COMP 335
Therefore: Are regular languages COMP 335
And trivially: is a regular language COMP 335
Proof – Part 2 2. For any regular language there is a regular expression with Proof by construction of regular expression COMP 335
Since is regular, take an • NFA that accepts it Single final state COMP 335