×
IT'S TIME TO WORK A LITTLE HARDER.
--Your friends at LectureNotes
Close

Note for Theory Of Computation - TC by Jitendra Pal

  • Theory Of Computation - TC
  • Note
  • Biju Patnaik University of Technology BPUT - BPUT
  • Computer Science Engineering
  • B.Tech
  • 327 Views
  • 8 Offline Downloads
  • Uploaded 5 months ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

BIJU PATNAIK UNIVERSITY OF TECHNOLOGY, ODISHA Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT -1 Prepared by, Dr. Subhendu Kumar Rath, BPUT, Odisha.

Text from page-2

Finite Automata and Languages UNIT 1 FINITE AUTOMATA AND LANGUAGES Structure 1.0 1.1 1.2 Page Nos. Introduction Objectives Regular Expressions 1.2.1 1.2.2 1.2.3 1.2.4 1.3 1.4 7 7 7 Introduction to Defining of Languages Kleene closure definition Formal Definition of Regular Expressions Algebra of Regular Expressions Regular Languages Finite Automata 13 14 1.4.1 1.4.2 Finite Automata Another method to describe FA 1.4.3 Finite Automata as Output Devices 1.5 1.6 Summary Solutions/Answers 23 23 1.0 INTRODUCTION We shall study different types of theoretical machines that are mathematical models for actual physical processes. By considering the possible inputs on which these machines can work, we can analyze their various strengths and weaknesses. We then arrive at what we may believe to be the most powerful machine possible. When we do so, we would be surprised to find the computational tasks that this machine cannot perform. This will be our ultimate result that no matter what machine we build, there will always be questions that are simple to state but even the most powerful machine possibly cannot answer. Along the way, we hope you would understand the concept of computability, which is the foundation of further research in this field. 1.1 OBJECTIVES After studying this unit, you should be able to: define alphabet, substring; define a language and various operations on languages; define and use a regular expression; define a finite automata for computation of a language; and obtain a finite automata for a known language; 1.2 REGULAR EXPRESSIONS In this unit, first we shall discuss the definitions of alphabet, string, and language with some important properties. 1.2.1 Introduction to Defining of Languages For a language, defining rules can be of two types. The rules can either tell us how to test a string of alphabet letters that we might be presented with, to see if it is a valid word, i.e., a word in the language or the rules can tell us how to construct all the words in the language by some clear procedures. 7

Text from page-3

Finite Automata and Formal Languages Alphabet: A finite set of symbols/characters. We generally denote an alphabet by . If we start an alphabet having only one letter, say, the letter z, then = {z} Letter : Each symbol of an alphabet may also be called a letter of the alphabet or simply a letter. Language over an alphabet : A set of words over an alphabet. Languages are denoted by letter L with or without a subscript. String/word over an alphabet: Every member of any language is said to be a string or a world. Example 1: Let L1 be the language of all possible strings obtained by L1 = {z, zz, zzz, zzzz . . . . . .} This can also be written as L1 = {zn} for n = 1, 2, 3, ….. A string of length zero is said to be null string and is represented by . Above given language L1 does not include the null string. We could have defined it so as to include . Thus, L = {zn n=0, 1, 2, 3…} contains the null string. In this language, as in any other, we can define the operation of concatenation, in which two strings are written down side by side to form a new longer string. Suppose u = ab and v = baa, then uv is called concatenation of two strings u and v and is uv = abbaa and vu = baaab. The words in this language clearly analogous to the positive integers, and the operation of concatenation are analogous to addition: zn concatenated with zm is the word zn+m. Example 2: If the word zzz is called c and the word zz is called d, then the word formed by concatenating c and d is cd = zzzzz When two words in our language L1 are concatenated they produce another word in the language L1. However, this may not be true in all languages. Example 3: If the language is L2 = {z, zzz, zzzzz, zzzzzzz…..} = {zodd} = {z2n+1 for n = 0, 1, 2, 3….} then c = zzz and d = zzzzz are both words in L2, but their concatenation cd = zzzzzzzz is not a word in L2. The reason is simple that member of L2 are of odd length while after concatenation it is of even length. Note: The alphabet for L2 is the same as the alphabet for L1. Example 4: A Language L3 may denote the language having strings of even lengths include of length 0. In other words, L3 = { , zz, zzzz, …..} Another interesting language over the alphabet = {z} may be Example 5: L4 = {zp : p is a prime natural number}. There are infinitely many possible languages even for a single letter alphabet = {z}, 8

Text from page-4

In the above description of concatenation we find very commonly, that for a single letter alphabet when we concatenate c with d, we get the same word as when we concatenate d with c, that is cd = dc But this relationship does not hold for all languages. For example, in the English language when we concatenate “Ram” and “goes” we get “Ram goes”. This is, indeed, a word but distinct from “goes Ram”. Finite Automata and Languages Now, let us define the reverse of a language L. If c is a word in L, then reverse (c) is the same string of letters spelled backward. The reverse (L) = {reverse (w), w L} Example 6: Reverse (zzz) = zzz Reverse (173) = 371 Let us define a new language called PALINDROME over the alphabet = {a,b}. PALINDROME = { , and all strings w such that reverse (w) = w} = { , a, b, aa, bb, aaa, aba, bab, bbb, aaaa, abba, …} Concatenating two words in PALINDROME may or may not give a word in palindrome, e.g., if u = abba and v = abbcba, then uv = abbaabbcbba which is not palindrome. 1.2.2 Kleene Closure Definition Suppose an alphabet , and define a language in which any string of letters from is a word, even the null string. We shall call this language the closure of the alphabet. We denote it by writing * after the name of the alphabet as a superscript, which is written as *. This notation is sometimes also known as Kleene Star. For a given alphabet , the language L consists of all possible strings, including the null string. For example, If = {z}, then, * = L1 = { , z, zz, zzz …..} Example 7: If = {0, 1}, then, * = { , 0, 1, 00, 01, 10, 11, 000, 001 …..} So, we can say that Kleene Star is an operation that makes an infinite language of strings of letters out of an alphabet, if the alphabet, . However, by the definition * alphabet may also be . In that case, is finite. By “infinite language, we mean a language with infinitely many words. Now, we can generalise the use of the star operator to languages, i.e., to a set of words, not just sets of alphabet letters. Definition: If s is a set of words, then by s* we mean the set of all finite strings formed by concatenating words from s, where any word may be used as often. Example 8: If s = {cc, d}, then s* = { or any word composed of factors of cc and d} = { or all strings of c’s and d’s in which c’s occur in even clumps}. The string ccdcccd is not in s* since it has a clump of c’s of length 3. {x : x = or x = (cc) i1 d j1 (cc) i 2 d j2 ......(cc) i m (d) jm } where i1, j1,….. im, jm 0 Positive Closure: If we want to modify the concept of closure to refer to only the concatenation leading to non-null strings from a set s, we use the notation + instead of *. This plus operation is called positive closure. 9

Lecture Notes