Automata Theory - Finding a regular expression for each of the following languages over {a,b} or {0,1}:
I've written the solution . Please show steps on how to approach the problems that I mentioned in parentheses. The ones where I put my own regular expression check and see if it's still right. Thanks
Strings with ....
odd # of a's ---> (b*ab*ab*)b*ab*
even # of 1's ---> 0*(10*10*)* ---> my answer was 0*10*10* (is this still right?)
start & end with same letter --> a(a+b)*a + b(a+b)*b + a + b ----> my answer was a(a+b)*a = b(a+b)*b (is this still right?)
no occurrence of 00 ----> 1*(011*)*(0+1)* --->(show steps to how to approach this)
exactly 1 occurrence of 00 ---> 1*(011*)*00(11*0)*1* ---> show steps to how to approach this
1)
odd # of a's ---> (b*ab*ab*)b*ab*
even # of 1's ---> 0*(10*10*)* [0*10*10* regex represents the strings containing only 2 1's. It does not accept strings contanining 4, 6 or 8 1's and hence, it is not correct.]
start & end with same letter --> a(a+b)*a + b(a+b)*b + a + b (= is not a valid character and does not work with regex, and moreover your regex does not accept strings "a" or "b", and hence wrong).
no occurrence of 00 ----> ((0?(1+0?)+)|0)
Explained:
Regular expressions such as 0?(1+0)* will match against any part of the string so it will match the middle part of a string such as 000011000000, it will match the 0110. To check that the whole string matches need to add the start and end of string anchors, giving ^0?(1+0)*$. This will also match an empty string. To match against a non-empty string we could use ^0?(1+0)+$ but this will not match a string with a single 0. So we need to add an alternative (using |) to match the 0, leading to the total expression ((0?(1+0?)+)|0)
exactly 1 occurrence of 00 ---> 1*(011*)*00(11*0)*1*
Explained:
1*(011*)* represents all string which does not contain any consecutive 0. Then, followed by a single occurrence of 00 and again the regex (11*0)* represents the strings not containing consecutive 0s. And, finally the string can end with any number of 1s, done using 1*.
Automata Theory - Finding a regular expression for each of the following languages over {a,b} or...
For each of the languages listed below, give a regular expression that generates the lan- guage. Briefly justify your answer. (a) The set of strings over (a, b such that any a in the string is followed by an odd number of b's. Examples: bbbab E L, but abb f L. (b) The set of strings over fa, b in which there is an a in every even position and the total number of b's is odd, where the first...
4. A regular expression for the language over the alphabet fa, b) with each string having an even number of a's is (b*ab*ab*)*b*. Use this result to find regular expressions for the following languages a language over the same alphabet but with each string having odd number of a's. (3 points) a. b. a language over the same alphabet but with each string having 4n (n >- 0) a's. (3 points)
Provide regular expressions for the following languages: a.) The set of strings over {0,1} whose tenth symbol from the right end is 1. b) The set of strings over {0,1} not containing 101 as a sub-string. ***IMPORTANT: PLEASE SHOW ALL WORK AND ALL STEPS, NOT JUST THE ANSWERS!!!
Regular expressions, DFA, NFA, grammars, languages Regular Languages 4 4 1. Write English descriptions for the languages generated by the following regular expressions: (a) (01... 9|A|B|C|D|E|F)+(2X) (b) (ab)*(a|ble) 2. Write regular expressions for each of the following. (a) All strings of lowercase letters that begin and end in a. (b) All strings of digits that contain no leading zeros. (c) All strings of digits that represent even numbers. (d) Strings over the alphabet {a,b,c} with an even number of a's....
1. Write regular expressions to capture the following regular languages: (a) The set of binary strings which have a 1 in every even position. (Note: odd positions may be either 0 or 1.) (b) The set of binary strings that do not contain 011 as a substring. (c) Comments in Pascal. These are delimited by (* and *) or by { and }, and can contain anything in between; they are NOT allowed to nest, however. 2. Write a DFA...
Automata Theory I've given my answer to 3d. Is it correct? If not, please correct it. Thanks 3. Context-free languages are useful for the definition of programming languages. For example, we have looked at grammars for defining Lisp and C. (a) Give a context-free language that is not regular, establishing the added power of CFL (b) What language is accepted by the following grammar: (c) Build a context-free grammar for the language (wb w-wR, k 0 a,by (d) Build a...
Provide a regular expression for the following languages: (a) the set of all strings over {a, b} that start with ab and end with ba, (b) the set of strings over {a, b} where four consecutive occurrences of both letters occur in every word.
8 Find CFGs that for these regular languages over the alphabet a, b. Draw a Finite Automata first and use this to create the CFG (a) The language of all words that consist only of double letters (aa or bb) (b) The set of all words that begin with the letter b and contains an odd number of a's or begin with the letter a and contains an even number of b's.
3) Construct a regular expression defining each of the following languages over the alphabet {a, b}. (a) L = {aab, ba, bb, baab}; (b) The language of all strings containing exactly two b's. (c) The language of all strings containing at least one a and at least one b. (d) The language of all strings that do not end with ba. (e) The language of all strings that do not containing the substring bb. (f) The language of all strings...
1. (10 marks) Prove that the following languages are non-regular, using the Pumping Lemma. (a) (10 marks) L1 = {W € {0,1}* ||w| is odd, and the symbol in the very middle of the string is 0} For example, the strings 01011, 000000000 and 0 are in L1.]