• Home
  • Textbooks
  • Languages and Machines: An Introduction to the Theory of Computer Science
  • Regular Languages and Sets

Languages and Machines: An Introduction to the Theory of Computer Science

Thomas A. Sudkamp

Chapter 7

Regular Languages and Sets - all with Video Answers

Educators


Chapter Questions

Problem 1

Use the technique from Section 7.2 to build the state diagram of an NFA- $\lambda$ that accepts the language $(a b)^* b a$. Compare this with the DFA constructed in Exercise 6.16 (a).

Check back soon!

Problem 2

For each of the state diagrams in Exercise 6.34, use Algorithm 7.2.2 to construct a regular expression for the language accepted by the automaton.

Check back soon!

Problem 3

The language of the DFA M in Example 6.3.4 consists of all strings over $\{a, b\}$ with an even number of $a$ 's and an odd number of $b$ 's. Use Algorithm 7.2.2 to construct a regular expression for $L(M)$. Exercise 2.37 requested a nonalgorithmic construction of a regular expression for this language, which, as you now see, is a formidable task.

Check back soon!

Problem 4

Let $\mathrm{G}$ be the grammar
$$
\text { G: } \begin{aligned}
S & \rightarrow a S|b A| a \\
A & \rightarrow a S|b A| b .
\end{aligned}
$$
a) Use Theorem 7.3.1 to build an NFA M that accepts L(G).
b) Using the result of part (a), build a DFA M' that accepts L(G).
c) Construct a regular grammar from $M$ that generates $L(M)$.
d) Construct a regular grammar from $M^{\prime}$ that generates $L\left(M^{\prime}\right)$.
e) Give a regular expression for $L(G)$.

Check back soon!

Problem 5

Let $\mathrm{M}$ be the NFA
(figure cant copy).
a) Construct a regular grammar from $M$ that generates $L(M)$.
b) Give a regular expression for $L(M)$.

Check back soon!

Problem 6

Let $\mathrm{G}$ be a regular grammar and $\mathrm{M}$ the NFA obtained from $\mathrm{G}$ according to Theorem 7.3.1. Prove that if $S \doteq w C$ then there is a computation $[S, w] \vdash[C, \lambda]$ in $\mathrm{M}$.

Check back soon!

Problem 7

Let $\mathrm{L}$ be a regular language over $\{a, b, c\}$. Show that each of the following sets is regular.
a) $\{w \mid w \in \mathrm{L}$ and $w$ contains an $a\}$
b) $\{w \mid w \in$ L or $w$ contains an $a\}$
c) $\{w \mid w \notin \mathrm{L}$ and $w$ does not contain an $a\}$

Check back soon!

Problem 8

Let $\mathrm{L}$ be a regular language. Show that the following languages are regular.
a) The set $\mathrm{P}=\{u \mid u v \in \mathrm{L}\}$ of prefixes of $\mathrm{L}$
b) The set $\mathrm{S}=\{v \mid u v \in \mathrm{L}\}$ of suffixes of $\mathrm{L}$
c) The set $\mathbf{L}^R=\left\{w^R \mid w \in \mathrm{L}\right\}$ of reversals of $\mathrm{L}$
d) The set $\mathrm{E}=\{u v \mid v \in \mathrm{L}\}$ of strings that have a suffix in $\mathrm{L}$

Check back soon!

Problem 9

Let $\mathrm{L}$ be a regular language containing only strings of even length. Let $\mathrm{L}^{\prime}$ be the language $\{u \mid u v \in \mathrm{L}$ and length $(u)=$ length $(v)\} . \mathrm{L}^{\prime}$ is the set of all strings that contain the first half of strings from $L$. Prove that $\mathrm{L}^{\prime}$ is regular.

Check back soon!
12:56

Problem 10

Use Corollary 7.5.2 to show that each of the following sets is not regular.
a) The set of strings over $\{a, b\}$ with the same number of $a$ 's and $b$ 's.
b) The set of palindromes of even length over $\{a, b\}$.
c) The set of strings over $$\{()$,$\} in which the parentheses are paired. Examples include$$ $\lambda,(),()(),(())()$.
d) The language $\left\{a^i(a b)^j(c a)^{2 i} \mid i, j>0\right\}$.

Chris Trentman
Chris Trentman
Numerade Educator
05:39

Problem 11

Use the pumping lemma to show that each of the following sets is not regular.
a) The set of palindromes over $\{a, b\}$
b) $\left\{a^n b^m \mid n<m\right\}$
c) $\left\{a^i b^j c^{2 j} \mid i \geq 0, j \geq 0\right\}$
d) $\left\{w w \mid w \in\{a, b\}^*\right\}$
e) The set of initial sequences of the infinite string
abaabaaabaaaab ... ba $b a^{n+1} b \ldots$
f) The set of strings over $\{a, b\}$ in which the number of $a$ 's is a perfect cube

Chris Trentman
Chris Trentman
Numerade Educator
01:57

Problem 12

Prove that the set of nonpalindromes over $\{a, b\}$ is not a regular language.

Adriano Chikande
Adriano Chikande
Numerade Educator
01:14

Problem 13

Let $L_1$ be a nonregular language and $L_2$ an arbitrary finite language.
a) Prove that $L_1 \cup L_2$ is nonregular.
b) Prove that $\mathrm{L}_1-\mathrm{L}_2$ is nonregular.
c) Show that the conclusions of parts (a) and (b) are not true if $\mathrm{L}_2$ is not assumed to be finite.

Doruk Isik
Doruk Isik
Numerade Educator

Problem 14

