Download presentation

Presentation is loading. Please wait.

Published byBrisa Kye Modified over 2 years ago

1
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)

2
NFAs: Nondeterministic Finite Automata Same as a DFA, except: On input a, state q may have more than one transition out, implying the possibility of multiple choices when processing an input symbol On input a, state q may have no transition out, implying the possibility of “being stuck” A string w is acceptable as long as there exists an admissible state sequence for w

3
NFAs A nondeterministic finite automaton M is a five-tuple M = (Q, , , q 0, F), where: Q is a finite set of states of M is the finite input alphabet of M : Q power set of Q, is the state transition function mapping a state-symbol pair to a subset of Q q 0 is the start state of M F Q is the set of accepting states or final states of M

4
Example NFA NFA that recognizes the language of strings that end in 01 q0q0 q2q2 0,1 0 1 q1q1 note: (q 0,0) = {q 0,q 1 } (q 1,0) = {} Exercise: draw the complete transition table for this NFA

5
^ definition for an NFA ^: Q X * power set of Q ^(q, ) = {q} ^(q, w), w = xa (where x is a string and a is a symbol) is defined as follows: Let ^(q, x) = {p 1,p 2,…p k } Then, ^(q, w) = (p i, a)

6
Language recognized by an NFA A string w is accepted by an NFA M if ^(q 0, w) F is non-empty Note that ^(q 0, w) represents a subset of states since the automaton is nondeterministic Equivalent definition: there exists an admissible state sequence for w in M The language L(M) recognized by an NFA is the set of strings accepted by M L(M) ={ w | ^(q 0, w) F is non-empty }

7
Converting NFAs to DFAs Given a NFA, M = (Q, , , q 0, F), build a DFA, M’ = (Q’, , ’, {q 0 }, F’) as follows. Q’ contains all subsets S of states in Q. The initial state of M’ is the set containing q 0 F’ is the set of all subsets of Q that contain at least one element in F (equivalently, the subset contains at least one final state)

8
Converting NFAs to DFAs ’ is determined by putting together, for each state in the subset and each symbol, all states that may result from a transition: ’(S, a) = (q, a) q S May remove “unreachable” states in Q’

9
Example conversion NFA DFA q0q0 q2q2 0,1 0 1 q1q1 {q 0 } 1 0 1 {q 0,q 1 } {q 0,q 2 } 0 0 1

10
NFA with -transitions NFA that allows the transition of an empty string from a state Jumping to a state is possible even without input Revision on NFA definition simply allows the “symbol” for

11
NFA with -transitions A nondeterministic finite automaton with - transitions (or -NFA) is a five-tuple M = (Q, , , q 0, F), where: Q is a finite set of states of M is the finite input alphabet of M : Q ( + ) power set of Q, is the state transition function mapping a state-symbol pair to a subset of Q q 0 is the start state of M F Q is the set of accepting states or final states of M

12
Converting -NFAs to NFAs Task: Given an -NFA M = (Q, , , q 0, F), build a NFA M’ = (Q, , ’, q 0, F’) Need to eliminate -transitions Need epsilon closure concept Add transitions to enable transitions previously allowed by the -transitions Note: the conversion process in the textbook instead builds a DFA from an -NFA The conversion described in these slides is simpler

13
Epsilon closure In an NFA M, let q Q ECLOSE(q) represents all states r that can be reached from q using only -transitions Recursive definition for ECLOSE If (q, ) is empty, ECLOSE(q) = {q} Else, Let (q, ) = {r 1, r 2,…, r n }. ECLOSE(q) = ECLOSE(r i ) {q} Note: check out constructive definition of ECLOSE in the textbook

14
Additional transitions NFA M’ = (Q, , ’, q 0, F’) such that ’ is described as follows Suppose ECLOSE(q) = {r 1, r 2,…, r n }. For each transition from state r i to state s j on (non-epsilon) symbol a, add a transition from q to s j on symbol a (For each transition from state s j to state q on (non-epsilon) symbol a, add a transition from s j to r j on symbol a, for each r j ) ’ = minus the epsilon transitions plus the additional transitions mentioned above

15
Final states NFA M’ = (Q, , ’, q 0, F’) such that F’ is described as follows F’ = F plus all states q such that ECLOSE(q 0 ) contains a state in F

16
Equivalence of Finite Automata Conversion processes between DFAs, NFAs, and -NFAs show that no additional expressive capacity (except convenience) is introduced by non- determinism or -transitions All models represent regular languages Note: possible exponential explosion of states when converting from NFA to DFA

17
Closure of Regular Languages under certain operations UnionL1 L2 ComplementationL1 IntersectionL1 L2 ConcatenationL1L2 Goal: ensure a FA can be produced from the FAs of the “operand” languages

18
Union Given that L1 and L2 are regular, then there exists FAs M1 = (Q1, 1, 1, q1 0, F1) and M2 = (Q2, 2, 2, q2 0, F2) that recognize L1 and L2 respectively Let L3 = L1 L2. Define M3 as follows: M3 = ({q3 0 } Q1 Q2, 1 2, 3, q3 0,F1 F2) where 3 is just 1 2 plus the following epsilon transitions: q3 0 q1 0 and q3 0 q2 0 M3 recognizes L3

19
Complementation Given that L1 is regular, then there exists DFA M1 = (Q, , , q 0, F) that recognizes L1 Define M2 as follows: M2 = (Q, , , q 0, Q - F) M2 recognizes L1 Strings that used to be accepted are not, strings not accepted are now accepted Note: it is important that M1 is a DFA; starting with an NFA poses problems. Why?

20
Intersection By De Morgan’s Law, L1 L2 = ( L1 L2 ) Applications of the constructions provided for and complementation provide a construction for

21
Concatenation Given that L1 and L2 are regular, then there exists FAs M1 = (Q1, 1, 1, q1 0, F1) and M2 = (Q2, 2, 2, q2 0, F2) that recognize L1 and L2 respectively Let L3 = L1L2. Define M3 as follows: M3 = (Q1 Q2, 1 2, 3, q1 0, F2) where 3 is just 1 2 plus the following epsilon transitions: q1 i q2 0 for all q1 i in F1 M3 recognizes L3

22
Finite Automata with Output Moore Machines Output symbol for each state encountered Mealy Machines Output symbol for each transition encountered Exercise: formally define Moore and Mealy machines

23
Next: Regular Expressions Defines languages in terms of symbols and operations Example (01)* + (10)* defines all even-length strings of alternating 0s and 1s Regular expressions also model regular languages and we will demonstrate equivalence with finite automata

Similar presentations

OK

Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.

Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on action words for grade 1 Ppt on game theory john Ppt on indian equity market Ppt on 5 star chocolate desserts Ppt on illegal immigration Ppt on biography of albert einstein Ppt on anti parkinson drugs Ppt on circles for class 9 download Ppt on food security in india class 9 Ppt on forests in india