Answers to Practice Test: Proofs by Induction and Recursion, Exams of Health sciences

Solutions to practice test questions related to proofs by induction and recursion. It includes examples of induction proofs for mathematical formulas and recursive definitions of formal languages. The document also includes a bonus problem on the concatenation of lists.

Typology: Exams

Pre 2010

Uploaded on 08/21/2009

koofers-user-80h-1
koofers-user-80h-1 🇺🇸

5

(1)

9 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Answers to Practice Test 4
Proofs by Induction. Use your blue books.
n
8. i(i!) = (n+1)! - 1.
i=1
Base Case. Let n = 1. It suffices to prove that 1 ∑ 1! = (1 + 1)! - 1
1 ∑ 1! = 1 ∑ 1
= 1
= 2 - 1
= 2! - 1
= (1 + 1)! - 1
Inductive Case.
Inductive hypothesis: the sum from 1 to k = (k + 1)! - 1
It suffices to show that the sum from 1 to k + 1 = (k + 2)! - 1.
Sum from 1 to k + 1 = sum from 1 to k + (k+1)∑(k+1)!
= (k + 1)! - 1 + (k+1)∑(k+1)!, by IH.
= (k + 2) ∑ (k+1)! - 1
9. Consider the formal language consisting of vocabulary items
k
and
=
. Grammatical
strings are defined recursively as follows:
(1) List(
k
) is a string.
(2) If è is a string, then List(
k
)^è^List(
=
) is a string.
(3) There are no other strings.
Prove that in any string, the number of
k
's is greater than the number of
=
's.
First, we use recursionn to define two functions, the number of ks function (n) and the
number of =s function (q):
n(List(k)) = 1
n(List(k)^è^List(=)) = n(è) + 1
q(List(k)) = 0
q(List(k)^è^List(=)) = q(è) + 1
Let ç be an arbitrary string
Base Case. String ç = List(k).
n(ç) = 1, q(ç) = 0, and 1 > 0.
Inductive case. ç = List(k)^ß^List(=).
Inductive hypothesis: n(ß) > q(ß).
n(ç) = n(ß) + 1, and q(ç) = q(ß) + 1,
So n(ç) > q(ç).
pf2

Partial preview of the text

Download Answers to Practice Test: Proofs by Induction and Recursion and more Exams Health sciences in PDF only on Docsity!

Answers to Practice Test 4

Proofs by Induction. Use your blue books.

n

8. › i(i!) = (n+1)! - 1.

i=

Base Case. Let n = 1. It suffices to prove that 1 ∑ 1! = (1 + 1)! - 1 1 ∑ 1! = 1 ∑ 1 = =2- = 2! - 1 = (1 + 1)! - 1

Inductive Case. Inductive hypothesis: the sum from 1 to k = (k + 1)! - 1 It suffices to show that the sum from 1 to k + 1 = (k + 2)! - 1. Sum from 1 to k + 1 = sum from 1 to k + (k+1)∑(k+1)! = (k + 1)! - 1 + (k+1)∑(k+1)!, by IH. = (k + 2) ∑ (k+1)! - 1

9. Consider the formal language consisting of vocabulary items k and =. Grammatical

strings are defined recursively as follows:

(1) List(k) is a string.

(2) If è is a string, then List(k)^è^List(=) is a string.

(3) There are no other strings.

Prove that in any string, the number of k 's is greater than the number of ='s.

First, we use recursionn to define two functions, the number of k’s function (n) and the number of =’s function (q):

n(List(k)) = 1 n(List(k)^è^List(=)) = n(è) + 1

q(List(k)) = 0 q(List(k)^è^List(=)) = q(è) + 1

Let ç be an arbitrary string Base Case. String ç = List(k). n(ç) = 1, q(ç) = 0, and 1 > 0.

Inductive case. ç = List(k)^ß^List(=). Inductive hypothesis: n(ß) > q(ß). n(ç) = n(ß) + 1, and q(ç) = q(ß) + 1, So n(ç) > q(ç).

Bonus Problem. (10 points maximum)

Use the following recursive definition of the concatenation function on lists :

  1. If x is a list, then x^NIL = x.
  2. If x and y are lists, then x^Cons(y,a) = Cons(x^y, a).

Prove that for all lists x, y and z, (x^y)^z = x^(y^z). [Hint: prove by induction on the length of z.]

Base Case. Let z = NIL. Show for all x, y, (x^y)^NIL = x^(y^NIL). (x^y) ^ NIL = (x ^ y). = x^ (y ^ NIL), since y = y ^ NIL.

Inductive Case. Let z = Cons(w,a). Inductive hypothesis: for all x, y, (x^y)^w = x^(y^w). Show: for all x, y, (x^y) ^ z = x^(y ^ z), (x^y) ^ z = (x^y) ^ Cons(w,a) = Cons(((x^y)^w),a), by definition of ^ = Cons((x^(y^w)),a), by IH. = (x^Cons((y^w),q), by definition of ^. = (x^(y^Cons(w,a)), by definition of ^. = (x^(y^z))