Give examples of languages $\mathrm{L}_1$ and $\mathrm{L}_2$ over $\{a, b\}$ that satisfy the descriptions below.
a) $\mathrm{L}_1$ is regular, $\mathrm{L}_2$ is nonregular, and $\mathrm{L}_1 \cup \mathrm{L}_2$ is regular.
b) $\mathrm{L}_1$ is regular, $\mathrm{L}_2$ is nonregular, and $\mathrm{L}_1 \cup \mathrm{L}_2$ is nonregular.
c) $L_1$ is regular, $L_2$ is nonregular, and $L_1 \cap L_2$ is regular.
d) $\mathrm{L}_1$ is nonregular, $\mathrm{L}_2$ is nonregular, and $\mathrm{L}_1 \cup \mathrm{L}_2$ is regular.
e) $L_1$ is nonregular and $L_1^*$ is regular.

Check back soon!

Problem 15

Let $\Sigma_1$ and $\Sigma_2$ be two alphabets. A homomorphism is a total function $h$ from $\Sigma_1^*$ to $\Sigma_2^*$ that preserves concatenation. That is, $h$ satisfies
i) $h(\lambda)=\lambda$
ii) $h(u v)=h(u) h(v)$.
a) Let $\mathrm{L}_1 \subseteq \Sigma_1^*$ be a regular language. Show that the set $\left\{h(w) \mid w \in \mathrm{L}_1\right\}$ is regular over $\Sigma_2$. This set is called the homomorphic image of $L_1$ under $h$.
b) Let $\mathrm{L}_2 \subseteq \Sigma_2^*$ be a regular language. Show that the set $\left\{w \in \Sigma_1^* \mid h(w) \in \mathrm{L}_2\right\}$ is regular. This set is called the inverse image of $\mathrm{L}_2$ under $h$.

Check back soon!
01:42

Problem 16

A context-free grammar $\mathrm{G}=(\mathrm{V}, \Sigma, \mathrm{P}, S)$ is called right-linear if each rule is the form
i) $A \rightarrow u$
ii) $A \rightarrow u B$,
where $A, B \in \mathrm{V}$, and $u \in \Sigma^*$. Show that the right-linear grammars generate precisely the regular sets.

Adriano Chikande
Adriano Chikande
Numerade Educator
01:36

Problem 17

A context-free grammar $\mathrm{G}=(\mathrm{V}, \Sigma, \mathrm{P}, S)$ is called left-regular if each rule is of the form
i) $A \rightarrow \lambda$
ii) $A \rightarrow a$
iii) $A \rightarrow B a$,
where $A, B \in \mathrm{V}$, and $a \in \Sigma$.
a) Design an algorithm to construct an NFA that accepts the language of a left-regular grammar.
b) Show that the left-regular grammars generate precisely the regular sets.

Adriano Chikande
Adriano Chikande
Numerade Educator
06:46

Problem 18

A context-free grammar $\mathrm{G}=(\mathrm{V}, \Sigma, \mathrm{P}, S)$ is called left-linear if each rule is of the form
i) $A \rightarrow u$
ii) $A \rightarrow B u$,
where $A, B \in \mathrm{V}$, and $u \in \Sigma^*$. Show that the left-linear grammars generate precisely the regular sets.

Chris Trentman
Chris Trentman
Numerade Educator
02:44

Problem 19

Give a regular language $\mathrm{L}$ such that $\equiv_{\mathrm{L}}$ has exactly three equivalence classes.

Prathan Jarupoonphol
Prathan Jarupoonphol
Numerade Educator

Problem 20

Give the $\equiv_L$ equivalence classes of the language $a^{+} b^{+}$.

Check back soon!

Problem 21

Let $[u]_{\bar{m}_{\mathrm{L}}}$ be a $\equiv_{\mathrm{L}}$ equivalence class of a language $\mathrm{L}$. Show that if $[u]_{\mathrm{e}_{\mathrm{L}}}$ contains one string $v \in \mathrm{L}$, then every string in $[u]_{\mathrm{E}_{\mathrm{L}}}$ is in $\mathrm{L}$.

Check back soon!
02:03

Problem 22

Let $u \equiv \mathrm{L} v$. Prove that $u x \equiv_{\mathrm{L}} v x$ for any $x \in \Sigma^*$ where $\Sigma$ is the alphabet of the language $\mathrm{L}$.

Mohamed Mohamed
Mohamed Mohamed
Numerade Educator

Problem 23

Use the Myhill-Nerode theorem to prove that the language $\left\{a^i \mid i\right.$ is a perfect square $\}$ is not regular.

Check back soon!
04:24

Problem 24

Let $u \in[a b]_{\equiv_{\mathrm{M}}}$ and $v \in[a b a]_{\equiv_{\mathrm{M}}}$ be strings from the equivalence classes of $(a \cup b)$ $\left(a \cup b^*\right)$ defined in Example 7.7.4. Show that $u$ and $v$ are distinguishable.

James Chok
James Chok
Numerade Educator

Problem 25

Give the equivalence classes defined by the relation $\equiv_M$ for the DFA in Example 6.3.1.

Check back soon!

Problem 26

Give the equivalence classes defined by the relation $\equiv_{\mathrm{M}}$ for the DFA in Example 6.3.3.

Check back soon!

Problem 27

Let $M_L$ be the minimal state DFA that accepts a language $L$ defined in Theorems 7.7.4 and 7.7.5. Let $M$ be another DFA that accepts $L$ with the same number of states as $M_L$. Prove that $M_L$ and $M$ are identical except (possibly) for the names assigned to the states. Two such DFAs are said to be isomorphic.

Check back soon!