SE 500 Mathematics for Software Engineering
Fall 2023 HW #9: Mathematical Induction
Sample Solutions

1. Prove by (weak) mathematical induction that  (+i | 1≤i≤n : 2i + 3) = n2 + 4n  for all n ≥ 0.

Solution: The proof is by mathematical induction on n. Taking P to be the given equation, to prove the base case, P.0 (i.e., P[n:=0]), we transform its left-hand side to its right-hand side. Similarly, in completing the induction step, we transform the left-hand side of P[n:=n+1] into its right-hand side.

Base Case: n=0
   (+i | 1≤i≤n : 2i + 3)[n:=0]

=    < textual substitution >

   (+i | 1≤i≤0 : 2i + 3)

=    < range is empty; (8.13);
       0 is identity of addition >

   0

=    < arithmetic >

   02 + 4·0

=    < textual substitution >

   (n2 + 4n)[n:=0]
Inductive Case: Let n≥0 be arbitrary, and assume an an induction hypothesis (IH) that (+i | 1≤i≤n : 2i + 3) = n2 + 4n
   (+i | 1≤i≤n : 2i + 3)[n:=n+1]

=    < textual substitution >

   (+i | 1≤i≤n+1 : 2i + 3)

=    < (8.23) >

   (+i | 1≤i≤n : 2i + 3) + (2i+3)[i:=n+1]

=    < IH, textual substitution, arithmetic >

   (n2 + 4n) + (2n + 5)

=    < algebra >

   (n2 + 2n + 1) + (4n + 4)

=    < algebra >

   (n+1)2 + 4(n+1)

=    < textual substitution >
   
   (n2 + 4n)[n:=n+1]

Perhaps a more likely way to have carried out the proof would have been to transform P[n:=0] to true (for the base case) and similarly for P[n:=n+1] (for the induction step). Showing this for the induction step:

Inductive Case: Let n≥0 be arbitrary, and assume P an an induction hypothesis (IH) (i.e., (+i | 1≤i≤n : 2i + 3) = n2 + 4n)
   P[n:=n+1]

=    < defn. of P >

   ((+i | 1≤i≤n : 2i + 3) = n2 + 4n)[n:=n+1]

=    < textual substitution >

   (+i | 1≤i≤n+1 : 2i + 3) = (n+1)2 + 4(n+1)

=    < (8.23), textual substitution >

   (+i | 1≤i≤n : 2i + 3) + (2(n+1)+3) = (n+1)2 + 4(n+1)

=    < IH, textual substitution, arithmetic >

   (n2 + 4n) + (2n + 5) = (n+1)2 + 4(n+1)

=    < algebra, arithmetic >

   n2 + 6n + 5  =  n2 + 6n + 5 

=    < = is reflexive >

   true


2. Prove by (weak) mathematical induction that  (+i | 1≤i≤n : 1/2i) = 1 - 1/2n  for all n ≥ 0.

Solution: Omitted, as it is very similar to a solution to Problem 1..


3. Prove by (weak) mathematical induction that  4n - 1 is divisible by 3, for all n ≥ 0.

Hint: If you divide 4n+1 - 1 by 4n - 1, you get a quotient of 4 and a remainder of 3. That is, 4n+1 - 1 = 4·(4n - 1) + 3

Solution: The proof is by mathematical induction on n.

Base Case: n=0
   (3 | 4n-1)[n:=0]

=    < textual substitution >

   3 | 40-1

=    < arithmetic >

   3 | 0

=    < zero is divisible by every 
       integer except itself      >
   true
Inductive Case: Let n≥0 be arbitrary, and assume an an induction hypothesis (IH) that 4n - 1 is divisible by 3. Let m the quotient when 3 is divided into 4n - 1. That is, let 3m = 4n - 1.
   (3 | 4n-1)[n:=n+1]

=    < textual substitution >

   3 | 4n+1-1

=    < algebra >

   3 | 4(4nn - 1) + 3

=    < IH >

   3 | 4(3m) + 3

