Scholarly article on topic 'A Prolog-based Query Language for OWL'

A Prolog-based Query Language for OWL Academic research paper on "Computer and information sciences"

CC BY-NC-ND
0
0
Share paper
Keywords
{OWL / "Logic Programming" / "Semantic Web"}

Abstract of research paper on Computer and information sciences, author of scientific article — Jesús M. Almendros-Jiménez

Abstract In this paper we investigate how to use logic programming (in particular, Prolog) as query language against OWL resources. Our query language will be able to retrieve data and meta-data about a given OWL based ontology. With this aim, firstly, we study how to define a query language based on a fragment of Description Logic, then we show how to encode the defined query language into Prolog by means of logic rules and finally, we identify Prolog goals which correspond to queries.

Academic research paper on topic "A Prolog-based Query Language for OWL"

Available online at www.sciencedirect.com

ScienceDirect

Electronic Notes in Theoretical Computer Science 271 (2011) 3-22

www.elsevier.com/locate/entcs

A Prolog-based Query Language for OWL

Jesús M. Almendros-Jiménez 1,2

Dpto. de Lenguajes y Computación Universidad de Almería 04120-Spain

Abstract

In this paper we investigate how to use logic programming (in particular, Prolog) as query language against OWL resources. Our query language will be able to retrieve data and meta-data about a given OWL based ontology. With this aim, firstly, we study how to define a query language based on a fragment of Description Logic, then we show how to encode the defined query language into Prolog by means of logic rules and finally, we identify Prolog goals which correspond to queries.

Keywords: OWL, Logic Programming, Semantic Web

1 Introduction

The Semantic Web framework [11,13] proposes that Web data represented by HMTL and XML have to be enriched by means of meta-data, in which modeling is mainly achieved by means of the Resource Description Framework (RDF) [22] and the Web Ontology Language (OWL) [16]. RDF and OWL are proposals of the W3C consortium 3 for ontology modeling. OWL is syntactically layered on RDF whose underlying model is based on triples. The RDF Schema (RDFS) [10] is also a W3C proposal and enriches RDF with specific vocabularies for meta-data. RDFS/RDF and OWL can be used for expressing both data and meta-data. OWL can be considered as an extension of RDFS

1 The author work has been partially supported by the Spanish MICINN under grant TIN2008-06622-C03-03.

2 Email: jalmen@ual.es

3 http://www.w3.org.

1571-0661/$ - see front matter © 2011 Elsevier B.V. All rights reserved. doi:10.1016/j.entcs.2011.02.008

in which a richer vocabulary allows to express new relationships. OWL offers more complex relationships than RDF(S) between entities including means to limit the properties of classes with respect to the number and type, means to infer that items with various properties are members of a particular class and a well-defined model of property inheritance. OWL is based on the so-called Description Logic (DL) [8], which is a family of logics (i.e. fragments) with different expressivity power. Most of fragments of Description Logic are subsets or variants of C2, the subset of first-order logic (FOL) extended with counting quantifiers, with formulas without function symbols and maximum two variables, which is known to be decidable [15]. Description Logic can therefore also be understood as an attempt to address the major drawbacks of using FOL for knowledge representation and inference, and also the syntax of DL allows a variable-free notation. The most prominent fragment of DL is SROIQ which is the basis of the new standarized OWL 2. OWL 2 semantics has been defined in [26], in which a direct semantics is defined based on Description Logic, and in [27] a RDF-based semantics is provided.

In this paper we investigate how to use logic programming (in particular, Prolog) as query language against OWL resources. Our query language will be able to retrieve data and meta-data about a given OWL based ontology. With this aim, firstly, we study how to define a query language based on a fragment of Description Logic, then we show how to encode the defined query language into Prolog by means of logic rules and finally, we identify Prolog goals which correspond to queries.

Basically, our work goes towards the use of logic programming as query language for the Semantic Web. It follows our previous research line about the use of logic programming for the handling of Web data. In particular, we have studied the encoding in logic programming of the XML query language XPath in [2,1], and the encoding in logic programming of the XML query language XQuery in [3,5], studying extensions of XQuery for the handling of RDF and OWL in [4,7,6]. In this framework, we would like to study how OWL querying and reasoning can be achieved by means of logic programming in order to be integrated with the proposal of the implementation of XQuery in logic programming.

1.1 Description Logic

Description Logic is a formalism for expressing relationships between concepts, between roles, between concepts and roles, and between concepts, roles and individuals. Formulas of Description Logic can be used for representing knowledge, that is, concept descriptions, about a domain of interest. Typically, Description Logic is used for representing a TBox (terminological box)

and the ABox (assertional box). The TBox describes concept (and role) hierarchies (i.e., relations between concepts and roles) while the ABox contains relations between individuals, concepts and roles. Therefore we can see the TBox as the meta-data description, and the ABox as the description about data.

In this context, we can distinguish between (1) reasoning tasks and (2) querying tasks from a given ontology. In both cases, a certain inference procedure should be present in order to deduce new relationships from a given ontology. The most typical (1) reasoning tasks, with regard to a given ontology, include: (a) instance checking, that is, whether a particular individual is a member of a given concept, (b) relation checking, that is, whether two individuals hold a given role, (c) subsumption, that is, whether a concept is a subset of another concept, (d) concept consistency, that is, consistency of the concept relationships, and (e) a more general case of consistency checking is ontology consistency in which the problem is to decide whether a given ontology has a model. However, one can be also interested in (2) querying tasks such as: (a) instance retrieval, which means to retrieve all the individuals of a given concept entailed by the ontology, and (b) property fillers retrieval which means to retrieve all the individuals which are related to a given individual with respect to a given role.

