NonDeterministic Finite Automata 1 Nondeterministic Finite Automaton NFA

  • Slides: 78
Download presentation
Non-Deterministic Finite Automata 1

Non-Deterministic Finite Automata 1

Nondeterministic Finite Automaton (NFA) Alphabet = 2

Nondeterministic Finite Automaton (NFA) Alphabet = 2

Alphabet = Two choices 3

Alphabet = Two choices 3

Alphabet = Two choices No transition 4

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 All input is consumed “accept” 8

First Choice All input is consumed “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 Input cannot be consumed “reject” 12

Second Choice Input cannot be consumed “reject” 12

An NFA accepts a string: when there is a computation of the NFA that

An NFA accepts a string: when there is a computation of the NFA that accepts the string There is a computation: all the input is consumed and the automaton is in an accepting state 13

Example is accepted by the NFA: “accept” because this computation accepts “reject” 14

Example is accepted by the NFA: “accept” because this computation accepts “reject” 14

Rejection example 15

Rejection example 15

First Choice 16

First Choice 16

First Choice “reject” 17

First Choice “reject” 17

Second Choice 18

Second Choice 18

Second Choice 19

Second Choice 19

Second Choice “reject” 20

Second Choice “reject” 20

An NFA rejects a string: when there is no computation of the NFA that

An NFA rejects a string: when there is no computation of the NFA that accepts the string. For each computation: • All the input is consumed and the automaton is in a non final state OR • The input cannot be consumed 21

Example is rejected by the NFA: “reject” All possible computations lead to rejection 22

Example is rejected by the NFA: “reject” All possible computations lead to rejection 22

Rejection example 23

Rejection example 23

First Choice 24

First Choice 24

First Choice No transition: the automaton hangs 25

First Choice No transition: the automaton hangs 25

First Choice Input cannot be consumed “reject” 26

First Choice Input cannot be consumed “reject” 26

Second Choice 27

Second Choice 27

Second Choice 28

Second Choice 28

Second Choice No transition: the automaton hangs 29

Second Choice No transition: the automaton hangs 29

Second Choice Input cannot be consumed “reject” 30

Second Choice Input cannot be consumed “reject” 30

is rejected by the NFA: “reject” All possible computations lead to rejection 31

is rejected by the NFA: “reject” All possible computations lead to rejection 31

Language accepted: 32

Language accepted: 32

Lambda Transitions 33

Lambda Transitions 33

34

34

35

35

(read head does not move) 36

(read head does not move) 36

37

37

all input is consumed “accept” String is accepted 38

all input is consumed “accept” String is accepted 38

Rejection Example 39

Rejection Example 39

40

40

(read head doesn’t move) 41

(read head doesn’t move) 41

No transition: the automaton hangs 42

No transition: the automaton hangs 42

Input cannot be consumed “reject” String is rejected 43

Input cannot be consumed “reject” String is rejected 43

Language accepted: 44

Language accepted: 44

Another NFA Example 45

Another NFA Example 45

46

46

47

47

48

48

“accept” 49

“accept” 49

Another String 50

Another String 50

51

51

52

52

53

53

54

54

55

55

56

56

“accept” 57

“accept” 57

Language accepted 58

Language accepted 58

Another NFA Example 59

Another NFA Example 59

Language accepted (redundant state) 60

Language accepted (redundant state) 60

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

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

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

• NFAs are interesting because we can express languages easier than FAs NFA FA 62

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 Accepting states 63

Transition Function 64

Transition Function 64

65

65

66

66

67

67

Extended Transition Function 68

Extended Transition Function 68

69

69

70

70

Formally : there is a walk from with label to 71

Formally : there is a walk from with label to 71

The Language of an NFA 72

The Language of an NFA 72

73

73

74

74

75

75

76

76

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

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

78

78