Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Extracting Coq function into OCaml function

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Extracting Coq function into OCaml function


Chronological Thread 
  • From: Li-yao Xia <lysxia AT gmail.com>
  • To: mukesh tiwari <mukeshtiwari.iiitm AT gmail.com>
  • Cc: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Extracting Coq function into OCaml function
  • Date: Thu, 30 May 2019 06:33:42 -0400
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=lysxia AT gmail.com; spf=Pass smtp.mailfrom=lysxia AT gmail.com; spf=None smtp.helo=postmaster AT mail-vs1-f41.google.com
  • Ironport-phdr: 9a23:fNg2VRMooqugsLpylxgl6mtUPXoX/o7sNwtQ0KIMzox0Lfv9rarrMEGX3/hxlliBBdydt6sdzbOM4uu6CSQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTagfL9+Ngi6oRvVu8UZn4dvKbs6xwfUrHdPZ+lY335jK0iJnxb76Mew/Zpj/DpVtvk86cNOUrj0crohQ7BAAzsoL2465MvwtRneVgSP/WcTUn8XkhVTHQfI6gzxU4rrvSv7sup93zSaPdHzQLspVzmu87tnRRn1gyoBKjU38nzYitZogaxGvhyhqRxxzY3abo6bO/VxfL/Sc9wBSGpdXMtcTTBNDp+yYoYNCecKIOZWr5P6p1sLtRawAwisCPrvyzBSgX/9wKw10+U7Hgrb2wEgG9IPsG/brdX0LqgfSu+1zKzSwjXCa/Nawyvy6I/Nch04p/yHQLx+cc3UyUY1FgPFiE2dqYPkPzOJ1uQNrnOU4/B8WuKojm4qrRx6rDu3xso0lIXFmoYYxkrH+Ch52oo5O8C0RUxhbdOrDZdcrz+WO5d3T884Xm1kpiY3xqcHtJKlZiQG1pQqyhjCYPKdaYeI+AjsVOOJLDd4mn1lfLW/ig638Ue6y+38UtC40EhRriZYi9XMuH8A2wHJ5siITft9+Uih2TKR2AzJ9u5EJkU0mbLaK54n3LEwioIevVrfEiLygkn7j6+bel869uS16enreLrrqoKEO49xkA7+M6AumsKlAeQ/NwgDR2yb+OSn1Lzs/E32Wq5HjvIzkqbDsZDaId4XqbK+Aw9Qyooj8QqwDy+60NQEmnkKNE5KeBWej4TwJ17OJO34AuykjlS3kDZrwujGMaf7DpXMKHjDirbhcqxn505S0gpghexYspdJCbwaILrvW1D4rt2QWhokMAGvw/rmF9xn18UfWGOTB4eWNarTtRmD4ed5cMeWY4pAnDe4OvEir87vhDdtnU4Gbaig9ZQSYXG8WP9hJhPKMjLXnt4dHDJS7UIFR+vwhQjaCG8BVzOJR6s5owoDJsejBIbHSJqqheXYjii+F5xSIGtBDwLVSCq6R8C/Q/4JLRmqDIphnzgDD+XzToYg0VSwr1a/xeY+aOXT/SIcuNTo090nv7SPxyF3ziR9CoGm60/IV3t9xzpaSDo/3aQ5qkt4mA+O

Hi Mukesh,

Extraction has commands to explicitly define how a given identifier gets extracted. For example, you can define a module of axioms for extraction looking like this:


Module KeyInstance <: Keys.
Parameter Prime : Type.
Parameter prime : Prime.

Extract Constant prime => "(* OCaml code here *)".
(* etc. *)
(* Might need to extract types too, I don't remember offhand. *)
End KeyInstance.


Cheers,
Li-yao

On 5/30/19 3:50 AM, mukesh tiwari wrote:
Hi Everyone,
I am trying to extract a Coq function [1] into OCaml function. I
understand that I need to pass a instance of Cand, Keys and
CryptoAxioms to Encschulze module to extract this function. Something
like this ? [2]

Module CandInstance <: Cand.
(* Definition and proof obligation *)
End CandInstance.

Module KeyInstance <: Keys.
(* Crypto Parameters *)
End KeyInstance.

Module CryptoAxiomInstance <: CryptoAxioms CandInstance KeyInstance.
(* Definition and proofs *)
End CryptoAxiomInstance.

Module E := Encschulze CandInstance KeyInstance CryptoAxiomInstance.

Extraction Language Ocaml.
Extraction "lib.ml" E.pschulze_winners.

My problem is, I can not produce instance of Keys and CryptoAxioms,
because we have taken them as axioms. The values and functions inside
these modules will be instantiated by external OCaml code [3] which is
a wrapper of cryptographic library unicrypt [4].

My question is, how can I extract the pshulze_winners function without
giving the instance of Keys and CryptoAxoims ? One potential solution
I can think of is giving some dummy values and admitting all the
proofs in Keys and CryptoAxioms module to create a instance to
facilitate the extraction. After extraction change all the values in
extracted code, but I am wondering if there is any better solution
than this.

(* Feel free to skip the paragraph *)
I have a working repo of this project [5], but it's very messy. The
reason this repo is working is that the whole development is in single
file, and all the cryptographic values and functions are lambda
abstracted [6] during the extraction.

Best regards,
Mukesh Tiwari

[1]
https://github.com/mukeshtiwari/Encschulze_module/blob/master/Encryptionschulze.v#L492
[2]
https://github.com/mukeshtiwari/Encschulze_module/blob/master/Instance.v#L37
3]
https://github.com/mukeshtiwari/Encschulze_module/blob/master/cryptobinding.ml
[4] https://github.com/bfh-evg/unicrypt/
[5]
https://github.com/mukeshtiwari/EncryptionSchulze/tree/master/code/Workingcode
[6]
https://github.com/mukeshtiwari/EncryptionSchulze/blob/master/code/Workingcode/main.ml#L45




Archive powered by MHonArc 2.6.18.

Top of Page