coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jean-Francois Monin <jean-francois.monin AT imag.fr>
- To: Guillaume Melquiond <guillaume.melquiond AT inria.fr>
- Cc: "Benjamin C. Pierce" <bcpierce AT cis.upenn.edu>, coq-club AT inria.fr
- Subject: Re: [Coq-Club] Destruct vs. inversion
- Date: Thu, 7 Apr 2011 16:37:35 +0800
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; b=qz6wuwSBvOZj1iX+Ojco17VUEV5jEobiyRKfucHcKPwHcQBJuJQoiIuF6tjyUlGVZE orgQGTtMvQF7AVTtGF5EGRuLq8xlOSIoDIF97YTu4kRncEovcH0Oi9Fg2Bp7jIbtHlBW QHiu9uDBublwwInqvUsH1cxujbC/PNzG2y8kg=
This small example can also be solved using destruct
(hence light proof term and easy control on names).
The script is not that long either.
On Thu, Apr 07, 2011 at 09:45:08AM +0200, Guillaume Melquiond wrote:
> Le mercredi 06 avril 2011 à 12:50 -0400, Benjamin C. Pierce a écrit :
>
> > Someone in my class asked a question about destruct vs. inversion: They
> > can be described in similar terms ("generate subgoals for each of the
> > possible ways that such-and-such could have been built..."), and there
> > are many situations where either can be used; so what's the actual
> > difference?
> >
> > Does anyone have a concise, intuitive way of explaining how they overlap
> > in function and how they differ, and/or a snappy characterization of when
> > to use one and when the other?
>
> Here is a short answer that encompasses the ones you already got:
> Whenever using dependent types, inversion looks at the dependency to
> keep only meaningful cases, while case/destruct generates all of the
> branches. The downside is that inversion terms are heavyweight, so you
> should not use it for plain inductive types for instance.
>
> Here is a small example:
>
> Variable a : nat.
> Inductive W : bool -> Type :=
> | W1 : a = 0 -> W false
> | W2 : a <> 0 -> W true.
> Goal W false -> a = 0.
> intros H.
> - destruct H. (* ignores "false" in H and generate two subgoals, one
> being unprovable! *)
> - inversion H. (* generates only the goal for the W1 branch *)
>
> Best regards,
>
> Guillaume
intros H.
change (if false then True else a = 0).
destruct H as [e | _]; try exact I.
There are many variants. For more examples, including from sf, you may
have a look at "Small Inversions".
http://hal.inria.fr/inria-00489412/en/
Hope this helps,
JF
- [Coq-Club] Destruct vs. inversion, Benjamin C. Pierce
- Re: [Coq-Club] Destruct vs. inversion, Daniel Schepler
- Re: [Coq-Club] Destruct vs. inversion, Nathan Collins
- Re: [Coq-Club] Destruct vs. inversion,
Guillaume Melquiond
- Re: [Coq-Club] Destruct vs. inversion, Jean-Francois Monin
- Re: [Coq-Club] Destruct vs. inversion,
Benjamin C. Pierce
- Re: [Coq-Club] Destruct vs. inversion, Jacques Garrigue
- Message not available
- Re: [Coq-Club] Destruct vs. inversion, Pierre Boutillier
- Message not available
- Re: [Coq-Club] Destruct vs. inversion, Paolo Herms
- <Possible follow-ups>
- Re: [Coq-Club] Destruct vs. inversion,
Daniel de Rauglaudre
- Re: [Coq-Club] Destruct vs. inversion, Chantal Keller
- Message not available
- Re: [Coq-Club] Destruct vs. inversion, Daniel de Rauglaudre
Archive powered by MhonArc 2.6.16.