coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Kevin Hamlen <hamlen AT utdallas.edu>
- To: "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: [Coq-Club] module "best practices"?
- Date: Fri, 17 Aug 2018 15:36:01 -0500
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=hamlen AT utdallas.edu; spf=Pass smtp.mailfrom=hamlen AT utdallas.edu; spf=None smtp.helo=postmaster AT esa3.hc50-71.r1.ces.cisco.com
- Ironport-phdr: 9a23:jhuJwRQI6q7W7OQWKdh9R6c2zdpsv+yvbD5Q0YIujvd0So/mwa69YxKN2/xhgRfzUJnB7Loc0qyK6/6mATRIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSizexfbJ/IA+qoQnNq8IbnZZsJqEtxxXTv3BGYf5WxWRmJVKSmxbz+MK994N9/ipTpvws6ddOXb31cKokQ7NYCi8mM30u683wqRbDVwqP6WACXWgQjxFFHhLK7BD+Xpf2ryv6qu9w0zSUMMHqUbw5Xymp4qF2QxHqlSgHLSY0/n/XhMJtj6xVrhyuqBNjzIDbYYGYL+Z+c6DHcN8GWWZMUMRcWipcCY28dYsPCO8BMP5doYbjuVsOrB2+DhSuCuz1zz9IgmH53asn2OkmEQHJxgkgH9YQv3TSt9j1KbsSXv2vw6nMyTXMdehW1S3j54fVbxAsuPeBVq9zf8rJ0UQiGQzIgk+OpYD4Ij+ZzPkBv3SB4+Z+Te6jlnIrpxtsrjWs2MsgkIvEip4PxlzZ+yh13J45KcCmREN/e9KoDYZcuz2AO4doTc4uXXtktDs1x7AFv5OwYTIEx449xxHFbvyKa4iI7QznVOaWOTp3mmlld6ixihqo8Uiv1u3xWtWt3FtIsyZJiMPMum0X2xPP9MeHUeFx8Vug2TaUyw/T7ftILlwzlareM5Ihw7gwmYQPsUnbECL7l1/6gLGLekk54OSk9vjrbq/4qpOEMo97kAD+MqAgmsylBuQ4NxADX2iB9uS50L3s40v5Ta5Xjv0qj6bWqpTaJcABqa6iGQNazJss6wunAze8zNsYhWUHLE5CeB+fk4fpPEjOLOnkAve7nlSjiyxmx+vGP73kGpXCNGLPkLbnfbZn6k5T0hA/zd5F58EcNrZUavn0Qwr6sMHSJh4/KQ29hej9Qp0p3YQHHGmLH6WxMaXIsFbO6Ph5cMeWY4pAmzvjKv5tx/friXI/0QsddKyt0J0/dWy0F/BiKl7fbHbx1IRSWVwWtxYzGbS5wGaJViReMi7rDvAMowojAYfjNr/tA4WkgbiPxiC+R8EEe3xKA1SIGGyueomZCa5VNHCiZ/R5mzlBboCPDpc73Ejy5hLmx7NjKuPPvCAUqMC7jYUn16jojRg3sAdMIYGd3mWKFDgmk3gBHHk21/0n5BMkjE3al6N1mLpTFMdY4LVCVQJobZM=
Dear Coq users,
What do Coq programmers consider the "right way" to organize large projects containing functors? In particular, how do authors of large projects define collections of modules that all build upon some shared functor without getting duplicate name-conflicts? Here's an example:
(* Input parameters and axioms are declared as a module type: *)
Module Type FOO_TYPE.
Parameter foo: Type.
End FOO_TYPE.
(* Another module builds definitions from the inputs: *)
Module FooDefs (Foo: FOO_TYPE).
Inductive bar := Bar (f:Foo.foo).
(* ... hundreds more definitions ... *)
End FooDefs.
(* Now we wish to create myriad modules that prove various things about FooDefs given a Foo. Here's one way that doesn't work well: *)
Module FooTheory1 (Foo: FOO_TYPE).
Module F := FooDefs Foo.
Import F.
Ltac silly1 := match goal with |- Bar _ = Bar _ => reflexivity end.
(* ... more theorems, proofs, and ltacs ... *)
End FooTheory1.
(* This doesn't work well because each module defined in this way has its own copy of FooDefs, which Coq doesn't always recognize as equal. *)
Module Foo:FOO_TYPE.
Definition foo:=nat.
End Foo.
Module FD := FooDefs Foo.
Module FT1 := FooTheory1 Foo.
Import FD.
Import FT1.
Theorem silly: forall (x:bar), x=x.
Proof.
destruct x.
Fail silly1. (* fails because FD.Bar is not the same as FT1.F.Bar. *)
Abort.
Here are two alternative options that also don't seem to work well:
(2) Using "Export F" in FooTheory1 instead of creating a separate FD module fixes the problem above, but then all FooTheory modules must be arranged in a linear hierarchy to avoid duplicating the definition of F. They can't be created independently, lest they export two distinctly named versions of F.
(3) We could make a FOO_DEFS module type (whose content is a verbatim copy of FooDefs) and then parameterize all the FooTheory modules with FOO_DEFS instead of FOO_TYPE modules. But that leads to a rather tortuous development regimen: Every new FooTheory module must also define a FOO_THEORY type that duplicates all its definitions, and instantiating the new FooTheory requires first laboriously instantiating all the modules it depends upon, just so that they can all import the shared definition of FooDefs.
What is the "right" way to do this sort of thing?
Thanks,
Kevin
- [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"?, Kevin Hamlen, 08/21/2018
Archive powered by MHonArc 2.6.18.