coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Suneel Sarswat <suneel.sarswat AT gmail.com>
- To: coq-club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] OCaml extraction and proof obligations
- Date: Sat, 23 Jan 2021 00:48:21 +0530
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=suneel.sarswat AT gmail.com; spf=Pass smtp.mailfrom=suneel.sarswat AT gmail.com; spf=None smtp.helo=postmaster AT mail-ej1-f48.google.com
- Ironport-phdr: 9a23:kP5ztR8v95AVj/9uRHKM819IXTAuvvDOBiVQ1KB20ukcTK2v8tzYMVDF4r011RmVBNSdsqwP27Oe8/i5HzBZvtDZ6DFKWacPfidNsd8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3wOgVvO+v6BJPZgdip2OCu4Z3TZBhDiCagbb9oIxi6sAHcutMLjYZjJao8yQbFqWZMd+hK2G9kP12ekwv+68uq4JJv7yFcsO89+sBdVqn3Y742RqFCAjQ8NGA16szrtR3dQgaK+3ARTGYYnAdWDgbc9B31UYv/vSX8tupmxSmVJtb2QqwuWTSj9KhkVhnlgzoaOjEj8WHXjstwjL9HoB+kuhdyzZLYbJ2TOfFjeK7WYNEUSndbXstJWCNBDIGzYYsBAeQCIOhWsZXyqkAUoheiHwShHv/jxiNKi3LwwKY00/4hEQbD3AE4AtwOrXLUo8vrO6cWTOu70bPHzS/Yb/JYwzj99JXDfxc6ofGRW7J/b9TeyU01GwPelFqQs5flPj2P2eQRqGWb4O9gWviui24jsQ1+vj+vxsI1h4TPm4kaxUzK+z9jz4YpOd23VlR7Ydi8HZZOqS2XKZV7T8IjTmxmpSo21LIItYOncSUFypkq2R3SZv6JfoSU4h/uVeifLCtmiX9le7+ymxi//FavxODhVMS51ktBoCRCktnJrH8N1hrT59CaSvtl4Eih3zCP2xrN5e5ZPEA4ja7bJIA6zbIql5oTqkLOFTL1lkXulKKaaFko9+yy5+nkYrjqvIGQO5J3hw3kPakjmcqyCvkiPAcURWiU4+G82aXj/ULnRLVKieU7kqzDv5DbIcQXv7C2Aw1I3oo65RayADSr3M4XnXkAK1JFdxaHgJbzN17SJ/D4CO+zg1WqkDh12/DLJqPtDonJI3TZk7rsfaxx51BBxAcw19xS6JFZBqkEIP3pW0/xsNLYDgU+Mwyx2+vnE8h91oUAVm2RBq+VKrjSvkWS5uI0LeiDfpMVtS3yK/gg/fHujHs5lUUBcqmu2JsbcGq4Eeh+I0WFfXrshc8MHnsNvgonVeDllFmCUSNIaHupRKI95jQ7CJq8AovZR4CthqaB3CahEZFMaGBGEAPELXC9fIKdHvwIdSjadsRmi3kPUaWrY44nzxCn8gHgnelJNO3RrxYFs5/u0JBO7vfIihguvWhvEsKQ3mXLVGhuhXwBWxc52al+pQp2zVLVgvswuOBRCdEGv6ABaQw9L5OJl7UnWeC3YRrIe5KycHjjQtiiBmtsHNc4wttLbkQkXtv+3lbM2C2lB7JTnLuOVsRto/DsmkPpLsM48E7okawojl0oWMxKbDT0iat29gyVDInMwRzAy/SaMJ8E1SuIz1+tiHKUtRgBAgF1WKTBG3sYYxmOoA==
Dear Frédéric,
I tried following and it worked without Coq.extraction.ExtrOcamlNatInt, but I am still not sure if I can call my program certified?Require Import ExtrOcamlBasic.
Require Import ExtrOcamlString.
Extract Inductive bool => "bool" [ "true" "false" ].
Extract Inductive nat => "int"
[ "0" "(fun x -> x + 1)" ]
"(fun zero succ n -> if n=0 then zero () else succ (n-1))".
Extract Constant plus => "( + )".
Extract Constant mult => "( * )".
Extract Constant Nat.eqb => "( = )".
Extract Constant Nat.leb => "(<=)".
Extraction Language OCaml.
Recursive Extraction Process.
Require Import ExtrOcamlString.
Extract Inductive bool => "bool" [ "true" "false" ].
Extract Inductive nat => "int"
[ "0" "(fun x -> x + 1)" ]
"(fun zero succ n -> if n=0 then zero () else succ (n-1))".
Extract Constant plus => "( + )".
Extract Constant mult => "( * )".
Extract Constant Nat.eqb => "( = )".
Extract Constant Nat.leb => "(<=)".
Extraction Language OCaml.
Recursive Extraction Process.
On Sat, Jan 23, 2021 at 12:42 AM Frédéric Besson <frederic.besson AT inria.fr> wrote:
Hello,
I would extract to arbitrary precision integers e.g., using the zarith
library. As zarith Z.t implements Z and not N, a thin layer will
sometimes be needed.
For instance, minus : nat -> nat -> nat would be extracted to
(fun (x y:Z.t) -> Z.max Z.zero (Z.minus x y))
The technique you mention "Lightweight Extraction to int" is probably
also needed on the Coq side (but extract int to Z.t) -- or you need to
keep nat morally abstract everywhere on the Coq side e.g., no pattern
matching.
Good luck,
--
Frédéric
On Sat, 2021-01-23 at 00:14 +0530, Suneel Sarswat wrote:
> Dear Members,I am not sure if this question is properly posed.
>
> I have a coq program and its proof.
> Now I want to run and test the extracted OCaml code on real data.
> The coq project is completed using natural numbers since the real
> problem only involves natural numbers.
> In the real data sets the numbers can be as large as millions.
>
> In the extracted OCaml code the nat, bool and the list has symbolic
> representation besides it is doing unary operations for add, mult,
> leb, eqb, sub.
> In order to use the OCaml code I used the library
> Coq.extraction.ExtrOcamlNatInt but it has a disclaimer
> "trying to obtain efficient certified programs by
> extracting nat into int is definitively *not* a good idea:"
> Can I call my program certified? Is there a better solution?
> Besides this, the above library does not convert eqb and leb for
> some reason?? So, I am doing it like this
>
> Extract Constant Nat.eqb => "( = )".
> Extract Constant Nat.leb => "( <= )".
>
> Is this correct? What are the proof obligations, if any?
>
>
> I looked possible at solution on net and found a sulution mentioned
> on https://softwarefoundations.cis.upenn.edu/vfa-current/Extract.html
> .
> For this, I need to convert my entire project (10k+ lines) from nat
> to int! Is there a quick fix?
>
> Thanks in advance,
> Suneel
- [Coq-Club] OCaml extraction and proof obligations, Suneel Sarswat, 01/22/2021
- Re: [Coq-Club] OCaml extraction and proof obligations, Frédéric Besson, 01/22/2021
- Re: [Coq-Club] OCaml extraction and proof obligations, Suneel Sarswat, 01/22/2021
- Re: [Coq-Club] OCaml extraction and proof obligations, Frédéric Besson, 01/22/2021
- Re: [Coq-Club] OCaml extraction and proof obligations, Suneel Sarswat, 01/22/2021
- Re: [Coq-Club] OCaml extraction and proof obligations, Frédéric Besson, 01/22/2021
Archive powered by MHonArc 2.6.19+.