360 likes | 500 Views
OWL. ARIN – KR Lecture 4. Suresh Manandhar . Outline. Limitations of RDFS OWL Introduction OWL examples Using Protégé (demo). What is OWL?. OWL stands for Web Ontology Language OWL provides a richer KR language compared to RDFS RDFS = straightfoward hierarchies +
E N D
OWL ARIN – KR Lecture 4 Suresh Manandhar
Outline • Limitations of RDFS • OWL Introduction • OWL examples • Using Protégé (demo)
What is OWL? • OWL stands for Web Ontology Language • OWL provides a richer KR language compared to RDFS • RDFS = straightfoward hierarchies + straightforward relations/properties • OWL = RDFS + rich language for complex KR
Some peculiarities • OWL/RDF is backwards compatible with RDFS • Every RDFS description is an OWL description • Just like every RDF description is an RDFS description • But RDF, RDFS, OWL have separate namespaces • Thus there are some things to bear in mind due to this.
Some peculiarities owl:Thing rdf:Resource rdfs:Class owl:Class
Back to Camera shop example • RDFS Domain/Range specification cannot say that: • A camera can have only one Lens and only one Maker • What if we do want to impose such a constraint Domain Range lens Camera Lens Maker Camera Maker
Our previous RDFS example @prefix : <http://www.shop.com/camera#> . @prefix dbpedia: <http://www.dbpedia.org/resource/> . @prefix Maker: <http://dbpedia.org/resource/Public_company> . :lens a rdf:Property; rdfs:domain :Camera; rdfs:range :Lens. Maker: a rdf:Property; rdfs:domain :Camera; rdfs:range Maker: .
RDFS spec. permits • Thus this: • both acceptable/consistent. • But what if we do not want this. :Nikon_D300 :lens :Nikon_F30Lens. :Nikon_D300 :lens :Nikon_F50Lens. and :Nikon_D300 Maker: dbpedia:Nikon. • :Nikon_D300 Maker: dbpedia:Samsung.
Similarly : • Cannot prevent the same camera to be bought by 2 different people. :Nikon_D300_sn8321686 :bought_by :Cust1242. :Nikon_D300_sn8321686 :bought_by :Cust4321.
OWL provides functional relations • Functional constraint on relations: owl:FunctionalProperty • @prefix owl: <http://www.w3.org/2002/07/owl#> . • :Camera a owl:Class. • :Customer a owl:Class. bought_by:a owl:FunctionalProperty; rdfs:domain :Camera; rdfs:range:Customer.
What is a functional relation? • If R is a functional relation then: • R(x,y) and R(x,z) implies y=z • Since bought_byis functional: Possible interpretations: • C1242 and C4321 both bought Nikon_D300_s2334 (distributive interpretation) • C1242 and C4321 are the same (functional interpretation) Customer Camera C1242 C4321 Nikon_D500 Bought_by Nikon_D300_s2334 implies C1242 = C4321
Functional relation - entailment • Thus now: • would imply :Nikon_D300_sn8321686 :bought_by :Cust1242. :Nikon_D300_sn8321686 :bought_by :Cust4321. :Cust1242 = :Cust4321 How do we state that the two customers are different?
OWL solution : distinctMembers • One solution will be to say: • But that would require too much typing…. At the instance level • The OWL solution: • States that the two instances are different. • Results in an inconsistent KB. :Cust1242≠ :Cust4321 [] rdf:typeowl:AllDifferent; owl:distinctMembers ( :Cust1242 :Cust4321).
owl:AllDisjointClasses [] rdf:typeowl:AllDisjointClasses; owl:members (:Nikon_F50Lens :Nikon_F30Lens). Lens Lens Nikon_F30Lens Nikon_F50Lens Nikon_F30Lens Nikon_F50Lens Incorrect Correct
Functional relation - entailment • Thus now: • would imply -- KB is inconsistent :Nikon_D300_s2334 :lens :Nikon_F30Lens_s432. :Nikon_D300_s2334 :lens :Nikon_F50Lens_s123. :Nikon_D300_s2334 rdf:type :Nikon_D300. :Nikon_F30Lens_s432 rdf:type :Nikon_F30Lens. :Nikon_F50Lens_s123 rdf:type :Nikon_F50Lens. and • [] rdf:typeowl:AllDisjointClasses; • owl:members (:Nikon_F50Lens :Nikon_F30Lens). • :lens a owl:FunctionalProperty; • rdfs:domain :Camera; • rdfs:range :Lens.
Aside – owl:ObjectProperty • The OWL equivalent for a (vanilla) relation between two classes • with no additional constraints :lens a rdf:Property; rdfs:domain :Camera; rdfs:range :Lens. :lens a owl:ObjectProperty; rdfs:domain :Camera; rdfs:range :Lens.
Functional relation - correctly • Actually the correct syntax to specify functional properties is: :lens a owl:ObjectProperty; a owl:FunctionalProperty; rdfs:domain :Camera; rdfs:range :Lens. and
Aside – owl:DatatypeProperty • For cases, when the range is a Datatype, OWL has a special DatatypeProperty keyword. :model a rdf:Property; rdfs:domain :Camera; rdfs:rangexsd:string. • :model a owl:DatatypeProperty; • a owl:FunctionalProperty; • rdfs:domain :Camera; • rdfs:rangexsd:string.
Lens instances • Currently, we still need to say, at the instance level • But we really don’t care about Lens instances • After all, nobody looks at the serial no. of lens • So, just want to say that Nikon_D300 camera comes with exactly one lens • And adding lens serial no. is optional :Nikon_D300_s2334 :lens :Nikon_F30Lens_s432. :Nikon_D300_s2334 rdf:type :Nikon_D300. :Nikon_F30Lens_s432 rdf:type :Nikon_F30Lens. :Nikon_F50Lens_s123 rdf:type :Nikon_F50Lens.
So we want to be able to: :Nikon_D300_s2334 :lens :Nikon_F30Lens_s432. (delete) :Nikon_D300_s2334 rdf:type :Nikon_D300. (keep) :Nikon_F30Lens_s432 rdf:type :Nikon_F30Lens. (delete) :Nikon_F50Lens_s123 rdf:type :Nikon_F50Lens. (delete)
OWL cardinality constraints • Cardinality constraints allows stating things like: • A camera comes with at least one lens • A camera comes with at most three lens
OWL cardinality constraints :Camera rdfs:subClassOf [ rdf:typeowl:Restriction; owl:minCardinality 1; owl:onProperty :lens ]. :Camera rdfs:subClassOf [ rdf:typeowl:Restriction; owl:maxCardinality 3; owl:onProperty :lens ].
OWL cardinality constraints :Nikon_D500 rdfs:subClassOf :Camera. :Nikon_D500 rdfs:subClassOf [ rdf:typeowl:Restriction; owl:cardinality 1; owl:onProperty :lens ]. • Similar to FunctionalProperty constraint but not identical. • Spot the difference?
Quantifiers in OWL • Closely related to cardinality constraints • owl:someValuesFrom (existential quantifier) • owl:allValuesFrom (universal quantifier) • So we can state: “All reviews of a camera is by a PhotoJournalist” • Would enforce the constraint: “0 or more reviewers for each Camera” “All reviewers must be PhotoJournalist”
Owl:allValuesFrom :Camera rdfs:subClassOf [ rdf:typeowl:Restriction; owl:allValuesFrom :PhotoJournalist; owl:onProperty :Reviewer ].
Owl:someValuesFrom :Camera rdfs:subClassOf [ rdf:typeowl:Restriction; owl:someValuesFrom :PhotoJournalist; owl:onProperty :Reviewer ]. • States that every camera has at least one reviewer. • KB still consistent even if a reviewer does not (yet) exist.
Open world semantics • OWL is based on Description Logics (DL) • DLs come with an open-world semantics • In plain English – this means: “My KB is only a partial picture of the real world” “There is lot more stuff I should have said but have not got around to saying it – or I don’t know it” “So do not make any extra assumptions beyond what is being stated” “Keep an open mind”
Open world semantics - implications • Instances can belong to multiple classes • The same class may have multiple names – the user does not yet know • A Class may inherit from multiple super classes in complicated ways • no constraint on the inheritance structure • All of the above applies to relations/properties • Formal semantics in the next lecture
Lets build a family ontology S1: Each person is either Male or Female S2: You cannot be both Male and Female :Male a owl:Class. :Female a owl:Class. • [] rdf:typeowl:AllDisjointClasses; • owl:members (:Male :Female). :Person a owl:Class; owl:unionOf (:Male :Female). • UnionOfimposes stronger constraint compared to using subClassOf
S3: Parent is Person with a Child :Parent owl:equivalentClass • [rdf:typeowl:Restriction; • owl:onProperty :hasChild; owl:someValuesFrom Person ] • equivalentClassimposes a stronger constraint compared to using subClassOf • Also harder to implement
But this does not impose the constraint that Parent is a Person. • The following adds this additional constraint. :Parent owl:equivalentClass • [rdf:typeowl:Class; • owl:intersectionOf • ( :Person • [rdf:typeowl:Restriction; • owl:onProperty :hasChild; • owl:someValuesFrom :Person • ] • )].
S4: Mother is Parent and Female. Father is Parent and Male. :Mother owl:equivalentClass • [rdf:typeowl:Class; • owl:intersectionOf (:Parent :Female)]. • :Father owl:equivalentClass • [rdf:typeowl:Class; • owl:intersectionOf (:Parent :Male)].
S5: A person is either Dead or Alive. S6: You cannot be Dead and Alive at the same time. • :Dead a owl:Class. • :Alive a owl:Class. • [] rdf:typeowl:AllDisjointClasses; • owl:members (:Dead :Alive). • :Person a owl:Class; • owl:unionOf (:Dead :Alive).
S7: hasParent and hasChild are inverses of each other. • :hasParentowl:inverseOf:hasChild. • Remember from MFCS: • (x,y) ∈ R implies (y,x) ∈ R-1 • Thus: • (x,y) ∈ hasParentimplies (y,x) ∈ hasChild
S8: Orphan is Person whole Parents are all Dead. :Orphan owl:equivalentClass • [rdf:typeowl:Restriction; • owl:onProperty :hasParent; owl:allValuesFrom :Dead ].
S9: My Parents are my Ancestors and my Parent’s Ancestors are my Ancestors too. equivalently S9: Ancestor is a transitive relation over Parent. • :hasParent • rdfs:subPropertyOf :hasAncestor. • :hasAncestor • rdf:typeowl:TransitiveProperty. • The first statement states: “Every parent is an ancestor”