Protege中Drools引擎能否基于owl:equivalentClass推理知识?
我在Protege中使用swrlx:makeOwlThing编写SWRL规则,因此采用Drools引擎。但其中一条规则依赖owl:equivalentClass断言推理出的类个体:用Pellet等推理机时,等价类断言能正常生效;但点击“OWL+SWRL”运行Drools时,规则失效,因为owl:equivalentClass的推理未被执行。
我手动做了个实验,尝试用SWRL规则复现在Protege里设置的两条owl:equivalentClass断言:
### http://www.semanticweb.org/user/ontologies/2023/11/untitled-ontology-330#ProcessData :ProcessData rdf:type owl:Class ; owl:equivalentClass [ rdf:type owl:Restriction ; owl:onProperty :isProcessData ; owl:hasValue "true"^^xsd:boolean ] . ### http://www.semanticweb.org/user/ontologies/2023/11/untitled-ontology-330#ProcessDataInput :ProcessDataInput rdf:type owl:Class ; owl:equivalentClass [ rdf:type owl:Restriction ; owl:onProperty :hasAE ; owl:hasValue :Vel ] ; rdfs:subClassOf :ProcessData .
我不确定是配置缺失,还是必须把所有owl:equivalentClass转换为SWRL规则?
核心原因
Drools的SWRL集成并非完整的OWL推理机,它仅聚焦于执行SWRL规则及自定义内置函数(如swrlx:makeOwlThing),不会自动处理OWL TBox层面的公理推理——比如owl:equivalentClass这类需要推导类成员关系的公理,Pellet、HermiT等专业OWL推理机默认会处理,但Drools不会。
可选解决路径
预推理后再用Drools
先通过完整OWL推理机把等价类的推导结果固化到本体中,再用Drools运行SWRL规则:- 在Protege中切换到Pellet或HermiT推理机,点击“运行推理”;
- 推理完成后,导出本体时勾选“包含推理结果”选项;
- 将导出的本体重新导入Protege,再使用Drools引擎运行SWRL规则——此时等价类推导的个体类型断言已存在,依赖该断言的规则就能正常执行。
将等价类公理转为SWRL规则
如果必须直接用Drools处理,需要把owl:equivalentClass的双向逻辑转换成对应的SWRL规则(等价类是双向推导关系):- 对应
ProcessData的等价类,需要两条规则:isProcessData(?x, true) → ProcessData(?x) ProcessData(?x) → isProcessData(?x, true) - 对应
ProcessDataInput的等价类,同样需要两条规则:hasAE(?x, :Vel) → ProcessDataInput(?x) ProcessDataInput(?x) → hasAE(?x, :Vel) - 另外,由于
ProcessDataInput是ProcessData的子类,Drools默认不会自动处理子类的类型推导,需要补充一条规则:ProcessDataInput(?x) → ProcessData(?x)
- 对应
配置说明
Drools的SWRL插件没有可开启的配置项来自动处理OWL等价类推理,这是由它的设计定位决定的——它的核心是扩展SWRL的自定义能力,而非替代专业OWL推理机完成TBox推理。
内容的提问来源于stack exchange,提问作者Yudop

