Chapter 16

Regular Expressions

[14/100%]
Show
LaTeX
Problem 247

Determine the concatenation for the following pairs of languages L1L_{1} and L2L_{2}:

?
(a)

L1={a,ab,abb}L_{1}=\left\{ a, a b, a b b\right\} and L2={ε,a,b,ab,ba}L_{2}=\left\{ \varepsilon , a, b, a b, b a\right\};

(b)

L1={ε,a,ab,abb}L_{1}=\left\{ \varepsilon , a, a b, a b b\right\} and L2={a,b,abb,ba}L_{2}=\left\{ a, b, a b b, b a\right\};

(c)

L1={ε,a,b,ab,aba}L_{1}=\left\{ \varepsilon , a, b, a b, a b a\right\} and L2={ε,a,b,ab,ba}L_{2}=\left\{ \varepsilon , a, b, a b, b a\right\}.

Problem 248

Let L={baa,bab,bba,bbb}L=\left\{ b a a, b a b, b b a, b b b\right\}. Which of the following languages is the iteration L∗L^{*} of this language?

?
(a)

{w:w=bw′ and ∣w∣ is divisible by 3}∪{ε}\left\{ w: w=b w^{\prime } \text{ and } \left|w\right| \text{ is divisible by 3}\right\} \cup \left\{ \varepsilon \right\};

(b)

{w:w=bw′ and ∣w∣⩾3}∪{ε}\left\{ w: w=b w^{\prime } \text{ and } \left|w\right| \geqslant 3\right\} \cup \left\{ \varepsilon \right\};

(c)

{w:w=x1x2x3…x3n,xi∈{a,b} and x3i+1=b for all i<n}∪{ε}\left\{ w: w=x_{1} x_{2} x_{3} \ldots x_{3 n}, x_{i} \in \left\{ a, b\right\} \text{ and } x_{3 i+1}=b \text{ for all }i<n\right\} \cup \left\{ \varepsilon \right\};

(d)

{w:w=bw′ and ∣w∣⩾12}\left\{ w: w=b w^{\prime } \text{ and } \left|w\right| \geqslant 12\right\}.

Problem 249

Prove the correctness of the regular expression in Example 77 on p. 316: the expression (1+01+001)∗(ε+0+00)(1+01+001)^{*}(\varepsilon +0+00) is claimed to represent the language of all words over {0,1}\{ 0,1\} that do not contain the substring "000".

?
Problem 250

Determine which language is represented by the following expressions:

?
(a)

0∗1∗00^{*} 1^{*} 0;

(b)

01∗001^{*} 0;

(c)

(01∗)∗0\left(01^{*}\right)^{*} 0;

(d)

(00+11+(01+10)(00+11)∗(01+10))∗\left(00+11+(01+10)(00+11)^{*}(01+10)\right)^{*}.

Problem 251

Prove the equivalences of Proposition 104 on p. 315: for any regular expressions r,q,pr, q, p,

  1. r+p≡p+rr+p \equiv p+r (commutativity of union);

  2. (r+p)+q≡r+(p+q)(r+p)+q \equiv r+(p+q) (associativity of union);

  3. (rp)q≡r(pq)(r p) q \equiv r(p q) (associativity of concatenation);

  4. (r∗)∗≡r∗(r^{*})^{*} \equiv r^{*} (idempotence of iteration);

  5. (r+p)q≡rq+pq(r+p) q \equiv r q+p q (distributivity).

?
Problem 252

Prove the following equivalences for regular expressions:

?
(a)

p∗(p+q)∗≡p∗(qp∗)∗≡(p+qp∗)∗≡(p+q)∗p^{*}(p+q)^{*} \equiv p^{*}\left(q p^{*}\right)^{*} \equiv \left(p+q p^{*}\right)^{*} \equiv (p+q)^{*};

(b)

p(qp)∗≡(pq)∗pp(q p)^{*} \equiv (p q)^{*} p;

(c)

(p∗q∗)∗≡(q∗p∗)∗\left(p^{*} q^{*}\right)^{*} \equiv \left(q^{*} p^{*}\right)^{*};

(d)

(pq)+(q∗p∗+q∗)≡(pq)∗pq+p∗(p q)^{+}\left(q^{*} p^{*}+q^{*}\right) \equiv (p q)^{*} p q^{+} p^{*}.

Problem 253

Simplify the following regular expressions:

?
(a)

00∗0+(00)∗00^{*} 0+(00)^{*};

(b)

(0+1)(ε+00)++(0+1)(0+1)(\varepsilon +00)^{+}+(0+1);

(c)

(0+ε)0∗1(0+\varepsilon ) 0^{*} 1;

(d)

(0∗+0)∗(01∗+0)\left(0^{*}+0\right)^{*}\left(01^{*}+0\right).

Problem 254

