coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Vincent Demange <vincent.demange AT ensiie.fr>
- To: Math Prover <mathprover AT gmail.com>
- Cc: "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k"
- Date: Mon, 03 Jun 2013 17:26:08 +0200
- Organization: ENSIIE
Hi the list,
Here is another solution, generating exactly the goals you want and
without relying on Ltac (see below).
The main idea is to prove the following statement:
(forall n > k, P n) -> P k -> ... -> P 0 -> forall n, P n
[Note the reverse order to ease the proof.]
Thanks to Mr. Forest for doing the hard work in seconds !
Vincent.
----8<------------------------------------------------------
Require Import Arith.
Fixpoint cases_aux (P: nat -> Type) (k:nat) {struct k} : Type :=
match k with
| 0 => P 0 -> forall n, P n
| S k' => P k -> cases_aux P k'
end.
Definition cases P k := (forall n, n>k -> P n) -> cases_aux P k.
Lemma magic k P : cases P k.
Proof.
unfold cases.
induction k as [ | k' IHk'].
intros Hinfty H0 .
intros [ | n].
exact H0.
apply Hinfty.
apply lt_0_Sn.
intros Hinfty H_S_k'.
fold cases_aux.
apply IHk'.
intros n H.
do 2 red in H.
case (le_lt_eq_dec (S k') n H); clear H; intro H.
apply Hinfty, H.
subst.
apply H_S_k'.
Qed.
Section example.
Variable P: nat -> Prop.
Lemma example: forall n, P n.
Proof.
apply (magic 5).
(* six goals to prove *)
Admitted.
End example.
- [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Math Prover, 06/01/2013
- [Coq-Club] Re: Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Math Prover, 06/01/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Yucheng Zhang, 06/01/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Math Prover, 06/01/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Pierre Courtieu, 06/03/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Math Prover, 06/03/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Math Prover, 06/03/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Yucheng Zhang, 06/03/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Math Prover, 06/03/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Yucheng Zhang, 06/03/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Pierre Courtieu, 06/03/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Math Prover, 06/01/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", gallais, 06/03/2013
- Re: [Coq-Club] Destructing a "nat" into 0, 1, 2, 3, ..., k-1 and ">= k", Vincent Demange, 06/03/2013
Archive powered by MHonArc 2.6.18.