coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: "Soegtrop, Michael" <michael.soegtrop AT intel.com>
- To: "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: RE: [Coq-Club] module "best practices"?
- Date: Sun, 19 Aug 2018 09:15:07 +0000
- Accept-language: de-DE, en-US
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=michael.soegtrop AT intel.com; spf=Pass smtp.mailfrom=michael.soegtrop AT intel.com; spf=None smtp.helo=postmaster AT mga02.intel.com
- Ironport-phdr: 9a23:58I3qB1gDpyM8DGKsmDT+DRfVm0co7zxezQtwd8ZseITKPad9pjvdHbS+e9qxAeQG9mDtbQc06L/iOPJYSQ4+5GPsXQPItRndiQuroEopTEmG9OPEkbhLfTnPGQQFcVGU0J5rTngaRAGUMnxaEfPrXKs8DUcBgvwNRZvJuTyB4Xek9m72/q99pHPYghEniaxba9vJxiqsAvdsdUbj5F/Iagr0BvJpXVIe+VSxWx2IF+Yggjx6MSt8pN96ipco/0u+dJOXqX8ZKQ4UKdXDC86PGAv5c3krgfMQA2S7XYBSGoWkx5IAw/Y7BHmW5r6ryX3uvZh1CScIMb7S60/Vza/4KdxUBLmiDkJOSMl8G/ZicJwgqBUoBO9qBNwzIDZe52VO+F6c6/BYd8WWWhMU8BMXCJBGIO8aI4PAvIPMehFqInyuVQOrQekBQmrHOPj0iJDiHj33aIm0+QuCx/J3AguE9kTt3nUqdT1O7sSUe+v0qbIyS/Pb+hR2Tjj54jIbgohofaUXb9rcMrRz1UvGB3BjlmKtYPlODaV2/0LvmOG4eRgUuevhHQmqwF3ujWvx8EsipXXiYIR0FzL6Dt2zYAoLtO7UE52ecOoHZVfui2AKod7TMwvT3t1tCs0y7AKo4C3cDQSxJg6xhPSZeaLfoaG7x75SuqcLzN1iGh4dL+8mhq+6VWsx+z4W8WuzlpHriVInsPSunwXyhDe6dSLR/1g9Um7wzmPzRrc6uRcLEA0i6XbL5khz6Y1lpocq0vPAjH6lF/3jK+QakUr5Oyo5/77bbXho5+QL450igfgPaQygsGzHOo1PwcUU2SG9+mx26fv8VD3TbhLlPE6jLXVvIjfJcsBp665BwFV0pwk6xa6Fzqm1dUYkmUHLF1fZh2Hi5LlO0rJIP/mAve/n06skDBzx/3dP73hBInNIWbHkLv7Ybl97EtcxBIpzd9D/5JUFq0BIPXrV0Dts9zYFwY1PBCww+b6E9pwzZgeWGKKAq+BKqzeq16I5uQ1I+mNfoAZojj9K+J2r8Lp2DUynkZYdq2017MWbmq5F7JoOQ/RNXHrm5IKFXoAlgs4Vu3jzlOYB219fXG3CugH4Tw0FJihFcOLY4GmgLWM2G3zSphXbWBPB1TKCnDleJmeXO8kaSSOL8snmTsBA+vyA7Q93A2j4Vepg4FsKfDZr3VB5MDTkeNt7uiWrikcsDl9DsCTyWaIFjgmn2UUSjtw16d68xUklgWzlJNgivkdLuR9outTW15jZ5/a0+F+Tdv1X1CZJ4rbeBOdWtyjRAoJYJcxztsJOhkvHtqr1kqF3iy2DrtTnLuOVsQ5
Dear Samuel,
I think I have shown how to fix this kind of issue in my post. I don't see
how your case is different. I would suggest to try the following:
- put the inductive type definitions from module functor Imp into a module
type functor IMP
- define module Imp as "Module Imp (P : ImpParameters) := Empty <+ IMP P."
- give everything which needs Imp a parameter of type IMP and instantiate it
with Imp
- possibly define combined module types and modules to avoid long parameter
lists
The trick is that now the inductive definition is in the module type rather
than in the module instance and the type is the same for all instances, so
the inductive types are the same. At the end of the code I posted, you can
actually prove the following:
Theorem Eq1: FD.bar = FDX.bar.
Proof.
reflexivity.
Qed.
Theorem Eq2: FD.Bar = FDX.Bar.
Proof.
reflexivity.
Qed.
although Coq still thinks FD.bar and FDX.bar are separate definitions as
Locate bar or Locate Bar shows.
This might seem like a bizarre hack, but I think it is quite logical to do it
this way. My view is that whatever is needed by other modules must be defined
in a module type. Modules are there to define concrete implementations of
abstract definitions in a module type. Other modules should only use module
types and not concrete modules. When you cannot abstract away from what is in
a module, it is part of the interface and doesn't belong in a module but in a
module type.
If you have an inductive definition and where you use this type you can
replace it with an abstract type (say a generic map data structure), the
inductive belongs in a module and the module type just provides an abstract
type. If you need the details of the inductive in modules using it, the
inductive belongs into a module type.
Of cause if a module A just uses another module B to implement its
functionality in such a way that nothing of B is visible at the interface
(signature) of A, A can just use a module B. This typically applies to
modules just defining a bunch of lemmas, tactics or notations but also to
modules defining helper data structures like maps or sets, which are
abstracted away at the external interface of module A. But anything about
other modules which is somehow visible in the signature of A, must be defined
in a module type, and not in a module.
In my experience the module system works quite well, if it is used in this
way.
I hope those who came up with the module system agree with this view.
Best regards,
Michael
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
- [Coq-Club] module "best practices"?, Kevin Hamlen, 08/17/2018
- RE: [Coq-Club] module "best practices"?, Soegtrop, Michael, 08/18/2018
- Re: [Coq-Club] module "best practices"?, Samuel Gruetter, 08/18/2018
- RE: [Coq-Club] module "best practices"?, Soegtrop, Michael, 08/19/2018
- Re: [Coq-Club] module "best practices"?, Kevin Hamlen, 08/20/2018
- RE: [Coq-Club] module "best practices"?, Soegtrop, Michael, 08/20/2018
- Re: [Coq-Club] module "best practices"?, Benjamin C. Pierce, 08/20/2018
- RE: [Coq-Club] module "best practices"?, Soegtrop, Michael, 08/23/2018
- Re: [Coq-Club] module "best practices"?, Benjamin C. Pierce, 08/20/2018
- RE: [Coq-Club] module "best practices"?, Soegtrop, Michael, 08/20/2018
- Re: [Coq-Club] module "best practices"?, Kevin Hamlen, 08/20/2018
- RE: [Coq-Club] module "best practices"?, Soegtrop, Michael, 08/19/2018
- Re: [Coq-Club] module "best practices"?, Adam Chlipala, 08/21/2018
- Re: [Coq-Club] module "best practices"?, Kevin Hamlen, 08/21/2018
- Re: [Coq-Club] module "best practices"?, Samuel Gruetter, 08/22/2018
- RE: [Coq-Club] module "best practices"?, Soegtrop, Michael, 08/23/2018
- Re: [Coq-Club] module "best practices"?, David Holland, 08/23/2018
- Re: [Coq-Club] module "best practices"?, Anders Lundstedt, 08/24/2018
- Re: [Coq-Club] module "best practices"?, David Holland, 08/23/2018
- RE: [Coq-Club] module "best practices"?, Soegtrop, Michael, 08/23/2018
- Re: [Coq-Club] module "best practices"?, Samuel Gruetter, 08/22/2018
- Re: [Coq-Club] module "best practices"?, Kevin Hamlen, 08/21/2018
Archive powered by MHonArc 2.6.18.