Solutions to CS 390 Test I



July 12, 2000



1. Which of the following statements are true and which are false ? [30]
(a) $(L^{+})^{*} = L^{+}$.                             False     (Empty string may not be in L+)
(b) $(01)^{*}0 = 0(10)^{*}$                       True
(c) $(0^{*} + 1)^{*} = (0 + 1^{*})^{*}$             True
(d) Suppose that $A$ and $B$ are sets, that $S$ and $T$ are subsets of $A$ and that $f$ is a function from $A$ to $B$.
Then $f(S) \cup f(T) \subseteq f(S \cup T)$.             True
(e) Suppose that $A$ and $B$ are sets and that $f: A \rightarrow B$ is a function. Also suppose that $g: B \rightarrow A$ is a function such that $f(g(y)) = y$ for every $y$ in $B$. Then $g$ is $onto$.             False     (A may have more elements than B.)

2. Find a regular expression for each of the following languages over alphabet {$a, b$}:
(a) All strings with at least two $a$'s. [15] $b^{*}ab^{*}a(a + b)^{*}$
(b) All strings which do not contain the substring $ab$. [10] $b^{*}a^{*}$

3. Prove by structural induction on string $y$ that $ \mid xy \mid = \mid x \mid + \mid y \mid$ for an arbitrary fixed string $x$.
You may use the following definitions.
$\Sigma^{*}$ is defined recursively as
Basis Clause: $\Lambda \in \Sigma^{*}$
Inductive Clause: If $w \in \Sigma^{*}$. then $wa \in \Sigma^{*}$ for all $a \in \Sigma$.
Extremal Clause: As usual.

Also for any string $y$, $\mid y \mid$ is defined as
Basis clause: $\mid \Lambda \mid = 0$
Inductive Clause: If $y \in \Sigma^{*}$ and $a \in \Sigma$, then $\mid ya \mid = \mid y \mid + 1$. [23]

Proof:
Basis Step: $y = \Lambda$. Then $\mid xy \mid = \mid x \mid$ since $xy = x$. Also $\mid x \mid + \mid y \mid =
\mid x \mid$ since $\mid y \mid = 0$. Hence $ \mid xy \mid = \mid x \mid + \mid y \mid$ holds.
Inductive Step: Assume that $ \mid xy \mid = \mid x \mid + \mid y \mid$ holds for an arbitrary string $y$. We try to show that $ \mid xya \mid = \mid x \mid + \mid ya \mid$ for every symbol $a \in \Sigma$.
By the definition of $ \mid x \mid$, $ \mid xya \mid = \mid xy \mid + 1$ for any $a \in \Sigma$.
Since by the induction hypotheis $ \mid xy \mid = \mid x \mid + \mid y \mid$, $ \mid xya \mid = \mid x \mid + \mid y \mid + 1$.
Also by the definition of $ \mid x \mid$, $\mid ya \mid = \mid y \mid + 1$ for any $a \in \Sigma$.
Hence $ \mid xya \mid = \mid x \mid + \mid ya \mid$ holds for every symbol $a \in \Sigma$.

4 (a) Recursively define the set of strings of the form $1^{*}0^{*}$. [10]

Solution:
Basis Clause: $\Lambda \in S$.
Inductive Clause: For any string $x$, if $x \in S$, then $1x \in S$ and $x0 \in S$.
Extremal Clause: Nothing is in $S$ unless it is obtained from the Basis and Inductive Clauses.

(b) Give a string of length 3 that is in the set of (a). [6]                         110 and others

(c) Give one of the shortest strings that is not in the set of (a). [6]             01