1

I need help proving the set difference between a context free grammar A and a regular language, B, is a context free language.

I'm trying to prove by example like this:

Let A = {a^n b^n | n >= 1}

Let B = {w {a,b}* | w has atleast three a's }

Then A-B should be {a^n b^n | 1 <= n < 3 }, ex. (ab, aabb)

If A-B is a context free language, then there must some context free grammar G than can represent it.

G = ({S}, {a,b}, P, S)

S->aAb | ab
A->ab

G is context free because it can be rewritten in Normal Chomsky form :

S -> BD | BC
D -> AC
A -> BC
B -> a
C -> b

Thus the result of A - B must also context free.

I'm not sure this is the correct way to approach this problem. Any assistance is welcome.

1 Answers1

1

Say we have a CF language C and a regular language R. Then there exists a PDA P and a DFA D where L(P)=C and L(D) = R.

So let us construct a new PDA that simulated C and D and only accepts if a word is accepted by C and rejected by D. Let us call this PDA M. So if x is in L(M) then x is in C and not in R so L(M)=C-R.

Therefore the set difference of a CF and Regular language is CF. QED

The strategy I used here was to try an used facts about generic machines that exist as a way to make a constructive proof detailing a machine that would accept a set difference. Also note that proof by example is not a proof, you might be thinking of proof by construction which very different.

Garrigan Stafford
  • 1,331
  • 9
  • 20