1 / 34

Theory of Computation

Theory of Computation. Text and Reference Material. Source: Introduction to Computer Theory (Automata Theory) By Daniel I. A. Cohen, Second Edition Slides Source: Virtual University of Pakistan. Basic Introduction. Automata: The plural of automaton

bcoleman
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. Text and Reference Material Source: Introduction to Computer Theory (Automata Theory) By Daniel I. A. Cohen, Second Edition Slides Source: Virtual University of Pakistan

  3. Basic Introduction Automata: The plural of automaton Means “something that works automatically” Language: Any set of strings over some fixed alphabets Alphabets: A finite non-empty set of symbols (letters), denoted by Σ Examples: Σ={a,b} or Σ={0,1}

  4. Strings Concatenation of finite symbols from the alphabet Example: If Σ= {a,b} then a, abab, aaabb, ababababababababab The number of letters in the string is called the length of strings, denoted by |s| Example: Σ={ a,b }, s=ababa, the |s|=5

  5. Length of StringsCont… Example: Σ= {B, aB, bab, d} s= BaBbabBd Tokenizing=(B), (aB), (bab), (B), (d) |s|=5

  6. Defining Languages The languages can be defined in different ways, such as Descriptive definition Using Regular Expressions(RE), and Using Finite Automaton(FA) etc.

  7. Descriptive definition The language is defined in such a way that describes the conditions imposed on its words. The language L of strings of odd length, defined over Σ={a}, can be written as L={a, aaa, aaaaa,…..} Example: The language L of strings that does not start with a, defined over Σ={a,b,c}, can be written as L={b, c, ba, bb, bc, ca, cb, cc, …}

  8. Descriptive definition Cont… The language PRIME, of strings defined over Σ={a}, as {ap : p is prime}, can be written as {aa,aaa,aaaaa,aaaaaaa,aaaaaaaaaaa…}

  9. The Language EVEN-EVEN The Language of strings, defined over Σ={a, b} having even number of a’s and even number of b’s. EVEN-EVEN = {Λ, aa, bb, aaaa,aabb,abab, abba, baab, baba, bbaa, bbbb,…} , its regular expression can be written as (aa+bb+(ab+ba)(aa+bb)*(ab+ba))*

  10. Equivalent RegularExpressions Definition: Two regular expressions are said to be equivalent if they generate the same language. Example: Consider the following regular expressions r1= (a + b)* (aa + bb) r2= (a + b)*aa + ( a + b)*bb then both regular expressions define the language of strings ending in aa or bb.

  11. Regular Languages The language generated by any regular expression is called a regular language. If r1, r2 are regular expressions, corresponding to the languages L1 and L2 then the languages generated by r1+ r2, r1r2 (or r2r1) and r1* (or r2*) are also regularlanguages.

  12. All Finite Languages areRegular Example: Consider the language L, defined over Σ={a,b}, of strings of length 2, starting with a, then L={aa, ab}. Its regular expression is aa+ab. Thus, by definition, L is a regular language.

  13. Defining Languages(Cont…) (Finite Automaton) Definition: A Finite automaton (FA), is a collection of: 1) Finite number of states, having one initial and some (maybe none) final states. 2) Finite set of input letters (Σ) from which input strings are formed. 3) Finite set of transitions i.e., for each state and for each input letter there is a transition showing how to move from one state to another.

  14. Example 1 Σ = {a,b} States: x, y, z, where x is an initial state and z is the final state. Transitions: 1. At state x reading a go to state z, At state x reading b go to state y, At state y reading a, b go to state y At state z reading a, b go to state z

  15. Example 1 Cont… These transitions can be expressed by the following transition table

  16. Example 1 Cont… The information of FA, given in the previous table, can also be depicted by the following transition diagram

  17. Example 1 Cont… The previous transition diagram is an FA accepting the language of strings, defined over Σ={a, b}, starting with a. This language may be expressed by the regular expression a (a + b)*

  18. Note To indicate the initial state, an arrow head can also be placed before that state and that the final state with double circle, as shown below. While expressing an FA by its transition diagram, the labels of states are not necessary.

  19. Example 2 States: x, y, where x is both initial and final state. Transitions: At state x reading a or b go to state y. At state y reading a or b go to state x.

  20. Example 2 Cont… These transitions can be expressed by the following transition table

  21. Example 2 Cont… The previous transition table may be depicted by the following transition diagram

  22. Example 2 Cont… The previous transition diagram is an FA accepting the language of strings, defined over Σ={a, b} of even length. This language may be expressed by the regular expression ((a+ b) (a + b))*

  23. Example 3 An FA for the language L of strings, defined over Σ={a, b}, ofodd length.

  24. Example 4 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 FA

  25. Example 5 Consider the language L of strings, defined over Σ={a, b}, ending in a. The language L may be expressed by RE (a+b)*a This language may be accepted by the following FA (Next slide)

  26. Example 5 Cont…

  27. Example 5 Cont…. There may be another FA corresponding to the given language.

  28. Note It may be noted that corresponding to a given language there may be more than one FA accepting that language, but for a given FA there is a unique language accepted by that FA.

  29. Note Given the languages L1 and L2 ,where L1= The language of strings, defined over Σ={a, b}, beginning with a L2 = The language of strings, defined over Σ={a, b}, not beginning with b The Λ does not belong to L1 while it does belong to L2 . This fact may be depicted by the corresponding transition diagrams of L1 and L2.

  30. FA1 Corresponding to L1 The language L1 may be expressed by the regular expression a(a+b)*

  31. FA2 Corresponding to L2 The language L2 may be expressed by the regular expression a(a+b)* + Λ

  32. Exercise Build an FA accepting the Language L of Strings, defined over Σ = {a, b}, beginning with and ending in same letters.

  33. Example 6 Consider the Language L of Strings of length two or more, defined over Σ = {a, b}, beginning with and ending in same letters. The language L may be expressed by the following regular expression a (a + b)* a + b (a + b)* b This language L may be accepted by the following FA (Next slide)

  34. Example 6 Cont…

More Related