owl: property domain restriction on property value - properties

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.

Related

How do I deduce all of a person's descendants?

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.

SPARQL selecting unittext (blank nodes)

I recently started working with Linked Data and SPARQL.
I've a dataset which contains unittext, indicating what kind of unit the property has (meters, kilograms and so on).
The unit is a values which is inserted on the relationship between object and its quantitative property.
In my RDF dataset the units are included in a blank node and indicated by https://schema.org/unitText.
An example of the data set is included below.
], [
a owl:Restriction ;
owl:minCardinality "0"^^xsd:nonNegativeInteger ;
owl:onProperty <https://someuri> ;
ns1:unitText "kg"
How can I select this property?
The query so far is:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
select distinct ?label ?aspect ?datatype where {
?s rdfs:subClassOf/owl:onProperty ?aspect .
?aspect rdf:type owl:ObjectProperty.
?aspect skos:prefLabel ?label .
?aspect rdfs:range ?datatype .
FILTER EXISTS{ ?aspect rdfs:range ?datatype. }
VALUES ?datatype {
xsd:string
xsd:gYear
xsd:boolean
xsd:decimal
xsd:integer
xsd:date
}
}
The RDF dataset looks actually like this:
rdfs:subClassOf [ a owl:Restriction ;
owl:minCardinality "0"^^xsd:nonNegativeInteger ;
owl:onProperty <someuri> ;
<https://schema.org/unitText> "kg"
] ;

Inferencing in Protege does not infer types based on `subClassOf`

We are developing an ontology, where we need to infer the type of each node, based on some mappings defined in # Test mapping file section. We tried rdfs:subClassOf, as in the below snippet, but it doesn't infer types. Ideally we want to infer Person 1 and Person 2 to NodeTypePerson, also sydney and canberra to NodeTypeCity.
I tried owl:equivalentClass instead but no luck. rdfs:range and rdfs:domain infer types as expected, but having trouble inferring with rdfs:subClassOf. Any advice is highly appreciated.
UPDATE:
owl:equivalentClass works in Protege. (If infers the type). But can't we use rdfs:subClassOf similarly? Actually I want a way to get this done with RDFS inferencing, where owl:equivalentClass doesn't work obviously. Is there any other RDFS property we can use here?
# baseURI: http://www.Test-app.com/ns
#prefix : <http://www.Test-app.com/ns#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix acl: <http://www.w3.org/ns/auth/acl#> .
#prefix cc: <http://creativecommons.org/ns#> .
#prefix cert: <http://www.w3.org/ns/auth/cert#> .
#prefix csvw: <http://www.w3.org/ns/csvw#> .
#prefix dc: <http://purl.org/dc/terms/> .
#prefix dcam: <http://purl.org/dc/dcam/> .
#prefix dcat: <http://www.w3.org/ns/dcat#> .
#prefix dctype: <http://purl.org/dc/dcmitype/> .
#prefix foaf: <http://xmlns.com/foaf/0.1/> .
#prefix ldp: <http://www.w3.org/ns/ldp#> .
#prefix posixstat: <http://www.w3.org/ns/posix/stat#> .
#prefix schema: <https://schema.org/> .
#prefix shacl: <http://www.w3.org/ns/shacl#> .
#prefix skos: <http://www.w3.org/2004/02/skos/core#> .
#prefix skosxl: <http://www.w3.org/2008/05/skos-xl#> .
#prefix solid: <http://www.w3.org/ns/solid/terms#> .
#prefix swapdoc: <http://www.w3.org/2000/10/swap/pim/doc#> .
#prefix ui: <http://www.w3.org/ns/ui#> .
#prefix vann: <http://purl.org/vocab/vann/> .
#prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
#prefix vs: <http://www.w3.org/2003/06/sw-vocab-status/ns#> .
#prefix ws: <http://www.w3.org/ns/pim/space#> .
#base <http://www.Test-app.com/ns> .
<http://www.Test-app.com/ns>
rdf:type owl:Ontology ;
dc:title "Test Ontology"#en ;
owl:versionIRI <http://www.Test-app.com/ns/0.1> .
# Test mapping file
#prefix test: <http://www.Test-app.com/ns#> .
:Person
a rdfs:Class ;
owl:equivalentClass :NodeTypePerson .
:locatedNear
a rdf:Property ;
rdfs:subClassOf :NodeCustomAttribute ;
rdfs:label "Located Near" .
:Location
a rdfs:Class ;
rdfs:label "Location" ;
rdfs:subClassOf :NodeTypeCity ;
rdfs:comment "This represents a geolocation." .
:City
a rdfs:Class ;
rdfs:label "City" ;
rdfs:comment "This represents a city." ;
rdfs:subClassOf :Location .
# Some graph instances data
:sydney
a :City ;
rdfs:label "Sydney" ;
rdfs:comment "Australia's largest city." .
:canberra
a :City ;
rdfs:label "Canberra" ;
rdfs:comment "Australia's national capital." .
:person1
a :Person ;
rdfs:label "Person 1" ;
rdfs:comment "First vertex." ;
:locatedNear :sydney .
:person2
a :Person ;
rdfs:label "Person 2" ;
rdfs:comment "Second vertex." ;
:locatedNear :canberra .
# Types
:NodeTypePerson
rdf:type rdfs:Class ;
rdfs:label "NodeTypePerson" ;
rdfs:comment "" ;
vs:term_status "stable" ;
rdfs:isDefinedBy <http://www.Test-app.com/ns> .
:NodeTypeCity
rdf:type rdfs:Class ;
rdfs:label "NodeTypeCity" ;
rdfs:comment "" ;
vs:term_status "stable" ;
rdfs:isDefinedBy <http://www.Test-app.com/ns> .```

Unsuccessful team-employs-player property chain

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.

Fuseki 1.0.1 SPARQL Update returns 404

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/