coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Clément Pit-Claudel <cpitclaudel AT gmail.com>
- To: Burak Ekici <ekcburak AT hotmail.com>, "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] fun <-> forall
- Date: Thu, 26 Oct 2017 12:07:24 -0400
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=cpitclaudel AT gmail.com; spf=Pass smtp.mailfrom=cpitclaudel AT gmail.com; spf=None smtp.helo=postmaster AT mail-qk0-f169.google.com
- Ironport-phdr: 9a23:xTOTPxNMZ5sAmnLsRV4l6mtUPXoX/o7sNwtQ0KIMzox0KPj/rarrMEGX3/hxlliBBdydsK0UzbeO+4nbGkU+or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6aijSI4DUTAhTyMxZubqSwQ9aKzpf/6+fn0YDJagYAqTm8arI6eBi1pg/MrMAVqYtlNqM4yx+PqXxNLaAej2hvPBeYmwv2zsa25p9qtSpK8bp1/MlZFK7+Yq4QTLpCDT1gPXpjt+PxshyWZg8O43YaTlIukwYNKAzM8R33Wt+luTP7quF50TSWMMneQrU9WDDk5KBuHky7wBwbPiI0pTmEwvd7i7hW9Vf4/0Ry
Turning this into a tactic turns out to be surprisingly tricky. Can someone
share a better solution? Here's mine:
Ltac specialize_eq_ind_argument eql x :=
constr:(fun f => ltac:(lazymatch (eval cbv beta in (eql f)) with
| ?l = ?r => exact (l x = r x)
end)).
Ltac quantify_equality eql arrow_type k :=
lazymatch (eval cbv beta in arrow_type) with
| forall (h:?hd), @?tl h =>
let binder := fresh "x" in
constr:(fun (binder: hd) =>
ltac:(let eql_with_hd := specialize_eq_ind_argument eql
binder in
let with_tl := quantify_equality eql_with_hd (tl
binder) k in
exact with_tl))
| _ => k eql
end.
Ltac reverse_functional_extensionality H :=
lazymatch type of H with
| _ = ?g =>
let tg := type of g in
let pr := quantify_equality (fun f0 => f0 = g) tg ltac:(fun eql =>
constr:(eq_ind_r eql eq_refl H)) in
let h' := fresh H in
pose proof pr as h';
cbv beta in h'
end.
And here's an example:
Axiom catC: Type.
Axiom obj: Type -> Type.
Axiom arrow: forall (catC: Type), obj catC -> obj catC -> Type.
Axiom fmap : forall {C: Type} (a b: obj C), arrow C b a -> Type.
Axiom foo : forall {C a b}, arrow C b a -> arrow C b a.
Goal ((fun (a b : obj catC) (f : arrow catC b a) => fmap a b (foo f)) =
(fun (a b : obj catC) (f : arrow catC b a) => fmap a b f) -> True).
Proof.
intros.
reverse_functional_extensionality H.
Clément.
On 2017-10-26 11:11, Burak Ekici wrote:
> Hi Clément,
>
> Thanks a lot! That's exactly what I was looking for...
>
> Best,
>
> ―
>
> Burak.
>
>
>
> On 26-10-2017 18:08, Clément Pit-Claudel wrote:
>> On 2017-10-26 10:25, Burak Ekici wrote:
>>> However, could not make it work whatever I did...
>> Does the following work for you?
>>
>> pose proof (fun x y z => eq_ind_r (fun f => f x y z = _ x y z) eq_refl
>> H1c) as H';
>> cbv beta in H'.
>>
>> Here's a complete example:
>>
>> Axiom catC: Type.
>> Axiom obj: Type -> Type.
>> Axiom arrow: forall (catC: Type), obj catC -> obj catC -> Type.
>> Axiom fmap : forall {C: Type} (a b: obj C), arrow C b a -> Type.
>> Axiom foo : forall {C a b}, arrow C b a -> arrow C b a.
>>
>> Goal ((fun (a b : obj catC) (f : arrow catC b a) => fmap a b (foo f)) =
>> (fun (a b : obj catC) (f : arrow catC b a) => fmap a b f) -> True).
>> Proof.
>> intros.
>> pose proof (fun x y z => eq_ind_r (fun f => f x y z = _ x y z) eq_refl
>> H) as H';
>> cbv beta in H'.
>>
>
- [Coq-Club] fun <-> forall, Burak Ekici, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Ralf Jung, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Robbert Krebbers, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Ralf Jung, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Burak Ekici, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Clément Pit-Claudel, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Burak Ekici, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Clément Pit-Claudel, 10/26/2017
- Message not available
- Re: [Coq-Club] fun <-> forall, Samuel Gruetter, 10/28/2017
- [Coq-Club] Macro for Ltac, Dominique Larchey-Wendling, 10/30/2017
- Re: [Coq-Club] Macro for Ltac, Pierre Courtieu, 10/30/2017
- Re: [Coq-Club] Macro for Ltac, Dominique Larchey-Wendling, 10/30/2017
- Re: [Coq-Club] fun <-> forall, Burak Ekici, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Clément Pit-Claudel, 10/30/2017
- Re: [Coq-Club] fun <-> forall, Clément Pit-Claudel, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Burak Ekici, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Jason Gross, 10/31/2017
- Re: [Coq-Club] fun <-> forall, Clément Pit-Claudel, 10/31/2017
- Re: [Coq-Club] fun <-> forall, Ralf Jung, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Cyril Cohen, 10/31/2017
- Re: [Coq-Club] fun <-> forall, Robbert Krebbers, 10/26/2017
- Re: [Coq-Club] fun <-> forall, Ralf Jung, 10/26/2017
Archive powered by MHonArc 2.6.18.