SWI-Prolog / packages-semweb

The SWI-Prolog RDF store
28 stars 14 forks source link

Assert RDF term type restrictions as constraints #49

Open wouterbeek opened 7 years ago

wouterbeek commented 7 years ago

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).