Coq中的模块错误类型不同
我很难想出如何写这段代码 例如,我有一个签名Coq中的模块错误类型不同,coq,Coq,我很难想出如何写这段代码 例如,我有一个签名a,一个函子C将a:a作为参数,为了能够使用C,我定义了一个模块B实现签名a Require Import String. Module Type A. Parameter toto : string -> nat. End A. Module C (Import a : A). ... End C. Module B <: A. Definition toto (s: string) := foo s. End B
a
,一个函子C
将a:a
作为参数,为了能够使用C
,我定义了一个模块B
实现签名a
Require Import String.
Module Type A.
Parameter toto : string -> nat.
End A.
Module C (Import a : A).
...
End C.
Module B <: A.
Definition toto (s: string) := foo s.
End B. (* COQ error *)
我将在D
我理解这个问题,因为我没有在toto
的定义中提供string list
参数
所以我的问题是我不知道在这种情况下如何提供参数字符串列表
在我的真实代码中,我使用了部分
和记录
类型,而不是模块
Record A : Type := mkA { too : string -> nat}.
然后我打开一个部分
Section B.
Variable l: string list.
Definition too (s: string) := foo s l.
Definition A := mkA too.
End B.
你能帮我写或者理解如何在模块中正确地写函子
B
?是否有一种方法可以在模块中定义/声明变量string list
?同样,在Coq
中定义之后,我将把它提取到OCaml
您始终可以这样做:
Require Import String.
Parameter foo: string -> list string -> nat.
Module Type A.
Parameter toto : string -> nat.
End A.
Module B <: A.
Variable (* or Parameter, or Axiom *) ls : list string.
Definition toto (s: string) := foo s ls.
End B.
但这可能不是你需要的。没有上下文,很难给你更好的建议。我两种方法都试过了。我选择了第二个,因为第一个有一个[Variable/…],它将在提取后生成一个[failthwith“Axiom…”。我的问题是第二个选择,我无法在Ocaml中定义签名[HasListString]的实现[ls],以便能够使用模块[B]中的函数。[ls]只是我真实代码中的一种类型。
Require Import String.
Parameter foo: string -> list string -> nat.
Module Type A.
Parameter toto : string -> nat.
End A.
Module B <: A.
Variable (* or Parameter, or Axiom *) ls : list string.
Definition toto (s: string) := foo s ls.
End B.
ModuleType HasListString.
Parameter ls : list string.
End HasListString.
Module B(LS: HasListString) : A.
Definition toto (s: string) := foo s LS.ls.
End B.