2

所以我目前正在学习数据记录。我启动它并输入以下内容:

parent(john, michael).

并立即得到一个未定义的谓词错误。据我了解,这应该是在模拟数据库中定义关系的正确方法。怎么了?我在互联网上进行了搜索,但一无所获。

我正在使用没有 GUI 的 Windows 64 位版本的程序

4

3 回答 3

3

正如 Datalog 的回答中提到的,不同的数据记录系统具有不同的行为。如果您正在寻找一种快速而简单的方式来了解一般的数据记录,您还可以尝试“LogiQL”数据记录变体的在线解释器:https ://repl.logicblox.com/ 。(披露:我为生产 LogiQL 的公司工作。)作为一个 hello-world,您可以尝试:

=> addblock 'parent("john", "michael").'
Succesfully added block
=> print parent
/-------------------\
| john   | michael  |
\-------------------/
于 2014-03-17T15:32:52.293 回答
2

您使用的数据记录系统的名称是什么?Datalog 是一种语言的名称。不同的系统接受不同的语言变体。有些可能要求您在使用谓词之前声明它们。

于 2014-03-17T00:42:58.780 回答
2

You can find answers to these questions in the user manual of DES, which is in the folder ./doc of the distribution and can also be downloaded from its web page. Anyway, what you have typed is a query, i.e., you are not trying to assert a new fact. If you want to interactively assert a fact, use the command /assert, as in:

DES> /assert parent(john, michael)

DES> parent(john,michael)

{            

  parent(john,michael)

}

Info: 1 tuple computed.          

The other way to assert Datalog facts (and also rules) is to store them in a file, say parents.dl, and consult it (notice the ending dot after a fact):

Contents of parents.dl:

parent(john,michael).

End of contents of parents.dl

To consult it:

DES> /consult parents             

Info: 1 rule consulted.

DES> parent(john,michael)

{          

  parent(john,michael)

}

Info: 1 tuple computed.          

Note that the query asks the system whether the fact parent(john,michael) is deduced from its database, which it is deduced indeed. Other uses of queries include variables, as in:

DES> parent(X,Y)                  

{             

  parent(john,michael)

}

Info: 1 tuple computed. 
于 2014-09-01T18:13:32.137 回答