coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Chris Dams <chris.dams.nl AT gmail.com>
- To: coq-club <coq-club AT inria.fr>
- Subject: [Coq-Club] I do not really understand coq modules, any ideas?
- Date: Wed, 3 Nov 2021 15:09:05 +0100
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=chris.dams.nl AT gmail.com; spf=Pass smtp.mailfrom=chris.dams.nl AT gmail.com; spf=None smtp.helo=postmaster AT mail-vk1-f174.google.com
- Ironport-hdrordr: A9a23:syxU8aMglPPeJsBcThujsMiBIKoaSvp037By7TEIdfUnSL3iqynOpoVk6faaskd0ZJhNo7G90ey7MArhHP1OkPgs1NWZLW7bUQKTRekIgOeMrQEIWReOkNK1vp0QEJSWfeeAaGSS+vyKgjVQfexB/DDNytHTuQ6X9QYRcei0UctdBxEQMHfmLqRZfng4OaYE
- Ironport-phdr: A9a23:xRrGWhU52g3tfrz0RE+POfe4MCbV8KzuVTF92vMcY1JmTK2v8tzYMVDF4r011RmVB92duqsP1rWempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9JDffRlEiCC5bL9vIxm7rQfcvdQKjIV/Lao81gHHqWZSdeRMwmNoK1OTnxLi6cq14ZVu7Sdete8/+sBZSan1cLg2QrJeDDQ9LmA6/9brugXZTQuO/XQTTGMbmQdVDgff7RH6WpDxsjbmtud4xSKXM9H6QawyVD+/6apgVR3mhzodNzMh/27ZisJ+gqFGrhy/uxNy2JLUbJ2POfZiYq/RYdEXSGxcVchRTSxBBYa8YpMRAuoBJ+ZYrpL9rEYAoxSkAAmsH/7kxzhUiX/2x6060v8hHRvb0wM6GtIOq27YrNPxNKoJXuC1ybPHzTTHb/9MxTj9743IfwknrPqRUr1+bdDfxlMzFwPZkFqQs4rlMiuX2+kJrWWW7uVuW+2hhWMktQx9vCSiytkih4TVho8YyE3J+yp2zog6JdO2R1N3bNG5HZZSuSyXNZZ7TMw8T210visx174IuYajcSQU1JgqwwTTZv+HfoSS/B7vSvudLS1liH9nd7+ygQu5/1K6xe3mTMa01U5HripbndnIsXAAzxnT5dKGSvt550uhxzWP2x3K5uFKPEw5l6XWJ4Quwr43kZoTvkDDETHslErqi6+Wc10o+umu6+v5frXrvoGQO5Nwhw3kMakjmtazDfomPgQTRWSX5Oax2bL78U38WrpKj/k2kqfDsJDdIMQWvrK2Aw9P0oYi8BazFSqp384dnXkcNl5FfhaHgpPmO1HLOv/4DPO/j06wnzdswvDKJqfhDYnVLnjfjLfheq5w5FJbyAoq1NxQ+5ZUCqwaL//oQU/wtNnYDgcjPACuwubnDs991oIEVm6VDK+ZKvCajVjd7eU2ZuKIeYVd7D36Mr0u4+PkpX4/g14UO6ezi8g5cne9S99mOUSCKVblh8xJRWwKpAslCuDjjUbEVzp7aHO7XqZ67TY+XtH1RbzfT5yg1eTSlBywGYdbMzgu4rWkHnLhdoHCUPAJOnr6yiBJnTkNVLznQIgkh0jGXO7SzrNmKq/K+XRdu8u8iJ564OrckRx0/jtxXZz17g==
Dear All,
The issue I am trying to solve is the following. I have a part of my
development where basically everything depends of a parameter. Let us
say S: Set. The part that depends on this parameter is, say, 5 files.
The most straightforward way to handle this would be to start every
definition and theorem with 'forall S: Set,'. As such that is possible
but it becomes really irritative when one realizes that all the things
one defines in this development also need to be passed this parameter
S. The code would basically be littered with S-es all over the place.
One possible way to solve this would be to turn S into an implicit
parameter in most places. This would help a bit, but I do not really
like the result of this too much because still quite a few S-es are
left and now one has to omit some parameters somewhere but not
everywhere. It is not that convenient.
So, I thought, let us use the module system to solve this. I put the
parameter S in a 'Module Type', and all of the code in a module that
depends on this Module Type. The problem is with the 5 files that
depend on one another. These 5 files each get a module that depends on
the Module Type and some of these modules need to Import some of the
other modules. What I am now running into is that when I import a
module it seems to basically copy the module contents. So, if module_1
contains and inductive definition D and module_2 imports module_1
there are now two inductive definitions module_1.D and module_2.D and
where it expects a parameter of type module_1.D it is not possible to
pass a parameter of type module_2.D. See example-1 below.
I think I can solve this by kind of linearly chaining these modules.
See example-2 below. After this I could just use the outer module
(Module5) and only mention things in de modules by going through
Module5 to avoid the confusion of the multiply defined objects.
Problem here are that the Imports get pretty ugly and that
conceptually these modules do not depend linearly on each other. It
may be that logically speaking one would like to use only Module1,
Module2 and Module4 and not import the rest of them because as such
they would not apply at certain place.
Anyone any ideas about this? Am I misusing the module system terribly?
Kind Regards,
Chris
Example-1:
Module Type Thing.
Parameter S: Set.
End Thing.
Module Module1 (T: Thing).
Inductive flups: Set := flups1 | flups2.
End Module1.
Module Module2 (T: Thing).
Module mod1 := Module1 T.
Import mod1.
End Module2.
Module SpecificThing <: Thing.
Definition S: Set := nat.
End SpecificThing.
Module SpecificModule1 := Module1 SpecificThing.
Module SpecificModule2 := Module2 SpecificThing.
Parameter p: SpecificModule1.flups.
Goal SpecificModule2.mod1.flups.
exact p.
Error: The term "p" has type "SpecificModule1.flups"
while it is expected to have type "SpecificModule2.mod1.flups".
Example-2:
Module Type Thing.
Parameter S: Set.
End Thing.
Module Module1 (T: Thing).
Inductive flups: Set := flups1 | flups2.
End Module1.
Module Module2 (T: Thing).
Module mod1 := Module1 T.
Export mod1.
End Module2.
Module Module3 (T: Thing).
Module mod2 := Module2 T.
Export mod2.
End Module3.
Module Module4 (T: Thing).
Module mod3 := Module3 T.
Export mod3.
End Module4.
Module Module5 (T: Thing).
Module mod4 := Module4 T.
Export mod4.
End Module5.
Module SpecificThing <: Thing.
Definition S: Set := nat.
End SpecificThing.
Module SpecificModule5 := Module5 SpecificThing.
Import SpecificModule5.
Import SpecificModule5.mod4.
Import SpecificModule5.mod4.mod3.
Import SpecificModule5.mod4.mod3.mod2.
Import SpecificModule5.mod4.mod3.mod2.mod1.
Check flups. (* flups: Set *)
- [Coq-Club] I do not really understand coq modules, any ideas?, Chris Dams, 11/03/2021
- Re: [Coq-Club] I do not really understand coq modules, any ideas?, Guillaume Melquiond, 11/03/2021
- Re: [Coq-Club] I do not really understand coq modules, any ideas?, Madhukar, 11/03/2021
- Re: [Coq-Club] I do not really understand coq modules, any ideas?, Raphaël Cauderlier, 11/03/2021
- Re: [Coq-Club] I do not really understand coq modules, any ideas?, Chris Dams, 11/03/2021
- Re: [Coq-Club] I do not really understand coq modules, any ideas?, Chris Dams, 11/05/2021
- Re: [Coq-Club] I do not really understand coq modules, any ideas?, Gaëtan Gilbert, 11/05/2021
- Re: [Coq-Club] I do not really understand coq modules, any ideas?, Sylvain Boulmé, 11/05/2021
- Re: [Coq-Club] I do not really understand coq modules, any ideas?, Chris Dams, 11/05/2021
Archive powered by MHonArc 2.6.19+.