You can also get your principle of induction from a valid induction form.
Notation " [ ] " := nil : list_scope. Notation " [ x1 ; .. ; x2 ] " := (cons x1 .. (cons x2 nil) ..) : list_scope. Open Scope list_scope. Conjecture C1 : forall t1 f1 p1, (forall x1, (forall x2, f1 x2 < f1 x1 -> p1 x2) -> p1 x1) -> forall x1 : t1, p1 x1. Conjecture C2 : forall t1 p1, p1 [] -> (forall x1 l1, p1 ([x1] ++ l1)) -> forall l1 : list t1, p1 l1. Conjecture C3 : forall t1 p1, p1 [] -> (forall x1 l1, p1 (l1 ++ [x1])) -> forall l1 : list t1, p1 l1. Conjecture C4 : forall t1 (x1 x2 : t1) l1, length l1 < length ([x1] ++ l1 ++ [x2]). Theorem T1 : forall t1 p1, p1 [] -> (forall x1, p1 [x1]) -> (forall x1 x2 l1, p1 l1 -> p1 ([x1] ++ l1 ++ [x2])) -> forall l1 : list t1, p1 l1. Proof. intros t1 p1 h1 h2 h3. induction l1 as [l1 h4] using (C1 (list t1) (@length t1)). induction l1 as [| x1 l1] using C2. eapply h1. induction l1 as [| x2 l1] using C3. simpl. eapply h2. eapply h3. eapply h4. eapply C4. Qed.
You can prove the hypothesis C1 by first applying the hypothesis to the conclusion, then using structural induction on f1 x1 , and then using some facts about < .
To prove C3 , which does not have an induction hypothesis, first use case analysis on is_empty l1 , and then use the facts is_empty l1 = true -> l1 = [] and is_empty l1 = false -> l1 = delete_last l1 ++ [get_last l1] ( get_last will need a default value).
user3551663
source share