简体   繁体   English

Coq,真实数据类型

[英]Coq, true datatype

So I have this problem:所以我有这个问题:

In environment n: nat The term "true" has type "Datatypes.bool" while it is expected to have type "bool".在环境 n 中:nat 术语“true”的类型为“Datatypes.bool”,而预期的类型为“bool”。

I have no idea what does it mean.我不知道这是什么意思。 trying to prove: Theorem eqb_0_l: forall n:nat, 0 =?试图证明:定理 eqb_0_l: forall n:nat, 0 =? n = true -> n = 0. n = 真 -> n = 0。

I guess you are working with Software Foundations - which has at least in the introductory chapters its own definition of bool.我猜您正在使用 Software Foundations - 至少在介绍性章节中有自己的 bool 定义。 If you Require modules from both, Software Foundations and the Coq standard library, you easily end up with multiple definitions of bool, nat, ... .如果你需要来自软件基础和 Coq 标准库的模块,你很容易得到 bool, nat, ... 的多个定义。

The solution is to not Require anything from the Coq standard library in the introductory chapters from Software Foundations.解决方案是在 Software Foundations 的介绍性章节中不需要 Coq 标准库中的任何内容。 Only Require modules which come with SF.仅需要 SF 附带的模块。

SF does this so because it explains how to define nat and bool and how to prove basic lemmas about these taypes. SF 这样做是因为它解释了如何定义 nat 和 bool 以及如何证明关于这些 taypes 的基本引理。 This can't be done without actually defining them, which leads to the mentioned problems.如果不实际定义它们,就无法做到这一点,这会导致上述问题。

I think all you need to do is define bool:认为您需要做的就是定义 bool:

Inductive bool : Type :=
  | true
  | false.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM