1 / 58

Theory of Computation

Theory of Computation. Transition Graph. Definition: A Transition graph (TG), is a collection of the following: Finite number of states, at least one of which is start state and some (maybe none) final states. Finite set of input letters ( Σ ) from which input strings are formed.

harleyd
Download Presentation

Theory of Computation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Theory of Computation

  2. Transition Graph Definition: A Transition graph (TG), is a collection of the following: Finite number of states, at least one of which is start state and some (maybe none) final states. Finite set of input letters (Σ) from which input strings are formed. Finite set of transitions that show how to go from one state to another based on reading specified substrings of input letters, possibly even the null string: Λ.

  3. Example Consider the Language L , defined over Σ = {a, b} of all strings including Λ. The language L may be accepted by the following TG The language L may also be accepted by the following TG a,b a,b + Λ -

  4. Example Continued … TG1 TG2 a,b  a,b  + a,b

  5. Example Consider the language L of strings, defined over Σ={a, b},starting with b. The language L may be expressed by RE b(a + b)* , may be accepted by the following TG –– + a,b b

  6. Example Consider the Language L of strings, defined over Σ = {a, b}, containing double a. The language L may be expressed by the following regular expression (a+b)* (aa) (a+b)*. This language may be accepted by the following TG

  7. Example Continued … b,a b,a aa 1- 2+

  8. Example Consider the language L of strings, defined over Σ={a, b},having double a or double b. The language L can be expressed by RE (a+b)* (aa + bb) (a+b)*. The above language may also be expressed by the following TGs.

  9. Example continued … x a a a,b a,b –– + b b y

  10. OR a,b a,b aa,bb - +

  11. Generalized Transition Graphs A generalized transition graph (GTG) is a collection of three things Finite number of states, at least one of which is start state and some (maybe none) final states. Finite set of input letters (Σ) from which input strings are formed. Directed edges connecting some pair of states labeled with regular expression.

  12. Example Consider the language L of strings, defined over Σ={a,b}, containing double a or double b. The language L can be expressed by the following regular expression (a+b)* (aa + bb) (a+b)* The language L may be accepted by the following GTG.

  13. Example continued … a+b a+b aa+bb - +

  14. Example Consider the language L of strings, defined over Σ = {a, b}, beginning and ending in different letters. The language L may be expressed by RE a(a + b)*b + b(a + b)*a The language L may be accepted by the following GTG

  15. Example Continued … + b(a+b)*a - a( a+b)* b + The language L may be accepted by the following GTG as well

  16. Example Continued … b(a+b)*a + a( a+b)* b - +

  17. Example Consider the language L of strings, defined over Σ={a, b},having triple a or triple b. The language L may be expressed by RE (a+b)* (aaa + bbb) (a+b)* This language may be accepted by the following GTG

  18. Example Continued … a+b a+b aaa+bbb - + OR (a+b)*(aaa+bbb)(a+b)* - +

  19. Kleene’s Theorem If a language is expressed by FA or TG or RE then it can also be expressed by other two as well. the theorem is proved by proving the following three parts

  20. Kleene’s Theorem continued … Kleene’s Theorem Part I If a language is accepted by an FA then it can be accepted by a TG as well. Kleene’s Theorem Part II If a language is accepted by a TG then it can be expressed by an RE as well. Kleene’s Theorem Part III If a language is expressed by an RE then it can also be accepted by an FA.

  21. Kleene’s Theorem continued … Proof(Kleene’s Theorem Part I) Since every FA can be considered to be a TG, therefore there is nothing to prove.

  22. Kleene’s Theorem continued … Proof(Kleene’s Theorem Part II) To prove part II of the theorem, an algorithm consisting of different steps is explained showing how a RE can be obtained corresponding to the given TG.

  23. Kleene’s Theorem part II continued … Step 1If a TG has more than one start state, then introduce a new start state connecting the new state to the old start states by the transitions labeled by Λ and make the old start states the non-start states.

  24. Example b b 3+ 1- aa a a 4+ 2- bb

  25. Example Continued ... b b 3+ 1 Λ aa a - Λ a 4+ 2 bb

  26. Kleene’s Theorem part II continued … Step 2: If a TG has more than one final state, then introduce a new final state, connecting the old final states to the new final state by the transitions labeled by Λ.

  27. Example b b 3+ 1 Λ aa a - a Λ 4+ 2 bb

  28. Example continued … b b 3 1 Λ Λ aa a - + Λ a Λ 4 2 bb

  29. Kleene’s Theorem part II continued … Step 3: If a state has more than one incoming transition edge labeled by the corresponding REs, from the same state (including the possibility of loops at a state), then replace all these transition edges with a single transition edge labeled by the sum of corresponding REs.

  30. Example The above TG can be reduced to r3 r1 5 …. …. 4 r2 r4 r3+r4 r1+r2 5 …. …. 4

  31. Note The step 3 can be generalized to any finite number of transitions as shown below The above TG can be reduced to … r1+r2 + +rn 5 …. …. r1 r2 …. …. 5 …. rn

  32. Kleene’s Theorem part II continued … Step 4 (bypass and state elimination) If three states in a TG are connected in a sequence then eliminate the middle state and connect the first state with the third by a single transition (including loops) labeled by the RE, which is the concatenation of corresponding two REs in the existing sequence.

  33. Example r3 r2 r4 5 …. 6 …. 4 To eliminate state 5 the above can be reduced to r2r3*r4 …. 6 …. 4

  34. Example Consider the part of a TG, containing a circuit at a state, as shown below To eliminate state 3 the above TG can be reduced to 4 3 r2 r3 r1 …. 2 …. r4 r4r2*r3 r1r2*r3 …. 4 …. 2

  35. Example Consider a part of the following TG To eliminate state 3 the above TG can be reduced to 4 3 2 r2 r9 r7 r3 r1 r5 …. …. r8 r4 r6

  36. Example continued ... To eliminate state 4 the above TG can be reduced to 2 4 2 r1 +r3 r5*r4 r9 +r8r5*r7 r2 +r3 r5*r7 …. …. r6 +r8r5*r4 (r1 +r3 r5*r4 )+(r2 +r3 r5*r7 )(r9 +r8 r5*r7 )*(r6 +r8 r5*r4 ) …. ….

  37. Example Consider the following TG To have single final state, the above TG can be reduced to the following aa,b 2+ aaa ab,ba - 1 bba 3+

  38. Example continued … To eliminate states 2 and 3, the above TG can be reduced to the following aa+b 2 Λ aaa ab+ba - 1 4+ bba Λ 3 aa+b ab+ba aaa Λ+bbaΛ - 1 4+

  39. Example continued … To eliminate state 1 the above TG can be reduced to the following Hence the required RE is (ab+ba)(aa+b)*(aaa+bba) (ab+ba)(aa+b)*(aaa+bba) - +

  40. Kleene’s Theorem Part III Continued … If r1 and r2 are regular expressions then their sum, concatenation and closure are also regular expressions

  41. Kleene’s Theorem Part III Continued … Method1 (Union of two FAs):Using the FAs corresponding to r1 and r2an FA can be built, corresponding to r1+r2. This method can be developed considering the following examples

  42. Example Let r1=(a+b)*b defines L1 and the FA1 is and r2 = (a+b )*aa(a+b )* defines L2and FA2 be a b b X1– X2+ a a,b b a a y2 y1- y3+ b

  43. Sum of two FAs Continued … Let FA3 be an FA corresponding to r1+ r2, then the initial state ofFA3 must correspond to the initial state of FA1 or the initial state of FA2. Since the language corresponding to r1+r2 is the union of corresponding languages L1 and L2, consists of the strings belonging to L1or L2 or both, therefore, a final state ofFA3 must correspond to a final state of FA1 or FA2or both.

  44. Example continued … a,b b a a y2 y1– y3+ a b b b X1– X2+ a

  45. Example continued …

  46. Example continued … RE corresponding to the above FA may be r1+r2 = (a+b)*b + (a+b)*aa(a+b)* Z2 a a b a b a Z5 + Z1- b Z4 + a b b Z3+

  47. Kleene’s Theorem Part III Continued … Method2 (Concatenation of two FAs): Using the FAs corresponding to r1 and r2, an FA can be built, corresponding to r1r2. This method can be developed considering the following examples

  48. Example Let r1=(a+b)*b defines L1 and FA1 is and r2 = (a+b )*aa (a+b )* defines L2and FA2is a b b X1– X2+ a a,b b a a y2 y1- y3+ b

  49. Concatenation of two FAs Cont… Let FA3 be an FA corresponding to r1r2, then: initial state of FA3 =initial state of FA1 final state of FA3 =final state of FA2 if final state of FA1 is entered, then initial state of FA2 will also be included.

  50. Example continued … a,b b a a y2 y1- y3+ a b b b X1– X2+ a

More Related