Take the 2-minute tour ×

I am trying to write an induction hypothesis specifically for proving properties of even numbers. I formulated and proved the following:

Theorem ind_hyp_on_evens:
forall (p : nat -> Prop), 
(p 0 -> (forall n, p n -> p (S (S n))) -> 
forall n, p (n + n)). 
intros p P0 P1.
intro n.
assert(p (n + n) /\ p (S (S (n + n)))). 
induction n as [| n'].  
split. unfold plus. assumption.
unfold plus. 
apply (P1 0).
destruct IHn' as [A B]. 
rewrite <- plus_Snm_nSm.
rewrite -> ? plus_Sn_m.
rewrite <- plus_Snm_nSm.
rewrite -> ? plus_Sn_m.
apply (P1 (S (S (n' + n')))).
destruct H as [H1 H2].
assumption. Qed. 

Despite the fact that it's proved, any attempt to use it results in the error message: "Error: Not the right number of induction arguments."

Can someone please tell me what is the problem with the induction hypothesis, or otherwise, how to apply it??



share|improve this question
How did you attempt to apply it? Post your code that led to the error message. –  Gilles May 12 '12 at 21:56
add comment

2 Answers

I believe induction assumes that any induction principle that will be used has the fixed form

forall ... (P : SomeType -> Type) ..., (* or ->Set or ->Prop *)
   ... ->
   forall (v : SomeType), P v

Your ind_hyp_on_evens matches only P (plus n n) which seems to confuse induction.

If you have a suitable goal, say forall n, is_even (n+n), you can manually do the steps that induction normally does and extend that to handle the special form.

intro n0;                            (* temp. var *)
pattern (n0 + n0);                   (* restructure as (fun x => (is_even x)) (n0+n0) *)
refine (ind_hyp_on_evens _ _ _ n0);  (* apply ind. scheme *)
clear n0; [| intros n IHn ].         (* clear temp., do one 'intros' per branch *)

I don't know if it's possible to pack that up as a general helper tactic for any induction scheme, packing these steps up as a per-scheme Ltac tactic should work however.

share|improve this answer
add comment

You could consider writing an inductive predicate that describes even numbers (code not tested):

Inductive even : nat -> Prop :=
| evenO : even O
| evenSSn : forall n, even n -> even (S (S n))

Coq will generate the induction principle automatically. You would have to prove that even n holds before being able to perform induction on the "evenness" of n.

share|improve this answer
This is correct, though you could equally well imagine writing the induction principle by hand using a simple Fixpoint definition, without going by way of introducing an auxiliary predicate. –  Kristopher Micinski Jun 17 '12 at 16:37
add comment

Your Answer


