如何阅读 Prolog 文档?

How to read Prolog documentation?

例如,如果我在 Prolog REPL 中键入 help(bagof).,则会弹出 window 和一些文档,其第一行显示为 bagof(+Template, :Goal, -Bag).

  1. 参数Template、Goal和Bag只是​​名称,还是可以系统研究的形式类型? (在第一种情况下,我将不得不依赖 bagof 的文档来理解它们;在后一种情况下,我将能够参考其他文档。)

  2. 我在哪里可以找到参数前的那些标点符号的文档? (在这种情况下,标点符号包括符号 +:-,但我见过其他符号。)

TemplateGoal 等只是这些参数的名称。有时,它们会给出一些关于相应参数的预期 type 的指示。例如,Goal 通常表示类型为 callable 的参数。像 List 这样的名称通常表示一个列表,等等。

+: 等是 模式指标 并表示预期的实例化模式:

引用自http://eu.swi-prolog.org/pldoc/man?section=modes

++  Argument is ground at call-time, i.e., the argument does not contain a variable anywhere.
+   Argument is fully instantiated at call-time, to a term that satisfies the type. etc.
-   Argument is an output argument. etc.
--  Argument is unbound at call-time. etc.
?   Argument is bound to a partial term of the indicated type at call-time. etc.
:   Argument is a meta-argument. Implies +.
etc.

最常用的模式指示符是+-?

另请注意,在文献和某些系统的文档中也使用了不同的约定和细微的变化来记录谓词的此类属性。