Creating inferred relation with multiple restrictions in OWL - owl

I have the following Turtle syntax file (see end of question), and I would like to be able to infer :hasSibling, but only full siblings, not half. i.e. I only want those children that share the same mother and father.
I have reviewed How to infer isBrotherOf property between two individuals, which solves half of the problem. The following SPARQL query:
PREFIX : <http://example.com/Test#>
SELECT DISTINCT *
WHERE {
?child :isSiblingOf ?sibling .
FILTER ( ?child = :jennySmith )
}
returns:
:jimJones - half-sibling, don't want
:joeSmith
:jennySmith - self, not ideal, but I can live with it
I've tried to use owl:intersectionOf and provide 2 sets, one using :hasFather in an owl:propertyChainAxiom and the other using :hasMother but that intersection is empty (it's possible -- likely -- I've got the syntax wrong, or that the 2 property chains are in fact returning different "things" -- I don't have a strong grasp of OWL yet):
:x1
a owl:Restriction ;
owl:intersectionOf (
[
owl:propertyChainAxiom(
:hasFather
:isParentOf
) ] [
owl:propertyChainAxiom(
:hasMother
:isParentOf
)
]
)
.
Another possibility is that such a thing is just not possible with OWL.
I have the repository in GraphDB set up with OWL2-RL. Please ignore that there are existing ontologies to define family trees, and that OWL might not be the best way to represent them. My goal is not to create a family tree, but to learn OWL restrictions and inferences. This was the MVCE I came up with to illustrate my problem.
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix owl2: <http://www.w3.org/2006/12/owl2#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix xml: <http://www.w3.org/XML/1998/namespace> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix : <http://example.com/Test#> .
<file:test.ttl>
a owl:Ontology ;
.
:Person
a owl:Class ;
rdfs:subClassOf owl:Thing ;
.
:hasGender
a owl:ObjectProperty ;
rdfs:domain :Person ;
.
:Man
a owl:Class ;
rdfs:subClassOf :Person ;
owl:equivalentClass [
a owl:Restriction ;
owl:onProperty :hasGender ;
owl:hasValue :male ;
]
.
:Woman
a owl:Class ;
rdfs:subClassOf :Person ;
owl:equivalentClass [
a owl:Restriction ;
owl:onProperty :hasGender ;
owl:hasValue :female ;
]
.
:Parent
a owl:Restriction ;
rdfs:subClassOf :Person ;
owl:onProperty :isParentOf ;
owl:someValuesFrom :Person ;
.
:Child
a owl:Restriction ;
rdfs:subClassOf :Person ;
owl:onProperty :hasParent ;
owl:someValuesFrom :Person ;
.
:Father
a owl:Class ;
rdfs:subClassOf :Parent ;
owl:equivalentClass [
a owl:Restriction ;
owl:intersectionOf ( :Parent :Man ) ;
] ;
.
:Mother
a owl:Class ;
rdfs:subClassOf :Parent ;
owl:equivalentClass [
a owl:Restriction ;
owl:intersectionOf ( :Parent :Woman ) ;
] ;
owl2:disjointObjectProperties :Father ;
.
:hasFather
owl:inverseOf :isFatherOf ;
.
:hasMother
owl:inverseOf :isMotherOf ;
.
:hasParent
a owl:ObjectProperty ;
.
:isMotherOf
a owl:ObjectProperty ;
rdfs:domain :Woman ;
rdfs:range: :Child ;
rdfs:subPropertyOf :isParentOf ;
.
:isFatherOf
a owl:ObjectProperty ;
rdfs:domain :Man ;
rdfs:range: :Child ;
rdfs:subPropertyOf :isParentOf ;
.
:isParentOf
a owl:ObjectProperty ;
rdfs:domain :Person ;
rdfs:range :Person ;
owl:inverseOf :hasParent ;
.
:isSiblingOf
a owl:ObjectProperty ;
owl:propertyChainAxiom(
:hasParent
:isParentOf
)
.
:janeSmith
a :Person ;
:hasGender :female ;
:isMotherOf :jimJones ;
:isMotherOf :joeSmith ;
:isMotherOf :jennySmith ;
.
:johnSmith
a :Person ;
:hasGender :male ;
:isFatherOf :joeSmith ;
:isFatherOf :jennySmith ;
.
:tomJones
a :Person ;
:hasGender :male ;
:isFatherOf :jimJones ;
.
:jimJones
a :Person ;
:hasGender :male ;
.
:joeSmith
a :Person ;
:hasGender :male ;
.
:jennySmith
a :Person ;
:hasGender :female ;
:isMotherOf :harrySmith ;
.
:harrySmith
a :Person ;
:hasGender :male ;
.

