how to convert model checking logic query to SPARQL query?

萝らか妹 提交于 2019-12-22 10:27:01

问题


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"

What SPARQL query could I use to check whether the RDF model satisfies the following logical formula?

∀x A(X) → B(x)

回答1:


SPARQL doesn't have conditionals or universal quantification, but does have existentials (does anything match this?), (implicit) conjunction and negation (in the 'absence' sense).

So rewrite the question:

∀x A(x) → B(x) ⇒
∀x ¬ ( A(x) ∧ ¬ B(x) ) ⇒
¬ ∃x A(x) ∧ ¬ B(x)

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 }
}

This query returns true if there are any violations of the constraint.



来源:https://stackoverflow.com/questions/37832758/how-to-convert-model-checking-logic-query-to-sparql-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!