diff --git a/data/rdfs.rules b/data/rdfs.rules new file mode 100644 index 0000000..be5a1cf --- /dev/null +++ b/data/rdfs.rules @@ -0,0 +1,67 @@ +#------------------------------------------------------------------ +# RDFS rule set v0.1. +# This is a direct implementation of the RDFS closure rules. +# $Id: $ +#------------------------------------------------------------------ + +#------------------------------------------------------------------ +# RDFS Axioms +#------------------------------------------------------------------ + +-> (rdf:type rdfs:range rdfs:Class). +-> (rdfs:Resource rdf:type rdfs:Class). +-> (rdfs:Literal rdf:type rdfs:Class). +-> (rdf:Statement rdf:type rdfs:Class). +-> (rdf:nil rdf:type rdf:List). +-> (rdf:subject rdf:type rdf:Property). +-> (rdf:object rdf:type rdf:Property). +-> (rdf:predicate rdf:type rdf:Property). +-> (rdf:first rdf:type rdf:Property). +-> (rdf:rest rdf:type rdf:Property). + +-> (rdfs:subPropertyOf rdfs:domain rdf:Property). +-> (rdfs:subClassOf rdfs:domain rdfs:Class). +-> (rdfs:domain rdfs:domain rdf:Property). +-> (rdfs:range rdfs:domain rdf:Property). +-> (rdf:subject rdfs:domain rdf:Statement). +-> (rdf:predicate rdfs:domain rdf:Statement). +-> (rdf:object rdfs:domain rdf:Statement). +-> (rdf:first rdfs:domain rdf:List). +-> (rdf:rest rdfs:domain rdf:List). + +-> (rdfs:subPropertyOf rdfs:range rdf:Property). +-> (rdfs:subClassOf rdfs:range rdfs:Class). +-> (rdfs:domain rdfs:range rdfs:Class). +-> (rdfs:range rdfs:range rdfs:Class). +-> (rdf:type rdfs:range rdfs:Class). +-> (rdfs:comment rdfs:range rdfs:Literal). +-> (rdfs:label rdfs:range rdfs:Literal). +-> (rdf:rest rdfs:range rdf:List). + +-> (rdf:Alt rdfs:subClassOf rdfs:Container). +-> (rdf:Bag rdfs:subClassOf rdfs:Container). +-> (rdf:Seq rdfs:subClassOf rdfs:Container). +-> (rdfs:ContainerMembershipProperty rdfs:subClassOf rdf:Property). + +-> (rdfs:isDefinedBy rdfs:subPropertyOf rdfs:seeAlso). + +-> (rdf:XMLLiteral rdf:type rdfs:Datatype). +-> (rdfs:Datatype rdfs:subClassOf rdfs:Class). + +#------------------------------------------------------------------ +# RDFS Closure rules +#------------------------------------------------------------------ + +# This one could be omitted since the results are not really very interesting! +[rdf1and4: (?x ?p ?y) -> (?p rdf:type rdf:Property), (?x rdf:type rdfs:Resource), (?y rdf:type rdfs:Resource)] +[rdfs7b: (?a rdf:type rdfs:Class) -> (?a rdfs:subClassOf rdfs:Resource)] + +[rdfs2: (?x ?p ?y), (?p rdfs:domain ?c) -> (?x rdf:type ?c)] +[rdfs3: (?x ?p ?y), (?p rdfs:range ?c) -> (?y rdf:type ?c)] +[rdfs5a: (?a rdfs:subPropertyOf ?b), (?b rdfs:subPropertyOf ?c) -> (?a rdfs:subPropertyOf ?c)] +[rdfs5b: (?a rdf:type rdf:Property) -> (?a rdfs:subPropertyOf ?a)] +[rdfs6: (?a ?p ?b), (?p rdfs:subPropertyOf ?q) -> (?a ?q ?b)] +[rdfs7: (?a rdf:type rdfs:Class) -> (?a rdfs:subClassOf ?a)] +[rdfs8: (?a rdfs:subClassOf ?b), (?b rdfs:subClassOf ?c) -> (?a rdfs:subClassOf ?c)] +[rdfs9: (?x rdfs:subClassOf ?y), (?a rdf:type ?x) -> (?a rdf:type ?y)] +[rdfs10: (?x rdf:type rdfs:ContainerMembershipProperty) -> (?x rdfs:subPropertyOf rdfs:member)] diff --git a/src/main/java/lu/jpt/csparqltest/Main.java b/src/main/java/lu/jpt/csparqltest/Main.java index 7198265..b7abd1f 100644 --- a/src/main/java/lu/jpt/csparqltest/Main.java +++ b/src/main/java/lu/jpt/csparqltest/Main.java @@ -47,6 +47,10 @@ public class Main { + "{ GRAPH { :room :isConnectedTo :room2 } }"; engine.execUpdateQueryOverDatasource(updateQuery); */ + + // Enable reasoning with rdfs rules from file and a tbox rdf file. + //engine.updateReasoner(c.getSparqlQueryId(), CsparqlUtils.fileToString("examples_files/rdfs.rules"), ReasonerChainingType.FORWARD, CsparqlUtils.serializeRDFFile("examples_files/tbox.rdf")); + // Debugging: Needed to verify which engine is being used //logger.debug("CWD: " + System.getProperty("user.dir"));