Design an attribute grammar recognizing the language consisting of binary strings containing the same number of 0’s and 1’s. Explain your construction
Design an attribute grammar recognizing the language consisting of binary strings containing the same number of...
Design a non-ambiguous grammar generating the language consisting of all binary strings, which contain an odd number of 0’s and an odd number of 1’s. Justify correctness of your construction.
13.) Write a grammar for the language consisting of strings that have n copies of the letter a followed by one more number of copies of the letter b, where n>0. For example, the strings abb, aaaabbbbb, and aaaaaaaabbbbbbbbb are in the language but a, ab, ba, and aaabb are not. Answer the aaaaaabbbbbbbh are in the languagebr 14.) Draw parse trees for the sentences abb and aabbb, as derived from the grammar of Problem 13. Answer:
Write a context-free grammar for the language where all strings are of even length and the first half of the string is all 0’s, but it must be an odd number of 0’s
1. Who are language descriptions intended for? Consider the following grammar: ab b | b a | a Which of the following sentences are in the language generated by this grammar? (DONE) a) baab ==> YES b) bbbab ==> NO c) bbaaaaaS ==> NO d) bbaab ==> YES 2. Write a BNF grammar for the language consisting of binary strings (any combination of 0s and 1s) of at least 2 digits.
Design a regular language where every sentence has to start with any number of strings 101 (any number is none or more), then repeats 00 any number of times, then repeats 01 at least once. Use regular expression notation. Clarification: alphabet is {0,1}. 'string' is the same as program, but here the programs are written using binary alphabet in a silly language.
DO NUMBER 4 AND 5 2. Let {acgt} and let L be the language of strings consisting of repeated copies of the pairs at, ta, cg, gc. Construct both a DFSM to accept the language and a regular expression that represents the language 3. Let a,b. For a string w E X", let W denote the string w with the a's and b's flipped. For example, for w aabbab: w bbaaba wR babbaa abaabb {wwR Construct a PDA to accept...
Homework. Section 5.1 #m}. Hint: Think of this language 1. Design a context-free grammar for the language {a" b n as the union of {a"b" | n > m} and {a") n<m}. 2. Consider the context-free grammar G = (N,T, P, S), defined by N = {S}, T = {a,b), and P = {S + Sbs | bSaS | }. Find derivations, and corresponding parse trees, for the following strings: aaabbb, bbbaaa, ababab. What is L(G)?
DO NUMBER 3 2. Let {acgt} and let L be the language of strings consisting of repeated copies of the pairs at, ta, cg, gc. Construct both a DFSM to accept the language and a regular expression that represents the language 3. Let a,b. For a string w E X", let W denote the string w with the a's and b's flipped. For example, for w aabbab: w bbaaba wR babbaa abaabb {wwR Construct a PDA to accept the language:...
For each of the following, construct context-free grammars that generate the given set of strings. If your grammar has more than one variable, we will ask you to write a sentence describing what sets of strings you expect each variable in your grammar to generate. For example, if your grammar were: S → EO E → EE CC 0+ EC C+01 We would expect you to say “E generates (non-empty) even length binary strings; O generates odd length binary strings;...
For a string s ∈ {0, 1} let denote the number represented by in the binary * s2 s numeral system. For example 1110 in binary has a value of 14 . Consider the language: L = {u#w | u,w ∈ {0, 1} , u } , * 2 + 1 = w2 meaning it contains all strings u#w such that u + 1 = w holds true in the binary system. For example, 1010#1011 ∈ L and 0011#100 ∈...