coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Thomas Braibant <thomas.braibant AT gmail.com>
- To: Michael <michaelschausten AT googlemail.com>
- Cc: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Induction with seld-defined cases
- Date: Wed, 1 Sep 2010 16:12:15 +0200
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=DD24f0aOwGV0Jv1huLAYbgaYKns8zw6eOng4Lx6r173//WswpEMRJP1sR+MZjiSnd0 ujeWWs/UjA2S1aMGw6RkMB89E3c78FV+zY+GdPp9i221kgjDc4QJt1QnAjJlb+EHLWXC qZ68taBWvbE4AxO1yHdpU4BL59gMY3rtJMsqY=
Basically, you have to prove your own induction principle, with one hypothesis for each case. You could also maybe encode it into an inductive. (Like the pos_view thing for positive numbers that you can find in the standard library).
For Z, the use of the lia tactic is convenient, here.
Require Import ZArith.
Require Import Psatz.
Section zind.
Variable P : Z -> Prop.
Hypothesis Hneg : forall z, Zlt z 0 -> P z.
Hypothesis H_0_to_10 : forall (z : Z), Zle 0 z -> Zle z 10 -> P z.
Hypothesis H_11 : P 11.
Hypothesis H_gt_11 : forall z, Zlt 11 z -> P z.
Lemma dicho : forall (z : Z), Zle 0 z -> (Zle z 10 \/ z = 11%Z \/ Zlt 11 z).
intros. lia.
Qed.
Lemma lia_helper :forall p, (0 <= Zpos p)%Z.
Proof.
intros. unfold Zle; discriminate.
Qed.
Hint Immediate lia_helper.
Lemma Zind : forall z, P z.
Proof.
induction z. apply H_0_to_10; lia.
destruct (dicho _ (lia_helper p)) as [H |[H |H]].
apply H_0_to_10; try lia; auto.
rewrite H. assumption.
apply H_gt_11. auto.
apply Hneg. unfold Zlt. simpl. auto.
Qed.
End zind.
Check Zind.
Lemma toto : forall (z : Z), Zle 0 (z * z).
Proof.
induction z using Zind.
Abort
With best regards
thomas
On Wed, Sep 1, 2010 at 3:49 PM, Michael <michaelschausten AT googlemail.com> wrote:
Hello,
I'd like to prove a Lemma (x : Z) with [induction x]. This gives me three
cases: x==0, x == Zpos p and x == Zneg p (p : positive).
However, I would like to have more self-defined cases, e.g.: x = Zneg p, x ==
0, 1 <= x <= 10, x == 11 and x > 11. I tried it with bindings (induction term
with bindings_list), but only received error. How can I do create those
self-defined cases?
Sincerely,
- [Coq-Club] Induction with seld-defined cases, Michael
- Re: [Coq-Club] Induction with seld-defined cases, Thomas Braibant
Archive powered by MhonArc 2.6.16.