Another NFA Example Fall 2004 COMP 335 1

  • Slides: 55
Download presentation
Another NFA Example Fall 2004 COMP 335 1

Another NFA Example Fall 2004 COMP 335 1

Language accepted (redundant state) Fall 2004 COMP 335 2

Language accepted (redundant state) Fall 2004 COMP 335 2

Remarks: • The symbol never appears on the input tape • Simple automata: Fall

Remarks: • The symbol never appears on the input tape • Simple automata: Fall 2004 COMP 335 3

 • NFAs are interesting because we can express languages easier than DFAs NFA

• NFAs are interesting because we can express languages easier than DFAs NFA Fall 2004 DFA COMP 335 4

Formal Definition of NFAs Set of states, i. e. Input aphabet, i. e. Transition

Formal Definition of NFAs Set of states, i. e. Input aphabet, i. e. Transition function Initial state Final states Fall 2004 COMP 335 5

Transition Function Fall 2004 COMP 335 6

Transition Function Fall 2004 COMP 335 6

Fall 2004 COMP 335 7

Fall 2004 COMP 335 7

Fall 2004 COMP 335 8

Fall 2004 COMP 335 8

Fall 2004 COMP 335 9

Fall 2004 COMP 335 9

Extended Transition Function Fall 2004 COMP 335 10

Extended Transition Function Fall 2004 COMP 335 10

Fall 2004 COMP 335 11

Fall 2004 COMP 335 11

Fall 2004 COMP 335 12

Fall 2004 COMP 335 12

Formally : there is a walk from with label Fall 2004 COMP 335 to

Formally : there is a walk from with label Fall 2004 COMP 335 to 13

The Language of an NFA Fall 2004 COMP 335 14

The Language of an NFA Fall 2004 COMP 335 14

Fall 2004 COMP 335 15

Fall 2004 COMP 335 15

Fall 2004 COMP 335 16

Fall 2004 COMP 335 16

Fall 2004 COMP 335 17

Fall 2004 COMP 335 17

Fall 2004 COMP 335 18

Fall 2004 COMP 335 18

Formally The language accepted by NFA is: where (final state) and there is some

Formally The language accepted by NFA is: where (final state) and there is some Fall 2004 COMP 335 19

Fall 2004 COMP 335 20

Fall 2004 COMP 335 20

NFA accept Regular Languages Fall 2004 COMP 335 21

NFA accept Regular Languages Fall 2004 COMP 335 21

Equivalence of FA Definition: An FA is equivalent to FA if that is if

Equivalence of FA Definition: An FA is equivalent to FA if that is if both accept the same language. Fall 2004 COMP 335 22

Example of equivalent FA NFA DFA Fall 2004 COMP 335 23

Example of equivalent FA NFA DFA Fall 2004 COMP 335 23

We will prove: Languages accepted by NFA Regular Languages That is, NFA and DFA

We will prove: Languages accepted by NFA Regular Languages That is, NFA and DFA have the same computation power Fall 2004 COMP 335 Languages accepted by DFA 24

Step 1 Languages accepted by NFA Regular Languages Proof: Every DFA is trivially an

Step 1 Languages accepted by NFA Regular Languages Proof: Every DFA is trivially an NFA Any language accepted by a DFA is also accepted by an NFA Fall 2004 COMP 335 25

Step 2 Languages accepted by NFA Regular Languages Proof: Any NFA can be converted

Step 2 Languages accepted by NFA Regular Languages Proof: Any NFA can be converted into an equivalent DFA Fall 2004 Any language accepted by an NFA is also accepted by a DFA COMP 335 26

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 27

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 27

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 28

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 28

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 29

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 29

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 30

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 30

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 31

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 31

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 32

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 32

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 33

Convert NFA to DFA NFA DFA Fall 2004 COMP 335 33

NFA to DFA: Remarks We are given an NFA We want to convert it

NFA to DFA: Remarks We are given an NFA We want to convert it into an equivalent DFA That is, Fall 2004 COMP 335 34

If the NFA has states Then the DFA has states in the powerset Fall

If the NFA has states Then the DFA has states in the powerset Fall 2004 COMP 335 35

Procedure NFA to DFA 1. Initial state of NFA: Initial state of DFA: Fall

Procedure NFA to DFA 1. Initial state of NFA: Initial state of DFA: Fall 2004 COMP 335 36

Example NFA DFA Fall 2004 COMP 335 37

Example NFA DFA Fall 2004 COMP 335 37

Procedure NFA to DFA 2. For every DFA’s state Compute in the NFA Add

Procedure NFA to DFA 2. For every DFA’s state Compute in the NFA Add the following transition to the DFA Fall 2004 COMP 335 38

Example NFA DFA Fall 2004 COMP 335 39

Example NFA DFA Fall 2004 COMP 335 39

Procedure NFA to DFA Repeat step 2 for all symbols in the alphabet ∑,

Procedure NFA to DFA Repeat step 2 for all symbols in the alphabet ∑, until no more transitions can be added. Fall 2004 COMP 335 40

Example NFA DFA Fall 2004 COMP 335 41

Example NFA DFA Fall 2004 COMP 335 41

Procedure NFA to DFA 3. For any DFA state: If some is a final

Procedure NFA to DFA 3. For any DFA state: If some is a final state in the NFA Then, is a final state in the DFA Fall 2004 COMP 335 42

Example NFA DFA Fall 2004 COMP 335 43

Example NFA DFA Fall 2004 COMP 335 43

Take NFA Theorem Apply the procedure to obtain DFA Then, Fall 2004 and are

Take NFA Theorem Apply the procedure to obtain DFA Then, Fall 2004 and are equivalent: COMP 335 44

Proof AND Fall 2004 COMP 335 45

Proof AND Fall 2004 COMP 335 45

First we show: Take arbitrary string : We will prove: Fall 2004 COMP 335

First we show: Take arbitrary string : We will prove: Fall 2004 COMP 335 46

Fall 2004 COMP 335 47

Fall 2004 COMP 335 47

We will show that if Fall 2004 COMP 335 48

We will show that if Fall 2004 COMP 335 48

More generally, we will show that if in : (arbitrary string) Fall 2004 COMP

More generally, we will show that if in : (arbitrary string) Fall 2004 COMP 335 49

Proof by induction on The basis case: Fall 2004 COMP 335 50

Proof by induction on The basis case: Fall 2004 COMP 335 50

Induction hypothesis: Fall 2004 COMP 335 51

Induction hypothesis: Fall 2004 COMP 335 51

Induction Step: Fall 2004 COMP 335 52

Induction Step: Fall 2004 COMP 335 52

Induction Step: Fall 2004 COMP 335 53

Induction Step: Fall 2004 COMP 335 53

Therefore if Fall 2004 COMP 335 54

Therefore if Fall 2004 COMP 335 54

We have shown: We also need to show: (proof is similar) Fall 2004 COMP

We have shown: We also need to show: (proof is similar) Fall 2004 COMP 335 55