coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Merlin Göttlinger <megoettlinger AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Mutual Fixpoints into mutual inductive types
- Date: Mon, 08 Jan 2018 18:25:26 +0000
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=megoettlinger AT gmail.com; spf=Pass smtp.mailfrom=megoettlinger AT gmail.com; spf=None smtp.helo=postmaster AT mail-io0-f171.google.com
- Ironport-phdr: 9a23:iQWAXx0wMiIC5FxxsmDT+DRfVm0co7zxezQtwd8ZseIWLfad9pjvdHbS+e9qxAeQG9mDsrQc06L/iOPJYSQ4+5GPsXQPItRndiQuroEopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZvJuTyB4Xek9m72/q99pHPfglEniaxba9vJxiqsAvdsdUbj5F/Iagr0BvJpXVIe+VSxWx2IF+Yggjx6MSt8pN96ipco/0u+dJOXqX8ZKQ4UKdXDC86PGAv5c3krgfMQA2S7XYBSGoWkx5IAw/Y7BHmW5r6ryX3uvZh1CScIMb7S60/Vza/4KdxUBLnhykHODw5/m/ZicJ+kbxVrw66qhNl34LZepuYOOZicq7fe94RWGpPXtxWVyxEGo6yaJUAD/AFPeZZqYnyv1oAtR2iBQmwAOPvyzlIhnDo0q0gzu8sFgTG0xIvH9IJrnvUsMn1NKMTUeCzw6nH0y/DYuhZ2Tf48ofIcxQhreuQUrJ3dMrc0E8iHB7LgFWXrIzqJTKV1uIVvmiZ6OpvT/6gi24mqwF0uzSg3d0shZfIhoIJzFDL6z95zJwoKtKmUEJ7bt+kEIdQtyGHLIR6WN8tQ2ZtuCs817YIuoa7cTAUxJg7wxPTcf+KfoiS7h79SuqcLy10iG9ndb6igRu57FKuxffmVsau1VZHtipFncfItnAKzxHT79KISvp5/ku42DaP0Bzf5vhKIUwpl6fXNoQtwrE3lpoUvkTDGjH5lF/qg6+Rc0Uo4umo6+L5bbX6vpKQKZN4hwXkPqktmsGzG/o0PhYAUmSB5Oix1qDv8VX8QLpQj/02lqfZsIrdJcQevqO5BhFa0okk6xmhEzemzNAYnXgBLFJKZh2HlZPkO17LIP/iDPe/h06gnytsx/DDJrHhGInCLmDfkLf9erZw81JTyA0qzdxG+51UDqwBL+noV0/qtN3YCwc5PBauz+bmDtV9zIIeVniVDq+XKqOB+WOPs+koOqyHYJIfkDf7MfksofD03lEjnlpIWKSz2ZoRX18mAuhiIkOWbGCk1tIMHmAHohY6TerlhUeqXjtaZnL0VKU5sGJoQLm6BJvOE9j+yIeK2z22S8Vb
Hi,
sorry for the confusion:
That should be a self contained file that exhibits the desired and the working implementation.
The version with traverse being implemented on instance creation is also in there as traverse'.
Cheers,
Merlin
Joachim Breitner <mail AT joachim-breitner.de> schrieb am Mo., 8. Jan. 2018 um 16:25 Uhr:
Hi,
I am a bit lost. Can you share a complete minimal working example of
the Coq code that you hoped to work, and also the variant that you
wrote that actually work?
Cheers,
Joachim
Am Montag, den 08.01.2018, 10:53 +0000 schrieb Merlin Göttlinger:
> Hi,
>
> Joachim Breitner <mail AT joachim-breitner.de> schrieb am Mo., 8. Jan. 2018 um 11:04 Uhr:
> > Hi,
> >
> >
> > Am Montag, den 08.01.2018, 08:23 +0000 schrieb Merlin Göttlinger:
> > > sure. My guess would be that I messed up the encoding of the
> > > hierarchy and the fmap call in the implementation of traverse is
> > > therefore not resolved to be be the Vector.map call.
> > > https://gist.github.com/mgttlinger/db35a3748f1dfe68c152678f9a714c06
> >
> > ah, you are using features I have not played around with (e.g. :>, and
> > default definitions in a record).
>
> I just tried implementing traverse like this:
>
> Definition traverse `{T: Traversable} `{@Applicative G} {t u} : (t -> G u) -> F t -> G (F u) :=
> let f := T _ (t_f__) in fun f ft => sequence (fmap f ft).
>
> As to not rely on the default implementation in the record. That didn't change anything.
> Implementing traverse at the instance creation also didn't help.
> I suspect it could be because my implementation is defined interactively.
>
> Definition vSequence {G} {n} `{Applicative G} : forall T, Vector.t (G T) n -> G (Vector.t T n).
> intros. induction X; pose proof _f as f; pose proof _p as p. apply pure; trivial. apply (@point (fun f => Vector.t f 0) _ _). eapply ap. apply (fmap (fun a b => a :: b) h). exact IHX.
> Defined.
>
> This is the definition. The Instance is then essentially
>
> Definition vTraversable {G} {n} : @Traversable__Dict (fun t => Vector.t t n) G := {| sequence__ _ := vSequence;
> |}.
> Global Instance vector_Traversable {n} {G} : @Traversable (fun t => Vector.t t n) G := fun r f => f vTraversable.
>
> > Does it work if you do not give the definition of traverse__ in the
> > Record definition, and instead give it during your Instance? Where is
> > your Instance?
> >
> > > What is the "local go" pattern? A quick google lead me only to things
> > > related to Go-lang.
> >
> > There might be a better name. It is the problem that nested recursion
> > through map defined like
> >
> > Fixpoint map f xs := match xs with
> > | [] => []
> > | x :: ys => f x :: map f ys end.
> >
> > fails but
> >
> > Definition map f :=
> > fix go xs := match xs with
> > | [] => []
> >
> > | x :: ys => f x :: go ys end.
> >
> > works.
>
> Good to know.
>
> Cheers,
> Merlin
--
Joachim Breitner
mail AT joachim-breitner.de
http://www.joachim-breitner.de/
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, (continued)
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Pierre Courtieu, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/07/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/07/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/08/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/08/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/08/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/08/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/08/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/08/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/07/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Joachim Breitner, 01/05/2018
- Re: [Coq-Club] Mutual Fixpoints into mutual inductive types, Merlin Göttlinger, 01/05/2018
Archive powered by MHonArc 2.6.18.