coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: e AT x80.org (Emilio Jesús Gallego Arias)
- To: Xavier Leroy <Xavier.Leroy AT inria.fr>
- Cc: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction]
- Date: Wed, 20 Dec 2017 23:01:51 +0100
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=e AT x80.org; spf=Pass smtp.mailfrom=e AT x80.org; spf=Pass smtp.helo=postmaster AT x80.org
- Ironport-phdr: 9a23:7OQR7RCyCIgVHDvLER/mUyQJP3N1i/DPJgcQr6AfoPdwSPT/pcbcNUDSrc9gkEXOFd2Cra4c0qyO6+jJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fcbglUmTaxe69+IAmrpgjNq8cahpdvJLwswRXTuHtIfOpWxWJsJV2Nmhv3+9m98p1+/SlOovwt78FPX7n0cKQ+VrxYES8pM3sp683xtBnMVhWA630BWWgLiBVIAgzF7BbnXpfttybxq+Rw1DWGMcDwULs5Qiqp4bt1RxD0iScHLz85/3/Risxsl6JQvRatqwViz4LIfI2ZMfxzdb7fc9wHX2pMRsZfWTJcDIO7YYsBAegOM+VWoIbyu1QDtge+CRW2Ce/z1jNFnH370Ksn2OohCwHG2wkgEsoQv3nPo9T4N7seXfqyzKnSwjXIcvda1zj46IjJdhAhoPaMVq90f8XP0kk3DRjFhUiRp4P/OzOV0voCs2ec7+F9Se+vkW8npBtqojSqwMonl4fHhoUQyl/e9CV5xp44JdK5SE5nYd6kDYBfuzuGOItxR8MvRXxjtiUiyrAepJK2fysHxI45yxLBavGLaZWE7xD+WOqLPDt1imxpdKq8ihuz60Sty+/xWtOw3VpQsyZJjNrBu3YQ3BLJ8MeHUOFy/kK51DaPyQ/T7uZELFg7lKfYN5It2LkwloAcsUjbHy/2nlv5jLOOe0k5+eWl6P7rbqv4qpKdLYN4lwPzPrk0lsCiD+k0LBACX22B9uS90L3j81f5QLJPjvAujKbUq5/bKMcHqqKjBA9VyIkj5w6lDzi6yNQYgWUHLFVddR2biIjpIkjCL+z8DfeimFuhiyxrxvDDPr35GJrBNHnDkLH7fbZ88UFQ0gQzzcpH7ZJOFr4BOO7zWlP2tNHAAR45NxK7w/zgCNR9zY4fWGOPAqqCP6PIq1CE/OMvI++WZI8UojnxMfYl5+S9xUM+zG8UY6ikx9MzZWq/D7wyE0yHYHf2xPMMC2Ablgs4Vu3jzlOYB219fXG3Cq8U9mFjToW8As+Da4WshL2GlAW2BQ9NLk9PDlSBHnCgXp+FUuxNO3HaGdNojjFRDevpcIQmzxz78Vaik7c=
- Organization: X80 Heavy Industries
Xavier Leroy
<Xavier.Leroy AT inria.fr>
writes:
> I find the following definition of vectors a lot easier to work with
> than the one that is currently in the standard library:
>
> Fixpoint vec (A: Type) (n: nat) : Type :=
> match n with
> | O => unit
> | S m => (A * vec A m)%type
> end.
>
> With this definition and the "convoy pattern" from CPDT you're in control!
Let me also suggest the approach of using a regular list + a proof of
size. The example I know is done in mathcomp:
Structure tuple_of : Type :=
Tuple {tval :> list T; _ : length tval == n}.
this has the advantage of extracting reasonably well [with a big of
massage] and avoiding the duplication of most list operations using
automatic inference of proofs.
It can be shown that `tval` is injective, and indeed math-comp provides
a "subType" mechanism that helps in mixing tuples and lists.
[In fact, both definitions of vectors can be declared to be a subType of
lists, not that this is very useful in practice, see [1] if you are
curious.]
E.
[1] https://github.com/ejgallego/ssr-tools/tree/master/coq-vector
- [Coq-Club] Trouble with dependent induction, Matěj Grabovský, 12/17/2017
- Re: [Coq-Club] Trouble with dependent induction, Jasper Hugunin, 12/17/2017
- Re: [Coq-Club] Trouble with dependent induction, Adam Chlipala, 12/17/2017
- [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Adam Chlipala, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Robby Findler, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Xavier Leroy, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/20/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/17/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Adam Chlipala, 12/18/2017
- Re: [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Adam Chlipala, 12/17/2017
- [Coq-Club] Vector in Coq [Was: Re: Trouble with dependent induction], Emilio Jesús Gallego Arias, 12/17/2017
- Re: [Coq-Club] Trouble with dependent induction, Matthieu Sozeau, 12/17/2017
- Re: [Coq-Club] Trouble with dependent induction, Matěj Grabovský, 12/19/2017
- Re: [Coq-Club] Trouble with dependent induction, Adam Chlipala, 12/17/2017
- Re: [Coq-Club] Trouble with dependent induction, Jasper Hugunin, 12/17/2017
Archive powered by MHonArc 2.6.18.