I have a function PolyInterpretation
(http://color.inria.fr/doc/CoLoR.PolyInt.APolyInt.html)
Definition PolyInterpretation := forall f : Sig, poly (arity f).
and a module signature TPolyInt
(http://color.inria.fr/doc/CoLoR.PolyInt.APolyInt_MA.html)
Module Type TPolyInt.
Parameter sig : Signature.
Parameter trsInt : PolyInterpretation sig.
Parameter trsInt_wm : PolyWeakMonotone trsInt.
End TPolyInt.
Module PolyInt (Export PI : TPolyInt).
Then in my file rainbow.v
, I define a module TPolyInt_imp
purpose to use functor PolyInt
Module TPolyInt_imp.
Variable arity : symbol -> nat.
Variable l : list {g : symbol & poly (arity f).
Definition sig := Sig arity.
Definition trsInt f := fun_of_pairs_list f l.
...
End TPolyInt_imp.
Where fun_of_pairs_list
has type: forall f: Cpf0.symbol, list {g : symbol & poly (arity g)} -> poly (arity f)
Then I define a module P
:
Module Export P := PolyInt TPolyInt_imp.
The Coq
proof assistant accepted the definition P
above.
Then I used extraction to extract to OCaml
.
I write it in another file: extraction.v
Extraction Language Ocaml.
Set Extraction Optimize.
Set Extraction AccessOpaque.
Separate Extraction rainbow.P.
It works fine.
Here is the code after the extraction
module TPolyInt_imp =
struct
(** val arity : symbol -> int **)
let arity =
failwith "AXIOM TO BE REALIZED"
(** val l : (symbol, poly) sigT list **)
let l =
failwith "AXIOM TO BE REALIZED"
(** val coq_sig : coq_Signature **)
let coq_sig =
coq_Sig arity
(** val trsInt : symbol -> poly **)
let trsInt f =
fun_of_pairs_list arity f l
end
module P = PolyInt(TPolyInt_imp)
Because inside the functor TPolyInt_imp
they included Variable
and generate the failwith AXIOM
then I decided to define a new signature to contain all those variables.
Module Type Arity.
Variable arity : symbol -> nat.
Variable l : list {g : symbol & poly (arity g)}.
End Arity.
Then define a new functor taking (Arity
) as a parameter. And inside this functor I define module TPolyInt_imp
(like TPolyInt_imp
before).
Module S (Import A: Arity).
Module TPolyInt_imp.
Definition sig := Sig arity.
Definition trsInt f := fun_of_pairs_list f l.
...
End TPolyInt_imp.
Module P := PolyInt TPolyInt_imp.
End S.
Then I use the extraction to extract it to Ocaml
.
Extraction Language Ocaml.
Set Extraction Optimize.
Set Extraction AccessOpaque.
Separate Extraction S.
Then I got an error saying that:
Error: Signature mismatch:
...
Values do not match:
val trsInt : Cpf0.symbol -> Polynom.poly
is not included in
val trsInt : APolyInt.coq_PolyInterpretation
File "rainbow.ml", line 534, characters 8-14: Actual declaration
The code after the extraction:
module type Arity =
sig
val arity : symbol -> int
val l : (symbol, poly) sigT list
end
module S =
functor (A:Arity) ->
struct
module TPolyInt_imp =
struct
(** val coq_sig : coq_Signature **)
let coq_sig =
coq_Sig A.arity
(** val trsInt : symbol -> poly **)
let trsInt f =
fun_of_pairs_list A.arity f A.l
end
module P = PolyInt(TPolyInt_imp)
What is wrong with the extraction? and the reason why they have this error? How can I correct my code that I can get the success compile after the extraction?
Also I do not want to define a new module that implement the signature Arity
.
I am so sorry for my code lacking of type and not able to compile. I am trying to give the idea of my problem.