[英]Simple Constraint Logic Programming sample CLP(Q) gives error in Prolog
I've started to learn Prolog and I follow the RIPTutorial PDF.我已经开始学习 Prolog 并遵循 RIPTutorial PDF。 At the Constraint Logic Programming CLP(Q) section, it says:在约束逻辑编程 CLP(Q)部分,它说:
Constraint Logic Programming CLP(Q) implements reasoning over rational numbers约束逻辑编程 CLP(Q) 实现对有理数的推理
Example:例子:
?- { 5/6 = X/2 + 1/3 }.
X = 1.
When I've tried this line on SWI-Prolog on Windows, it gave:当我在 Windows 上的 SWI-Prolog 上尝试这一行时,它给出了:
ERROR: Unknown procedure: {}/1 (DWIM could not correct goal)
The same line on commandline SWI-Prolog-7.2.0 on macOS gives: macOS 上命令行 SWI-Prolog-7.2.0 上的同一行给出:
ERROR: toplevel: Undefined procedure: {}/1 (DWIM could not correct goal)
How to get the expected output of X = 1.
?如何获得X = 1.
的预期输出X = 1.
?
Using SWI-Prolog .使用SWI-Prolog 。
As noted in the comments you need to load the code for CLP(Q) first.如注释中所述,您需要先加载CLP(Q)的代码。
?- use_module(library(clpq)).
true
Then enter the query as in the example.然后按照示例输入查询。
?- {5/6 = X/2 + 1/3}.
X = 1.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.