coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Abhishek Anand <abhishek.anand.iitg AT gmail.com>
- To: coq-club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] A question regarding Coq rational arithmetic
- Date: Wed, 22 Mar 2017 20:56:04 -0400
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=abhishek.anand.iitg AT gmail.com; spf=Pass smtp.mailfrom=abhishek.anand.iitg AT gmail.com; spf=None smtp.helo=postmaster AT mail-qt0-f176.google.com
- Ironport-phdr: 9a23:arDxZxDkgdFSb5KMjRF/UyQJP3N1i/DPJgcQr6AfoPdwSPT4rsbcNUDSrc9gkEXOFd2CrakV16yO6+jJYi8p2d65qncMcZhBBVcuqP49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6JvjvGo7Vks+7y/2+94fdbghMizexe69+IAmrpgjNq8cahpdvJLwswRXTuHtIfOpWxWJsJV2Nmhv3+9m98p1+/SlOovwt78FPX7n0cKQ+VrxYES8pM3sp683xtBnMVhWA630BWWgLiBVIAgzF7BbnXpfttybxq+Rw1DWGMcDwULs5Xymp4aV2Rx/ykCoINTA5/mHZhMJzkaxVvg6uqgdlzILIeoyYLuZycr/fcN4cWGFPXtxRVytEAo6kc4YAFOoBPedDr4n9uVQOrga1CBWqBOz1zD9Hm2L90Kog3Os6EQHG3RcgH9IQv3TXttn6LqESXvqzzKbV1znDbvJW2Svy6IXTfRAhpOuDXbN0ccbL1UYvEAbFg0yWpIf4MT2V0eENvHKa7+pmTe+gl2knqxt3ojexwscsjpPFiZwIxVDZ7Sl5wYA1Jce5SEFhe9KkHoFQuzmVN4t3XsMiQ3xotz0gxrIavp67eS4Hw4kkyR7Hc/GLbZSE7xb5WOuSITp0nmxpdK++ihqo7EStyOzxW8+p21hQtCVFiMPDtnUV2hzT9MeHTvx981+k2TmV1gDT7vhIIVkolabHMpIhzKM8m5gSvEjZES/2n0L2jKCSdko64OSn9+PnYrD+qp+dMY97lB3+P7wwlsCjBek0KAsDUmiB9eiiybHu/Ff1TKhIg/A3iqXZtYrVJcUfpq63GQ9V1YMj5g6lADi90NQYnGIHLFJbdxKElYTmIVfOL+r+DfiimViskTZrx+zJPrD6DZXNK2LMkLblfbpn90Fczw8zwchF551IErEBPO7zWkjpudPECR85KhW4zPrjCNVgzYwTQnmPA6+cMKPKq1CE/OMvI++WZI8UojnxMfYl5+S9xUM+zFQaZOyi2YYdICSzGe0jKEGEa1LthM0AGCEEpFxtYvbtjQirWz5SfHa/XOoV4Dg9BMryBI3DR5utjb/H1SGyGJEQZ2FaBXiDFH7pc8OPXPJaO3HaGdNojjFRDevpcIQmzxz77AI=
To trade-off some of the correctness guarantees for speed, you may want to replace functions like Z.add (which calls BinPos.add) with native Haskell ones by adding the following imports before invoking extraction:
Require Import ExtrHaskellZInteger.
Require Import ExtrHaskellZNum.
For better correctness guarantees, you may also want to look at:
Also, you may want to generalize your code to be parametrically polymorphic over an interface of rationals (see MathClasses).
Then you would be able to swap in and out various implementations of rationals easily.
(It is quite likely that much weaker interfaces suffice for parts of your code.)
-- Abhishek
http://www.cs.cornell.edu/~aa755/On Wed, Mar 22, 2017 at 8:04 PM, Milad Ketabii <ketabii.math AT gmail.com> wrote:
Good DayWe're using coq libraries for rational arithmetic to formalize some electronic voting schemes, and then extract in Haskell to actually do the counting for a real election. Our extracted code in Haskell works fine for up tp 68 number of votes. However, when we go for 69 (or above) the program does not terminate!When we do profiling, there is nothing strange with respect to memory consumption or time for numbers below 69. However, there is a function "add" from library "BinPos" for adding two Positives, which takes up to 70% of the memory. It seems this function is the culprit, but such behaviour is weird. Has anyone ever encountered something similar with Coq rational arithmetic before? Any suggestion is welcome.BestMilad
- [Coq-Club] A question regarding Coq rational arithmetic, Milad Ketabii, 03/23/2017
- Re: [Coq-Club] A question regarding Coq rational arithmetic, Abhishek Anand, 03/23/2017
- Re: [Coq-Club] A question regarding Coq rational arithmetic, Laurent Thery, 03/23/2017
Archive powered by MHonArc 2.6.18.