=    < algebra >

   3 | 3(4m + 1)

=    < Divisibility 1 >

   true


4. Define f : ℕ → ℕ as follows:

f.0 = 1
f.1 = 3
f.n =  4·f(n−1) − 3·f(n−2)    (for n≥2)

Prove by (strong) mathematical induction that f.n = 3n  for all n ≥ 0.

Solution: Omitted.


5. Assume as true the claim that every acyclic graph that contains at least one edge also includes a vertex of degree one. Let G be an connected acyclic graph (i.e., a (free) tree). Prove by mathematical induction that v(G) = e(G) + 1 (i.e., the number of vertices in G is one more than the number of edges in G).

Procedure: Show that the statement is true in the case that v(G) = 1. That is the base case, or basis. Then take as an induction hypothesis (IH) that the statement is true for all trees having exactly n vertices, where n≥1 is arbitrary. Let G be a tree having n+1 vertices. Use the IH in arguing that the statement is true for G. (That is the induction step.)

Solution: By mathematical induction on the number of vertices. For a graph G, let vG and eG, respectively, be the number of vertices and edges in G.

Base Case: vG = 1. Hence,
   vG = eG + 1

=    < eG = 0, as any graph having
       only one vertex has zero edges. >

   1 = 0 + 1

=    < arithmetic >

   1 = 1  

=    < reflexivity of = >

  true
Inductive Step: Let n≥1 be arbitrary and assume, as an IH, that every tree having exactly n vertices has exactly n-1 edges (so that vG = eG + 1 for all such trees). Let G be a tree having exactly n+1 vertices. Construct H from G by removing a vertex of degree one and its incident edge. (The problem said that you could assume that such a vertex must exist.) We can make these observations:
  • H is a tree. (Why? Because the removal of a vertex of degree one from a graph cannot disconnect the graph.)
  • vG = vH + 1. In particular, vH = n
  • eG = eH + 1
   vG = eG + 1

=    < observations above >

   vH + 1 = eH + 1 + 1

=    < vH = n and H is a tree, so by the IH we have vH = eH + 1>

   eH + 1 + 1 = eH + 1 + 1

=    < = is reflexive >

  true


6.
       *
      / \
     /   \
    /     \
   *       *
  / \      |
 /   \     |
*     *    *
     / \
    /   \
   *     *
   |    / \
   |   /   \
   *  *     *
   |        | 
   |        |
   *        *
A rooted binary tree has one of the three forms shown below, where each of TC, TL, and TR is itself a rooted binary tree. An example appears to the right.

Root is
a leaf
T0
Root has
one child
T1
Root has
two children
T2
   *
    *
    |
    |
    |
    |
    *
   / \
  /   \
 / TC  \
+-------+
         *
        / \
       /   \
      /     \
     /       \
    *         *
   / \       / \
  /   \     /   \
 / TL  \   / TR  \
+-------+ +-------+

The height of a rooted tree is equal to the length of a longest path among all paths from the root to the leaves. Recursively, the height of a rooted tree is zero if the root is its only node and, otherwise, the height is one plus the height of its "tallest" proper subtree (which would be a subtree rooted at one of the children of the root).

Referring to the diagram above, we have

Prove by (weak) mathematical induction that, for all n≥0, every rooted binary tree having no less than 2n nodes has height no less than n.

To clarify, what is to be proved is that, for all n≥0 and all rooted binary trees T,

v(T) ≥ 2n   ⟹   h(T) ≥ n

where v(T) is the number of nodes/vertices in T and h(T) is the height of T.

Hint: Regarding the induction step, suppose that T is a rooted binary tree having at least 2n+1 nodes. If T is of the form of T1, how many nodes must be in TC? If T is of the form of T2, how many nodes must be in larger among TL and TR?

Solution: We offer two solutions, the first of which includes some Gries & Schneider flavor but otherwise is similar to what you would expect to find in most math books; the second solution is more strictly in the style of Gries & Schneider.


