You are on page 1of 6
Formal Language Selected Homework Chapter 3.3 H Construct right- and left-linear grammars for the language L= {a :n22,m>3}. | pen Dhaosam 1 5peoua there op Lichy* Csk ip) GW) Find a regular grammar for the language L = {a"b™ : n +m is even}. (18) Find regular grammars for the following languages on (a, 5}. (a) L= {wing (w) and ng(w) are both even}. (0) L = {w: (ng (w) ~ ms (w)) mod 3 = 1} DH Let G, = (Vi,8, 51, Pi) be right-linear and G2 = (V2,E, S2, Pa) be a left- \~ linear grammar, and assume that Vi and V2 are disjoint. Consider the linear | grammar G = ({S}UVi U V2, 5, S, P), where S is not in Vi U V2 and P {8 — S;|S2} U.P; U Ps. Show that Z(G) is regular. Sil. 4. Right linear grammar: S > aaA A aA\B B boc C > bO\r Left linear grammar: S —» Abbb A ADB B= Caa C > Cald 11. Split this into two cases: (i) n and m are both even and (ii) n and m are both odd. The solution then falls out easily, with $+ aaS|A 5/045’ laB A= bbAIA 8 obBlo taking care of case (i). ", Sniftal vavable Sp» 515” 13. (a) First construct a dfa for L. This is straightforward and gives transitions such as 6 (qo, a) = 41,5 (40,6) = a2, 6 (1,4) = go; (gn,0) 4 (2,4) = 93,5 (g2,6) = a0, 5 (qs,@) = 42,4 (as,b) = a1, e with qo the initial and final state. Then the construction of The- orem 3.4 gives the answer 4g — aq [bol A, a — baslago, 4% — ags|bao, a3 > age|ban (see nex re 17. Obviously, L(G1) is regular, as is L(G2). We can show that their union is also regular by constructing the following dfa. fa for L(G,) ala for L(G,) ‘The condition that V; and V2 should be disjoint is essential so that the two nfa’s are distinct. So at $68,,4) = 4 OZ2 OL DO sareh QF Ste) #% o $ (3,029, 4,7 62,| 64, §(31/69°%

You might also like