• Keine Ergebnisse gefunden

Schema-Agnostic Query Rewriting in SPARQL 1.1

N/A
N/A
Protected

Academic year: 2022

Aktie "Schema-Agnostic Query Rewriting in SPARQL 1.1"

Copied!
27
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Fakultät Informatik, Institut Künstliche Intelligenz, Professur Computational Logic

Schema-Agnostic Query Rewriting in SPARQL 1.1

Stefan Bischof, Markus Krötzsch,

Axel Polleres and Sebastian Rudolph

(2)

Query

Q

Data

D

Plain  Query  Answering  

(3)

Query

Q

Data

D

Ontological  Query  Answering  

Ontology

Σ

(4)

Query

Q

Knowledge Base

The Knowledge Representation View:

Data

D

Views  on  Ontological  Query  Answering  

Ontology

Σ

(5)

Query

Q

Knowledge Base

The Knowledge Representation View:

Data

D

Views  on  Ontological  Query  Answering  

Ontology Σ

standard approach:

materialization

Data

D’

(6)

Query

Q

Data

D

Ontological  Query  Answering  

Ontology

Σ

(7)

Query

Q The Database View:

Data

D

Views  on  Ontological  Query  Answering  

Ontology Σ

Ontology-mediated Query

(8)

Query

Q The Database View:

Data

D

Views  on  Ontological  Query  Answering  

Ontology Σ

Ontology-mediated Query

Query

Q’

standard approach:

query

rewriting

(9)

Our  Scenario:  CQs  over  OWL  QL  

Data (RDF)

Ontology (OWL QL)

Conjunc- tive Query

(SPARQL)

•  OWL QL based on DL-Lite family

•  typically used for data-intensive scenarios

•  also covers RDFS in standard use

(i.e. without schema hijacking)

(10)

Knowledge Base = RDF Graph

•  data and schema knowledge all mixed together

•  schema knowledge expressed as data using special vocabulary: rdfs:subClassOf, …

•  assumption: RDF Graph not known in advance

Data (RDF)

Ontology (OWL QL as RDF)

Our  Scenario:  CQs  over  OWL  QL  

Conjunc- tive Query

(SPARQL)

“ ”

(11)

Query‘

Knowledge Base = RDF Graph

•  data and schema knowledge all mixed together

•  schema knowledge expressed as data using special vocabulary: rdfs:subClassOf, …

•  assumption: RDF Graph not known in advance

•  Can we still do query rewriting? … Let’s try!

Data (RDF)

Ontology (OWL QL as RDF)

Our  Scenario:  CQs  over  OWL  QL  

“ ”

(12)

Example  

Query: Give me all the individuals known to be persons.

first attempt:

SELECT ?p!

WHERE ?p rdf:type ex:Person!

does not work for:

ex:shakespeare !rdf:type ! !ex:Author .!

ex:Author ! !rdfs:subClassOf !ex:Person .

!

(13)

Example  

Query: Give me all the individuals known to be persons.

second attempt:

SELECT ?p!

WHERE {?p rdf:type ex:Person} UNION !

{?p rdf:type ?c . ?c rdfs:subClassOf ex:Person}

does not work for:

ex:shakespeare !rdf:type ! !ex:Author .!

ex:Author ! !rdfs:subClassOf !ex:Artist .

(14)

Example  

Query: Give me all the individuals known to be persons.

We need to incorporate arbitrarily long subclass paths.

Use SPARQL 1.1!

SELECT ?p!

WHERE {?p rdf:type ?c . ?c rdfs:subClassOf* ex:Person}

Is this it?

(15)

Example  

Query: Give me all the individuals known to be persons.

We need to incorporate arbitrarily long subclass paths.

Use SPARQL 1.1!

SELECT ?p!

WHERE {?p rdf:type ?c . ?c rdfs:subClassOf* ex:Person}

Is this it? No!

(16)

Example  

ex:shakespeare !ex:authorOf ! ex:hamlet .!

rdf:authorOf !rdfs:subPropertyOf ex:creatorOf .!

