coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Castéran Pierre <pierre.casteran AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] cases in leq proof
- Date: Wed, 23 Dec 2020 09:30:14 +0100
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=pierre.casteran AT gmail.com; spf=Pass smtp.mailfrom=pierre.casteran AT gmail.com; spf=None smtp.helo=postmaster AT mail-wr1-f42.google.com
- Ironport-phdr: 9a23:5gvh1x9JxTScIv9uRHKM819IXTAuvvDOBiVQ1KB20+kcTK2v8tzYMVDF4r011RmVBNqdsaoawLqP+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxhKiTanf79+MBS7oQrSu8ULnIBvNrs/xhzVr3VSZu9Y33loJVWdnxb94se/4ptu+DlOtvwi6sBNT7z0c7w3QrJEAjsmNXs15NDwuhnYUQSP/HocXX4InRdOHgPI8Qv1Xpb1siv9q+p9xCyXNtD4QLwoRTiv6bpgRRn1gykFKjE56nnahMxsg61UvRyvqRJ/zZDWb4+WM/RzZbnScc8fRWdbXsZdSy5MD4WhZIUPFeoBOuNYopHjqlQUthu+GROrBPn1xT9OnnD4x6w63Po7EQHcwgMrAtUDsGzVrNrrLqcSS/66wLPUwjrZdPNWxSny6JLSfRAnuvyMUrdwftDQyUkrDQ/KklKQqYn8Mj6Ty+8CvHSV4fB6WuKzl24otRtxoj63y8sylITEh54Yx1LL+Chl3Io4Idy1RUB7b9OrDpdcqTyWO5ZoT80iQmxluyY3xLIItJC1cyYH1JcqywDdZvCab4WF5A/oWuWJITpgmn5pZLayiwyx/EWg0OHwSNe43EtQoidKjNXArm4B2AbP5sSaT/Zy4lyu1SuL2g3W6OxLOkA5mK/VJpE/3rI8ip8evVnfEiL3hUn7iaCbeV8h9+S26enqYajpq5qAOINolg3zNqIjkdGlD+siKAgBRW2b9Py81LL9+U35R61HjvgsnanYtJDWPMoaprSkDwNM3IYu5AizAy2p0NQfmnkHI1ZFdwydg4f1PFHOJej0Dfa5g1uyjDdm3+7KMqHlD5nXLXXOkK3tcahj50JB0gY+ws5T64pRCr4bIfLzXkHxtMbfDh88KwG02+fnB8tn1oMER22DGLOWP7nJsV+U+O0vOfODZIkOtTbyLvgq/f/ujXsjlVABeqmp2IMbaGqkEfR+P0WZfX3sj88dHmcNpwoyVfDliFmfUTFIfHuyRKI95jQjCI28F4vDR4atgKaA3CihBJFWaHpGWRiwFiLjcJzBUPMRYgqTJNVgm3oKT+uPUYgkgDqnrxN70bNhGdLV9zcCuNq3zNl4/ffe0xo77iB5Fc2b+26IRmBw2GgPQmllj+hEvUVhxwLbguBDiPtCGIkLvqIbYkIBLZfZitdCJZX3UwPFcM2OTQ//ENqjCDA1CNk2xo1XOhovK5CZlhnGmhGSLfoNjbXSXc4796vd2z76IMMvky+bhplktEEvR450DUPjhqN78FKOVYvAkkHciLzzMKpAhmjC82CMyWfIt0ZdAlZ9
Dear Patricia,
A good way to get familiar with inversion is to prove some simple properties of le with and without this tactic.
First, with a plain destruct, we prove an « Inversion lemma »:
Lemma le_inv : forall n p, n <= p -> n = p \/ exists k, p = S k /\ n <= k.
Proof.
intros n p H; destruct H.
- left; trivial.
- right; exists m; split; trivial.
Qed.
Then the analysis of some hypotheses like n <= 0, or S.n <= S p can be done using le_inv:
Corollary le_n_0: forall n, n <= 0 -> n = 0.
Proof.
intros n H; destruct (le_inv n 0 H).
- assumption.
- destruct H0 as [k [H1 _]]; discriminate.
Qed.
With inversion :
Lemma le_n_0': forall n, n <= 0 -> n = 0.
Proof.
intros n H; inversion H; trivial.
Qed.
As an exercise, you can prove (forall n p, S n <= S p -> n <= p) the same ways.
(Note you will probably have to apply the transitivity of le).
On this example, you will notice that inversion often uses discriminate and injection.
With some practice, you will know easily when to use induction or inversion, according to the context.
Pierre
P.S.
On which goal did you obtain this error message ?
Le 22 déc. 2020 à 22:15, Patricia Peratto <psperatto AT vera.com.uy> a écrit :Thank you by your help. I would like to apply inversionto know how to manage proofs in Prop.I get the message:Inversion would require case analysis on sort
Set which is not allowed for inductive
definition le.De: "Adam Chlipala" <adamc AT csail.mit.edu>
Para: coq-club AT inria.fr
Enviados: Martes, 22 de Diciembre 2020 17:21:23
Asunto: Re: [Coq-Club] cases in leq proofIt's certainly a good exercise to learn how to work with "le" proofs in a more fundamental way, but your example falls within linear arithmetic, a decidable theory, so there is a very simple proof.
Require Import Omega.
Theorem le_to_exist : forall n m,
S n <= m
-> exists k, S k + n = m.
Proof.
intros.
exists (m - S n).
omega.
Qed.
On 12/22/20 3:16 PM, Patricia Peratto wrote:
997646937.2536423.1608668177032.JavaMail.zimbra AT vera.com.uy">I want to prove:
Theorem le_to_exist (n m:nat)(p:le (S n) m):
exists_prop nat
(fun (k:nat)=>add (S k) n = m).
Patricia
De: "Patricia Peratto" <psperatto AT vera.com.uy>
Para: "coq-club" <coq-club AT inria.fr>
Enviados: Martes, 22 de Diciembre 2020 17:04:08
Asunto: [Coq-Club] cases in leq proof
Is there some way to make a case analisis over a proofof a leq proposition?
Regards,Patricia
- [Coq-Club] cases in leq proof, Patricia Peratto, 12/22/2020
- Re: [Coq-Club] cases in leq proof, Adam Chlipala, 12/22/2020
- Re: [Coq-Club] cases in leq proof, Patricia Peratto, 12/22/2020
- Re: [Coq-Club] cases in leq proof, Adam Chlipala, 12/22/2020
- Re: [Coq-Club] cases in leq proof, Robbert Krebbers, 12/22/2020
- Re: [Coq-Club] cases in leq proof, Patricia Peratto, 12/22/2020
- Re: [Coq-Club] cases in leq proof, Dominique Larchey-Wendling, 12/23/2020
- Re: [Coq-Club] cases in leq proof, Castéran Pierre, 12/23/2020
- Re: [Coq-Club] cases in leq proof, Adam Chlipala, 12/22/2020
Archive powered by MHonArc 2.6.19+.