A → -B | 0C | 1C
B → 0C | 1C
C → 0C | 1C | bE | .D
D → 0D | 1D | bE
E → ε
Other answers are possible, perhaps by noting that L(M) = L(r) for the regular expressionOne grammar based on this observation would have start symbol B and productions
B → U | -U
U → Sb | S.b | S.Sb
S → 0 | 1 | 0S | 1S
The subgraph isomorphism problem is in NP, since for each vertex in S one may guess the corresponding vertex in G. If |S| and |G| are the number of vertices in S and G respectively, this requires |S| guesses of at most lg |G| bits each. That edges exist between corresponding vertices in G iff they exist between the original vertices in S requires |S|2 lookups in an adjacency matrix or adjacency list. In each case, as well as for showing that the guessed vertices are all distinct, the amount of work required is polynomial in the size of the instance, which under our assumptions is at least |G| + |S|.
Note that showing NP-completeness of the clique problem is relatively easy -- it was part of last year's exam.