coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Fritjof Bornebusch <fritjof AT uni-bremen.de>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] conversion from vector to list and back
- Date: Fri, 22 May 2020 09:55:41 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=fritjof AT uni-bremen.de; spf=Pass smtp.mailfrom=fritjof AT uni-bremen.de; spf=None smtp.helo=postmaster AT gabriel-vm-2.zfn.uni-bremen.de
- Ironport-phdr: 9a23:dO+y/xWlrDdGuoZOLmY3WkPQDA7V8LGtZVwlr6E/grcLSJyIuqrYbRyFt8tkgFKBZ4jH8fUM07OQ7/m9HzVZu93Y6ilKWacPfidNsd8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3wOgVvO+v6BJPZgdip2OCu4Z3TZBhDiCagbb9oIxi6sAXcutMLjYd/NKo9xQbFrmVVd+9L2W5mOFWfkgrm6Myt5pBj6SNQu/wg985ET6r3erkzQKJbAjo7LW07/dXnuhbfQwSB4HscSXgWnQFTAwfZ9hH6X4z+vTX8u+FgxSSVJ8z2TbQzWTS/86dmTQLjhSkbOzIl9mzcl8t/gr9GoBK6vxxw3ZLbYJ2bOvp5e6PSZ9IaRWxcVcpVWCFMBoawYo0SBOQDIOlYtZHwqVUOoxWgGAeiB+3vxTBUiXDr36I3yPghHR3c0QA8A94CrHbZodPoP6kSS+C1y6zIwC3DYfNM2Df99IrIchcvofqRQL9wdtDRyU8xGAzek1WQspDqPzOI3ekKvWib9etgVf6ti24gpQF8uSWvxsEtioXQnY0V0E7L9SBnz4YzP9G3VVB0bMeiHZBNuC6UK5F4Tdk+Q2F0pik60LsGtIa0ciUWxpkpyR7RZfyHfYSU7B/uVPqcLDZliX95e7+xhwq//Emkx+PySMS60FJHoyVGn9TQq3wA2BLe59SFR/Vy+EqqxDiB1wfW6u5eIEA0k7LWK5Egwr4slpoTrF/MEjX3mEXxlKOWeUQk+vSo6+T6ebrqvIOTN4hxig3mKKsugMO+AeUmMgQUWGib4+u82bv+9kP6WLVHluA6n6fWvZzAOMgXurC1DxVV34o/8RqzEjWr3MwbkHUZNl5JZg6LgorzN13QPvz0Ee2zj0mvnTprwf3NI6fvDY/XLnfZlbfsZbZ95FBYyAo01d1f6IhbBaobIPLyREDxsMXUDgE8MwCt3errEtR81o0YWW6VH6+ZNqLSvUaT6eI1PeaMYZEauDDnJ/c4+fHilX45mVkDcqm1xZYbdX61E/t8L0mEfXbgnM0NHGcWsgYkUeDnikWOUTtJaHazW6I86Cs7CIWjDYrbSICtmr2B3Du5Hp1RaGBLEU2MEXHpd4mdQPgMcjydIsp/nTwCT7SuVpEu2Qm0tADm07pnMvbU+ioAuJ3/09h1/vTfmg029TxpFMuQyHqNTmFxnmMQXTA6xqF/oUpnyleCy6d0mfJYFcYAr89OBww9LNvXy/FwI9H0QAPIONmTG3i8RdDzLyswUtA2zZckZFx7Ft+/lRvDl36kGb4JlbuFLIEy8+fWxXX0KsA7x3uQh/pptEUvXsYabT7uvaV47QWGW9+Qwhep0p2yfKFZ5xbjsWKKzG6ApkZdCVMiTKPEGHoFa07bq5L16xGbFuP8OfEcKgJEjPW6BO5ScNSw0AdbQvamMs7TZm+33Wu9V07Rm+G8KbHycmBY5x3zTUgJlwdIpySJPAIkByql5nzbSWYoB1zpJV7q8Kx0sn6+Q0lywwzYN0A=
On Thu, May 21, 2020 at 08:27:05PM -0700, Talia Ringer wrote:
> I guess they also give the functions for the equivalence in a really
> awkward form in the standard library. The equivalence between { l :
> list T & length l = n } to vector T n will move this problem to a place
> where it actually makes sense for it to show up.
>
> On Thu, May 21, 2020, 8:12 PM Talia Ringer
> <[1]tringer AT cs.washington.edu> wrote:
>
> In general, this happens with dependent types when you are dealing with
> some kind of equivalence. If two types are equivalent, you can find
> functions that get you back and forth that are mutual inverses, so:
>
> f : A -> B
>
> g : B -> A
>
> where two properties called section and retraction hold:
>
> section: forall a, g (f a) = a
>
> retraction: forall b, f (g b) = b
>
> But note that these properties don't hold definitionally. You must
> prove section and retraction hold, and then you rewrite by it in order
> to get the type you actually want. So the Coq specification is correct.
> This problem of dealing with equivalent types is called "transport,"
> and it's hard. It is easier in homotopy type theory, or in my tool
> DEVOID for some types like lists and vectors (paper:
> [2]http://tlringer.github.io/pdf/ornpaper.pdf, tool:
> [3]https://github.com/uwplse/ornamental-search), or in the univalent
> parametricity framework ([4]https://arxiv.org/pdf/1909.05027.pdf).
> If you want to do these conversions yourself, without using any
> external tools at all, your best bet is to prove section and
> retraction, and then rewrite by those. But it will suck. I really
> recommend using a tool for this kind of thing.
> Talia
>
Thank you for the explanation and the hint. I will take a look
at your tool.
--f.
> On Thu, May 21, 2020 at 6:05 AM Fritjof Bornebusch
> <[5]fritjof AT uni-bremen.de> wrote:
>
> On Thu, May 21, 2020 at 02:34:31PM +0200, Maximilian Wuttke wrote:
> > On 21/05/2020 14:18, Fritjof Bornebusch wrote:
> > >
> > > => In environment
> > > bv : BitVector_10
> > > The term "Vector.of_list (Vector.to_list bv)" has type
> > > "Vector.t bool (length (Vector.to_list bv))"
> > > while it is expected to have type "BitVector_10".
> >
> > You might have to 'cast' `length (Vector.to_list bv)` to `10`.
> (The are
> > equal, but not simply by conversion). You can try to use the
> function
> > `cast: forall {A m} (v: t A m) {n}, m = n -> t A n`.
> >
> > Heads up: Some functions (including `cast` and `to_list`) in the
> vector
> > library don't have the expected `cbn` simplification behaviour.
> Also,
> > many obvious lemmas are missing. There are some libraries that
> extend
> > (among others) this part of the standard library.
> >
> >
> Thanks for the hint. Do you have a link to these libraries?
>
> References
>
> 1. mailto:tringer AT cs.washington.edu
> 2. http://tlringer.github.io/pdf/ornpaper.pdf
> 3. https://github.com/uwplse/ornamental-search
> 4. https://arxiv.org/pdf/1909.05027.pdf
> 5. mailto:fritjof AT uni-bremen.de
- [Coq-Club] conversion from vector to list and back, Fritjof Bornebusch, 05/21/2020
- Re: [Coq-Club] conversion from vector to list and back, Siegfried, 05/21/2020
- Re: [Coq-Club] conversion from vector to list and back, Maximilian Wuttke, 05/21/2020
- Re: [Coq-Club] conversion from vector to list and back, Fritjof Bornebusch, 05/21/2020
- Re: [Coq-Club] conversion from vector to list and back, Talia Ringer, 05/22/2020
- Re: [Coq-Club] conversion from vector to list and back, Talia Ringer, 05/22/2020
- Re: [Coq-Club] conversion from vector to list and back, Fritjof Bornebusch, 05/22/2020
- Re: [Coq-Club] conversion from vector to list and back, Talia Ringer, 05/22/2020
- Re: [Coq-Club] conversion from vector to list and back, Talia Ringer, 05/22/2020
- Re: [Coq-Club] conversion from vector to list and back, Fritjof Bornebusch, 05/21/2020
Archive powered by MHonArc 2.6.19+.