You can define :isFullSiblingOf with a custom rule like this. Read about Constraints and Cut at http://graphdb.ontotext.com/documentation/enterprise/reasoning.html
id: isFullSiblingOf
x <:hasFather> f
x <:hasMother> m
y <:hasFather> f [Constraint x != y] [Cut]
y <:hasMother> m
----------------
x <:isSiblingOf> y
PS1: I assume you already have inverse reasoning. The best is to pick the axioms you need, then add your own: eg you don't have to include all RL axioms if you don't need them. See more advice: http://graphdb.ontotext.com/documentation/standard/rules-optimisations.html
PS2: You should also declare isFullSiblingOf as owl:SymmetricProperty. BTW I would use hasFullSibling since the inverse name is harder to grasp
PS3: owl2:disjointObjectProperties :Father above is a mistake, you can't use that on classes.
PS4: <file:test.ttl> uses a relative URL without base, which is not very good.

Related

Protege Incremental inference and complementOf

Please I have two questions ;
Q1: I have implemented the ChildlessPerson class in Protege 5.5.0 and defined an individual of type person with no haschild property. I tried with Hermet, Pellet, ontop, none derives that the individual is a ChildlessPerson.
:ChildlessPerson rdf:type OWL:Class ;
rdfs:subClassOf [ rdf:type OWL:Class ; OWL:intersectionOf ( :Person
[ rdf:type OWL:Class ;
OWL:complementOf [ rdf:type OWL:Restriction ;
OWL:onProperty :hasChild ; OWL:someValuesFrom OWL:Thing]
] ) ] .
Q2 : In the ontology I have Parent subclassOf Person and Father subclassOf Parent. I defined an individual of typefather, it is inferred that it is a parent, but the fact that is a person is not inferred. I checked also with Pellet incremental. Why ?
:Father rdf:type OWL:Class ; rdfs:subClassOf :Parent; OWL:disjointWith :Mother.
:Mother rdf:type OWL:Class ; rdfs:subClassOf :Parent.
:Parent rdf:type OWL:Class ; rdfs:subClassOf :Person.
:Person: rdf:type OWL:Class ; rdfs:comment "Represents the set of all people."
Thanks in advance.

How to constraint OWL ObjectProperty values with SKOS Concepts from a specific ConceptScheme?

I need to express the fact that the allowed values of an ObjectProperty in my ontology are "controlled" by Concepts from a specific SKOS ConceptScheme.
EDIT:
Here is an example:
ex:colours rdf:type skos:ConceptScheme ;
skos:hasTopConcept ex:teal ;
skos:hasTopConcept ex:green .
ex:teal rdf:type skos:Concept ;
skos:inScheme ex:colours ;
skos:topConceptOf ex:colours .
ex:green rdf:type skos:Concept ;
skos:inScheme ex:colours ;
skos:topConceptOf ex:colours .
ex:P_has_colour rdf:type owl:ObjectProperty ;
rdfs:domain ex:ColoredStuff ;
rdfs:range ??? .
I want to express the fact that the values of the ex:P_has_colour ObjectProperty must be a Concept from the ex:colours SKOS ConceptScheme. I think I can add a type to each and every SKOS Concept which denotes a colour (something like ex:teal rdf:type ex:ColourConcept ;), and set the range of my property: ex:P_has_colour rdfs:range ex:ColourConcept. Is this the right way to go?
Translated from Manchester syntax to turtle, this seems to be the answer:
ex:colours rdf:type skos:ConceptScheme ;
skos:hasTopConcept ex:teal ;
skos:hasTopConcept ex:green .
ex:teal rdf:type skos:Concept ;
skos:inScheme ex:colours ;
skos:topConceptOf ex:colours .
ex:green rdf:type skos:Concept ;
skos:inScheme ex:colours ;
skos:topConceptOf ex:colours .
ex:P_has_colour rdf:type owl:ObjectProperty ;
rdfs:domain ex:ColoredStuff ;
rdfs:range [ owl:intersectionOf ( :ConceptScheme
[ rdf:type owl:Restriction ;
owl:onProperty :inScheme ;
owl:hasValue :colours
]
) ;
rdf:type owl:Class
] .

