Sketch of Solutions to Exercises

1.4.1

1.4.2

1.4.3

(a)
For a given G =< N, S, P, S > and a string w try all derivations S ==> g1 ==> g2 ==> ... ==> gi for i > 1 until the string w = gi is encountered.
(b)
For a given G =< N, S, P, S > try all derivations S ==> g1 ==> g2 ==> ... ==> gi until a string of terminal sybols is encountered.

1.4.4 For a given (G, x) try all derivations S ==> *g s.t. |g| < |x|.

1.4.5 For a grammar G let Li(G) denote the set of all strings in L(G) of length i. For the given (G1, G2) determine Li(G1) and Li(G2), i = 0, 1, 2, ... Declare G1 /= G2 when an i such that Li(G1) /= Li(G2) is reached.

1.4.6 Type 3 grammars are special cases of type 0 grammars. As a result

Consequently, (a) No. (b) Yes. (c) Yes (d) No.

1.4.7

(a)
Given Q(x1, ..., xn) try all assignments to (x1, ..., xn) in canonical ordering, i.e.,
  0, ..., 0    0's only 
  O, ..., 1    0's and 1's only 
       . 
       . 
       . 
  1, ..., 1 
  0, ..., 2    0's,  1's, and 2's  only 
       . 
       . 
       . 
  2, ..., 2 
       . 
       . 
       . 
(b)
Given (P 1, P 2) try all inputs to P 1 and P 2 in canonical ordering.