OWL/DL reasoning is a topic of research of increasing interest in the literature. Most of DL reasoners (for instance, Racer [20], FaCT++ [30], Pellet [28]) are based on tableaux based decision procedures. Based on logic programming, the DLog system [23] reasons with an ontology by means of the encoding into Prolog and the use of the PTTP theorem prover. The KAON2 tool [9,19] is based on the encoding of the SHIQ fragment into disjuntive Datalog [18]. They have studied a resolution-based inference.

We believe that an interesting research line would be to design a query language whose aim is to express such reasoning and querying tasks. In other words, the study of some kind of formalism in which we can express the kind of task (i.e. reasoning and querying task) one wants to achieve with respect to a given ontology. Such a language should be equipped with some kind of formulas for representing the query. In addition, such a query language should be equipped with an inference mechanism in order to reason with the ontology. Such inference mechanism could be based on an entailment relationship. The query language we propose will be based on Description Logic formulas which can contain free variables. Free variables represent the elements of the formula for which we want to retrieve values. Such values should represent the names of concepts, roles and individuals satisfying a given query (i.e. the DL formula). In such a case, we would obtain the answers to a given querying task. In the

case of formulas without free variables, the query would represent a reasoning task, and the answer would be true or false.

The definition of a set of entailment rules for RDFS and OWL has attracted the attention of the Semantic Web community. An entailment relationship defines which relationships can be deduced from a given ontology. In this context, the authors of [25] have observed that the rules of entailment of the official RDF Semantics specification are not complete, and have suggested for the case of RDFS, to identify a fragment which encompasses the essential features of RDFS, which preserves the original semantics, be easy to formalize and can serve to prove results about its properties. With this aim they have defined a fragment of RDFS that covers the crucial vocabulary of RDFS, they have proved that it preserves the original RDF semantics, and avoids vocabulary and axiomatic information that only serves to reason about the structure of the language itself and not about the data it describes. The studied fragment of RDFS lifts the structural information into the semantics of the language hiding them from developers and users. They have given a sound and entailment relationship for a fragment of RDF including rdf:type, rdfs:subClassOf, rdfs:subPropertyOf, rdfs:domain and rdfs:range. In the case of OWL, there is a proposal for extending rules for entailment with RDFS to OWL. The so-called pD* approach [29] is a proposal for an extension of the RDFS vocabulary with some elements of OWL: owl:Functio-nalProperty, owl:InverseFunctionalProperty, owl:sameAs, owl:Symme-tricProperty, owl : TransitiveProperty and owl:inverseOf. For such a fragment, they have defined a complete set of simple entailment rules. The pD* approach has been successfully applied to the SAOR (Scalable Authoritative OWL reasoner) [17], a system which focuses on a good performance with RDF and OWL data.

In this line, our approach considers a set of entailment rules for a fragment of OWL. Such fragment differs from the fragment of the pD* [29], neither pD* is include in our fragment, nor our fragment is included in pD*, but our fragment includes the RDFS fragment of [25]. In addition, our fragment of DL allows to encode the entailment relationship by means of logic programming, in particular, by Prolog. For this reason, we have studied the relationship between Description Logic and Logic Programming.

1.2 Description Logic and Logic Programming

In this area of research, some authors [14,31] have studied the intersection of Description Logic and Logic Programming, in other words, which fragment of Description Logic can be expressed in Logic Programming. In [14], they have defined the so-called Description Logic Programming (DLP), which cor-

responds with a fragment of SHIQ. With this aim, firstly, the fragment of DL is encoded into a fragment of FOL; and after the fragment of FOL is encoded into logic programming. Other fragments of OWL/DL can be also encoded into logic programming, in particular, Volz [31] has encoded fragments of SHOIN into Datalog, Datalog(=), Datalog(=,IC) and Prolog(=,IC); where "=" means "with equality", and "IC" means "with Integrity constraints". Some other proposals have encoded the fragment SHIQ into disjunctive Datalog [18], and into Datalog(IC,=,not) [12], where "not" means "with negation".

In our proposal, we have focused on one of the Volz's fragments which can be encoded into Datalog. It is a fragment of SHOIN, which includes the OWL elements: rdf:type, rdfs:subClassOf, rdfs:subPropertyOf, owl : equivalentProperty, owl:equivalentClass, rdfs:domain, rdfs:range, owl: someValuesFrom, owl:hasValue and owl:allValuesFrom, and handles owl:union and owl:intersection operators, and owl:TransitiveProper-ty, owl:SymmetricProperty and owl:inverseOf properties. All of them are used with some restrictions. We believe that our proposal could be extended to other fragments of SHOIN studied in [31].

Our work can be intended as an extension of the DLP framework in the following sense. The encoding of DL into logic programming defines an en-tailment relationship based on the rules. However, our encoding differs from DLP encoding: instead of encoding class and role names as Prolog predicates, we encode them as Prolog atoms. In fact, our encoding only uses a predicate called triple which defines by means of Prolog facts the relationships (i.e. the ABox and TBox elements) of the ontology. Therefore the ontology can be easily stored in secondary memory with efficient access. As a consequence of such encoding concept and role names are now first-class citizens, and they can be handled as individuals in the corresponding Prolog program and goals. In addition, in our approach, and in contrast with the DLP approach, complex concepts in Description Logic are handled by means of Prolog terms. For instance, yP.C is represented as a Prolog term forall(P, C). It also allows to handle complex concepts also as first-class citizens. Our work can be also considered as an extension of DLP framework because we investigate a more flexible query language than in DLP. By studying the entailment relationship between Description Logic formulas of the given fragment, we are able to provide semantics to a more flexible query language than the underlying query language in the DLP framework. For instance, we are able to entail in our framework typing formulas of the style 3P.C(I), that is, I is an individual of type 3P.C, in the spite of 3P.C(I) is not explicitely declared in the ABox. But more interesting, such a typing (i.e., 3P.C) can be retrieved as a answer of our query language. It is not possible with the DLP encoding because 3P.C

