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