Question

In: Computer Science

Consider two languages A and B where A is a context free language and B is...

Consider two languages A and B where A is a context free language and B is a regular language. Show that the set difference, A-B, must also be context free.

Also show that B-A may not be context free

Solutions

Expert Solution

Context free language is a language that is accepted by a context free grammar and it is processed by pushdown automata. It is described using context free grammar. A language is said to be context free if and only accepted by push down automata. A context free language is closed under union,concatenation,closure and homomorphism.

Regular language is a language that are expressed using regular expression.It is also expressed using deterministic or non-deterministic finite automata or state machine. The closure properties of regular languages include union, concatenation, intersection, kleen closure and compliment.

Every regular language is accepted by finite automata , Every finite automata is automatically a pushdown automata which ignores stack., so we can conclude that every regular language is also a context free language.

A and B are the languages given in the question. A is a context free language and B is a regular language.

Answer to first question

The intersection of context free language and regular language is context free.

Here we have to prove that A-B(set difference) is context free.

we can write A - B = A B' where B' is compliment of B.

B' is regular because all regular languages are closed under compliment. Therefore A   B' is a context free by the above defined law. i.e the intersection of context free language and regular language is also context free, because A B.

So A - B is context free.

Answer to second question

Show that B - A may not be context free.

We can write, B - A = B A' , but A' is not context free because context free languages are not closed under compliment. So that B - A is need not be context free.


Related Solutions

(a) How Context Free languages are different from Regular languages. (b) What are the automata accepting...
(a) How Context Free languages are different from Regular languages. (b) What are the automata accepting those languages and how they are different from DFA and NFA. (c) How the grammar of Context Free Languages looks different from those in Regular languages.
Closure under Context-Free Languages Show that the following operations are closed under context-free languages: union concatentation...
Closure under Context-Free Languages Show that the following operations are closed under context-free languages: union concatentation Kleene star
Consider the context-free grammar G = ( {S}, {a, b}, S, P) where P = {...
Consider the context-free grammar G = ( {S}, {a, b}, S, P) where P = { S -> aaSb | aab }. Construct a NPDA M that such that L(M) = L(G). I would like the transition graph for this NPDA please.
Prove the following Closure Properties with respect to Context Free Languages. 1. Show that Context Free...
Prove the following Closure Properties with respect to Context Free Languages. 1. Show that Context Free Languages are Closed under union(∪), concatenation(·), kleene star(*). (Hint: If L1 and L2 are Context Free languages then write Context Free grammar equivalent to L1 ∪ L2, L1 · L2, L∗ 1 ) 2. Show that if L1 and L2 are Context Free Languages, then L1 ∩ L2 is not necessarily Context Free. (Hint: Use Proof by Counter Example)
Given two languages A and B, let A/B denote the language {w | w x ∈...
Given two languages A and B, let A/B denote the language {w | w x ∈ A for some x ∈ B}. Show that if A is a context-free language and B is a regular language, then A/B is a context-free language. hint (construct PDAs)
Prove that all regular languages are context free. Note: Proof must proceed by structural induction on...
Prove that all regular languages are context free. Note: Proof must proceed by structural induction on regular expressions Please prove by Structural Induction. Will Upvote for correct answer. Thanks
Give context free grammars for the languages below. To avoid mistakes, I recommend using scratch paper...
Give context free grammars for the languages below. To avoid mistakes, I recommend using scratch paper to check that your grammars produce the right set of string. This question is structured so that nonterminals (and associated rules) from an earlier subquestion might be useful in a grammar for a later sub-question. That’s why, rather than “S” as the start symbol, we will used different start symbols for each part. If you do use a nonterminal from an earlier sub-question, say...
Give context free grammars for the languages below. To avoid mistakes, I recommend using scratch paper...
Give context free grammars for the languages below. To avoid mistakes, I recommend using scratch paper to check that your grammars produce the right set of string. This question is structured so that nonterminals (and associated rules) from an earlier subquestion might be useful in a grammar for a later sub-question. That’s why, rather than “S” as the start symbol, we will used different start symbols for each part. If you do use a nonterminal from an earlier sub-question, say...
Use Context-Free Pumping Lemma to prove that that following languages over the alphabet {'x', 'y', 'z'}...
Use Context-Free Pumping Lemma to prove that that following languages over the alphabet {'x', 'y', 'z'} are NOT context-free (a) {xjy2jzj : j > 0} (b) { xmynzk : m, n, k ≥ 0 and k = min(m,n) }
Consider two containers A and B where A is a rigid container and B is a...
Consider two containers A and B where A is a rigid container and B is a container with a massless, frictionless piston that maintains constant pressure. NH3 (g) is injected into both containers and allowed to come to equilibrium. At equilibrium, 2 atm of Argon gas is injected into each container. Explain any changes (up, down or no change) to the equilibrium concentrations of NH3 , N2 and H2 ? a) do the partial pressures of container A change or...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT