Download - Handout 3.docx

Transcript

Tahir Naseem/Handout 3-1-Theory of Automata and Formal LanguagesLecture 3

Objectives Defining Languages Kleen Closure Positive Closure Concatenation Reverse Palindrome Lexicographic OrderDefining LanguagesExamples to define LanguagesExample 1L1 = All strings that contain the substring to Over1 = {a, b, , z} stop, to, toe are in L1 , oyster are not in L1 L1 = {x 1*: x contains the substring to} Example 2L2 = x 2*: x is divisible by 7}Over2 = { 0, 1, , 9} { 7, 14, 21, }

Example 3L3 = {s#s: s {a, b, , z}*} ab#ab is in L3 ab#ba is not in L3 a##a# is not in L3Example 4L4 = The language of all strings consisting of n 0s followed by n 1s for some n0 Over = {0, 1} {, 0, 1, 01, 001, 0011,.} is invalid because 0 and 1 cannot be occurred alone; both should be occurred with equal time. {, 01, 001, 0111, 0010, 0011,.} is also invalid because 001l cannot be occurred ; all of 0s should be appear before 1s. {, 01, 0011, 00011, 000111,.} is valid according to statement. Example 5L5 = The language of all strings consisting of equal no. of 0s and 1s. Over = {0, 1} L5 = { , 01, 10, 1100, 0011, 1001,0110,.}Example 6L = {x, xx, xxx, xxxx,}Over = {x} L= { xn for n N}Kleen Closure Language of all possible words called kleen closure. It is denoted by *Example = {a b}* ={ , a, b, ab, ba, aa, bb, }Positive Closure Language of all possible words excluding empty string called positive closure. It is denoted by +Example = {a b}+ ={ a, b, ab, ba, aa, bb, }Concatenation Concatenation is an operation that is performed on two languages. In the result of concatenation of language combination( word from one language are combined with words of another language). The resultant string may not belong to that language as Language of odd length over ={x} is {x, xxx, xxxxx,} If words of above language are concatenated with x the resultant language will be even length language; so resultant words not belong to the original language. The resultant string may also belong to that language as Language of all strings (*) over = { a b} is {, a, b, aa, ab, ba, bb,..} If words of language are concatenated with a then resultant word will also belong to the original language.Reverse If x is a word in some language L, then reverse (x) is the string of letters spelled backward, called the reverse of x, even if this backward string is not a word in L. Example: Language of all strings that starts with a and having at least one a over ={a b} is {a, ab, aba, abb, abba,} reverse of a and aba, abba will word of original language reverse of ab and abb is not word of original language.Palindrome: For a word x; if reverse of word is equivalent to that word then we say that particular word is palindrome Palindrome ={, and all string such that reverse(x) = x} Example: reverse (aba) = aba so is palindrome

Lexicographic Order Order according to size, from shorter to longer length. {, a, b, aa, bb, ab, ba, aaa, aba, aab, } is in lexicographic order {, ab, abbb, a, b, aa, bb, abaa, ba, aaa, aba, aab, } is not in lexicographic order.