


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Show that the following languages are not regular.
{ wtw : w, t ∈ { 0 , 1 }+
} . Solution: We prove that L 4 is nonregular by the pumping lemma. Let p be any given positive integer, and let s = 0p 110 p1. Clearly s ∈ L 4 (with w = 0p1 and t = 1), and |s| = 2p + 3 > p. Write s = xyz, where y 6 = ε and |xy| ≤ p. Since s starts with p 0’s and |xy| ≤ p, just as above y consists of only 0’s and at least one 0. Thus
xy^2 z = 0q 110 p1 where q > p. We claim that xy^2 z can not be written in the form wtw, where w, t ∈ { 0 , 1 }+. Write x^2 z = utv, where u, t, v are all nonempty. If the middle substring t contains the first 1 in xy^2 z, then u would end with 0 and v would end with 1, thus u 6 = v. If t does not contain the first 1 in xy^2 z, then |u| ≥ q + 1 and |v| ≤ p + 1, and since q > p, |u| > |v| and hence u 6 = u. Therefore xy^2 z 6 ∈ L 4 , and thus L 4 is nonregular. 2
Problem 1.31 on Page 88 of Sipser. Show that regular languages are closed under reversal, that is, if A is regular then so is AR.
Solution: Let A be any regular language, and let M be a DFA recognizing A. To show that AR is regular, we construct an NFA N that recognizes AR, which we describe as follows. In N we keep all the states of M and reverse the direction of all the transition arrows in N. We set the accept state of N to be the start state of M. We also introduce a new state q 0 as the start state of N which goes to every accept state of M by an ε-transition.
Claim 1 AR^ ⊆ L(N ).
Proof: For every w ∈ A = L(M ), the path that w follows in M starts at the start state of M and ends at one of M ’s accept states. If we input wR^ to N , it starts at the new start state q 0 and forks into different paths starting at each of the accept state of M. The computation can reach the accept state of N (that is, the start state of M ) by following the same path as w in M but in the opposite direction. Thus wR^ ∈ L(N ). 2
Claim 2 L(N ) ⊆ AR.
Proof: For every x ∈ L(N ), there is a path P starting at q 0 , going through some accept state of M , say qa, and stopping at the unique accept state of N (that is, the start state of M ). If we input xR^ to M , we can go from M ’s start state to qa in M by following the path P in the opposite direction. Thus x ∈ AR. 2
Therefore, L(N ) = AR^ and AR^ is regular. 2
Problem 1.48 on Page 90 of Sipser.
Solution: We observe that a string w over { 0 , 1 }∗^ contains an even number of occurrences of 01 and 10 if and only if w starts and ends with the same symbol. (Prove this.) Therefore the language D is described by the regular expression 0Σ∗ 0 ∪ 1Σ∗1, and hence regular. 2
Give context-free grammars that generate the following languages.
Problem 2.19 on Page 130 of Sipser. For extra credit, give a rigorous proof of your claims.
Solution: The given grammar G describes exactly the language consisting of all strings not of the form anbn. (Prove this by induction.) Thus L(G) = {anbn^ : n ≥ 0 }, and is generated by the grammar
S → aSb | ε.
2
Parts (b) and (d) of Problem 2.6 on Page 129 of Sipser.
{ x 1 # · · · #xk : k ≥ 1, xi ∈ {a, b}k, and xi = xRj for some i and j
} . Solution:
S → U P V P → aP a | bP b | T | ε T → #M T | # U → M #U | ε V → #M V | ε M → aM | bM | ε
2