Using equivalent transformations of regular expressions, simplify the result rr obtained in Example 81 on p. 328: r=(aa)∗+a(aa)∗(ba(aa)∗)∗b(aa)∗+a(aa)∗+a(aa)∗(ba(aa)∗)∗ba(aa)∗r=(a a)^{*}+a(a a)^{*}\left(b a(a a)^{*}\right)^{*} b(a a)^{*}+a(a a)^{*}+a(a a)^{*}\left(b a(a a)^{*}\right)^{*} b a(a a)^{*}.

?
Problem 255

Let Nr\mathfrak {N}_{r} be the automaton constructed in the proof of Theorem 111 on p. 322 from the regular expression rr (Theorem 111: for every regular expression rr one can effectively construct an NFA recognizing L(r)L(r), by induction on rr's structure — a fixed automaton for each base case ∅\varnothing, ε\varepsilon, a∈Σa \in \Sigma, and, given automata for r1r_{1} and r2r_{2}, a combined automaton for r1+r2r_{1}+r_{2}, r1&r2r_{1} \& r_{2}, and r1∗r_{1}^{*} built by gluing them together with new ε\varepsilon-transitions). Prove the following statements:

?
(a)

in the diagram of Nr\mathfrak {N}_{r}, at most two edges leave each vertex, and at most one leaves each accepting vertex;

(b)

the number of states of Nr\mathfrak {N}_{r} exceeds the length of the expression rr by at most a factor of three, that is ∣Q∣⩽3∣r∣\left|Q\right| \leqslant 3\left|r\right|;

(c)

when using optimized methods, the number of states of Nr\mathfrak {N}_{r} exceeds the length of the expression rr by at most a factor of two, that is ∣Q∣⩽2∣r∣\left|Q\right| \leqslant 2\left|r\right|.

Problem 256

Complete the proof of Proposition 110 on p. 321 by showing that if w∈(L(M1))∗w \in \left(L\left(\mathfrak {M}_{1}\right)\right)^{*}, then w∈L(N)w \in L(\mathfrak {N}), where M1\mathfrak {M}_{1} is a finite automaton with initial state q01q_{0}^{1} and a single accepting state qf1q_{f}^{1}, and N\mathfrak {N} is obtained from M1\mathfrak {M}_{1} by adding a new initial-and-only-accepting state q0q_{0} together with the two ε\varepsilon-transitions q0→εq01q_{0} \xrightarrow {\varepsilon } q_{0}^{1} and qf1→εq0q_{f}^{1} \xrightarrow {\varepsilon } q_{0} (so that L(N)=(L(M1))∗L(\mathfrak {N})=(L(\mathfrak {M}_{1}))^{*}, per Proposition 110).

?
Problem 257

Apply the determinization procedure from Theorem 100 on p. 302 (Theorem 100: for every NFA N\mathfrak {N} one can effectively construct a DFA M\mathfrak {M} such that L(M)=L(N)L(\mathfrak {M})=L(\mathfrak {N})) and construct a DFA equivalent to the NFA N\mathfrak {N} from Example 80 on p. 323.

?
Problem 258

Construct a regular expression defining the language LL over the alphabet Σ={0,1}\Sigma =\left\{ 0,1\right\}:

?
(a)

L={w:w contains an odd number of 0 digits and an even number of 1 digits}L=\left\{ w: w\text{ contains an odd number of 0 digits and an even number of 1 digits}\right\};

(b)

L={w:w contains the substring 001 or the substring 110}L=\left\{ w: w\text{ contains the substring 001 or the substring 110}\right\};

(c)

L={w:w contains at least two consecutive 0’s}L=\left\{ w: w\text{ contains at least two consecutive 0's}\right\};

(d)

L={w:w does not contain the substrings 011 and 010}L=\left\{ w: w\text{ does not contain the substrings 011 and 010}\right\}.

Problem 259

Let ww be an arbitrary word of length kk, and let m1,…,mnm_{1}, \ldots , m_{n} be pairwise distinct natural numbers arranged in increasing order. Prove that the language {wm1,…,wmn}\left\{ w^{m_{1}}, \ldots , w^{m_{n}}\right\} can be described by a regular expression of length no greater than 4kmn+4n−74 k m_{n}+4 n-7 (taking into account all symbols required by the definition).

?
Problem 260

Above, in Problem 243 on p. 310, it was proposed to construct an automaton that checks the correctness of addition. Construct a regular expression defining the language SS recognized by this automaton, that is, the following set of words over the alphabet {0,1}3\left\{ 0,1\right\}^{3}:

S = \left\{ \left\llbracket \begin{array}{l} a_{1} \\ b_{1} \\ c_{1} \end{array} \right\rrbracket \ldots \left\llbracket \begin{array}{l} a_{n} \\ b_{n} \\ c_{n} \end{array} \right\rrbracket \; : \; c_{n} \ldots c_{1}\text{ is the sum of the binary numbers } a_{n} \ldots a_{1} \text{ and } b_{n} \ldots b_{1}\right\}
?