Non Deterministic Automata 1 Nondeterministic Finite Accepter NFA

  • Slides: 88
Download presentation
Non Deterministic Automata 1

Non Deterministic Automata 1

Nondeterministic Finite Accepter (NFA) Alphabet = 2

Nondeterministic Finite Accepter (NFA) Alphabet = 2

Nondeterministic Finite Accepter (NFA) Alphabet = Two choices 3

Nondeterministic Finite Accepter (NFA) Alphabet = Two choices 3

Nondeterministic Finite Accepter (NFA) Alphabet = Two choices No transition 4

Nondeterministic Finite Accepter (NFA) Alphabet = Two choices No transition 4

First Choice 5

First Choice 5

First Choice 6

First Choice 6

First Choice 7

First Choice 7

First Choice “accept” 8

First Choice “accept” 8

Second Choice 9

Second Choice 9

Second Choice 10

Second Choice 10

Second Choice No transition: the automaton hangs 11

Second Choice No transition: the automaton hangs 11

Second Choice “reject” 12

Second Choice “reject” 12

Observation An NFA accepts a string if there is a computation of the NFA

Observation An NFA accepts a string if there is a computation of the NFA that accepts the string 13

Example is accepted by the NFA: 14

Example is accepted by the NFA: 14

Lambda Transitions 15

Lambda Transitions 15

16

16

17

17

(read head doesn’t move) 18

(read head doesn’t move) 18

19

19

“accept” String is accepted 20

“accept” String is accepted 20

Language accepted: 21

Language accepted: 21

Another NFA Example 22

Another NFA Example 22

23

23

24

24

25

25

“accept” 26

“accept” 26

Another String 27

Another String 27

28

28

29

29

30

30

31

31

32

32

33

33

“accept” 34

“accept” 34

Language accepted 35

Language accepted 35

Another NFA Example 36

Another NFA Example 36

Language accepted 37

Language accepted 37

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

Formal Definition of NFAs Set of states, i. e. Input aplhabet, i. e. Transition function Initial state Final states 38

Transition Function 39

Transition Function 39

40

40

41

41

42

42

Extended Transition Function 43

Extended Transition Function 43

44

44

45

45

Formally It holds if and only if there is a walk from with label

Formally It holds if and only if there is a walk from with label to 46

The Language of an NFA 47

The Language of an NFA 47

48

48

49

49

50

50

51

51

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

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

53

53

Equivalence of NFAs and DFAs 54

Equivalence of NFAs and DFAs 54

Equivalence of Machines For DFAs or NFAs: Machine is equivalent to machine if 55

Equivalence of Machines For DFAs or NFAs: Machine is equivalent to machine if 55

Example NFA DFA 56

Example NFA DFA 56

Since machines and are equivalent NFA DFA 57

Since machines and are equivalent NFA DFA 57

Equivalence of NFAs and DFAs Question: NFAs = DFAs ? Same power? Accept the

Equivalence of NFAs and DFAs Question: NFAs = DFAs ? Same power? Accept the same languages? 58

Equivalence of NFAs and DFAs Question: NFAs = DFAs ? YES! Same power? Accept

Equivalence of NFAs and DFAs Question: NFAs = DFAs ? YES! Same power? Accept the same languages? 59

We will prove: Languages accepted by NFAs Languages accepted by DFAs 60

We will prove: Languages accepted by NFAs Languages accepted by DFAs 60

We will prove: Languages accepted by NFAs Languages accepted by DFAs NFAs and DFAs

We will prove: Languages accepted by NFAs Languages accepted by DFAs NFAs and DFAs have the same computation power 61

Step 1 Languages accepted by NFAs Languages accepted by DFAs 62

Step 1 Languages accepted by NFAs Languages accepted by DFAs 62

Step 1 Languages accepted by NFAs Proof: Languages accepted by DFAs Every DFA is

Step 1 Languages accepted by NFAs Proof: Languages accepted by DFAs Every DFA is also an NFA 63

Step 1 Languages accepted by NFAs Proof: Languages accepted by DFAs Every DFA is

Step 1 Languages accepted by NFAs Proof: Languages accepted by DFAs Every DFA is also an NFA A language accepted by a DFA is also accepted by an NFA 64

Step 2 Languages accepted by NFAs Languages accepted by DFAs 65

Step 2 Languages accepted by NFAs Languages accepted by DFAs 65

Step 2 Languages accepted by NFAs Proof: Languages accepted by DFAs Any NFA can

Step 2 Languages accepted by NFAs Proof: Languages accepted by DFAs Any NFA can be converted to an equivalent DFA 66

Step 2 Languages accepted by NFAs Proof: Languages accepted by DFAs Any NFA can

Step 2 Languages accepted by NFAs Proof: Languages accepted by DFAs Any NFA can be converted to an equivalent DFA A language accepted by an NFA is also accepted by a DFA 67

NFA to DFA NFA DFA 68

NFA to DFA NFA DFA 68

NFA to DFA NFA DFA 69

NFA to DFA NFA DFA 69

NFA to DFA NFA DFA 70

NFA to DFA NFA DFA 70

NFA to DFA NFA DFA 71

NFA to DFA NFA DFA 71

NFA to DFA NFA DFA 72

NFA to DFA NFA DFA 72

NFA to DFA NFA DFA 73

NFA to DFA NFA DFA 73

NFA to DFA NFA DFA 74

NFA to DFA NFA DFA 74

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 to an equivalent DFA With 75

If the NFA has states the DFA has states in the powerset 76

If the NFA has states the DFA has states in the powerset 76

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

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

Example NFA DFA 78

Example NFA DFA 78

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 transition 79

Exampe NFA DFA 80

Exampe NFA DFA 80

Procedure NFA to DFA Repeat Step 2 for all letters in alphabet, until no

Procedure NFA to DFA Repeat Step 2 for all letters in alphabet, until no more transitions can be added. 81

Example NFA DFA 82

Example NFA DFA 82

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 83

Example NFA DFA 84

Example NFA DFA 84

Theorem Take NFA Apply procedure to obtain DFA Then and are equivalent : 85

Theorem Take NFA Apply procedure to obtain DFA Then and are equivalent : 85

Finally We have proven Languages accepted by NFAs Languages accepted by DFAs 86

Finally We have proven Languages accepted by NFAs Languages accepted by DFAs 86

We have proven Languages accepted by NFAs Languages accepted by DFAs Regular Languages 87

We have proven Languages accepted by NFAs Languages accepted by DFAs Regular Languages 87

We have proven Languages accepted by NFAs Regular Languages accepted by DFAs Regular Languages

We have proven Languages accepted by NFAs Regular Languages accepted by DFAs Regular Languages 88