The following is from a homework that I already did, and did wrong. I fail to see why the solution is sufficient. (After one week of reading and googling I turn to asking.)
The example is similar to an example used in the Hutton book on Haskell.
Base case:
add Zero m
= { applying add }
m
= { property of add }
add m Zero
Inductive case:
add (Succ n) m
= { applying add }
Succ (add n m)
= { induction hypothesis }
Succ (add m n)
= { property of add }
add m (Succ n)
-- Hypothesis:
add n m = add m n
-- Method:
by induction on n
-- Using:
add n (Succ m) = Succ (add n m)
add n Zero = n
data Nat = Zero
| Succ Nat
add :: Nat -> Nat -> Nat
add Zero m = m
add (Succ n) m = Succ (add n m)
What I fail to see is why the induction case is allowed to stop where it stops. It uses the hypothesis, and then un-applies add to generate something that is the version of the hypothesis of the induction case.
add n m = add m n -- hypothesis
add m (Succ n) -- hypthesis applied to the induction case add (Succ n) m
In other words, another version of the hypothesis was generated by already assuming that the hypothesis holds.
That is enough? Can I always treat the hypothesis as valid when I find one single case in which it works? And for the inductive case it is always sufficient if I can generate a version of the hypothesis applied to the inductive case by assuming that the hypothesis itself is already proven?
I have troubles to transfer induction from numbers to function. Please don't let me die stupid. Thanks.