2

Given G = {a, b, c, d}, {S, X, Y}, S, {S->XY, X->aXb, X->ab, Y->cYd, Y->cY, Y->cd}}

Prove that |w|c-|w|d+|w|a≥|w|b

|w|a is how many 'a's there are in the string. This makes sense that there will be more (or the same amount of) 'c's than 'd's as there is no production rule that makes a d without making a c while 'c's can be made without 'd's using Y->cY. I need to formally prove this using induction on the number of derivation steps and have been trying all day. Any help appreciated.

Matthew Cassar
  • 223
  • 2
  • 5
  • 13

1 Answers1

0

We will use this grammar

S -> XY
X -> aXb
X -> ab
Y -> cYd
Y -> cY
Y -> cd

And show the language of the grammar has |w|c - |w|d + |w|a ≥ |w|b. The proof is by induction on the number of applications of the productions X -> aXb, Y -> cYd and Y -> cY.

Base case: there is only one string derived without invoking these productions, namely, abcd, and it satisfies |w|c - |w|d + |w|a >= |w|b since 1 - 1 + 1 >= 1.

Induction hypothesis: assume the claim holds for all strings derived using up to and including k applications of one of the three productions given above.

Induction step: we show that the claim holds for strings derived by k+1 applications of the productions. Since each of our productions has the same type and number of nonterminals in the LHS and RHS, and since the RHS also contains terminals in all cases, there is a shorter string in the language derived with at least one fewer application of these productions. By the hypothesis, that shorter string has |w|c - |w|d + |w|a >= |w|b. For our string, there are three cases:

  1. X -> aXb was the k+1st production applied. This increases |w|a and |w|b by 1, and we have |w|c - |w|d + |w|a + 1 >= |w|b + 1 iff |w|c - |w|d + |w|a >= |w|b, which we have already determined.
  2. Y -> cYd was the k+1st production applied. This increases |w|c and |w|d by 1, and we have |w|c + 1 - (|w|d + 1) + |w|a >= |w|b which holds iff |w|c - |w|d + |w|a >= |w|b, which we have already determined.
  3. Y -> cY was the k+1st production applied. This increases |w|c by 1, giving |w|c + 1 - |w|d + |w|a >= |w|b which is true since |w|c + 1 - |w|d + |w|a > |w|c - |w|d + |w|a >= |w|b.

In each of the three possible cases of the choice for the k+1st production, the string derived in k+1 productions maintains the property. By induction, the property holds for all numbers n of applications of these productions.

Patrick87
  • 27,682
  • 3
  • 38
  • 73