Coq “未知”的解释_/_&引用;尽管进口了Arith

Coq “未知”的解释_/_&引用;尽管进口了Arith,coq,Coq,我试图编写一个函数,将nat转换为coq中的string。这是我的尝试 Require Import Arith String. (* append is part of the string library. Its signature is (s1 : string) : string -> string *) Fixpoint convert_nat_to_string (n : nat) : string := match n with

我试图编写一个函数,将
nat
转换为
coq
中的
string
。这是我的尝试

Require Import Arith String.

(*
  append is part of the string library. Its signature is
                 (s1 : string) : string -> string
*)

Fixpoint convert_nat_to_string (n : nat) : string :=
match n with
  | 0 => String "0" EmptyString 
  | 1 => String "1" EmptyString
  | 2 => String "2" EmptyString
  | 3 => String "3" EmptyString
  | 4 => String "4" EmptyString
  | 5 => String "5" EmptyString
  | 6 => String "6" EmptyString
  | 7 => String "7" EmptyString
  | 8 => String "8" EmptyString
  | 9 => String "9" EmptyString
  | _ => (append (convert_nat_to_string (n/10))) (convert_nat_to_string (n mod 10))
end.   
但是,在最后一个分支上,
coqide
给了我一个错误

错误:符号“\uu/\uu”的解释未知

即使我已经导入了
Arith
库。有人知道我为什么会收到这个错误消息吗


证明
/
Arith
的一部分:

Coq < Require Import Arith.
[Loading ML file z_syntax_plugin.cmxs ... done]
[Loading ML file quote_plugin.cmxs ... done]
[Loading ML file newring_plugin.cmxs ... done]
<W> Grammar extension: in [tactic:simple_tactic], some rule has been masked
<W> Grammar extension: in [tactic:simple_tactic], some rule has been masked
<W> Grammar extension: in [tactic:simple_tactic], some rule has been masked
<W> Grammar extension: in [tactic:simple_tactic], some rule has been masked
<W> Grammar extension: in [tactic:simple_tactic], some rule has been masked

Coq < Check 5/10.
5 / 10
     : nat
Coq<需要导入算术。
[正在加载ML文件z_syntax_plugin.cmxs…完成]
[正在加载ML文件quote_plugin.cmxs…完成]
[正在加载ML文件newring_plugin.cmxs…完成]
语法扩展:在[策略:简单策略]中,一些规则被掩盖了
语法扩展:在[策略:简单策略]中,一些规则被掩盖了
语法扩展:在[策略:简单策略]中,一些规则被掩盖了
语法扩展:在[策略:简单策略]中,一些规则被掩盖了
语法扩展:在[策略:简单策略]中,一些规则被掩盖了
Coq<检查5/10。
5/10
:纳特

从Coq 8.6开始,此功能可在
Coq.Arith.PeanoNat
中使用

Require Import Coq.Arith.PeanoNat.

Check 10 / 5. (* --> 10 / 5 : nat *)

我用的是coq8.6。我按原样尝试了您的代码,但无法重现您看到的错误。您将看到另一个与总体性有关的错误。您可以使用
程序定点
或遵循建议的方法(查找
字符串_nat
)来处理它。@AntonTrunov为此欢呼。我尝试直接从命令行运行代码,但得到了与您提到的相同的错误。但是,当从IDE运行它时,会出现问题中提到的错误。我不知道如何修复它,因为我不是CoqIDE用户。你可能想给ProofGeneral+company coq(可选)一个机会:)我看到很多关于CoqIDE的问题。不过我承认,在这里配置Emacs可能不是您的优先事项:)谢谢Arthur。您知道是否有任何方法可以检查
coqide
使用的
coq
版本,以便我可以确认这确实是问题所在吗?因为当我在命令行中运行
coqtop-v
时,我得到的版本为
8.5pl13
@iamwhoiam我的coqide版本显示了它启动时使用的coq版本,在右下角。如果你的工具栏上没有,你可以试试工具栏上的“关于”菜单。你在用什么操作系统?我知道了。它是
8.4pl5
。所以我相信错误是由于不同的版本造成的。不过,我不能通过下载另一个版本来确认这一点,因为官方网站现在似乎已经关闭了。不幸的是,是的,它已经关闭,可能会一直关闭到明天。您可以尝试从OPAM或Nix(或源代码)安装Coq。如果你在Windows上,尽管我没有解决方案(从Windows上的源代码编译是可能的,但很复杂)。