Presentation is loading. Please wait.

Presentation is loading. Please wait.

Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter 2002-2003.

Similar presentations


Presentation on theme: "Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter 2002-2003."— Presentation transcript:

1 Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter 2002-2003

2 Rina Zviel-Girshin @ASC2 Overview Equivalence of the nondeterministic model to the deterministic model revisited Examples Closures of regular languages

3 Rina Zviel-Girshin @ASC3 DFA construction algorithm Let A be an NFA where A = (Q A, ,  A, q 0A, F A ). We construct a DFA M equivalent to A, where M = ( Q, , , q 0, F). Q = P(Q A )  =  For each R in Q and  in   (R,  ) is q 0 = E(q 0A ) F = { R  Q | there exists r  R such that r  F A } AA

4 Rina Zviel-Girshin @ASC4 Explanation Create all the subsets of set of states of A. Those will become the states of M. The alphabet remains the same. The transition function : for each state m in M and a letter  find what are the states qi..qj in A included in m for each qi  m find a set R of states which you can reach in A using  -closure, letter  and  -closure unite all the sets R you reach one set : S the next state of m on  in M is S.

5 Rina Zviel-Girshin @ASC5 Explanation The initial state in M is the set which includes only E(q 0A ). The final states in M - all the sets in which at least one state is final (accepting) state in A. Eliminate all the unreachable states in M - states to which the is no path from the initial state of M. The automaton you have is deterministic automaton equivalent to A.

6 Rina Zviel-Girshin @ASC6 Formal proof We prove that L(M)=L(A). First we show that for each word w  *,  A ’(q 0A,w) =  ’(q 0,w). We use induction.

7 Rina Zviel-Girshin @ASC7  A ’(q 0A,w) =  ’(q 0,w) Induction basis: w= .  A ’(q 0A,  ) = P   A ’(q 0A, .. ..  ) = P  P =  ’(q 0,  ). Induction hypothesis: Assume that theorem is true for some word w:  A ’(q 0A,w) =  ’(q 0,w) Induction step: Proof that the theorem is true for w .  A ’(q 0A, w  ) =  ’ A (  A ’(q 0A, w),  )  by induction hypothesis   ’ A (  ’(q 0, w),  )  by definition of    ’(  ’(q 0, w),  )=  ’( q 0, w  ).

8 Rina Zviel-Girshin @ASC8 L(M)=L(A) w  L(A)   A ’(q 0A,w)=P and P  F A   by definition of F   A ’(q 0A,w) =P and P  F  by the previous theorem   ’(q 0,w) =P and P  F  w  L(M)

9 Rina Zviel-Girshin @ASC9 Example Convert a given nondeterministic finite automaton to a deterministic finite automaton. A:

10 Rina Zviel-Girshin @ASC10 Example Using the algorithm we construct the following automaton: M:

11 Rina Zviel-Girshin @ASC11 Example Convert a given nondeterministic finite automaton to a deterministic finite automaton. B:

12 Rina Zviel-Girshin @ASC12 Example Using the algorithm we construct the following states: M:

13 Rina Zviel-Girshin @ASC13 Example M:

14 Rina Zviel-Girshin @ASC14 Example Some states of this automaton are unreachable from q0. After elimination of all unreachable states in M the resulting automaton is:

15 Rina Zviel-Girshin @ASC15 Theorem Every NFA with  -transitions has an equivalent NFA without  -transitions. Proof idea: We give a constructive proof - by giving an algorithm to build a NFA without  - transitions which is equivalent to a given NFA.

16 Rina Zviel-Girshin @ASC16 Constructive proof Let EM be NFA with  -transitions where EM = (Q EM, ,  EM, q 0EM, F EM ). We will construct an NFA without  -transitions ND which is equivalent to EM, where ND= (Q, , , q 0, F). Q= Q EM  =  For each q in Q and  in   (q,  ) is E(  EM (E(q),  )=  EM (q,  …   ..  ) (This means you have to add new edges to automaton ND)

17 Rina Zviel-Girshin @ASC17 Constructive proof q 0 =q 0EM F: –if E(q 0EM )  F =  (the empty word does not belong to L(EM)) then F= F EM –else (the empty word belongs to L(EM)) F= F EM  {q 0EM }

18 Rina Zviel-Girshin @ASC18 Example Build a NFA without  -transitions which is equivalent to a given NFA with  -transitions. q1 1 2 q2 q0 0 

19 Rina Zviel-Girshin @ASC19  (q0,0)={q0,q1,q2}  (q0,1)={q1,q2}  (q0,2)={q2} q1 1 2 q2 q0 0   (q1,0)=?  (q1,1)={q1,q2}  (q1,2)={q2}  (q2,0)=?  (q2,1)=?  (q2,2)={q2} q1 1 q0 0 2 q2 0,11,2 0,1,2

20 Rina Zviel-Girshin @ASC20 A NFA without  -transitions We use an NFA without  -transitions to construct a DFA that is equivalent to a given NFA with  -transitions. Basic construction idea: –We are given an NFA EM with  -transitions –Build an NFA M without  -transitions –Build a DFA D equivalent to M.

21 Rina Zviel-Girshin @ASC21 Example Build a DFA equivalent to a given NFA. q1 1 2 q2 q0 0  EM:

22 Rina Zviel-Girshin @ASC22 Example The NFA M without  -transitions: M: q1 1 q0 0 2 q2 0,11,2 0,1,2

23 Rina Zviel-Girshin @ASC23 Example A DFA D equivalent to M: D: 0 q0,1,2 q0 2 q2 0 1 2 q1,2 1 1 2  0,1,2 0 0,1 2

24 Rina Zviel-Girshin @ASC24 Closure of regular languages Theorem: The class of languages accepted by finite automata is closed under: union concatenation Kleene (star) closure.

25 Rina Zviel-Girshin @ASC25 Basic proof idea Proof by construction: In each case we will construct an automaton M that accepts the appropriate language. We will use non-deterministic models.

26 Rina Zviel-Girshin @ASC26 Union Let M 1 recognize L 1 where M 1 = (Q 1, ,  1, q 01, F 1 ) and M 2 recognize L 2 where M 2 = (Q 2, ,  2, q 02, F 2 ). Construct M to recognize L 1  L 2, where M = ( Q, , , q 0, F).

27 Rina Zviel-Girshin @ASC27 Union

28 Rina Zviel-Girshin @ASC28 Union We construct M in a way that uses nondeterminism to “guess” whether the input word w is in L 1 or L 2 and then process the string exactly as the corresponding automaton (M 1 or M 2 ).

29 Rina Zviel-Girshin @ASC29 Union M = ( Q, , , q 0, F) where Q=Q 1  Q 2  {q 0 }   =  1  2  {  (q 0,  )=q 01,  (q 0,  )=q 02 } q 0 F=F 1  F 2

30 Rina Zviel-Girshin @ASC30 Proof We gave the formal proof during the last lecture. The basic idea of the proof is: if w  *, then  ’(q 0,w)=q for some q  F iff either  ’(q 01,w)=q for some q  F 1 or  ’(q 02,w)=q for some q  F 2 Hence M accepts w iff M 1 accepts w or M 2 accepts w.

31 Rina Zviel-Girshin @ASC31 Concatenation Let M 1 recognize L 1 where M 1 = (Q 1, ,  1, q 01, F 1 ) and M 2 recognize L 2 where M 2 = (Q 2, ,  2, q 02, F 2 ). Construct M to recognize L 1  L 2, where M = ( Q, , , q 0, F).

32 Rina Zviel-Girshin @ASC32 Concatenation

33 Rina Zviel-Girshin @ASC33 Concatenation We construct M that simulates M1 for a while Then M "jumps" nondeterministically from a final state of M1 to the initial state of M2 And then M will simulate M2 for the rest of the input.

34 Rina Zviel-Girshin @ASC34 Concatenation M = ( Q, , , q 0, F) where Q=Q 1  Q 2  =  1  2  {for each state f  F1  (f,  )=q 02 }  q 0 =q 01 F= F 2

35 Rina Zviel-Girshin @ASC35 Proof The basic proof idea is: if w  *, then  ’(q 0,w)=q for some q  F iff w=uv and  ’(q 01,u)=f for some f  F 1 and  ’(q 02,v)=q for some q  F 2. Hence M accepts w iff M 1 accepts u and M 2 accepts v.

36 Rina Zviel-Girshin @ASC36 Kleene star Let M 1 recognize L 1 where M 1 = (Q 1, ,  1, q 01, F 1 ). Construct M to recognize L 1 *, where M = ( Q, , , q 0, F).

37 Rina Zviel-Girshin @ASC37 Kleene (star) closure We will construct M in a way similar to concatenation. M simulates M 1 on w all the way plus it has an option to go back to q 01. M also excepts .

38 38 Kleene (star) closure M = ( Q, , , q 0, F) where Q=Q 1  {q 0 }  =  1   (q 0,  )=q 01   {for each state f  F  (f,  )=q 01 }  q 0 =q 0 F= {q 0 }  F 1

39 Rina Zviel-Girshin @ASC39 Any Questions?


Download ppt "Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter 2002-2003."

Similar presentations


Ads by Google