Solution #1:
Base Case: n=0. Let T be a rooted binary tree with at least 20 nodes. Clearly its height is at least zero (as is every tree's), as required.

Induction step. Assume, as an IH, that for an arbitrary n≥0, every rooted binary tree having at least 2n nodes has height at least n.

Let T be a rooted binary tree with at least 2n+1 nodes. To be demonstrated is that h(T) ≥ n+1.

Case 1: The root of T has only one child. Call the subtree rooted there TC. Then TC has at least 2n+1 - 1 nodes, which is at least 2n. Which means that the IH can be applied to TC. Also, the height of Tc is one less than that of T.

   h(T)

=    < observation above >

   h(TC) + 1

≥    < IH applied to TC says h(TC) ≥ n; 
       number theory a≥b ⇒ a+c ≥ b+c    >

   n + 1

Case 2: The root of T has two children. Call the subtrees rooted at those children TL and TR. Here are some observations:

   h(T)

≥    < observation above >

   h(TL) + 1

≥    < IH applied to TL says h(TL) ≥ n; 
       number theory a≥b ⇒ a+c ≥ b+c    >

   n + 1 


Solution #2: Recall that what is to be proved is that, for every binary tree T and natural number n, P: v(T) ≥ 2n ⟹ h(T) ≥ n.

Base Case: n=0.

   P[n:=0]

=    < defn of P; text. sub> >

   v(T) ≥ 20 ⟹ h(T) ≥ 0

=    < Every tree has height at least zero >

   v(T) ≥ 20 ⟹ true

=    < (3.72) >

   true

Induction Step: Assume P as an IH. Show P[n:=n+1].

Case 1: The root of T has a single child. Call the tree rooted at that child TC.
   LHS(P[n:=n+1])

=    < defn of P; text. sub. >

   v(T) ≥ 2n+1 

=    < v(T) = v(TC) + 1 >

   v(TC) + 1 ≥ 2n+1 

=    < algebra >

   v(TC) ≥ 2n+1 - 1

⟹  < 2n+1 - 1 ≥ 2n;
       ≥ is transitive >

   v(TC) ≥ 2n

⟹  < IH >

   h(TC) ≥ n

=    < h(T) - 1 = h(TC) >

   h(T) - 1 ≥ n

=    < algebra > 

   h(T) ≥ n+1

=    < defn of P; text. sub. >

   RHS(P[n:=n+1)


















Case 2: The root of T has two children. Call the trees rooted at those children TL and TR
   LHS(P[n:=n+1])

=    < defn of P; text. sub. >

   v(T) ≥ 2n+1 

=    < v(T) = v(TL) + v(TR) + 1 >

   v(TL) + v(TR) + 1 ≥ 2n+1 

=    < algebra >

   v(TL) + v(TR) ≥ 2n+1 - 1

⟹  < number theory: a + b ≥ c ⟹ 2·(a max b) ≥ c >

   2·(v(TL) max v(TR)) ≥ 2n+1 - 1

=    < algebra; all quantities here are integers >

   v(TL) max v(TR) ≥ ⌈(2n+1 - 1) / 2⌉

=    < algebra >

   v(TL) max v(TR) ≥ ⌈(2n - 1/2)⌉

=    < number theory: 0≤α<1 ⟹ ⌈a - α⌉ = a >

   v(TL) max v(TR) ≥ 2n

=    < number theory: a max b ≥ c ⟹ a≥c ∨ b≥c >

   v(TL) ≥ 2n  ∨  v(TR) ≥ 2n

⟹ < IH twice; (4.2) twice >

   h(TL) ≥ n  ∨  h(TR) ≥ n

=    < number theory: a≥c ∨ b≥c ≡ a max b ≥ c >

   h(TL) max h(TR) ≥ n

=    < h(T) - 1 = h(TL) max h(TR) >

   h(T) - 1 ≥ n

=    < algebra >

   h(T) ≥ n+1

=    < defn of P; text. sub >

   RHS(P[n:=n+1])