Retrieving URIs in Report of OWL2DL violations in the OWL API

I need to check the violations to the OWL2DL profile in this simplified ontology:
#prefix : <http://www.onto.com/test#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#base <http://www.onto.com/test#> .
<http://www.onto.com/test#> rdf:type owl:Ontology ;
rdfs:label "Test"#en .
xsd:date rdf:type rdfs:Datatype .
<http://www.onto.com/test#hasPart2> rdf:type owl:ObjectProperty .
<http://www.onto.com/test#isPartOf> rdf:type owl:ObjectProperty ,
owl:TransitiveProperty ;
rdfs:domain <http://www.onto.com/test#TestRestriction> .
<http://www.onto.com/test#isPartOf2> rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf owl:topObjectProperty ;
rdf:type owl:TransitiveProperty ;
rdfs:domain <http://www.onto.com/test#A2PartOfClass> .
<http://www.onto.com/test#maxCardinality0> rdf:type owl:ObjectProperty .
<http://www.onto.com/test#A2PartOfClass> rdf:type owl:Class .
<http://www.onto.com/test#TestRestriction> rdf:type owl:Class ;
rdfs:subClassOf [ rdf:type owl:Restriction ;
owl:onProperty <http://www.onto.com/test#isPartOf2> ;
owl:minQualifiedCardinality "0"^^xsd:nonNegativeInteger ;
owl:onClass <http://www.onto.com/test#A2PartOfClass>
] ;
rdfs:comment "A1 PartOf Class Comment"#en ;
rdfs:label "A1PartOfClass"#en .
<http://www.onto.com/test#isPartOf2> rdf:type owl:Class .
To this end, I have the following code in the OWL API to check for the violations of the given ontology to the OWL2DL profile.
OWL2DLProfile profile = new OWL2DLProfile();
OWLProfileReport report = profile.checkOntology(ontology);
for(OWLProfileViolation v:report.getViolations()) {
System.out.println(v);
}
In the console I'm getting this:
Use of non-simple property in a restriction: ObjectMinCardinality(0 <http://www.onto.com/test#isPartOf2> <http://www.onto.com/test#A2PartOfClass>) [SubClassOf(<http://www.onto.com/test#TestRestriction> ObjectMinCardinality(0 <http://www.onto.com/test#isPartOf2> <http://www.onto.com/test#A2PartOfClass>)) in OntologyID(OntologyIRI(<http://www.onto.com/test#>) VersionIRI(<null>))]
And I would like to retrieve the URIs involved, i.e., http://www.onto.com/test#isPartOf2, http://www.onto.com/test#A2PartOfClass
as well as the message of the violation, i.e., Use of non-simple property in a restriction.
How can I achieve this?
You can get the signature of the axiom involved in the violation as follows:
violation.getAxiom()
.signature()
.forEach(System.out::println);
There is no easy way to get the type of the violation besides doing the following:
violation.getClass().getSimpleName()
which will return UseOfNonSimplePropertyInCardinalityRestriction.

Inferring knowledge in OWL by counting properties

I have an ontology with Person and City classes. People travel to cities and this travel is represented in the traveledTo object property. I'd like to add a WorldTraveler class. People are world travelers if they have traveled to 2 or more cities. How can I do this in my ontology?
#prefix : <http://www.semanticweb.org/chris/ontologies/2017/9/untitled-ontology-64#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix xml: <http://www.w3.org/XML/1998/namespace> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#base <http://www.semanticweb.org/chris/ontologies/2017/9/untitled-ontology-64> .
<http://www.semanticweb.org/chris/ontologies/2017/9/untitled-ontology-64> rdf:type owl:Ontology .
:traveledTo rdf:type owl:ObjectProperty ;
rdfs:domain :Person ;
rdfs:range :City .
:City rdf:type owl:Class .
:Person rdf:type owl:Class .
:Bob rdf:type owl:NamedIndividual ,
:Person ;
:traveledTo :London ,
:Ottawa ,
:Paris .
:Brussels rdf:type owl:NamedIndividual ,
:City .
:London rdf:type owl:NamedIndividual ,
:City .
:Ottawa rdf:type owl:NamedIndividual ,
:City .
:Paris rdf:type owl:NamedIndividual ,
:City .
:Ralph rdf:type owl:NamedIndividual ,
:Person ;
:traveledTo :Rome .
:Rome rdf:type owl:NamedIndividual ,
:City .
:Washington rdf:type owl:NamedIndividual ,
:City .
I tried adding the following Class but it didn't seem to work:
:WorldTraveler rdf:type owl:Class ;
owl:equivalentClass [ owl:intersectionOf ( :Person
[ rdf:type owl:Restriction ;
owl:onProperty :traveledTo ;
owl:minQualifiedCardinality "2"^^xsd:nonNegativeInteger ;
owl:onClass :City
]
) ;
rdf:type owl:Class
] .
I believe that my reasoner may not be able to infer that Ralph is not a WorldTraveler because of the open world assumption. However, it should be able to infer that Bob is a WorldTraveler because he has traveled to 3 cities.
Thanks for your help.
Chris
In addition to the open world assumption (OWA), there exists the unique name assumption (UNA). OWL does make the former (OWA) and does not make the latter (UNA).
You should explicitely make individuals different.
In the Turtle syntax, it should look like this:
:London owl:differentFrom :Paris .
or
[ rdf:type owl:AllDifferent ;
owl:distinctMembers ( :Brussels :London :Ottawa :Paris :Rome :Washington )
] .

SWRL and Rolification cannot return what I want

I have developed an ontology and I want to add the following SWRL in protege:
Divider_intersection(?node), is_extent_of(?node, ?s), builds(?s, ?l),Segment(?s),Lane(?l),detailed_partition(?d), builds(?l, ?d)-> is_divided_at(?d, ?node)
with this I wish to add an object property, is_divided_at, between an individual from detailed_partition (?d) and a node that is classified as a divider_intersection if it is the extent of a segment (?s) that build a lane (?l) which then build the detailed?partition (?d). As noted here, I am looking for NamedIndividuals, hence I presume the SWRL should do the job.
Further research, I found Rolification (1, 2, 3) as a possible answer however I have never used it before, but I made the following chain:
r_Divider_intersection o is_extent_of o r_Segment o builds o r_Lane o builds o r_detailed_partition
still I do not get the answer. Any idea what is wrong?
Your approach works, and without seeing your ontology (your link requires permissions, and offsite links aren't very helpful anyhow) we can't see why your particular construction of it works. One thing that jumps out from your question is that the it looks like your is_divided_at property has its arguments (?d,?node) in the opposite order from what the property chain axiom would produce. Anyhow, here's a working example.
#prefix : <urn:ex:#> .
#prefix ex: <urn:ex:#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
ex:isDividedAt a owl:ObjectProperty ;
owl:propertyChainAxiom ( ex:_DividerIntersection ex:isExtentOf ex:_Segment ex:builds ex:_Lane ex:builds ex:_DetailedPartition ) .
ex:Segment a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_Segment
] .
ex:_DetailedPartition
a owl:ObjectProperty .
ex:DividerIntersection
a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_DividerIntersection
] .
ex:_Segment a owl:ObjectProperty .
ex:_Lane a owl:ObjectProperty .
ex:builds a owl:ObjectProperty .
ex:dividerIntersection0
a owl:NamedIndividual , ex:DividerIntersection ;
ex:isExtentOf ex:segment0 .
<urn:ex:> a owl:Ontology .
ex:detailedPartition0
a owl:NamedIndividual , ex:DetailedPartition .
ex:_DividerIntersection
a owl:ObjectProperty .
ex:segment0 a owl:NamedIndividual , ex:Segment ;
ex:builds ex:lane0 .
ex:DetailedPartition a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_DetailedPartition
] .
ex:isExtentOf a owl:ObjectProperty .
ex:lane0 a owl:NamedIndividual , ex:Lane ;
ex:builds ex:detailedPartition0 .
ex:Lane a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_Lane
] .

Resources