13

I'm having trouble importing definitions from modules in Coq. I'm new to Coq, but couldn't solve the problem using the language's reference manual or online tutorial. I have a module that defines a signature and axioms for finite sets, which I intend to implement in another module. There's more to it, but it looks something like this (for reference, I'm closely following Filliatre's paper on finite automata):

Module FinSet.    
...
Parameter fset     : Set -> Set.
Parameter member   : forall A : Set, A -> finset A -> Prop.
Parameter emptyset : forall A : Set, fset A.
Parameter union    : forall A : Set, fset A -> fset A -> fset A.
...
Axiom axiom_emptyset :
  forall A : Set, forall a : A, ~ (member a (emptyset A)).
Axiom axiom_union    :
  forall A : Set, forall a b : fset A, forall x : A, i
    member x (union a b) <-> (member x a) \/ (member x b).
...
End FinSet.

I compile the module using coqc and attempt to load it into another module, say FinSetList or FinSetRBT, with the command Require Import FinSet. When I attempt to import the module, Coq (via Proof General) issues the warning:

Warning: trying to mask the absolute name "FinSet"!

Furthermore, I can't see anything defined in FinSet. How do I import the definitions (in this case, axioms) from one module into another? I essentially followed the steps outlined in Pierce's "Software Foundations" lectures. However, they aren't working for me.

emi
  • 5,380
  • 1
  • 27
  • 45

2 Answers2

6

I think your confusion arises from the fact that in Coq, "module" can mean two different things - a source file (Foo.v) and a module within a source file (Module Bar.) Try naming your source file differently from your module in that source file. Then use Require Import to import one source file into another (so, specify the name of the source file, not the name of the module in the source file).

Also, I am not very familiar with Modules and Module Types in Coq, but don't you need to have Module Type there, not Module?

Robin Green
  • 32,079
  • 16
  • 104
  • 187
  • Yes, this seems to be right. I apparently wasn't importing modules correctly. – emi Oct 29 '11 at 18:37
  • 3
    The source file has to be compiled with `coqc name_of_the_source.v` before being imported with `Require Import name_of_the_source`. You can also, if different paths are involved, use `Add LoadPath "../mypath/"` at the beginning of your `.v` file. – Clément Dec 31 '15 at 22:17
2

Try adding to your .emacs file some explicit include paths:

 '(coq-prog-args (quote ("-I" "/home/tommd/path/to/some/stuff/lib" "-I" "/home/tommd/path/to/more/stuff/common")))
Thomas M. DuBuisson
  • 64,245
  • 7
  • 109
  • 166
  • Yes, I tried this. The combination of `Add LoadPath "/home/pordan30/test"` in a `.v` file and `'(coq-prog-args (quote ("-I" "/home/pordan30/test")))` in my `.emacs` file results in the same problem when importing compiled modules in `~/test` (i.e., in that `.v` file in which the loadpath is added). Thanks for offering some help, though. – emi Oct 28 '11 at 14:27