本文介绍了如何将模型检查逻辑查询转换为SPARQL查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我具有以下RDF数据:
Suppose I have the following RDF data:
@prefix : <urn:ex:>
:m :A "a"
:m :A "b"
:m :A "c"
:m :B "a"
:m :B "b"
我可以使用哪种SPARQL查询来检查RDF模型是否满足以下逻辑公式?
What SPARQL query could I use to check whether the RDF model satisfies the following logical formula?
∀x A(X) → B(x)
推荐答案
SPARQL没有条件或通用量化,但是具有存在性(是否与之匹配?),(隐式)合取和否定(在不存在"中) ").
SPARQL doesn't have conditionals or universal quantification, but does have existentials (does anything match this?), (implicit) conjunction and negation (in the 'absence' sense).
所以重写问题:
∀x A(x) → B(x) ⇒
∀x ¬ ( A(x) ∧ ¬ B(x) ) ⇒
¬ ∃x A(x) ∧ ¬ B(x)
这是SPARQL可以做的,差不多:
and that's something SPARQL can do, pretty much:
# Is there anything of type A but not B?
ASK {
{ ?x a :A } MINUS { ?x a :B }
}
如果违反任何约束条件,此查询将返回 true .
This query returns true if there are any violations of the constraint.
这篇关于如何将模型检查逻辑查询转换为SPARQL查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!