coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Sylvain Boulmé <Sylvain.Boulme AT univ-grenoble-alpes.fr>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Extracting runnable relations (from Impure Library)
- Date: Fri, 26 Oct 2018 11:11:25 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=Sylvain.Boulme AT univ-grenoble-alpes.fr; spf=Pass smtp.mailfrom=Sylvain.Boulme AT univ-grenoble-alpes.fr; spf=None smtp.helo=postmaster AT zm-mta-out-1.u-ga.fr
- Ironport-phdr: 9a23:69E5tReOP41dJgdQnSRL2MCYlGMj4u6mDksu8pMizoh2WeGdxcW6bB7h7PlgxGXEQZ/co6odzbaO7Oa4ASQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTahY75+Ngm6oRnMvcQKnIVuLbo8xAHUqXVSYeRWwm1oJVOXnxni48q74YBu/SdNtf8/7sBMSar1cbg2QrxeFzQmLns65Nb3uhnZTAuA/WUTX2MLmRdVGQfF7RX6XpDssivms+d2xSeXMdHqQb0yRD+v6bpgRh31hycdLzM37X/ZisJwgqxYrhyuqRNwzIzIb4+aL/d+YqDQcMkGSWZdUMtcVSpMCZ68YYsVCOoBOP5VoZT9plsKsxuxHwisBOX3xTJVgX/2wKk60+E7Fgrb2wEuAtIPsHDKrNrvNacSV/q5wbTPzTXea/NW3Cny5ZPVchAnoPGMQ6t8ccXLyUYxEQPFiU6fqYj7MD+MzOsNt3Cb4PR7Ve61hW4nsRh8rz6yzckijYnJg5gaylHC9ShhwYY1I8e4SE9hbtK+HptQrTmWOJFsQsw+Q2FouTg6xaMduZKieygK1YonyADFa/ybbYeI+QjvVOiLITtgi3Jlea6/hxav8Ue70OHzSs600FNMoyFYkdfMrmgA2wHT58SZUPdw/EWs1SyR2wzP9u1IO0A5mKvDJ5I83LI9koAfvEfAEyPsl0j7grWaelgn9+Wo7ensf6/oqYWGN4BujwHzKqQuldK7AeQ/KgUPXm2b9f251L3/50L1WbJKjuAqkqXArZzWP9kbqre2AwBPyIoj5Qy/Ay+n0NQeg3YHMEpIdA+HgoT3IV3DIvL1Ae2hj1iwjDtn3fDLM7z5DpXINHfDkbPhfbhn605bzQo+1c1R5pJQCrEfOv3zW0nxuMbFAx8+Lgy0x+PnB8tm24MDX2KPA7GZPLrdsV+S+O0vJe6Ma5QRuDnjMvQq/frujWcnll8GZ6Wp04EXZGiiHvt6O0WZfWbsgtAZHGgWuQo+VfXmh0GGUT5OfHm/RLk85zE+CIK+F4jPXIGtgLqb3Ce6BJJafG5GCkrfWUvvIo6DQrIHbD+YCs5niD0NE7a7GKE70hT7jx7+1bNmKN3+/TAcsBOrgONk4/PalBd03ztpC8GQ+3yLTn8xkXkFQTg82K06qEhlx0zF37Iu0K8QLsBa+/4cClRyDpXb1eEvU4mjCDKERc+ATROdevvjBDgwStwrxNpUPxRgHdS8yx/Z0iytCbsY0rWPHJEvtKzGjSGoe5RNjk3e3axktGEIB9NVPDf61LN59haWCJTElUKTk6vvfKAE0TWL+n3RlTPT7nEdaxZ5VOD+ZV5aZkbSqo6jtFHHCrqyAPEgLxcEkIifb6RDLNPz3w1L
Hello,
Sorry but on this subject, I feel the need to advertise on the works of our team in Verimag at Grenoble ;-)
One major application of programming with "relations" is to invoke external OCaml oracles from Coq code. Indeed, an OCaml function is possibly non-deterministic from Coq eyes, and needs thus to be encoded as a relation. Moreover, any Coq function invoking such a non-deterministic function is itself non-deterministic.
On way to extract (some) relations into runnable programs, is to axiomatize the predicate type transformer:
P(B) = B -> Prop.
The good news is that P(.) as naturally the structure of a monad, and is thus fully compatible with functional programming.
Thus, we can axiomatize P(B) as a type ??B using a monad structure providing a "~~>" relation of type ?? B -> P(B).
NB: given k:??B and x:B, "k ~~> x" is read "k may return x".
In this view, a binary relation of A -> B -> Prop is encoded as a function of A -> ?? B.
At extraction "?? B" is simply extracted like "B"
See details of the axioms in
https://github.com/boulme/ImpureDemo/blob/master/coq_src/Impure/ImpMonads.v
Some applications of this idea:
- Verified Polyhedra Library:
https://github.com/VERIMAG-Polyhedra/VPL
- satans-cert: a Coq-certified tool that wraps state-of-the-art Boolean SAT-solvers and checks their result.
https://github.com/boulme/satans-cert
To have more details on this idea (still under development):
- https://github.com/boulme/ImpureDemo
- my slides on the Coq Workshop 2018:
https://coqworkshop2018.inria.fr/files/2018/07/coq2018_talk_boulme.pdf
- the original paper where this idea has appeared:
https://hal.archives-ouvertes.fr/hal-00991853
Rem: of course, we could imagine other extraction scheme, like extracting "?? B" on "'b Lazy.t" or "'b list" ...
Best regards,
Sylvain.
Le 26/10/2018 à 08:27, Cao Qinxiang a écrit :
This is an interesting idea.
Coq requires functions to terminate (and we have to shows its termination by kind of structure recursion) but ocaml does not require that. A ``function'' may be more convenient to be formalized as a relation instead of a function in Coq. And it will be amazing if those relations can be extracted as functions.
Here is an example,
Inductive log2: nat -> nat -> Prop :=
| log2_base: log2 1 0
| log2_step: forall n k, log2 (div2 n) k -> log2 n (S k).
Qinxiang Cao
Tenure Track Assistant Professor
Shanghai Jiao Tong University, John Hopcroft Center
Room 1102-2, SJTUSE Building
800 Dongchuan Road, Shanghai, China, 200240
On Thu, Oct 25, 2018 at 2:20 PM Xuanrui Qi <xqi01 AT cs.tufts.edu <mailto:xqi01 AT cs.tufts.edu>> wrote:
Hello Kakadu,
This would look interesting to me. I can envision a miniKanren-style
program relation correct w/ respect to some specification, and then
extract the relation to miniKanren, e.g. for program synthesis.
I do not know if Will Byrd is on this list, but I guess he would be a
person to approach.
-Ray
-- Xuanrui "Ray" Qi
Department of Computer Science
Tufts University
161 College Ave, Halligan Hall
Medford, MA 02144, USA
Email:
xqi01 AT cs.tufts.edu
<mailto:xqi01 AT cs.tufts.edu>
On Thu, 2018-10-25 at 10:52 +0000, Kakadu wrote:
> Hello,
>
>
> AFAIU, proving something in terms of relations is convenient but it's
> difficult to extract them to runnable code. Let's say we can extract
> them to a logical programming language embedded into OCaml. How
> useful can it be? Can you easily imagine any concrete use cases?
>
>
> Happy hacking,
> Kakadu
>
>
- [Coq-Club] Extracting runnable relations, Kakadu, 10/25/2018
- Re: [Coq-Club] Extracting runnable relations, Xuanrui Qi, 10/25/2018
- Re: [Coq-Club] Extracting runnable relations, Cao Qinxiang, 10/26/2018
- Re: [Coq-Club] Extracting runnable relations (from Impure Library), Sylvain Boulmé, 10/26/2018
- Re: [Coq-Club] Extracting runnable relations, Dominique Larchey-Wendling, 10/26/2018
- Re: [Coq-Club] Extracting runnable relations, mukesh tiwari, 10/27/2018
- Re: [Coq-Club] Extracting runnable relations, Cao Qinxiang, 10/26/2018
- Re: [Coq-Club] Extracting runnable relations, Xuanrui Qi, 10/25/2018
Archive powered by MHonArc 2.6.18.