-2

I have come up with:

S→0SX | 1SY | 2SZ | SS | ϵ
X→1
Y→0 | 2
Z→1

I think I am wrong. Any directions?

Desperado
  • 49
  • 7

1 Answers1

2

These observations may help when using induction:
1) Since the number of $1$s is equal to the sum of numbers of $0$s and $2$s, any string in $L$ is of even length.
2) Starting from $S$ any number of steps of a derivation without using $S \rightarrow SS \ | \ \epsilon$ results in a string $a_1a_2 \dots S \dots a_{n-1}a_n$ where number of $1$s is equal to the sum of $0$s and $2$s.
3) If $x = a_1a_2 \dots a_{n-1}a_n \in L$ ($|x|$ is even and number of $1$s in $x$ is equal to the total number of $0$s and $2$s) then $x$ has at least one of substrings $12, 21, 01$ or $10$ which is derived from $S \rightarrow 0S1 \ | \ 1S0 \ | \ 1S2 \ | \ 2S1$.

fade2black
  • 9,905
  • 2
  • 26
  • 36