你知道如何在 SWRL 中翻译递归吗?例如,这种类型的 Prolog 规则:(祖先是父母或父母的祖先。
ancestor(X,Y):- parent (X,Y).
ancestor(X,Y):- parent(X,Z), ancestor(Z,Y).
本质上,SWRL 是Datalog。只是颠倒头部和身体:
hasParent(?x, ?y) -> hasAncestor(?x, ?y)
hasAncestor(?y, ?z) ^ hasParent(?x, ?y) -> hasAncestor(?x, ?z)
Protégé 中的 SWRLTab:
初步断言:
推断(通过 Pellet)断言:
当然,也存在纯 OWL 解决方案。