安装 Ocaml 旧版本,因为库失败

Install Ocaml older version, because libraries fail

我无法运行有关逻辑和推理的代码:https://www.cl.cam.ac.uk/~jrh13/atp/

例如,在最近的版本中,新版本似乎无法识别Num 库。我尝试了不同的在线编译器,但它们都在某个时候失败了。然后,唯一的方法是安装编写代码的确切版本:3.09.3

所以,问题是:如何安装该版本?我可以降级我的 Opam 吗?或者你会推荐另一种选择。我使用 Mac.

我尝试了 opam switch create 3.09.3 并报告了这些问题:


The following actions failed
│ λ build ocaml-base-compiler 3.09.3
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray base
│ ∗ install base-threads  base
│ ∗ install base-unix     base

您正在正确安装所有内容,无需降级 opam。您实际上并没有表明问题出在哪里。错误消息表明某些事情终于失败了,但实际的错误消息在上面。还有一条消息包含错误日志的路径。我尝试使用 opam switch create 3.09.3 在我的机器上安装 3.09.3 并且没有任何问题,

$ opam switch create 3.09.3

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ocaml-base-compiler.3.09.3] downloaded from cache at https://opam.ocaml.org/cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
∗ installed ocaml-base-compiler.3.09.3
∗ installed ocaml-config.1
∗ installed ocaml.3.09.3
Done.

因此可能是您的系统存在一些本地问题,例如 space 中的 运行。

话虽如此,您仍然可以在现代版本的 OCaml 中尝试 运行 这些示例。要在现代版本的 OCaml 中启用 nums,您需要安装包(不再随 OCaml 编译器分发,但在 opam 中仍然可用),

opam install num

然后,您可以在顶层(ocaml 解释器)中加载 num,使用以下

#use "topfind";;
#require "num-top";

num-top 库将加载 nums 库,甚至安装顶级打印机,使您与任意精度数字的交互更加舒适。这两行应该代替 init.ml 文件中的 #load "nums.cma";; 行。