ex:creatorOf !rdfs:domain! ! ex:Artist .!

ex:Artist ! !rdfs:subClassOf ! ex:Person .!

(17)

Example  

ex:shakespeare ex:authorOf ex:hamlet. ex:authorOf rdfs:subPropertyOf ex:creatorOf. !

!

ex:shakespeare ex:creatorOf ex:hamlet. ex:creatorOf rdfs:domain ex:Artist.!

!

!

ex:shakespeare rdf:type ex:Artist. ex:Artist rdfs:subClassOf ex:Person.!

!

!

ex:shakespeare rdf:type ex:Person.!

Important Observations:

•  proof tree is linear

•  leaf triples in the proof tree form sort of a chain

(18)

Results (1/2) Rewriting for Single Triples

Theorem:

For (almost) all OWL QL ontologies, each of the following

reasoning tasks can be expressed in a single SPARQL 1.1 query:

§  Is the ontology consistent?

§  Is the class A consistent?

§  Does the ontology entail A rdfs:subClassOf B ?

§  Does the ontology entail R rdfs:subPropertyOf S ?

§  Does the ontology entail c rdf:type A ?

§  Does the ontology entail c R d ?

Directly extends to schema queries: A,B,R,S can be variables!

(19)

Computational Logic Group Institute for Artificial Intelligence 19 23.10.2014 Sebastian Rudolph Schema-Agnostic Query Rewriting in SPARQL 1.1

ISWC 2014

Example

SPARQL 1.1 query retrieving all inconsistent classes:

Table 3. Pattern empty C lass [x] for detecting empty classes.

