From 37b6800cd3546c38a01b83bcb4b73428a290ac54 Mon Sep 17 00:00:00 2001 From: tomit4 Date: Tue, 14 Jul 2026 06:57:10 -0700 Subject: [PATCH] :construction: Setup for 5.9 --- chapter_5/exercises.md | 317 +++++++++++++++++++++++++++++++++++++ chapter_5/notes.md | 246 ++++++++++++++++++++++++++++ chapter_5/test_yourself.md | 22 +++ 3 files changed, 585 insertions(+) diff --git a/chapter_5/exercises.md b/chapter_5/exercises.md index c6da977..537148f 100644 --- a/chapter_5/exercises.md +++ b/chapter_5/exercises.md @@ -12292,3 +12292,320 @@ c. Express the explicit formula for the Fibonacci sequence in terms of $\phi_1$ and $\phi_2$. Omitted. + +--- + +Page 397 + +**Exercise Set 5.9** + +1. Consider the set of Boolean expressions defined in Example 5.9.1. Give + derivations showing that each of the following is a Boolean expression over + the English alphabet $\{a, b, c, \dots, x, y, z\}$. + +a. $\neg p \vee (q \wedge (r \vee \neg s))$ + +b. $(p \vee q) \vee \neg((p \wedge \neg s) \wedge r)$ + +2. Consider the set $C$ of parenthesis structures defined in Example 5.9.2. Give + derivations showing that each of the following is in $C$. + +a. $()(())$ + +b. $(())(())$ + +3. Let $S$ be the set of all strings over a finite set $A$ and let $a$, $b$, and + $c$ be any characters in $A$. + +a. Using Theorem 5.9.1 but not Theorem 5.9.3 or 5.9.4, show that +$(ab)c = a(bc)$. + +b. Show that $ab$ is a string in $S$. Then use the result of part (a) to +conclude that $a(bc)$ is a string in $S$. + +(This exercise shows that parentheses are not needed when writing the string +$abc$.) + +4. Consider the _MIU_-system discussed in Example 5.9.4. Give derivations + showing that each of the following is in the _MIU_-system. + +a. MIUI + +b. MUIIU + +5. The set of arithmetic expressions over the real numbers can be defined + recursively as follows: + +I. Base: Each real number $r$ is an arithmetic expression. + +II. Recursion: If $u$ and $v$ are arithmetic expressions, then the following are +also arithmetic expressions: + +(a) $(+u)$ + +(b) $(-u)$ + +\(c\) $(u + v)$ + +(d) $(u - v)$ + +(e) $(u \cdot v)$ + +(f) $\left(\frac{u}{v}\right)$ + +III. Restriction: There are no arithmetic expressions over the real numbers +other than those obtained from I and II. + +(Note that the _expression $\left(\dfrac{u}{v}\right)$ is allowed to be an +arithmetic expression even though the value of $v$ may be $0$.) Give the +derivations showing that each of the following is an arithmetic expression. + +a. $((2 \cdot (0.3 - 4.2)) + (-7))$ + +b. $\left(\frac{(9 \cdot(6 \cdot 1 + 2))}{((4 - 7) \cdot 6)}\right)$ + +6. Let $S$ be a set of integers defined recursively as follows: + +I. Base: $5$ is in $S$. + +II. Recursion: Given any integer $n$ in $S$, $n + 4$ is in $S$. + +III. Restriction: No integers are in $S$ other than those derived from rules I +and II above. + +Use structural induction to prove that for every integer $n$ in $S$, +$n \mod 2 = 1$. + +7. Define a set $S$ of strings over the set $\{0, 1\}$ recursively as follows: + +I. Base: $1 \in S$ + +II. Recursion: If $s \in S$, then + +(a) $0s \in S$ + +(b) $1s \in S$ + +III. Restriction: Nothing is in $S$ other than objects defined in I and II +above. + +Use structural induction to prove that every string in $S$ ends in a $1$. + +8. Define a set $S$ of strings over the set $\{a, b\}$ recursively as follows: + +I. Base $a \in S$ + +II. Recursion: If $s \in S$, then + +(a) $sa \in S$ + +(b) $sb \in S$ + +III. Restriction: Nothing is in $S$ other than objects defined in I and II +above. + +Use structural induction to prove that every string in $S$ begins with an $a$. + +9. Define a set $S$ of strings over the set $\{a, b\}$ recursively as follows: + +I. Base: $\lambda \in S$ + +II. Recursion: If $s \in S$, then + +(a) $bs \in S$ + +(b) $sb \in S$ + +\(c\) $saa \in S$ + +(d) $aas \in S$ + +III. Restriction: Nothing is in $S$ other than objects defined in I and II +above. + +Use structural induction to prove that every string in $S$ contains an even +number of $a$'s. + +10. Define a set $S$ of strings over the set of all integers recursively as + follows: + +I. Base +$1 \in S, 2 \in S, 3 \in S, 4 \in S, 5 \in S, 6 \in S, 7 \in S, 8 \in S, 9 \in S$ + +II. Recursion: If $s \in S$ and $t \in S$, then + +(a) $s0 \in S$ + +(b) $st \in S$ + +III. Restriction: Nothing is in $S$ other than objects defined in I and II +above. + +Use structural induction to prove that no string in $S$ represents an integer +with a leading zero. + +11. Define a set $S$ of strings over the set of all integers recursively as + follows: + +I. Base: $1 \in S, 3 \in S, 5 \in S, 7 \in S, 9 \in S$ + +II. Recursion: If $s \in S$ and $t \in S$, then + +(a) $st \in S$ + +(b) $2s \in S$ + +\(c\) $4s \in S$ + +(d) $6s \in S$ + +(e) $8s \in S$ + +III. Restriction: Nothing is in $S$ other than objects defined in I and II +above. + +Use structural induction to prove that every string in $S$ represents an odd +integer when written in decimal notation. + +12. Define a set $S$ of integers recursively as follows: + +I. Base: $0 \in S, 5 \in S$ + +II. Recursion: If $k \in S$ and $p \in S$, then + +(a) $k + p \in S$ + +(b) $k - p \in S$ + +III. Restriction: Nothing is in $S$ other than objects defined in I and II +above. + +Use structural induction to prove that every integer in $S$ is divisible by $5$. + +13. Define a set $S$ of integers recursively as follows: + +I. Base: $0 \in S$ + +II. Recursion: If $k \in S$, then + +(a) $k + 3 \in S$ + +(b) $k - 3 \in S$ + +III. Restriction: Nothing is in $S$ other than objects defined in I and II +above. + +Use structural induction to prove that every integer in $S$ is divisible by $3$. + +14. Is the string _MU_ in the _MIU_-system? Use structural induction to prove + your answer. + +15. Determine whether either of the following parenthesis configuration is in + the set $c$ defined in Example 5.9.2. Use structural induction to prove your + answers. + +a. $()(()$ + +b. $(()()))(()$ + +16. Give a recursive definition for the set of all strings of $0$'s and $1$'s + that have the same number of $0$'s and $1$'s. + +17. Give a recursive definition for the set of all strings of $0$'s and $1$'s + for which all the $0$'s precede all the $1$'s. + +18. Give a recursive definition for the set of all strings of $a$'s and $b$'s + that contain an odd number of $a$'s. + +19. Give a recursive definition for the set of all strings of $a$'s and $b$'s + that contain exactly one $a$. + +20. + +a. Let $A$ be any finite set and let $L$ be the length function on the set of +all strings over $A$. Prove that for every character $a$ in $A$, $L(a) = 1$. + +b. If $A$ is a finite set, define a set $S$ of strings over $A$ as follows: + +I. Base: Every character in $A$ is a string in $S$. + +II. Recursion: If $s$ is any string in $S$, then for every character $c$ in $A$, +$csc$ is a string in $S$. + +III. Restriction Nothing is in $S$ except strings obtained from the base and the +recursion. + +Use structural induction to prove that given any string $s$ in $S$, the length +of $S$, $L(s)$, is an odd integer. + +21. Write a complete proof for Theorem 5.9.4. + +22. If $S$ is the set of all strings over a finite set $A$ and if $u$ is any + string in $S$, define the _string reversal function_, $\text{Rev}$, as + follows: + +a. $\text{Rev}(\lambda) = \lambda$ + +b. For every string $u$ in $S$ and for every character $a$ in $A$, +$\text{Rev}(ua) = a\text{Rev}(u)$. + +Use structural induction to prove that for all strings $u$ and $v$ in $S$, +$\text{Rev}(uv) = \text{Rev}(v)\text{Rev}(u)$. + +23. Use the definition of McCarthy's 91 function in Example 5.9.7 to show the + following: + +a. $M(86) = M(91)$ + +b. $M(91) = 91$ + +24. Prove that McCarthy's 91 function equals $91$ for all positive integers less + than or equal to $101$. + +25. Use the definition of the Ackermann function in Example 5.9.8 to compute the + following: + +a. $A(1, 1)$ + +b. $A(2, 1)$ + +26. Use the definition of the Ackermann function to show the following: + +a. $A(1, n) = n + 2$, for each nonnegative integer $n$ + +b. $A(2, n) = 3 + 2n$, for each nonnegative integer $n$ + +c. $A(3, n) = 8 \cdot 2^n - 3$, for each nonnegative integer $n$ + +27. Compute $T(2), T(3), T(4), T(5), T(6)$, and $T(7)$ for the "function" $T$ + defined after Example 5.9.9. + +28. Student $A$ tries to define a function: $F: \mathbb{Z}^+ \to \mathbb{Z}$ by + the rule + +$$ +F(n) = +\begin{cases} +1 & \text{if } n \text{ is } 1 \\ +F\left(\dfrac{n}{2}\right) & \text{if } n \text{ is even} \\ +1 + F(5n - 9) & \text{if } n \text{ is odd and } n > 1 +\end{cases} +$$ + +for each integer $n \geq 1$. Student $B$ claims that $F$ is not well defined. +Justify student $B$'s claim. + +29. Student $C$ tries to define a function $G: \mathbb{Z}^+ \to \mathbb{Z}$ by + the rule + +$$ +G(n) = +\begin{cases} +1 & \text{if } n \text{ is } 1 \\ +G\left(\dfrac{n}{2}\right) & \text{if } n \text{ is even} \\ +2 + G(3n - 5) & \text{if } n \text{ is odd and } n > 1 +\end{cases} +$$ + +for each integer $n \geq 1$. Student $D$ claims that $G$ is not well defined. +Justify student $D$'s claim. diff --git a/chapter_5/notes.md b/chapter_5/notes.md index 25ab051..8bd359b 100644 --- a/chapter_5/notes.md +++ b/chapter_5/notes.md @@ -1244,3 +1244,249 @@ $$ a_n = Cr^n + Dnr^n $$ where $C$ and $D$ are the real numbers whose values are determined by the values of $a_0$ and any other known value of the sequence. + +--- + +Page 389 + +**Recursive Definition for the Set of All Strings over a Finite Set** + +Let $A$ be any finite set. Call the elements of $A$ characters, and define the +set $S$ **of all strings over** $A$ as follows: + +I. Base: $\lambda$ is a string in $S$, where $\lambda$ denotes the **null +string**, the "string" with no characters. + +II. Recursion: New strings are formed according to the following rules: + +(a) If $u$ is any string in $S$ and if $c$ is any character in $A$, then + +$$ uc \text{ is a string in } S $$ + +where $uc$ is called the **concatenation of $u$ and $c$**, and is obtained by +appending $c$ on the right of $u$. + +(b) If $u$ is a string in $S$, then both the concatenation of $\lambda$ and $u$, +denoted $\lambda u$, and the concatenation of $u$ and $\lambda$, denoted +$u\lambda$, are defined to equal $u$. Symbolically: + +$$ \lambda u = u\lambda = u $$ + +\(c\) If $u$ and $v$ are any strings in $S$, and if $c$ is any character in $A$, +then the concatenation of $u$ and $vc$ is defined to equal the concatenation of +$uv$ and $c$. Symbolically: + +$$ u(vc) = (uv)c $$ + +III. Restriction: Nothing is a string in $S$ other than objects obtained from +the base and the recursion. + +--- + +Page 389 + +**Theorem 5.9.1 Characters are Strings** + +If $A$ is a finite set and $S$ is the set of all strings over $A$, then every +character in $A$ is a string in $S$. + +**Proof:** + +(1) Suppose $c$ is any character in $A$. + +(2) By part I of the definition of string, $\lambda$ is a string in $S$. + +(3) By part II(a) of the definition of string, $\lambda c$ is a string in $S$. + +(4) By part I of the definition of string, $\lambda c = c$. + +(5) Thus $c$ is a string in $S$. + +--- + +Page 391 + +**Structural Induction for a Recursively Defined Set** + +Let $S$ be a set that has been defined recursively, and let $P(x)$ be a property +that objects in $S$ may or may not satisfy. To prove that every object in $S$ +satisfies $P(x)$, perform the following two steps: + +**Step 1 (basis step):** + +Show that $P(a)$ is true for each object $a$ in the base for $S$. + +**Step 2 (inductive step):** + +Show that for each $x$ in $S$, if $P(x)$ is true and if $y$ is obtained from $x$ +by applying a rule from the recursion, then $P(y)$ is true. To perform this +step, + +**suppose** that $x$ is an arbitrarily chosen element of $S$ for which $P(x)$ is +true. + +_[This supposition is the **inductive hypothesis**.]_ + +Then + +**show** that if $y$ is obtained from $x$ by applying a rule from the recursion +for $S$, then $P(y)$ is true. + +**Conclusion:** Because no objects other than those obtained from the base and +recursion are contained in $S$, steps 1 and 2 prove that $P(x)$ is true for +every object $x$ in $S$. + +--- + +Page 392 + +**Definition Length of a String** + +Given the set of all strings $S$ over a finite set $A$, the **length $L$ of a +string in $S$** is defined as follows: + +1. $L(\lambda) = 0$. + +2. For every string $u$ in $S$ and for every character $a$ in $A$, the length of + $ua$ is one more than the length of $u$. Symbolically: + +$$ L(ua) = L(u) + 1 \quad \text{ where } \quad u \in S \text{ and } a \in A $$ + +--- + +Page 393 + +**Theorem 5.9.2 Additive Property of String Length** + +If $S$ is the set of all strings over a finite set $A$, then for all strings $u$ +and $v$ in $S$, $L(uv) = L(u) + L(v)$. + +**Proof (by structural induction):** + +Let $S$ be the set of all strings over a finite set $A$. Given any string $v$ in +$S$, let the property $P(v)$ be the sentence + +For every string $u$ in $S$, $L(uv) = L(u) + L(v)$. + +We will show that $P(v)$ is true for every string $v$ in $S$. + +_Show that $P(a)$ is true for each string $a$ in the base for $S$:_ + +The only string in the base for $S$ is $\lambda$, and if $u$ is any string in +$S$, then + +$$ L(u\lambda) = L(u) $$ + +$$ = L(u) + 0 $$ + +$$ = L(u) + L(\lambda) $$ + +This shows that $P(\lambda)$ is true. + +_Show that for each string $x$ in $S$, if $P(x)$ is true and if $y$ is obtained +from $x$ by applying a rule from the recursion for $S$, then $P(y)$ is true:_ + +The recursion for $S$ consists of three rules denoted II(a), II(b), II\(c\), but +rule II(a) is the only one that generates new strings in $S$. Suppose $v$ is any +string in $S$ such that $P(v)$ is true. In other words, suppose that +$L(uv) = L(u) + L(v)$. _[This is the inductive hypothesis.]_ + +When rule II(a) is applied to $v$, the result is $vc$, where $c$ is a character +in $A$. So, to complete the inductive step, we must show that $P(vc)$ is true. +Now + +$$ L(u(vc)) = L((uv)c) $$ + +$$ = L(uv) + 1 $$ + +$$ = (L(u) + L(v)) + 1 $$ + +$$ = L(u) + (L(v) + 1) $$ + +$$ = L(u) + L(vc) $$ + +Hence $P(vc)$ is true _[as was to be shown]_. + +_Conclusion:_ + +Because there are no strings in $S$ other than those obtained through the base +and the recursion for $S$, we conclude that every string in $S$ satisfies the +additive property for string length. + +--- + +Page 394 + +**Theorem 5.9.3 The Concatenation of Any Two Strings is a String** + +If $S$ is the set of all strings over a finite set $A$ and $u$ and $v$ are any +strings in $S$, then $uv$ is a string in $S$. + +**Proof (by structural induction):** + +Let $S$ be the set of all strings over a finite set $A$. Given any string $v$ in +$S$, let the property $P(v)$ be the sentence + +For every string $u$ in $S$, $uv$ is a string in $S$. + +We will show that $P(v)$ is true for every string $v$ in $S$. + +_Show that $P(a)$ is true for each string $a$ in the base for $S$:_ + +The only string in the base for $S$ is $\lambda$, and if $u$ is any string in +$S$, then by rule II(b) in the definition of string, $u\lambda = u$. Hence the +concatenation of $u$ and $\lambda$ is a string in $S$, and so $P(\lambda)$ is +true. + +_Show that for each string $x$ in $S$, if $P(x)$ is true and if $y$ is obtained +from $x$ by applying a rule from the recursion for $S$, then $P(y)$ is true:_ + +The recursive definition for $S$ consists of three rules denoted II(a), II(b), +and II(c\), but rule II(a) is the only one that generates new strings in $S$. +Suppose $v$ is any string in $S$ such that $P(v)$ is true. In other words, +suppose that for every string $u$ in $S$, $uv$ is a string in $S$. _[This is the +inductive hypothesis.]_ + +Then rule II(a) is applied to $v$, the result is $vc$, where $c$ is a character +in $A$. To complete the inductive step, we must show that $P(vc)$ is true. To do +so, we will show that $u(vc)$ is a string in $S$. + +Now because $uv$ is a string in $S$, it follows from rule II(a) that $(uv)c$ is +also a string in $S$. In addition, by rule II\(c\), + +$$ (uv)c = u(vc) $$ + +Therefore, $u(vc)$ is a string in $S$, which means that $P(vc)$ is true _[as was +to be shown]_. + +_Conclusion:_ + +Because there are no strings in $S$ other than those obtained from 5he base and +the recursion for $S$, we conclude that the concatenation of any two strings in +$S$ is a string in $S$. + +--- + +Page 394 + +**Theorem 5.9.4 Concatenation of Strings is Associative** + +If $S$ is the set of all strings over a finite set $A$ and $u$, $v$, and $w$ are +any strings in $S$, then $u(vw) = (uv)w$. + +**Idea of a proof by structural induction:** Let $S$ be the set of all strings +over a finite set $A$. Given any string $w$ in $S$, let the property $P(w)$ be +the sentence + +For all strings $u$ and $v$ in $S$, $u(vw) = (uv)w$. + +The proof must show (1) that $P(\lambda)$ is true, and (2) that if $w$ is any +string in $S$ such that $P(w)$ is true and if $y$ is obtained from $w$ by +applying a rule from the recursion for $S$, then $P(y)$ is true. Now when rule +II(a) is applied to $w$ the result is $wc$ for some character $c$ in $A$. A +crucial step is to show that $u((vw)c) = (u(vw))c$. This follows from the +definition of string because $u$ and $vw$ are in $S$ and $c$ is in $A$. + +Exercise 21 at the end of this section asks you to write a complete proof. + +--- diff --git a/chapter_5/test_yourself.md b/chapter_5/test_yourself.md index b281789..efaf69b 100644 --- a/chapter_5/test_yourself.md +++ b/chapter_5/test_yourself.md @@ -253,3 +253,25 @@ complex numbers. sequence is given by an explicit formula of the form _____. $a_n = Cr^n + Dnr^n$ where $C$ and $D$ are real numbers. + +--- + +Page 397 + +**Test Yourself** + +1. The base for a recursive definition of a set is _____. + +2. The recursion for a recursive definition of a set is _____. + +3. The restriction for a recursive definition of a set is _____. + +4. One way to show that a given element is in a recursively defined set is to + start with an element or elements in the _____ and apply the rules from the + _____ until you obtain the given element. + +5. To use structural induction to prove that every element in a recursively + defined set $S$ satisfies a certain property, you show that _____ and that, + for each rule in the recursion, if _____ then _____. + +6. A function is said to be defined recursively if, and only if, _____.