Example Nim (one pile of pebbles, a move means remove 1-3; last player to move loses (as they spoil the fun).) Show: If remainder(n,4)=0, then second-player-to-move has a forced win. Corollary: in all other cases, next-player-to-move has a forced win.
Proof by induction. (We'll parameterize "3" as "m".) Let P(n) be ``if remainder(n,m+1)=0, then the second-player-to-move has a forced win, else the next-player-to-move has a forced win."
(Notes: Originally written as "player 1", "player 2", but this interfered with the -1's going on in the proof. Renamed to players A and B throughout, for slightly clearer presentation. But, this then made the last step difficult to phrase (since you want to interchange the role of A and B, but our inductive statement neglected to explicitly make A,B free.) So we end up using the names A and B only within case 2, not in P(). Perhaps using the terms "active player" and "nonactive player" would be better, or keeping A and B and just mention the role reversal (technically incorrect, but perhaps clearer; presumably anybody who understands the incorrectness will also understand how to fix it).
Looking back on this solution: (arguably) base cases of n=1,n=2,n=3, and n=4 pebbles were needed so that the inductive step could use P(k-4).
In general (esp. for strong induction), you can show several base cases (say, kappa of them), and then separately in induction that for all k ≥ κ, P(1)…P(k) ⇒ P(k+1) (where presumably this argument needs to use P(k+1-κ), which is why you needed to have k+1-κ > 0.)
A more involved example: This is Rosen Example 12; he phrases it slightly differently to get it into regular induction but I prefer the strong-induction phrasing.
;; schedule-greedy: (list-of talk) --> (list-of talk) ;; Given a list of requested talks sorted by end-time, ;; return a non-conflicting list of talks. ;; Precondition: talks is sorted by non-descending talk-end time. ;; ;; Schedule as per Rosen's Section 3.3 Example 12: ;; Out of all feasible choices, select the talk which ends soonest. ;; (define (schedule-greedy talks) (cond [(empty? talks) empty] [else (let* {[next-talk (first talks)] [next-free-time (talk-end next-talk)] } (cons next-talk (schedule-greedy (filter (lambda (t) (>= (talk-begin t) next-free-time)) (rest talks)))))]))(full code)
Key step: if there is an optimal schedule w/o e1, then there is another optimal schedule that does include e1 instead. ``If opt = ei1,ei2,…,eim, then opt' = e1,ei2,…,eim is also optimal.'' Clearly it's the same size, and there are no conflicts becase e1 ends no later than any other jobs, in particular e1 ≤ ei1.
Thus, an optimal solution has the size of 1+opt(jobs-that-don't-conflict-with-e1). By inductive hypothesis, schedule-greedy gives the correct answer on those non-conflicting jobs, so our total answer is one bigger, which is therefore optimal.
See also: Rosen's Example 14: n can be expressed as the product of primes, for n>1. This is strong-induction where you need to use the inductive hypotheses twice.
When P(n) is about certain structures of size n, and you are doing your inductive step to show that P(k) ⇒ P(k+1), don't say "we take a structure of size k, and extend it by one". Instead, say "we take an arbitrary structure of size k+1"; if you then look at its substructures, there's no problem. The reason for this is, it's not clear that all possible bigger structures can be composed out of a size-one-smaller structure.
Consider ``trees of size k, where every node is either a leaf, has a prime number of children''; call such trees ``prime-branching''. For (say) k=24, there are many prime-branching trees of size 24 that can be created by splicing together smaller prime-branching trees. However, the tree with 23 leaves hanging from a single root cannot be. So proofs which start with two smaller cases and stitching them together will inadvertently miss this case! (It's not clear to me whether other prime-branching trees of size 24 can't be built up this way either.)
However, if you say "start with any prime-branching trees of size k+1 = 24", then you're okay. (Presumably this will alert you to any illegal constructions, because if you try to argue 'any such tree can be decomposed into …', you'll get hung up on explaining that construction.)
[an error occurred while processing this directive] [an error occurred while processing this directive]