Question

In: Computer Science

Prove that the language consisting of all the words that have equal number of a's and...

Prove that the language consisting of all the words that have equal number of a's and c's and exactly twice as many b's is not context-free.

Solutions

Expert Solution

The language is not context free. This can be proved by pumping lemma as follows:

Consider a string z that belongs to the above language(L) such that length of string z, |z| >= n.

One such z will be ancnb2n.

If this language were context free, then by pumping lemma, it should be possible to find u,v,w,x,y such that :

z = uvwxy and

(1) |vwx| ≤ n
(2) |vx| ≥ 1
(3) for all i ≥ 0: uviwxiy ∈ L

i.e., we must be able to pump v and x any number of times(including 0 times) and still the resulting string must be in the given language.

Now let's look at the possibilities for vwx.

vwx cannot contain all of a, c and b as the length of vwx is less than or equal to n. Thus following cases are possible for vwx.

i) vwx contains a and c. Then for i=0: uv0wx0y = uwy. Since the length of vx is greater than or equal to 1, this essentially decreases the total number of a's or c's in the string, however the number of b's remains the same. This means that total number of b's will not be twice the number of a's or c's. Thus, the resulting string is not in L.

ii) vwx contains c and b. Then again for i=0  uv0wx0y = uwy. Again the number of b's or c's decreases but number of a's remains the same. Again the resulting string will not be in L.[Number of c's decreases - it is not equal to n, Number of b's decreases: b's will be less than twice the number of a's]

iii) vwx consists of only either a's or b's or c's. Then for i=0: uv0wx0y = uwy. In this case number of one of either a's or b's or c's will decrease while others will remain same which will violate the property of strings in L.

Thus, it can be seen that in either case, it is impossible to find a combination of u,v,w,x,y that satisfies pumping lemma.

Hence, we have found a string in L with length greater than or equal to n but does not satisfy pumping lemma. So, the language is not context free.


Related Solutions

Prove that {0n1n2n:n≥1} is not a regular language. The decimal notation for a number is the...
Prove that {0n1n2n:n≥1} is not a regular language. The decimal notation for a number is the number written in the usual way, as a string over the alphabet {0,1,⋯9}. For example, the decimal notation for 13 is a string of length 2. In unary notation, only the symbol “I” is used; thus 5 would be represented as IIIII in unary notation. Show that each of the following is or is not a regular language. (For regular languages, write down its...
Prove that the range of a matrix A is equal to the number of singular non-null...
Prove that the range of a matrix A is equal to the number of singular non-null values of the matrix and Explain how the condition number of a matrix A relates to its singular values.
t was determined that the percentage of​ a's in the English language in the 1800s was...
t was determined that the percentage of​ a's in the English language in the 1800s was 12% A random sample of 600 letters from a current newspaper contained 80 a's. Test the hypothesis that the proportion of​ a's has changed in modern​ times, using the 0.05 level of significance. Treat the newspaper as a random sample of all letters used. Determine the​ z-test statistic. z= Answer _____ ​(Round to two decimal places as​ needed.) What is the ​p-value = Answer...
Using the pumping lemma, prove that the language {1^n | n is a prime number} is...
Using the pumping lemma, prove that the language {1^n | n is a prime number} is not regular.
The Declaration of Independence contains the famous words that “all men are created equal” and that...
The Declaration of Independence contains the famous words that “all men are created equal” and that all “unalienable rights to life, liberty, and the pursuit of happiness.” Has American society lived up to the ideals mentioned in this sacred document or has the nation fallen short? You may discuss this question up through the modern era.
Let the cardinal number of N, the set of all natural numbers, be א0. Prove that...
Let the cardinal number of N, the set of all natural numbers, be א0. Prove that the product set N × N = {(m,n);m ∈ N,n ∈ N} has the same cardinal number. Further prove that Q+, the set of all positive rational numbers, has the cardinal number N_0. Hint: You may use the formula 2^(m−1)(2n − 1) to define a function from N × N to N, see the third example on page 214 of the textbook.
Prove that all parallel lines have the same vanishing point.
Prove that all parallel lines have the same vanishing point.
Prove that for all integers n ≥ 2, the number p(n) − p(n − 1) is...
Prove that for all integers n ≥ 2, the number p(n) − p(n − 1) is equal to the number of partitions of n in which the two largest parts are equal.
the language is matlab 1) Write a code that will print a list consisting of “triangle,”...
the language is matlab 1) Write a code that will print a list consisting of “triangle,” “circle,” and “square.” It prompts the user to choose one, and then prompts the user for the appropriate quantities (e.g., the radius of the circle) and then prints its area. If the user enters an invalid choice, the script simply prints an error message. For calculating the area, create separate functions for each choice. Name them as calcTriangle, calcCircle, calcSquare respectively, which are only...
Prove that there exists a negative number.
Prove that there exists a negative number.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT