I am intrigued by Using Property Chains to get inferred Knowledge in an OWL Ontology(Protege)
The accepted answer has two solutions: two OWL expressions, or a SWRL rule. I get the sense that the OP found the all-OWL (property chain) solution confusing but was satisfied with the SWRL answer.
I am trying to implement the all-OWL solution. So far, I don't see an inference that Steven_Gerrard is employed by England when reasoning with Pellet.
I do see the inference
Steven_Gerrard R_NationalPlayer Steven_Gerrard
Is that an error?
Should I use a different reasoner? The OP got an error from FaCT++.
Is my substitution of some for values breaking the reasoning?
The answerer suggested a General Class Axiom of
hasNationalStatus value National_Player EquivalentTo R_NationalPlayer some Self
but Protege compalined about my use of vlaue. It does accept the following:
hasNationalStatus some ({National_Player}) EquivalentTo R_NationalPlayer some Self
Have I made some mistake in modelling Club, Country and Nationality?
My implementation:
#prefix : <http://example.com/> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<http://example.com/playerEmployment.owl> rdf:type owl:Ontology .
<http://example.com/R_NationalPlayer> rdf:type owl:ObjectProperty .
<http://example.com/employs> rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf owl:topObjectProperty ;
owl:propertyChainAxiom ( [ owl:inverseOf <http://example.com/hasNationality>
]
<http://example.com/R_NationalPlayer>
) .
<http://example.com/hasNationalStatus> rdf:type owl:ObjectProperty .
<http://example.com/hasNationality> rdf:type owl:ObjectProperty .
<http://example.com/Club> rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Restriction ;
owl:onProperty <http://example.com/employs> ;
owl:someValuesFrom <http://example.com/Player>
] .
<http://example.com/NationalStatus> rdf:type owl:Class .
<http://example.com/Nationality> rdf:type owl:Class .
<http://example.com/Player> rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Restriction ;
owl:onProperty <http://example.com/hasNationalStatus> ;
owl:someValuesFrom <http://example.com/NationalStatus>
] ,
[ rdf:type owl:Restriction ;
owl:onProperty <http://example.com/hasNationality> ;
owl:someValuesFrom <http://example.com/Nationality>
] .
<http://example.com/England> rdf:type owl:NamedIndividual ,
<http://example.com/Club> ,
<http://example.com/Nationality> .
<http://example.com/National_Player> rdf:type owl:NamedIndividual ,
<http://example.com/NationalStatus> .
<http://example.com/Steven_Gerrard> rdf:type owl:NamedIndividual ,
<http://example.com/Player> ;
<http://example.com/hasNationalStatus> <http://example.com/National_Player> ;
<http://example.com/hasNationality> <http://example.com/England> .
[ rdf:type owl:Restriction ;
owl:onProperty <http://example.com/hasNationalStatus> ;
owl:someValuesFrom [ rdf:type owl:Class ;
owl:oneOf ( <http://example.com/National_Player>
)
] ;
owl:equivalentClass [ rdf:type owl:Restriction ;
owl:onProperty <http://example.com/R_NationalPlayer> ;
owl:hasSelf "true"^^xsd:boolean
]
] .
Ugh. Pellet can make the desired inference from the ontology included in my question.
I was looking on Steven's Individual page. I should have been looking on England's individual page.
Related
Here is my example.owl:
#prefix : <#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#base <http://ex.org> .
<http://ex.org> rdf:type owl:Ontology .
:hasChild rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf :hasDescendant .
:hasDaughter rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf :hasChild ;
owl:propertyDisjointWith :hasSon .
:hasDescendant rdf:type owl:ObjectProperty .
:hasSon rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf :hasChild .
:Person rdf:type owl:Class .
:Bob rdf:type owl:NamedIndividual , :Person ;
:hasDaughter :Mary ;
:hasSon :John .
:LittleBoy rdf:type owl:NamedIndividual , :Person .
:LittleGirl rdf:type owl:NamedIndividual , :Person .
:John rdf:type owl:NamedIndividual , :Person ;
:hasSon :LittleBoy .
:Mary rdf:type owl:NamedIndividual , :Person ;
:hasDaughter :LittleGirl .
I want to get all of a Bob's descendants or Bob's child by a Sparql query,
How do I write this SPARQL statement?
Thanks for help.
My question is about using SPARQL to query some owl ontology where owl:Restrictions are heavily used (in my case this is the "Cell Ontology").
Here is an example of some typical entry (in Turtle format, extracted from the above mentioned ontology):
### http://purl.obolibrary.org/obo/CL_0000792
obo:CL_0000792 rdf:type owl:Class ;
owl:equivalentClass [ owl:intersectionOf ( obo:CL_0000624
[ rdf:type owl:Restriction ;
owl:onProperty obo:RO_0002104 ;
owl:someValuesFrom obo:PR_000001380
]
[ rdf:type owl:Restriction ;
owl:onProperty obo:RO_0002215 ;
owl:someValuesFrom obo:GO_0050777
]
[ rdf:type owl:Restriction ;
owl:onProperty <http://purl.obolibrary.org/obo/cl#has_low_plasma_membrane_amount> ;
owl:someValuesFrom obo:PR_000001869
]
) ;
rdf:type owl:Class
] ;
rdfs:subClassOf obo:CL_0000624 ,
obo:CL_0000815 ,
[ rdf:type owl:Restriction ;
owl:onProperty obo:RO_0002104 ;
owl:someValuesFrom obo:PR_000001380
] ,
[ rdf:type owl:Restriction ;
owl:onProperty obo:RO_0002215 ;
owl:someValuesFrom obo:GO_0050777
] ,
[ rdf:type owl:Restriction ;
owl:onProperty <http://purl.obolibrary.org/obo/cl#has_low_plasma_membrane_amount> ;
owl:someValuesFrom obo:PR_000001869
] .
Here my ultimate goal is to transfer the owl equivalent properties to subClassOf properties:
CL_0000792 rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty obo:RO_0002104 ;
owl:someValueFrom obo:PR_000001380
] ;
rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty obo:cl#has_low_plasma_membrane_amount ;
owl:someValueFrom obo:PR_000001869
] .
What I do not achieve is to obtain all three properties from the rdfs:subclass part and then bind them properly to the subClassOf sorts of properties (then filtering out the obo:RO_0002215 would be easy).
EDIT: As I made some progress here a new SPARQL Query
EDIT2: following Damyan Ognyanov's answer updated the SPARQL query part which was ignoring the collection within the owl:intersectionOf part and which also more compact/elegant
Here my current SPARQL query:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX tpo: <http://www.definiens.com/ontologies/TissuePhenomicsOntology>
PREFIX cl: <http://purl.obolibrary.org/obo/cl.owl>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX efo: <http://www.ebi.ac.uk/efo/efo.owl>
CONSTRUCT {
?cell rdfs:subClassOf [ rdf:type owl:Restriction ;
owl:onProperty ?cellProp ;
owl:someValuesFrom ?cellPropValue
] .
?cellProp ?cellPropProp ?cellPropObj .
?cellPropValue ?cellPropValueProp ?cellPropValuePropValue .
?cell ?cellProp2 ?cellProp2Obj .
}
FROM named cl:
FROM named tpo:
WHERE {
# query cl to get our information
graph cl:
{
?cell (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first)) ?x .
?x owl:onProperty ?cellProp ;
owl:someValuesFrom ?cellPropValue .
?cellProp ?cellPropProp ?cellPropObj .
?cellPropValue ?cellPropValueProp ?cellPropValuePropValue .
?cell ?cellProp2 ?cellProp2Obj .
}
# limit ?cell to the entries already present in TPO
graph tpo:
{
?cell rdfs:subClassOf* obo:CL_0000000 .
}
}
If you replace the CONSTRUCT part with a SELECT * then it appears that all variables are correctly assigned, the information is there.
What I am still missing though is a proper CONSTRUCT part to reconstruct the "somewhat convoluted" owl:Property restriction. As such this query mostly returns a long list of blank nodes, which won't be parsed properly by Protege for instance.
#AKSW also rightly pointed out that SPARQL may not be the tool of choice to query and construct OWL graphs. It indeed appears clearly here that one needs to know the precise data structure in order to build a working query, in this manner at least.
?cell (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first)) ?x .
?x owl:onProperty ?cellProp ;
owl:someValuesFrom ?cellPropValue .
?cellProp ?cellPropProp ?cellPropObj .
?cellPropValue ?cellPropValueProp ?cellPropValuePropValue .
?cell ?cellProp2 ?cellProp2Obj .
The value of owl:intersectionOf is an RDF list and the above Turtle snippet uses the RDF list syntax to enumerate the members of the owl:intersectionOf collection (e.g., entries are enclosed between ( and )).
So, you should also include rdf:rest*/rdf:first properties in your property paths, since these are used to construct the collection.
For the query, I'll introduce an additional variable where to bind the restriction of interest and use it to fetch the values of owl:onProperty and owl:someValuesFrom, e.g., your WHERE clause may look something like:
?cell (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first)) ?x .
?x owl:onProperty ?cellProp ;
owl:someValuesFrom ?cellPropValue .
?cellProp ?cellPropProp ?cellPropObj .
?cellPropValue ?cellPropValueProp ?cellPropValuePropValue .
?cell ?cellProp2 ?cellProp2Obj .
I want to get all the pizza names which has cheese toppings but the result shows (_:b0) which is kind of an owl restriction following is my query
PREFIX pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT ?X WHERE {
?X rdfs:subClassOf* [
owl:onProperty pizza:hasTopping ;
owl:someValuesFrom pizza:CheeseTopping
]
}
using Pizza ontology from stanford
This works (Without reasoning enabled)
PREFIX pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT ?X ?topping WHERE {
?X rdfs:subClassOf ?Y .
?Y owl:someValuesFrom ?topping .
?topping rdfs:subClassOf* pizza:CheeseTopping
}
ORDER BY ?X
Some are listed more than once as they could contain more than one CheeseTopping. To remove duplicates:
PREFIX pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT DISTINCT ?X WHERE {
?X rdfs:subClassOf ?Y .
?Y owl:someValuesFrom ?topping .
?topping rdfs:subClassOf* pizza:CheeseTopping
}
ORDER BY ?X
This works if you enable a reasoner:
PREFIX pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT DISTINCT ?X WHERE {
?X rdfs:subClassOf pizza:CheeseyPizza
}
Ref:
Used the pizza ontology from here: http://protege.stanford.edu/ontologies/pizza/pizza.owl
That query works but is really complex and might be incomplete because some pizzas use complex OWL constructs:
PREFIX pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
SELECT DISTINCT ?pizza WHERE {
{
?pizza rdfs:subClassOf* pizza:Pizza .
?pizza owl:equivalentClass|rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty pizza:hasTopping ;
owl:someValuesFrom/rdfs:subClassOf* pizza:CheeseTopping
]
} UNION {
?pizza owl:equivalentClass _:b0 .
_:b0 rdf:type owl:Class ;
owl:intersectionOf _:b1 .
_:b1 (rdf:rest)*/rdf:first ?otherClass.
?otherClass rdf:type owl:Restriction ;
owl:onProperty pizza:hasTopping ;
owl:someValuesFrom/rdfs:subClassOf* pizza:CheeseTopping
}
}
I am studying the inference in OWL, currently the restriction in domain definition:
#prefix : <http://www.test.org/2015/4/ontology#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#base <http://www.test.org/2015/4/ontology> .
<http://www.test.org/2015/4/ontology> rdf:type owl:Ontology .
:Class1 rdf:type owl:Class .
:Prop1 rdf:type owl:DatatypeProperty ;
rdfs:domain [ rdf:type owl:Class ;
owl:intersectionOf ( :Class1
[ rdf:type owl:Restriction ;
owl:onProperty :Prop1 ;
owl:hasValue "class1"
]
)
] .
:Ind1 rdf:type owl:NamedIndividual ;
:Prop1 "p" .
I've expected that the reasoner (Pellet) infers
:Ind1 rdf:type :Class1
only if there is
:Ind1 :Prop1 "class1"
but it seems to ignore the restriction in the domain definition.
Is it correct to define restrictions in damain definitions? The reasoner (Pellet) does not forbid me to do that.
I'm trying to learn to update data in Fuseki, but when I try I get a 404 error. I am clearly not doing something right. Perhaps it is my INSERT command? I've tried a ton of them though.
I am using the web based SPARQL interface at /sparql.tpl.
I can get SPARQL Queries to work on that same page just fine. But the second form, labeled SPARQL Updates is what I'm using for my update, and that gives me errors:
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX booklet: <http://www.semanticweb.org/cstepnitz/ontologies/booklet>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ontology: <http://dbpedia.org/ontology/>
INSERT DATA
{ <http://dbpedia.org/resource/Johnny_Got_His_Gun>
rdf:type ontology:Book
}
This is the error I get when the form posts to the url localhost:3030/bookfinder/update:
Error 404: Not Found
Fuseki - version 1.0.1 (Build date: 2014-01-18T19:01:20+0000)
This is my TTL file.
#prefix : <http://www.semanticweb.org/cstepnitz/ontologies/bookreader#> .
#prefix bibo: <http://purl.org/ontology/bibo/> .
#prefix booklet: <http://www.semanticweb.org/cstepnitz/ontologies/booklet> .
#prefix dbp: <http://dbpedia.org/ontology/> .
#prefix dbpedia: <http://dbpedia.org/ontology/> .
#prefix dbpedia-owl: <http://dbpedia.org/ontology/> .
#prefix NS5: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix rdms: <http://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systems> .
#prefix owlapi: <http://www.semanticweb.org/owlapi#> .
#prefix schema: <http://schema.org/> .
#base <http://www.semanticweb.org/cstepnitz/ontologies/bookreader> .
<http://www.semanticweb.org/cstepnitz/ontologies/bookreader> NS5:type owl:Ontology ;
owl:imports dbp: .
booklet:readbook NS5:type owl:ObjectProperty ;
rdfs:range dbpedia-owl:Book ;
rdfs:domain booklet:Reading ;
rdfs:subPropertyOf owl:topObjectProperty .
booklet:reading NS5:type owl:ObjectProperty ;
rdfs:domain booklet:Bookreader ;
rdfs:range booklet:Reading .
:OWLObjectProperty_18e83c77_09cb_4d9b_90c6_93b2a5095d78 NS5:type owl:ObjectProperty ;
rdfs:label "recommendedBooks"#en ;
rdfs:range dbpedia-owl:Book ;
rdfs:domain booklet:Bookreader .
:OWLObjectProperty_86497b97_bef7_4b9e_80bc_6080ce0cbfe3 NS5:type owl:ObjectProperty ;
rdfs:label "bookrating"#en ;
rdfs:range booklet:Bookrating ;
rdfs:domain booklet:Reading ;
rdfs:subPropertyOf owl:topObjectProperty .
dbpedia-owl:Book NS5:type owl:Class .
schema:Person NS5:type owl:Class .
booklet:Bookrating NS5:type owl:Class .
booklet:Bookreader NS5:type owl:Class ;
rdfs:subClassOf schema:Person .
booklet:Reading NS5:type owl:Class .
:OWLClass_38c67bca_82ba_44b7_85dd_31d0c2883702 NS5:type owl:Class ;
rdfs:label "Poor"#en ;
rdfs:subClassOf booklet:Bookrating .
:OWLClass_5630d470_6dda_4cd5_9596_ddf0eab29cde NS5:type owl:Class ;
rdfs:label "Best"#en ;
rdfs:subClassOf booklet:Bookrating .
:OWLClass_694d8a9e_5fba_45a2_81b3_f47f1a21af4d NS5:type owl:Class ;
rdfs:label "Average"#en ;
rdfs:subClassOf booklet:Bookrating .
:OWLClass_dfb73eb5_8a7c_4628_a423_72056e7ee81f NS5:type owl:Class ;
rdfs:label "Good"#en ;
rdfs:subClassOf booklet:Bookrating .
:OWLClass_f3923184_fbb7_48ec_954e_49e233454099 NS5:type owl:Class ;
rdfs:label "Awful"#en ;
rdfs:subClassOf booklet:Bookrating .
Any guesses?
As explained in the comments on my question, the problem was the "--update" flag needed to be added at startup. See http://jena.apache.org/documentation/serving_data/