coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Guillaume Melquiond <guillaume.melquiond AT inria.fr>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] How can I extract data from this exists Prop?
- Date: Mon, 10 Aug 2020 10:02:04 +0200
Le 10/08/2020 à 05:55, Agnishom Chattopadhyay a écrit :
> I have a function that is something like this:
>
> Definition isPrefixOf (x : list A) (y : list A) :=
> exists z, x ++ z = y.
>
> Now, I want to define a witness function. Informally, it can be
> described as follows: Given x and y such that (isPrefixOf x y), return z
> which satisfies the criteria exists z, x ++ z = y.
>
> I would try to define it this way, but that would not work (possibly
> because exists z, x ++ z = y is a Prop and we are asking for something
> in Type) :
>
> Definition witness (x y : list A) {H : isPrefixOf x y} : list A.
> destruct H.
> Abort.
Indeed, H is a proof of proposition, so you cannot use it to produce an
actual value. It can only be used for things like proving the
termination of a recursive function.
Note that the witness function does not have to return z such that "x ++
z = y" in the general case (it is impossible anyway). It only has to do
so, if there actually exists such a z. So, we can use any dirty trick we
want to define the witness function.
For example, the function below will almost always return nonsensical
results, but we can prove that, if "isPrefixOf x y" holds, then "x ++
witness (x y) = y" holds too.
Definition witness (x y : list A) := skipn (length x) y.
Note that we do not even need to use H in the definition, since
termination is already proved by definition.
Best regards,
Guillaume
- [Coq-Club] How can I extract data from this exists Prop?, Agnishom Chattopadhyay, 08/10/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Guillaume Melquiond, 08/10/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Castéran Pierre, 08/10/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Agnishom Chattopadhyay, 08/10/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Emilio Jesús Gallego Arias, 08/25/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Agnishom Chattopadhyay, 08/25/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, jonikelee AT gmail.com, 08/25/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Robbert Krebbers, 08/25/2020
- Message not available
- Message not available
- Re: [Coq-Club] How can I extract data from this exists Prop?, jonikelee AT gmail.com, 08/25/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, jonikelee AT gmail.com, 08/26/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Arthur Azevedo de Amorim, 08/26/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, Robbert Krebbers, 08/27/2020
- Re: [Coq-Club] How can I extract data from this exists Prop?, jonikelee AT gmail.com, 08/25/2020
- Message not available
- Message not available
- Re: [Coq-Club] How can I extract data from this exists Prop?, Robbert Krebbers, 08/25/2020
Archive powered by MHonArc 2.6.19+.