Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Separation of interface and implementation

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Separation of interface and implementation


Chronological Thread 
  • From: Anders Lundstedt <anders AT anderslundstedt.se>
  • To: "coq-club AT inria.fr" <coq-club AT inria.fr>
  • Subject: [Coq-Club] Separation of interface and implementation
  • Date: Thu, 12 Oct 2017 16:50:30 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=anders AT anderslundstedt.se; spf=Pass smtp.mailfrom=anders AT anderslundstedt.se; spf=None smtp.helo=postmaster AT mail-wm0-f49.google.com
  • Ironport-phdr: 9a23:qvSzBxGTgQqkc73fxca4WZ1GYnF86YWxBRYc798ds5kLTJ76r8uwAkXT6L1XgUPTWs2DsrQf1LqQ7viocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TXhpQIVT1/0MhMwLeDoEKbTid623qa84debNw5PnX+2Za54BBSwtwTY8McM19hMMKE0nzLPrnZSYKxy2GVkPk6ekwq0ss628JN56AxZvf4s7dVETKP2ZLg1QaAeFzlwYDN939HiqRSWFVjH3XAbSGhDyhc=

Hi,


I am doing some theorem proving in Coq. My development is split over
multiple files. I would like each file to first list all its
definitions and theorems. Some definitions should be transparent: they
should be listed in full here. Theorems and some definitions should be
opaque: only their name and type should be shown. The proof of
theorems and implementation of opaque definitions should come later.
Any helper lemmas and functions used here should not be exposed at
all. So, something like this:

(* exposing the definition of f *)
Definition f : nat -> nat := fun n => n.

(* g should be opaque, its definition is not shown here *)
Parameter g : nat -> nat.

(* opaque theorems *)
Axiom t : True.

(* implementations *)

(* helper lemma, should not be exposed at all *)
Lemma helper_lemma : True.
Proof. exact I. Qed.

Theorem t : True.
Proof. apply helper_lemma. Qed.

(* helper function, should not be exposed at all *)
Definition g_helper : nat -> nat := S.

Definition g : nat -> nat := g_helper.


Questions:

(1) What is the best way to accomplish this in Coq?

(2) Is this a good idea? If not, what should I do instead?


Regarding (1): I can achieve this using modules, but I have not found
a way to avoid having to define all transparent definitions
twice—first in the module type and then in the module. (If I also have
notations I want to expose it seems even worse: I have to define them
in the module type and in the module and then outside the module.)
Here is how I have achieved the above example using modules:

Module Type TEST_SIG.

Definition f : nat -> nat := fun n => n.

Parameter g : nat -> nat.

Axiom t : True.

End TEST_SIG.

Module TEST : TEST_SIG.

Definition f : nat -> nat := fun n => n.

Definition g_helper : nat -> nat := S.

Definition g : nat -> nat := g_helper.

Lemma helper_lemma : True.
Proof. exact I. Qed.

Theorem t : True.
Proof. apply helper_lemma. Qed.

End TEST.




Anders



Archive powered by MHonArc 2.6.18.

Top of Page