coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Guillaume Melquiond <guillaume.melquiond AT inria.fr>
- To: "Benjamin C. Pierce" <bcpierce AT cis.upenn.edu>
- Cc: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Destruct vs. inversion
- Date: Thu, 07 Apr 2011 09:45:08 +0200
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
- [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.