3
$ coqtop -v
The Coq Proof Assistant, version 8.4pl5 (February 2015)
compiled on Feb 06 2015 17:44:41 with OCaml 4.02.1
予定義的下列CoInductive
類型,stream
:
$ coqtop
Welcome to Coq 8.4pl5 (February 2015)
Coq < CoInductive stream (A : Type) : Type :=
Coq < | Cons : A -> stream A -> stream A.
stream is defined
Coq < Check stream.
stream
: Type -> Type
Coq < Check Cons.
Cons
: forall A : Type, A -> stream A -> stream A
然後,我試圖定義以下CoFixpoint
定義,zeros
:
Coq < CoFixpoint zeros : stream nat := Cons 0 zeros.
然而,我得到了以下錯誤:
Toplevel input, characters 38-39:
> CoFixpoint zeros : stream nat := Cons 0 zeros.
> ^
Error: In environment
zeros : stream nat
The term "0" has type "nat" while it is expected to have type
"Type".
我想通了,我必須顯式實例變量A
:
Coq < CoFixpoint zeros : stream nat := Cons nat 0 zeros.
zeros is corecursively defined
爲什麼不勒柯克本身推斷A
類型?我如何使其推斷A
的類型?
旁註隱含參數的更多信息:項目2.和3.聲明'A'爲[最大插入(HTTPS://coq.inria。 fr/refman/Reference-Manual004.html#Implicit%20Arguments)參數。使用「設置隱式參數」指令推斷的隱式參數未聲明爲最大可插入。因此,如果適用,可能需要添加「設置最大隱式插入」。 –