formulas can not be handled as first-class citizens. Moreover, P and C can work as query result, providing more flexible queries. In other words, our DLP extension can be considered as second order extension (i.e. predicate names in DLP can be replaced by variables) of the DLP approach. For such extension, we provide an entailment relationship. The entailment relationship defined in our proposal is also an extension of the underlying entailment relationship of the DLP fragment. Our entailment relationship is able to infer new DL formulas of the kind 3P.C C D when they are not explicitely declared in the TBox. Such new DL formulas would correspond with the inference of new rules from the DLP encoding of the selected fragment. In summary, our entailment relationship can obtain the same statements about the ABox: individual assertions and property fillers than the DLP approach for the same fragment, but we can also obtain new statements about the TBox: subclass and subproperty assertions with respect to the DLP approach.

We have developed a prototype of our approach which can be downloaded from http://indalog.ual.es/OProlog. We have tested our prototype with several examples of ontologies including the running example presented bellow. With respect to the implementation we have to make the following remarks:

• We have implemented the OWL-based query language using the SWI-Prolog interpreter.

• We have used the RDFS library of SWI-Prolog [32] for implementing loading of OWL triples. The RDFS library of SWI-Prolog has limited querying capabilities. Our proposal can be considered as an extension of such library for OWL querying.

• The syntactic structure of entailment rules makes that the implementation in Prolog loops: the predicate triple can call to itself with the same arguments. However, we have solved that problem by implementing an small Prolog interpreter which runs Prolog rules in such a way that it memorizes the facts about the predicate triple, and avoids calls with the same arguments.

The structure of the paper is as follows. Section 2 will present the fragment of DL of our proposal. Section 3 will define the query language proposed from the fragment. Section 4 will describe the encoding of the query language in Prolog. Finally, Section 5 will conclude and present future work.

2 Web Ontology Language

In this section we will show what kind of ontologies will be allowed in our framework. It will also define the entailment relationship.

Fig. 1. An Example of Ontology

(I) Man C Person

(3) Person n 3author_of.Manuscript C Writer (5) Book n 3topic.{"XML"} C XMLbook

(7) Manuscript C Vrating.Score (9) author_of = writes

(II) authored_by = author_of-(13) TCV author_of~ .Person

(15) TCV reviewed_by- .Manuscript

(2) Woman C Person

(4) Paper U Book C Manuscript

(6) Manuscript n 3reviewed_by.Person

C Reviewed (8) Manuscript C Vtopic.Topic (10) average_rating C rating (12) TCV author_of.Manuscript (14) T CV reviewed_by.Person

(1) Man("Abiteboul")

