6

我有一个功能PolyInterpretationhttp://color.inria.fr/doc/CoLoR.PolyInt.APolyInt.html

Definition PolyInterpretation := forall f : Sig, poly (arity f).

和一个模块签名TPolyInthttp://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).

然后在我的文件rainbow.v中,我定义了一个TPolyInt_imp使用仿函数的模块用途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.

哪里fun_of_pairs_list有类型:forall f: Cpf0.symbol, list {g : symbol & poly (arity g)} -> poly (arity f)

然后我定义一个模块P

Module Export P := PolyInt TPolyInt_imp.

Coq证明助理接受了上述定义P

然后我使用提取来提取到OCaml.

我把它写在另一个文件中:extraction.v

Extraction Language Ocaml.
Set Extraction Optimize.
Set Extraction AccessOpaque.
Separate Extraction rainbow.P.

它工作正常。

这是提取后的代码

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)

TPolyInt_imp因为在他们包含Variable并生成的仿函数内部,failwith AXIOM我决定定义一个新的签名来包含所有这些变量。

Module Type Arity.
 Variable arity : symbol -> nat.
 Variable l : list {g : symbol & poly (arity g)}.
End Arity.

Arity然后定义一个以 ( ) 作为参数的新函子。在这个函子中我定义了模块TPolyInt_imp(像TPolyInt_imp以前一样)。

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.

然后我使用提取将其提取到Ocaml.

Extraction Language Ocaml.
Set Extraction Optimize.
Set Extraction AccessOpaque.
Separate Extraction S.

然后我收到一条错误消息:

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

提取后的代码:

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)
  

提取有什么问题?以及他们出现此错误的原因?如何更正我的代码,以便在提取后成功编译?

另外我不想定义一个实现签名的新模块Arity

我很抱歉我的代码缺少类型并且无法编译。我试图给出我的问题的想法。

4

0 回答 0