Single Final State for NFAs and DFAs 1

  • Slides: 50
Download presentation
Single Final State for NFAs and DFAs 1

Single Final State for NFAs and DFAs 1

Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA

Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state 2

Example NFA Equivalent NFA 3

Example NFA Equivalent NFA 3

NFA In General Equivalent NFA Single final state 4

NFA In General Equivalent NFA Single final state 4

Extreme Case NFA without final state Add a final state Without transitions 5

Extreme Case NFA without final state Add a final state Without transitions 5

Some Properties of Regular Languages 6

Some Properties of Regular Languages 6

Properties For regular languages we will prove that: and Union: Concatenation: Are regular Languages

Properties For regular languages we will prove that: and Union: Concatenation: Are regular Languages Star: 7

We Say: Regular languages are closed under Union: Concatenation: Star: 8

We Say: Regular languages are closed under Union: Concatenation: Star: 8

Regular language NFA Single final state 9

Regular language NFA Single final state 9

Example 10

Example 10

Union NFA for 11

Union NFA for 11

Example NFA for 12

Example NFA for 12

Concatenation NFA for 13

Concatenation NFA for 13

Example NFA for 14

Example NFA for 14

Star Operation NFA for 15

Star Operation NFA for 15

Example NFA for 16

Example NFA for 16

Regular Expressions 17

Regular Expressions 17

Regular Expressions Regular expressions describe regular languages Example: describes the language 18

Regular Expressions Regular expressions describe regular languages Example: describes the language 18

Recursive Definition Primitive regular expressions: Given regular expressions and Are regular expressions 19

Recursive Definition Primitive regular expressions: Given regular expressions and Are regular expressions 19

Examples A regular expression: Not a regular expression: 20

Examples A regular expression: Not a regular expression: 20

Languages of Regular Expressions : language of regular expression Example 21

Languages of Regular Expressions : language of regular expression Example 21

Definition For primitive regular expressions: 22

Definition For primitive regular expressions: 22

Definition (continued) For regular expressions and 23

Definition (continued) For regular expressions and 23

Example Regular expression: 24

Example Regular expression: 24

Example Regular expression 25

Example Regular expression 25

Example Regular expression 26

Example Regular expression 26

Example Regular expression = { all strings with at least two consecutive 0 }

Example Regular expression = { all strings with at least two consecutive 0 } 27

Example Regular expression = { all strings without two consecutive 0 } 28

Example Regular expression = { all strings without two consecutive 0 } 28

Equivalent Regular Expressions Definition: Regular expressions and are equivalent if 29

Equivalent Regular Expressions Definition: Regular expressions and are equivalent if 29

Example = { all strings with at least two consecutive 0 } and are

Example = { all strings with at least two consecutive 0 } and are equivalent regular expr. 30

Regular Expressions and Regular Languages 31

Regular Expressions and Regular Languages 31

Theorem Languages Generated by Regular Expressions Regular Languages 32

Theorem Languages Generated by Regular Expressions Regular Languages 32

Theorem - Part 1 Languages Generated by Regular Expressions 1. Regular Languages For any

Theorem - Part 1 Languages Generated by Regular Expressions 1. Regular Languages For any regular expression the language is regular 33

Theorem - Part 2 Languages Generated by Regular Expressions 2. For any regular language

Theorem - Part 2 Languages Generated by Regular Expressions 2. For any regular language a regular expression Regular Languages there is with 34

Proof - Part 1 1. For any regular expression the language is regular Proof

Proof - Part 1 1. For any regular expression the language is regular Proof by induction on the size of 35

Induction Basis Primitive Regular Expressions: NFAs regular languages 36

Induction Basis Primitive Regular Expressions: NFAs regular languages 36

Inductive Hypothesis Assume for regular expressions and that and are regular languages 37

Inductive Hypothesis Assume for regular expressions and that and are regular languages 37

Inductive Step We will prove: Are regular Languages 38

Inductive Step We will prove: Are regular Languages 38

By definition of regular expressions: 39

By definition of regular expressions: 39

By inductive hypothesis we know: and are regular languages We also know: Regular languages

By inductive hypothesis we know: and are regular languages We also know: Regular languages are closed under union concatenation star 40

Therefore: Are regular languages 41

Therefore: Are regular languages 41

And trivially: is a regular language 42

And trivially: is a regular language 42

Proof – Part 2 2. For any regular language a regular expression there is

Proof – Part 2 2. For any regular language a regular expression there is with Proof by construction of regular expression 43

Since NFA is regular take that accepts it Single final state 44

Since NFA is regular take that accepts it Single final state 44

From construct the equivalent Generalized Transition Graph transition labels are regular expressions Example: 45

From construct the equivalent Generalized Transition Graph transition labels are regular expressions Example: 45

Another Example: 46

Another Example: 46

Reducing the states: 47

Reducing the states: 47

Resulting Regular Expression: 48

Resulting Regular Expression: 48

In General Removing states: 49

In General Removing states: 49

Obtaining the final regular expression: 50

Obtaining the final regular expression: 50