(2) Man("Bunemanv)

(4) Book("Data on the Web")

(6) Paper("Growing XQuery")

(8) author_of("Abiteboul","Data on the Web")

(10) author_of("Suciu","Data on the Web")

(12) writes("Simeon","Growing XQuery")

(14) reviewed_by(uGrowing XQuery","Almendros")

(16) rating("XML in Scottland","excellent")

(18) topic("Data on the Web","XML") (20) topic("XML in Scottland","XML")

(3) Man("Suciu")

(5) Book("XML in Scottland")

(7) Person("Anonymous")

(9) authored_by("Data on the Web",

"Buneman")

(11) author_of("Buneman", "XML in Scottland") (13) reviewed_by("Data on the Web", Anonymous")

(15) average_rating("Data on the Web", "good")

(17) average_rating("Growing XQuery". "good")

(19) topic("Data on the Web","Web")

An ontology O in our framework contains a TBox including a sequence of definitions T of the form given in Table 1 below, where E, F are

class (i.e. concept) descriptions of equivalence type (denoted by E,F G 6) of the form:

E ::= Co | Ex n E2 | 3P.{O}

In addition, C is a class (i.e. concept) description of left-hand side type (denoted by C GL), of the form:

C ::= Co | Ci n C2 | 3P.{O} | Ci U C2 | 3P.C

(rdfs:subClassof) (owl:equivalentClass) (rdfs:subPropertyOf) (owl:equivalentProperty) (owl:inverseOf) (owl:SymmetricProperty) (owl:TransitiveProperty) (rdfs:domain) (rdfs:range)

Table 1

Definitions for an ontology O

and D is a class (i.e. concept) description of right-hand side type (denoted by D 6R), of the form:

D ::= A | Di n D2 | 3P.{O} | VP.D

In all previous cases, C0 is an atomic class (i.e. class name), P, Q are property (i.e. role) names and O is an individual name. In addition, the ABox contains a sequence of definitions A1,..., Am of the form:

A := P(A,B) | Co(A) | T(A)

where P is a property name, C0 is a class name, and A, B are individual names.

Basically, the proposed subset of DL restricts the form of class descriptions in right and left hand sides of subclass and class equivalence definitions, and in individual assertions. Such restriction is required according to [31] in order to be able to encode the fragment of DL into logic programming. Following [31], the universal quantification is only allowed in the right hand sides of DL formulas, which corresponds in the encoding to the occurrence of the same quantifier in the left hand sides (i.e. heads) of rules. The existential quantification only occurs in the right hand by the same reason. Union formulas are required to occur in the left hand sides of DL formulas, which corresponds in the encoding to the definition of two rules.

C Q D | E = F I P Q Q I P = Q I P = Q- I

P = P- I P + Q P I T Q^P-.D I P.D

Table 2 Inference Calculus hQI

Rule Name Inference

(Eq1) hQI E = E

(Eq2) E = F, F = G \~QI e = G

(Eq3) E = F \~QI F = E

(Eq4) E C F, F C E \~QI E = F

(Subl) E = F hQI E C F

(Sub2) C C D, D C E hQI C C E

(Sub3) C U D C E hQI C C E

(Sub4) E C C n D hQI E C C

(Sub5) Ci n C2 C D, E C Ci hQI E n C2 C D

(Sub6) Ci U C2 C D, E C C1 hQI E U C2 C D

(Sub7) C C Di n D2, Di C E hQI C C E n D2

(Sub8) 3P.{O} CD, Q C P ^qi 3Q.{O}CD

(Sub9) 3P.C C D, Q C P hoi 3Q.C C D

(SublO) 3P.C C D, E C C hQI 3P.E C D

(Subll) C C 3P.{O}, P C Q hoi C C3Q.{O}

(Sub12) C C VP.D, Q C P hoi C CVQ.D

(Sub13) C C VP.D, D C E hQI C C VP.E

(Typel) C(A), C C D hoi D(A)

(Type2) P(A,O), 3P.{O} C D hoi D(A)

(Type3) P(A,B),C(B) 3P.C C D hoi D(A)

(Type4) C(A), P(A,B), C C VP.D hoi D(B)

(Type5) C(A), P(B, A), C C VP- .D hoi D(B)

(Type6) Cond(Ei), ni^i^nEi C D hoi D(A)

(Type7) hoi T(A)

(Propl) hQI P = P

(Prop2) P = Q, Q = R hQI P = R

(Prop3) P = Q hQI Q = P

(Prop4) P C Q, Q C P hQI P = Q

(Prop5) P = Q hQI P C Q

(Prop6) P C Q, Q C R hQI P C R

(Prop7) P C Q, P(A, B) hQI Q(A,B)

(Prop8) P C Q-, P(A, B) hoi Q(B, A)

(Prop9) Q- C P, Q(A,B) hoi P(B, A)

(ProplO) P + C P, P(A, B), P(B,C) hoi P(A, C)

(Propll) C(A), C C 3P.{O} hoi P(A, O)

Let us see an example of an ontology O0 (see Figure 1). The ontology O0 describes meta-data in the TBox defining that the elements of Man and the elements of Woman are elements of Person (cases (1) and (2)); and the elements of Paper and elements of Book are elements of Manuscript (case (4)). In addition, a Writer is a Person who is the author_of a Manuscript (case (3)), and the class Reviewed contains the elements of Manuscript reviewed_by a Person (case (6)). Moreover, the XMLBook class contains the elements of Manuscript which have as topic the value "XML" ((5)). The classes Score and Topic contain, respectively, the values of the properties rating and topic associated to Manuscript (cases (7) and (8)). The property average_rating is a subproperty of rating (case (10)). The property writes is equivalent to author_of (case (9)), and authored_by is the inverse property of author_of (case (11)). Finally, the property author_of, and conversively, reviewed_by, has as domain a Person and as range a Manuscript (cases (12)-(15)).

The ABox describes data about two elements of Book: "Data on the Web" and "XML in Scottland" and a Paper: "Growing XQuery". It describes the author_of and authored_by relationships for the elements of Book and the writes relation for the elements of Paper. In addition, the elements of Book and Paper have been reviewed and rated, and they are described by means of a topic.

2.1 Entailment Relationship

Now, we would like to show an inference calculus, denoted by hOI, which defines the entailment relationship between formulas of the selected fragment. The inference calculus is shown in Table 2. In the rule (Eq1) E is a class name, and D is a class name in rules (Typel) to (Type5). In the rule (Type6) A is an individual name, and in the rule (Prop1) P is a property name. In addition, in the rule (Type6) we have that Cond(E) = E(A) if E is atomic; Cond(E) = P(A, O) if E = 3P.{O}, Cond(E) = P(A, B), C(B) if E = 3P.C. Finally, in the rules (Prop1) to (Prop6), and (Sub12), (Sub13), P and Q can have the form S, S- and S+. The rules from (Eq1) to (Eq4) handle about equivalence. (Eq1) infers equivalence by reflexivity, (Eq2) infers equivalence by transitivity, and (Eq3) infers equivalence by symmetry. (Eq4) infers equivalence from the subclass relationship. The rules from (Sub1) to (Sub13) handle inference about subclasses. Cases from (Sub3) to (Sub7) define new subclass relationships from union and intersection operators. However, the calculus does not introduce new union and intersection operators. For instance C n E C D is not entailed from C C D. The same can be said for C U E C D which is not entailed from C C D and E C D. The same happens with C C D n E from C C D and C C E. Cases from (Sub8)

to (Sub13) define new subclass relationships for complex formulas. Such entailment of complex formulas is the main contribution of our inference calculus with respect to DLP framework and the pD* approach. In the former case, the entailment relationship can only entail formulas about individual and property fillers assertions, and not about complex formulas. In the later case, pD* does not handle owl:someValuesFrom, owl:allValuesFrom and owl:hasValue and therefore such rules have not sense in pD*. However, the pD* handles for instance owl:FunctionalProperty which is not consider in our framework.

The rules (Type1) to (Type7) infer type relationships from subclass and equivalence relationships. The most relevant ones are the cases from (Type2) to (Type5) defining the meaning of complex formulas w.r.t. individuals. Finally, the rules (Prop1) to (Prop11) infer relationships about roles. The most relevant ones are the case (Prop8) and (Prop9) about the inverse of a property and the case (Prop10) about the transitivity relationship. Our inference calculus is able to infer new information from a given ontology. For instance, O0 hOI Reviewed^'Data on the Web"), using the following TBox and ABox information of O0:

Book ("Data on the Web''). Book Q Manuscript. Person ("Anonymous '').

reviewed_by("Data on the Web'','' Anonymous''). Manuscript n 3Reviewed_by.Person Q Reviewed. by means of the following reasoning:

^(Typei) Manuscript^'Data on the Web") ^(Type3) Reviewed(''Data on the Web'')

Our inference calculus can be used for proving a given Description Logic formula of the selected fragment from an ontology of the same fragment. Our inference calculus can be used for inferring all the entailments from a given ontology. The idea is to apply the rules up to a fix point is reached. In addition, we have designed the inference calculus in order to be implemented in logic programming, in particular, in Prolog. It forces to limit the inference capabilities of our system. The inference calculus only handles the user-defined DL complex formulas (i.e. those included in the TBox). For instance, we

cannot infer new relations like C Q VP.D because it requires to check all the relations between individuals for P in the ABox. The same can be said for 3P.C Q D, and P Q Q.

3 A Query Language based on Description Logic

In this section we will define the query language based on Description Logic. Such query language will introduce variables in DL formulas in order to express the values to be retrieved in the query result. In addition, our query language can handle conjunctions of DL formulas. We will use variable names starting with lower-case letters to distinguish them from non-variables.

Assuming a set Vc of variables for concepts c, d,... and a set Vp of variables for roles p, q, ..., and a set Vi of variables for individuals a, b..., a query Q against of an ontology O is a conjunction Q\,...,Qn where each Qi has the form:

Q ::= C Ç D | E = F | R Ç T | R = T | P (A, B) | C0(A)

where C G LV, D G RV, E,F G £V, R,T = P, P-,P+ and P G PV and G I, Co G Vc or is a class name. In addition, £V contains the set of formulas of the form:

c | c G Vc

Co | atomic class

Ei n E2 | Ei,E2 G EV

3P.{O] 1 P G PV, O GIV

CV contains the set of formulas of the form:

c 1 c G Vc

Co | atomic class

Ci n C2 1 Ci,C2 glv

3P.{O] 1 P GPV, O giV

Ci U C2 1 Ci, C2 GLV

3P.C 1 C glv, P gpv

TZV contains the set of formulas of the form:

c | c e Vc

Co | atomic class

Di n D2 | DuD2 eRV

3P.{O] 1 P ePV, O elv

VP.D 1 D eRV, P ePV

and finally, Pv contains property names and elements of Vp, and Iv contains individual names and elements of V¿.

As in the case of the data and meta-data definition language, the query language is restricted to a fragment of DL in order to be encoded in logic programming (i.e. in Prolog). Assuming that variable names start with lower case letters, queries are formulas like:

• type("Growing XQueryv) whose meaning is "Find the type of Growing XQuery'.

• Person(p), Reviewed_by ("Growing XQuery",p), whose meaning is "Retrieve the reviewers of "Growing XQueryand

• Manuscript(m), Reviewed_by(m,"Almendros") whose meaning is "Retrieve the manuscripts in which "Almendros" is a reviewer"

• Author_of (author,'Data on the Webv) whose means is "Retrieve the authors of "Data on the Web"". Let us remark that in this case, subproperties of "Author_of" are taken into account (for instance, "Authored_by" and "Writes").

Let us remark that the previous queries can be answered from the TBox and the ABox of the ontology. Meta-data can be retrieved by means of our query language, however, queries about meta-data can be only answered from the TBox of the ontology. For instance, using union and intersection operators we can retrieve:

• intersection = Book n Reviewed whose meaning is "Find the intersections of Book and Reviewed".

• TC V Writes .range whose meaning is "Find the ranges of Writes".

• TC Vp .Book whose meaning is "Find the properties whose range is Book".

• 3p.Person C Book whose meaning is "Find the properties about Person's in which the range belongs to Book".

• class C 3p.{uXMLv} whose meaning is "Find the classes having a role related to "XML"".

An answer of a query Q w.r.t. an ontology O and vocabulary V is a mapping 0 from DVar(Q) into V such that O hOI 0(Q), where DVar(Q) denotes the set of variables of Q.

Finally, we have to remark that some syntactic sugar can be considered in our query language. For instance VP.C(A) represents a(A), a Q VP.C, and 3P-.{O}(A) represents a Q 3q.{O},q Q P-,a(A).

4 Encoding into Prolog

Now, we would like to show how to use Prolog in our framework. The role of Prolog is double. Firstly, we can encode any given ontology instance of the considered fragment into Prolog. Secondly, our inference system hOI can be encoded into Prolog by means of rules, in such a way that a certain class of Prolog goals, which implement the Description Logic based query language can be used as query language.

4-1 Ontology Instance Encoding

The encoding of an ontology instance consists of Prolog facts of a predicate called triple, representing the RDF-triple based representation of OWL. In the case of the TBox: (a) en (C Q D) = triple (en (C), rdfs : subClassOf ,-en (D)); (b) en (E = F) = triple (en (E), owl : equivalentClass, en (F)); (c) en (P Q Q) = triple (en (P), rdfs : subPropertyOf, en (D)); and (d) en (P = Q) = triple (en (P), owl : equivalent Property, en (Q)). In addition, en (C), en(D), en(E), en(F), en(P) and en(Q) represents the encoding of classes and properties in which class and property names C, P,... are translated as Prolog atoms c, d, — The special case of T is encoded as en(T) = owl : thing. In addition, Prolog terms are used for representing complex DL formulas as follows: (a) en (P+) = trans (en (P)); (b) en (P-) = inv (en (P)); (c) en (VP .C) = forall (en (P), en (C)); (d) en (3P .C) = exists (en (P), en (C)); (e) en (3P .{O }) = hasvalue (en (P), en (O)); (f) en (n^ <n C) = inter ([en (Ci), ..., en (Cn)]) and (h) en (Li <8 <n Ci) = union ([en (Di),..., en (Dn)]). Finally, the elements of the ABox are also encoded as Prolog facts relating pairs of individuals by means of properties, and defining memberships to classes: (a) en (P (A, B)) = triple (A, en (P), B) and (b) en (C0 (A)) = triple (A, rdf : type, Co).

4-2 Encoding of the Inference Calculus hOI

Now, the second element of the encoding consists of Prolog rules for encoding the hOI inference calculus. The set of rules can be found in Tables 3, 4 and 5

Table 3

Encoding of the Inference Calculus I

Rule Name Prolog Rules

(Eq1) triple(E, owl equivalentClass,E) : -class(E).

(Eq2) triple(E, owl equivalentClass, G) : -triple(E, owl : equivalentClass, F),

triple(F, owl : equivalentClass,G).

(Eq3) triple(E, owl equivalentClass,F) : -triple(F, owl : equivalentClass,E).

(Eq4) triple(E, owl equivalentClass,F) : -triple(E, rdfs : subClassOf ,F),

triple(F, rdfs : subClassOf, E).

(Subl) triple(E, rdfs subClassOf, F) : -triple(E, owl : equivalentClass,F).

(Sub2) triple(C, rdfs subClassOf, E) : -triple(C, rdfs : subClassOf ,D),

triple(D, rdfs : subClassOf, E).

(Sub3) triple(D, rdfs subClassOf, E) : -triple(union(U), rdfs : subClassOf, E),member(D, U).

(Sub4) triple(E, rdfs subClassOf, C) : -triple(E, rdfs : subClassOf, inter(I)),member(C, I).

(Sub5) triple(inter(I2), rdfs : subClassOf, D) : -triple(inter(11), rdfs : subClassOf ,D),

member(C, 11),triple(E, rdfs : subClassOf ,C),

replace(I1,C,E,I2).

(Sub6) triple(union(U2), rdfs : subClassOf, D) : -triple(union(U 1), rdfs : subClassOf ,D),

member(C, U1), triple(E, rdfs : subClassOf, C),

replace(U 1,C,E,U2).

(Sub7) triple(C, rdfs subClassOf ,inter(I2)) : -triple(C, rdfs : subClassOf, inter (11)),

member(D, I1), triple(D, rdfs : subClassOf, E),

replace(I1,D,E,I2).

(Sub8) triple(hasvalue(Q,O), rdfs : subClassOf, D) : -triple(Q, owl : subPropertyOf ,P),

triple(hasvalue(P, O), rdfs : subClassOf ,D).

(Sub9) triple(exists(Q, C), rdfs : subClassOf, D) : -triple(Q, owl : subPropertyOf ,P),

triple(exists(P, C), rdfs : subClassOf, D).

(SublO) triple(exists(P, E), rdfs : subClassOf, D) : -triple(E, rdfs : subClassOf ,C),

triple(exists(P, C), rdfs : subClassOf, D).

(Subll) triple(C, rdfs subClassOf, hasvalue(Q, O)) : -triple(P, owl : subPropertyOf ,Q),

triple(C, rdfs : subClassOf, hasvalue(P, O)).

(Sub12) triple(C, rdfs subClassOf, forall(Q, D)) : -triple(Q, owl : subPropertyOf ,P),

triple(C, rdfs : subClassOf, forall(P, D)).

(Sub13) triple(C, rdfs subClassOf, forall(P, E)) : -triple(D, rdfs : subClassOf, E),

triple(C, rdfs : subClassOf, forall(P, D)).

where facts for predicates class, property and individual are defined for each atomic classes, (inverse and transitive) properties and individuals.

Table 4

Encoding of the Inference Calculus II

Rule Name Prolog Rules

(Typel) triple(A, rdf type, D) —triple(C, rdfs : subClassOf ,D), triple(A, rdf : type, C).

(Type2) triple(A, rdf type, D) —triple(inter(E), rdf : type,D), triple cond(A,E).

(Type3) triple(A, rdf type, D) -triple(exists(P, C),rdfs : subClassOf, D), triple (B, rdf : type,C), triple(A, P, B).

(Type4) triple(A, rdf type, D) -triple(hasvalue(P,O),rdfs : subClassOf, D), triple(A, P, O), individual(O).

(Type5) triple(B, rdf type,D) -triple(forall(P, C), rdfs : subClassOf, D), triple(A, P, B),triple(A, rdf : type, C).

(Type6) triple(A, rdf type, D) -triple(forall(inv(P),C),rdfs : subClassOf, D), triple(A, P, B),triple(A, rdf : type, C).

(Type7) triple(A, rdf type, owl thing) : —individual(A).

Table 5

Encoding of the Inference Calculus III

Rule Name Prolog Rules

(Propl) triple(P, owl : equivalentProperty,P) : —property(P).

(Prop2) triple(P, owl : equivalentProperty, R) : —triple(P, owl : equivalentProperty,Q),

triple(Q, owl : equivalentProperty, R).

(Prop3) triple(P, owl : equivalentProperty, Q) : —triple(Q, owl : equivalentProperty,P).

(Prop4) triple(P, owl : equivalentProperty, Q) : —triple(P, rdfs : subPropertyOf, Q),

triple(Q, rdfs : subPropertyOf ,P).

(Prop5) triple(P, rdfs subPropertyOf, Q) : —triple(P, owl : equivalentProperty,Q).

(Prop6) triple(P, rdfs subPropertyOf, R) : —triple(P, rdfs : subPropertyOf ,Q),

triple(Q, rdfs : subPropertyOf, R).

(Prop7) triple(A,Q,B) : —triple(P, rdfs : subPropertyOf, Q), triple(A, P, B).

(Prop8) triple(B, Q, A) : —triple(P, rdfs : subPropertyOf ,inv(Q)),triple(A, P, B).

(Prop9) triple(B,P, A) : —triple(inv(Q), rdfs : subPropertyOf, P),triple(A, Q, B).

(ProplO) triple(A,P, C) : —triple(trans(P), rdfs : subPropertyOf ,P),

triple(A, P, B),triple(B, P, C).

(Propll) triple(A, P, O) : —triple(C, rdfs : subClass, hasvalue(P, O)), triple(A, rdf : type, C).

4-3 Using Prolog as Query Language

In this section, we will show how to use Prolog as query language for OWL. Basically, each query fi = in our query language can be encoded as

a Prolog goal ? — triple (en (ipt)),..., triple (en (ipn)) in which each element of Vc, Vp and Vi is encoded as a Prolog Variable. Now, we will show examples of queries against the ontology O0 and the corresponding answers. Let us remark

that in Prolog variables start with upper case letters.

Query 1: The first query we like to show is "Retrieve the authors of manuscripts", which can be expressed in our query language as Author_of(a,b), Manuscript(b). It can be encoded as:

? — triple (A, author _of, B),triple(B, rdf : type, manuscript).

Let us remark that our inference system is able to infer that a Paper and a Book is a Manuscript and therefore the above query retrieves all the manuscripts of the ontology O0. In addition, our inference system is able to infer that author_of is a equivalent property to writes, and the inverse of authored_by, and therefore all the cases are retrieved by the query language. In this case, the answers will be "Abiteboul", "Buneman", "Suciu", "Simeon", "Buneman" , together with names of manuscripts.

Query 2: The second query we would like to show is "Retrieve the books of topic XML" which can be expressed as Book(book) ,topic(book, "XML"). Now, it can be expressed as:

? — triple (Book, rdf : type, book ),triple(Book, topic, "XML").

However, given that the ontology already includes the class "XMLBook' we can express the same query in a more concise way as XMLBook (book) and therefore as:

? — triple (Book, rdf : type, xmlbook)

Query 3: The third query we would like to show is "Retrieve the writers of reviewed manuscripts". It can be expressed as Reviewed(manuscript),Writes(au-thor, manuscript). In this case, the query can be expressed as:

? — triple (Manuscript, rdf : type, reviewed ),triple( Author, writes, Manuscript).

Query 5: Let us see an example of query for retrieving meta-data from the ontology. For instance range C ^Reviewed_by.domain whose meaning is "Find the domain and range of Reviewed_by" is encoded as:

? — triple (Range, rdfs : subClassOf, f orall(reviewed_by, Domain)).

In this case the answers will be Manuscript, Book, Paper for Domain and Man, Woman, Person for Range.

20 J.M. Almendros-Jiménez /Electronic Notes in Theoretical Computer Science 271 (2011) 3—22

5 Conclusions and Future Work

In this paper we have proposed a query language for OWL based on Prolog. The query language is able to query about data and meta-data of a given ontology. As future work, we would like to extend our approach to richer fragments of DL and OWL.

In this line, the W3C has recently proposed a set of entailment rules for OWL, the so-called OWL RL [24]. Such set of rules subsumes our proposed entailment relationship and the pD* approach. Therefore, our approach can be seen as a contribution to the OWL RL framework, providing an implementation by means of Prolog rules. We believe that our approach can be extended to OWL RL following the same technique here presented.

In addition, we would like to extend our work in the line of the SWRL [21] by incorporating Prolog rules to the reasoning with OWL, and therefore for enriching the defined query language.

References

[1] J. M. Almendros-Jiménez, A. Becerra-Terón, and Francisco J. Enciso-Baños. Magic sets for the XPath language. Journal of Universal Computer Science, 12(11):1651-1678, 2006.

[2] J. M. Almendros-Jiménez, A. Becerra-Terón, and Francisco J. Enciso-Baños. Querying XML documents in logic programming. Theory and Practice of Logic Programming, 8(3):323-361, 2008.

[3] J. M. Almendros-Jiménez, A. Becerra-Terón, and F. J. Enciso-Baños. Integrating XQuery and Logic Programming. In Proceedings of the 17th International Conference on Aplications of Declarative Programming and Knowledge Management, INAP'07 and 21th Workshop on (Constraint) Logic Programming, WLP'07, pages 117-135, Heidelberg, Germany, 2009. Springer LNAI, 5437.

[4] J. M. Almendros-Jiménez. An RDF Query Language based on Logic Programming. In Proceedings of the 3rd Int'l Workshop on Automated Specification and Verification of Web Systems. Electronic Notes on Theoretical Computer Science (200), 67-85, 2008.

[5] J. M. Almendros-Jiménez. An Encoding of XQuery in Prolog. In Procs of the Sixth International XML Database Symposium XSym'09, at VLDB'09, pages 145-155, Heidelberg, Germany, 2009. Springer, LNCS 5679.

[6] J. M. Almendros-Jiménez. Extending XQuery for Semantic Web Reasoning. In Procs of the International Conference on Applications of Declarative Programming and Knowledge Management, INAP'09, pages 109-124, 2009.

[7] J. M. Almendros-Jiménez. Ontology Querying and Reasoning with XQuery. In Proceedings of the PLAN-X 2009: Programming Language Techniques for XML, An ACM SIGPLAN Workshop co-located with POPL 2009. http://db.ucsd.edu/planx2009/papers.html, 2009.

[8] F. Baader, D. Calvanese, D.L. McGuinness, P. Patel-Schneider, and D. Nardi. The description logic handbook: theory, implementation, and applications. Cambridge Univ Press, 2003.

[9] Erol Bozsak, Marc Ehrig, Siegfried Handschuh, Andreas Hotho, Alexander Maedche, Boris Motik, et al. KAON - Towards a Large Scale Semantic Web. In E-commerce and Web technologies: Third International Conference, EC-Web 2002, pages 304-313. Springer, 2002.

Dan Brickley and R.V. Guha. RDF Vocabulary Description Language 1.0: RDF Schema. Technical report, http://www.w3.org/TR/rdf-schema/, 2004.

T. Berners-Lee, J. Hendler, O. Lassila, et al. The semantic web. Scientific american, 284(5):28-37, 2001.

Jos de Bruijn, Rubén Lara, Axel Polleres, and Dieter Fensel. OWL DL vs. OWL flight: conceptual modeling and reasoning for the semantic Web. In WWW '05: Proceedings of the 14-th international conference on World Wide Web, pages 623-632, New York, NY, USA, 2005. ACM.

T. Eiter, G. Ianni, T. Krennwallner, and A. Polleres. Rules and ontologies for the semantic web. In Reasoning Web, pages 1-53. Springer, LNCS 5224, 2008.

Benjamin N. Grosof, Ian Horrocks, Raphael Volz, and Stefan Decker. Description Logic Programs: Combining Logic Programs with Description Logic. In Proc. of the International Conference on Word Wide Web, pages 48-57, NY, USA, 2003. ACM Press.

E. Gradel, P.G. Kolaitis, and M.Y. Vardi. On the decision problem for two-variable first-order logic. Bulletin of Symbolic Logic, 3(1):53-69, 1997.

W3C Working Group. OWL 2 Ontology Web Language. Technical report, http://www.w3. org/TR/owl2-overview/, 2009.

A. Hogan, A. Harth, and A. Polleres. SAOR: Authoritative Reasoning for the Web. In Proceedings of the 3rd Asian Semantic Web Conference on The Semantic Web, pages 76-90. Springer-Verlag, 2008.

Ullrich Hustadt, Boris Motik, and Ulrike Sattler. Reasoning in Description Logics by a Reduction to Disjunctive Datalog. J. Autom. Reasoning, 39(3):351-384, 2007.

U. Hustadt, B. Motik, and U. Sattler. Deciding expressive description logics in the framework of resolution. Information and Computation, 206(5):579-601, 2008.

V. Haarslev, R. Moller, and S. Wandelt. The revival of structural subsumption in tableau-based description logic reasoners. In Proceedings of the 2008 International Workshop on Description Logics (DL2008), CEUR-WS, pages 701-706, 2008.

Ian Horrocks, Peter F. Patel-Schneider, Harold Boley, Said Tabet, Benjamin Grosof, and Mike Dean. SWRL: A Semantic Web Rule Language Combining OWL and RuleML. W3C Member Submission, 21 May 2004. Available at http://www.w3.org/Submission/SWRL/.

Graham Klyne and Jeremy J. Carroll. Resource Description Framework (RDF): Concepts and Abstract Syntax. Technical report, http://www.w3.org/TR/2004/ REC-rdf-concepts-20040210/, 2004.

G. Lukacsy, P. Szeredi, and B. Kadar. Prolog based description logic reasoning. In Proceedings of the 24th International Conference on Logic Programming (ICLP'08), pages 455469, Heidelberg,Germany, 2008. Springer, LNCS 5366.

Boris Motik, Bernardo Cuenca Grau, Ian Horrocks, Zhe Wu, Achille Fokoue, and Carsten Lutz. OWL 2 Web Ontology: Reasoning in OWL 2 RL and RDF Graphs using Rules. Technical report, http://www.w3.org/TR/owl2-profiles/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_ using_Rules, 2009.

S. Munoz, J. Pérez, and C. Gutierrez. Minimal deductive systems for RDF. In Proceedings of the 4th European conference on The Semantic Web: Research and Applications, page 53, Heidelberg, Germany, 2007. Springer, LNCS 4519.

Boris Motik, Peter F. Patel-Schneider, and Bernardo Cuenca Grau. OWL 2 Web Ontology Language Direct Semantics. Technical report, http://www.w3.org/TR/ owl2-direct-semantics/, 2009.

27] Michael Schneider. OWL 2 Web Ontology Language RDF-Based Semantics. Technical report, http://www.w3.org/TR/owl2-rdf-based-semantics/, 2009.

[28] Evren Sirin, Bijan Parsia, Bernardo C. Grau, Aditya Kalyanpur, and Yarden Katz. Pellet: A practical OWL-DL reasoner. Web Semantics: Science, Services and Agents on the World Wide Web, 5(2):51-53, June 2007.

[29] Herman J. ter Horst. Extending the rdfs entailment lemma. In International Semantic Web Conference, pages 77-91. Springer, LNCS 3298, 2004.

[30] D. Tsarkov and I. Horrocks. FaCT+—+ Description Logic Reasoner: System Description. In Proc. of the Int. Joint Conf. on Automated Reasoning (IJCAR 2006), pages 292-297. Springer, LNAI 4130, 2006.

[31] Raphael Volz. Web Ontology Reasoning with Logic Databases. PhD thesis, Universität Fridericiana zu Karlsruhe, 2004.

[32] J. Wielemaker, G. Schreiber, and B. J. Wielinga. Prolog-Based Infrastructure for RDF: Scalability and Performance. In International Semantic Web Conference, pages 644-658. Springer, LNCS 2870, 2003.