x ( sCO | eqC | ˆ eqC | int L ist M ember | owl:someValuesFrom |

( owl:onProperty / (I nv | S po E qp ) / (ˆ owl:onProperty | rdfs:domain | rdfs:range )) ?C . { { ?C sub C lass O f owl:Nothing } UNION

{ ?C sub C lass O f ?D1 {{ ?C sub C lass O f ?D2 } UNION univ C lass [ ?D2 ] } { { ?D1 disjoint C lasses ?D2 } UNION

{ ?V rdf:type owl:AllDisjointClasses . two M embers [ ?V , ?D1 , ?D2 ] } }} UNION

{ ?C ( owl:onProperty / (I nv | S po E qp ) ) ?P . {

{ ?P sub P roperty O f owl:bottomObjectProperty } UNION

{ ?P sub P roperty O f ?Q1 {{ ?P sub P roperty O f ?Q2 } UNION univ P roperty [ ?Q2 ] } { { ?Q1 ( owl:propertyDisjointWith | ˆ owl:propertyDisjointWith ) ?Q2 } UNION

{ ?V rdf:type owl:AllDisjointProperties . two M embers [ ?V , ?Q1 , ?Q2 ] } }} }

}

– some P rop I nv B ( owl:onProperty / sub I nv P roperty O f / rdfs:range ),

– sub C lass O f B ( sCO | eqC | ˆ eqC | int L ist M ember | some P rop | some P rop I nv ) . Moreover, we let univ C lass [x] denote the pattern { owl:Thing sub C lass O f x } UNION { owl:topObjectProperty ((S po E qp | I nv ) / (ˆ owl:onProperty | rdfs:domain | rdfs:range ) / sub C lass O f ) x }

Proposition 2. Consider an OWL QL ontology G with classes c 2 SPC and d 2 SBC such that G [ { _:a rdf:type c } is consistent. Then G entails c rdfs:subClassOf d i ↵ the pattern { c sub C lass O f d } UNION univ C lass [d] matches G.

It remains to identify classes that are incoherent, i.e., for which c rdfs:subClassOf owl:Nothing is entailed. To do this, we need to consider the patterns of Table 2.

Definition 4. For arbitrary terms x, y, and z, let two M embers [ x , y , z] be the pattern { x ( owl:members / rdf:rest ) ?W . ?W rdf:first y . ?W ( rdf:rest + / rdf:first ) z } , and let disjoint C lasses be the property path expression ( owl:disjointWith | ˆ owl:disjointWith |

owl:complementOf | ˆ owl:complementOf ). The query pattern empty C lass [ x] is defined as in Table 3, and the query pattern empty P roperty [x] is defined as in Table 4.

We can now completely express OWL QL schema reasoning in SPARQL 1.1:

Theorem 2. An OWL QL ontology G is inconsistent i ↵ it has a match for the pattern

{ ?X rdf:type ?C . empty C lass [ ?C ] } UNION { ?X ?P ?Y . empty P roperty [ ?P ] } UNION { ?X owl:differentFrom ?X } UNION

{ ?V rdf:type owl:AllDifferent . two M embers [ ?V , ?X , ?X ] } . (26)

(20)

Result (2/2) Rewriting for CQs

Theorem: For (almost) all OWL QL ontologies, for all conjunctive queries Q, there is a schema-agnostic SPARQL 1.1 rewriting of linear size.

→ More complicated due to non-distinguished variables

→ Use more SPARQL features: VALUES and FILTER (some guessing involved)

→ Resulting query still of the same complexity as before

(21)

First Implementation and Testing

Prototype path rewriter available for download

•  Simple web interface and commandline application

•  http://stefanbischof.at/publications/iswc14/

(22)

First Implementation and Testing

Preliminary evaluation with LUBM and Jena ARQ.

Compared to REQUIEM using QL fragment of the LUBM ontology

•  It works!

•  Rewriting is always faster than REQUIEM

•  Size of rewritings usually smaller than REQUIEM

•  Query evaluation is usually slower than REQUIEM

(23)

Limits of the Approach

Limit 1: Reasoning complexity

A query language with data complexity C cannot express a reasoning task of combined complexity C’ > C.

What does this mean for us?

SPARQL 1.1 is in NLogSpace (data complexity).

Reasoning is PTime-hard for:

OWL EL, OWL RL, RDFS in nonstandard use

→ No schema-agnostic rewriting possible for these cases

unless NLogSpace = PTime.

(24)

Limits of the Approach

Limit 2: Query expressivity

Query languages usually do not solve all problems of their complexity class – some things might be impossible.

What does this mean for us?

SPARQL 1.1 cannot support owl:SymmetricProperty axioms, although it can support inverse properties.

We require OWL 2 QL with owl:SymmetricProperty

paraphrased.

(25)

Take-Home Message

Every RDF database featuring SPARQL 1.1

queries can be used as an OWL QL reasoner,

with full support for conjunctive queries including

schema variables.

(26)

Future Work

§  Evaluation

§  Optimization

§  order of triple patterns impact performance

§  Exploit algebraic equivalences

§  Materialize some re-occurring query fragments

§  For example subClassOf “macro”

§  What can we do for more expressive ontologies?

§  Combined approaches (touch the data just a little bit)

§  More powerful queries (such as variants of Datalog)

(27)

Thank You!

Referenzen

ÄHNLICHE DOKUMENTE

Karlsruher Institut f¨ ur Technologie Institut f¨ ur Theoretische Festk¨ orperphysik.. Ubungen zur Theoretischen Physik F ¨

Die Kollinearität ergibt sich auch, wenn die beiden Startpunkte auf verschiedenen Ästen der Hyperbel liegen (Abb... 2: Punkte auf

Durch Punktspiegelung an M erhalten wir folgende Variante: Wir setzen einem Rhom- bus kongruente rechtwinklige Dreiecke zyklisch an (Abb. 4: Rhombus mit

The language includes major concepts and resource types, features an easy to understand syntax and is powerful enough to satisfy the information needs of customers and providers

Ontology-based Query Answering The query rewriting approach Query rewriting for OBQA Ontology-based Data Access Query rewriting for OBDA Conclusions..

Therefore, we introduce RDF streams as the natural extension of the RDF data model to the new scenario continuous and Continuous SPARQL (or simply C-SPARQL) as the extension of

C-SPARQL adds RDF streams to the SPARQL data types, in the form of an extension done much in the same way in which the stream type has been introduced to extend relations in

[r]