packages-semweb
packages-semweb copied to clipboard
Assert RDF term type restrictions as constraints
When we perform Basic Graph Pattern (BGP) queries we can often deduce that instantiations must be of a specific type. E.g., in the following BGP there is no need to instantiate X to a literal:
rdf(a, b, X),
\+ rdf_is_literal(X),
rdf(X, d, e).
It would be great if we could assert such type restrictions as constraints:
{rdf_is_subject(X)},
rdf(a, b, X),
rdf(X, d, e).
The interaction between RDF constraints would allow senseless queries to fail early, for instance the following would immediately fail (because one constraint assumes X is a literal while another constraint states that X cannot be a literal):
{X < "2017"^^xsd:gYear},
{rdf_is_subject(X)},
rdf(X, p, o).