

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Answers to Practice Test 4
Proofs by Induction. Use your blue books.
n
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
strings are defined recursively as follows:
(3) There are no other strings.
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(ç).
Use the following recursive definition of the concatenation function on lists :
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))