coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Clément Pit-Claudel <cpitclaudel AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] fun <-> forall
- Date: Tue, 31 Oct 2017 08:43:56 -0400
- Authentication-results: mail2-smtp-roc.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-f179.google.com
- Ironport-phdr: 9a23:rjfvBxcYyZhfv7jv5Ny/NBdslGMj4u6mDksu8pMizoh2WeGdxc28YB7h7PlgxGXEQZ/co6odzbGJ4+a9ASQp2tWojjMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpW1aJhKqPg1sY+/xB4T6jsKt1un09YeATR9PgW+WZTJ3IROqmj3Qqow9hYJ/Jqs1gk/CunpUcOBf2G9lIXqcmh/94oG7+5s1oHcYgO4o68MVCfayRK8/V7ENVDk=
On 2017-10-31 01:19, Jason Gross wrote:
> Does this work? It's shorter, but I don't have a computer at the moment to
> test it with.
Yes! Much nicer.
> On Thu, Oct 26, 2017, 9:08 AM Clément Pit-Claudel
> <cpitclaudel AT gmail.com
>
> <mailto:cpitclaudel AT gmail.com>>
> wrote:
>
> 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'.
> >>
> >
>
- Re: [Coq-Club] fun <-> forall, (continued)
- 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, Cyril Cohen, 10/31/2017
Archive powered by MHonArc 2.6.18.