10.07.2015 Views

Rules & Ontologies OWL 2 RL & SWRL Description Logic ... - LPIS

Rules & Ontologies OWL 2 RL & SWRL Description Logic ... - LPIS

Rules & Ontologies OWL 2 RL & SWRL Description Logic ... - LPIS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Rules</strong> & <strong>Ontologies</strong><strong>Description</strong> <strong>Logic</strong> Programs (DLP)4-1<strong>OWL</strong> 2 <strong>RL</strong> & SW<strong>RL</strong><strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-2• Horn logic (rules) and description logics (ontologies) areorthogonal• The simplest integration approach is the intersection ofboth logics– The part of one language that can be translated in a semanticspreservingway to the other• <strong>OWL</strong>2 <strong>RL</strong> capture this fragment of <strong>OWL</strong> (previouslycalled <strong>Description</strong> <strong>Logic</strong> Programs - DLP)– Horn-definable part of <strong>OWL</strong>, or– <strong>OWL</strong>-definable part of Horn logic<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition<strong>OWL</strong> 2 <strong>RL</strong>Open-World Assumption (OWA)• <strong>OWL</strong> 2 is based on <strong>Description</strong> <strong>Logic</strong>.– A fragment of first-order logic– Inherits open-world assumption and non-uniquenameassumption• <strong>OWL</strong> 2 <strong>RL</strong> is an interesting sublanguage g of<strong>OWL</strong> 2 DL– Above assumptions do not make a difference• We cannot conclude some statement x to befalse simply because we cannot show x to betrue.• The opposite assumption (closed world, CWA)would allow deriving falsity from the inability toderive truth.• <strong>OWL</strong> is strictly committed to the OWA– In some applications is not the right choice4-3<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-4<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition1


OWA vs. CWAExamplesUnique-Name Αssumption (UNA)4-5• Example in favor of OWA– Question: “Did it rain in Tokyo yesterday?”– Answer: “I don’t know that it rained, but that’s notenough reason to conclude that it didn’t rain.”• Example in favor of CWA– Question: “Was there a big earthquake disaster inTokyo yesterday?”– Answer: “I don’t know, but if there had been such adisaster, I’d have heard about it. Therefore I concludethat there wasn’t such a disaster.”<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-6• When two individuals are known by differentnames, they are in fact different individuals.– Sometimes works well and sometimes not• In favor: when two products in a catalog are knownby different codes, they are different• Against: two people in our social environmentinitially known with different identifiers (e.g., “Prof.van Harmelen” and “Frank”) are sometimes thesame person<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd EditionUnique-Name Αssumption (UNA)CWA vs. OWA• <strong>OWL</strong> does not make the unique-nameassumption• It is possible to explicitly assert of a set ofidentifiers that they are all unique– using owl:allDifferente • Databases and logic-programming systemssupport closed worlds and unique names• Knowledge representation systems andtheorem provers support open worlds andnon-unique names• <strong>Ontologies</strong> are sometimes in need of oneand sometimes in need of the other.– Big debate in the literature4-7<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-8<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition2


<strong>OWL</strong> 2 <strong>RL</strong><strong>OWL</strong> 2 <strong>RL</strong> Advantages (1/2)• Debate resolved by <strong>OWL</strong> 2 <strong>RL</strong>• The largest fragment of <strong>OWL</strong> 2 on which thechoice for CWA and UNA does not matter– <strong>OWL</strong> 2 <strong>RL</strong> is weak enough so that the differencesbetween the choices don’t show up.– Still large enough to enable useful representationand reasoning tasks.• Applications that wish to make differentchoices on these assumptions (CWA, UNA,etc) can still exchange ontologies in <strong>OWL</strong> 2<strong>RL</strong> without harm.• Outside <strong>OWL</strong> 2 <strong>RL</strong>, they will draw differentconclusions from the same statements.– They disagree on the semantics.4-9<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-10<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition<strong>OWL</strong> 2 <strong>RL</strong> Advantages (2/2)<strong>OWL</strong> 2 <strong>RL</strong> constructs• Freedom to use either <strong>OWL</strong> 2 or rules (and associatedtools and methodologies) for modeling purposes• <strong>Description</strong> logic reasoners or deductive rule systemscan be used for implementation.– Extra flexibility - interoperability with tools• Preliminary experience with using <strong>OWL</strong> 2 has shownthat existing ontologies frequently use very fewconstructs outside the <strong>OWL</strong> 2 <strong>RL</strong> language.• Which constructs of RDF Schema and <strong>OWL</strong> 2can be expressed in Horn logic?– They lie within the expressive power of DLP• Some constructs cannot be expressed4-11<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-12<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition3


Allowed <strong>OWL</strong> constructors• Class and property equivalence• Equality- inequality between individuals• Inverse, transitive, symmetric and functionalproperties• Intersection of classes• Excluded constructors– Union, existential quantification, and arbitrarycardinality constraints4-13<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd EditionSimple RDF constructs• A triple (a, P, b) is expressed as a fact P(a, b)• An instance declaration type(a,C),– a is an instance of class C– expressed as C(a)• C is a subclass of DC(X) → D(X)• Similarly for subpropertyP(X,Y) → Q(X,Y)4-14<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd EditionMore RDF Constructs• Domain and Range Restrictions– C is the domain of property PP(X, Y) → C(X)– C’ is the range of property PP(X, Y) → C’(Y) C(Y)<strong>OWL</strong> Constructs• equivalentClass(C,D)– pair of rulesC(X) → D(X)D(X) → C(X)• Similarly for equivalentProperty(P,Q)P(X,Y) → Q(X,Y)Q(X,Y) → P(X,Y)4-15<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-16<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4


More <strong>OWL</strong> ConstructsUnion (1)4-17• Transitive PropertiesP(X, Y ), P(Y,Z) → P(X,Z)• Boolean operators.– The intersection of C1 and C2 is a subclass of DC1(X), C2(X) → D(X)– C is a subclass of the intersection of D1 and D2C(X) → D1(X) C(X) → D2(X)– the opposite is outside the expressive power of Hornlogic<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-18• The union of C1 and C2 is a subclass of DC1(X) → D(X) C2(X) → D(X)• The opposite direction is outside theexpressive power of Horn logic.– To express that C is a subclass of the union of D1and D2 would require a disjunction in the head ofthe corresponding rule<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd EditionUnion (2)<strong>OWL</strong> Restrictions allValuesFrom• There are cases where the translation ispossible– when D1 is a subclass of D2, then the ruleC(X) → D2(X)– is sufficient to express that C is a subclass of theunion of D1 and D2• There is not a translation that works in allcases• allValuesFrom(P,D)– the anonymous class of all x such that y must be aninstance of D whenever P(x, y)• C subClassOf allValuesFrom(P,D)C(X),P(X,Y)→ D(Y)• The opposite direction cannot in general beexpressed4-19<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-20<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition5


<strong>OWL</strong> Restrictions someValuesFromNon-expressible constructs• someValuesFrom(P,D)– the anonymous class of all x for which there existsat least one y instance of D, such that P(x, y).• someValuesFrom(P,D) subClassOf CP(X,Y), D(Y) → C(X)• The opposite direction cannot in general beexpressed.• Cardinality constraints and Complement ofclasses cannot be expressed in Horn logic inthe general case.4-21<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-22<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition<strong>OWL</strong> 2 <strong>RL</strong> – ConclusionsSemantic Web <strong>Rules</strong> Language(SW<strong>RL</strong>)• Allowed constructors allow usefulexpressivity for many practical cases• Guarantees correct interchange between<strong>OWL</strong> reasoners independent of CWA andUNA• Allows for translation into efficientlyimplementable reasoning techniques basedon databases and logic programs• A proposed Semantic Web languagecombining <strong>OWL</strong> 2 DL with function-free Hornlogic, written in Datalog RuleML• It allows Horn-like rules to be combined with<strong>OWL</strong> 2 DL ontologies.4-23<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-24<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition6


<strong>Rules</strong> in SW<strong>RL</strong>Rule Heads4-25• B 1 , …,B n → A 1 , …,A m• commas denote conjunction on both sides ofthe arrow• A 1 , …,A m ,B 1 , …,B n can be– C(x), P(x, y), sameAs(x, y), differentFrom(x,y),– C is an <strong>OWL</strong> description, P is an <strong>OWL</strong> property,– x, y are Datalog variables, <strong>OWL</strong> individuals, or<strong>OWL</strong> data values.<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-26• If the head of a rule has more than one atomthe rule can be transformed to an equivalentset of rules with one atom in the head in astraightforward way– conjunction of atoms without shared variables• A(X,Y)→ B(X),C(Y)– A(X,Y)→ B(X)– A(X,Y)→ C(Y)<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd EditionComplexity of SW<strong>RL</strong>SW<strong>RL</strong> vs. <strong>OWL</strong> 2 <strong>RL</strong>4-27• Arbitrary <strong>OWL</strong> expressions (e.g. restrictions),can appear in the head or body of a rule.• This adds significant expressive power to<strong>OWL</strong>, but at the high price of undecidability• There can be no inference engine that drawsexactly the same conclusions as the SW<strong>RL</strong>semantics.<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-28• <strong>OWL</strong> 2 <strong>RL</strong> tries to combine the advantages of bothlanguages in their common sublanguage• SW<strong>RL</strong> takes a more maximalist approach and unitestheir respective expressivities.• The challenge is to identify sublanguages of SW<strong>RL</strong> thatfind the right balance between expressive power andcomputational tractability.– A candidate is the extension of <strong>OWL</strong> DL with DL-safe rules– Every variable must appear in a non-description logic atom in the rulebody<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition7


Example SW<strong>RL</strong> <strong>Rules</strong>:ReclassificationExample SW<strong>RL</strong> <strong>Rules</strong>:Property Value Assignment4-29Man(?m) → Person(?m)– Possible in <strong>OWL</strong> - subclassOf relation– Some rules are <strong>OWL</strong> syntactic sugarPerson(?m) hasSex(?m,male) → Man(?m)– Possible in <strong>OWL</strong> – hasValue (sufficient) restriction– Not all such reclassifications are possible in <strong>OWL</strong><strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-30hasParent(?x, ?y) hasBrother(?y, ?z)→ hasUncle(?x, ?z)– Property chaining– Possible in <strong>OWL</strong> 2 - Not possible in <strong>OWL</strong> 1.0Person(?p) hasSibling(?p,?s) Man(?s)→ hasBrother(?p,?s)– Not possible in <strong>OWL</strong><strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd EditionExample SW<strong>RL</strong> <strong>Rules</strong>:Named IndividualsExample SW<strong>RL</strong> <strong>Rules</strong>:Built-insPerson(Fred) hasSibling(Fred, ?s) Man(?s)→ hasBrother(Fred, ?s)Person(?p) hasAge(?p,?age) swrlb:greaterThan(?age,17)→ Adult(?p)• Built-insins dramatically increase expressivity– most rules are not expressible in <strong>OWL</strong> 1– Some built-ins can be expressed in <strong>OWL</strong> 24-31<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-32<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition8


Example SW<strong>RL</strong> <strong>Rules</strong>:String Built-insPerson(?p) hasNumber(?p, ?number) swrlb:startsWith(?number, "+")→ hasInternationalNumber(?p, true)Example SW<strong>RL</strong> <strong>Rules</strong>:Built-ins / Argument BindingPerson(?p) hasSalaryInPounds(?p, ?pounds) swrlb:multiply(?dollars, ?pounds, 2.0)→ hasSalaryInDollars(?p, ?dollars)Person(?p) hasSalaryInPounds(?p, ?pounds) swrlb:multiply(2.0, ?pounds, ?dollars)→ hasSalaryInDollars(?p, ?dollars)4-33<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-34– Arguments can bind in any position– Usually implementations support binding of the 1 st arg<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd EditionCan define new Built-in LibrariesSW<strong>RL</strong>Tab Built-in Librarieshttp://protege.cim3.net/cgibin/wiki.pl?SW<strong>RL</strong>TabBuiltInLibraries4-35• Temporal built-ins:– temporal:before("1999-11-01T10:00", "2000-02-01T11:12:12.000")– temporal:duration(2, "1999-11-01", "2001-02-01",temporal:Years)• • TBox built-ins: ins:– tbox:isDatatypeProperty(?p)– tbox:isDirectSubPropertyOf(?sp, ?p)• • Mathematical built-ins:– swrlm:eval(?circumference, "2 * pi * r", ?r)<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-36<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition9


SW<strong>RL</strong> and Open World Semantics:sameAs, differentFromSW<strong>RL</strong> is Monotonic:does not Support Negated Atoms4-37Publication(?p) hasAuthor(?p, ?y) hasAuthor(?p, ?z) differentFrom(?y, ?z)→ cooperatedWith(?y, ?z)• Like <strong>OWL</strong>, SW<strong>RL</strong> does not adopt the uniquename assumption– Individuals must also be explicitly stated to bedifferent (using owl:allDifferents restriction)<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-38Person(?p) not hasCar(?p, ?c)→ CarlessPerson(?p)• Not possible - language does not supportnegation here• Potential invalidation - what if a person latergets a car?<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd EditionSW<strong>RL</strong> is Monotonic:retraction (or modification) not supportedSW<strong>RL</strong> is Monotonic:counting not supported4-39Person(?p) hasAge(?p,?age) swrlb:add(?newage, ?age,1)→ hasAge(?p, ?newage)• Incorrect:– will run forever and attempt to assign an infinitenumber of values to hasAge property• There is no retraction of old value– Even if there was, it would run forever<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-40Publication(?p) hasAuthor(?p,?a) → SingleAuthorPublication(?p)• Not expressible - open world applies• Potential invalidation - what if author isadded later?<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition10


SW<strong>RL</strong>TabSW<strong>RL</strong>Tab Wiki :http://protege.cim3.net/cgi-bin/wiki.pl?SW<strong>RL</strong>Tab4-41• A Protégé-<strong>OWL</strong> development environment forworking with SW<strong>RL</strong> rules• Supports editing and execution of rules• Extension mechanisms to work with third-partyrule engines• Mechanisms for users to define built-in methodlibraries• Supports querying of ontologies<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-42<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd EditionWhat is the SW<strong>RL</strong> Editor?SW<strong>RL</strong> Editor• The SW<strong>RL</strong> Editor is an extension to Protégé-<strong>OWL</strong> that permits the interactive editing ofSW<strong>RL</strong> rules.• The editor can be used to create SW<strong>RL</strong>rules, edit existing SW<strong>RL</strong> rules, and read andwrite SW<strong>RL</strong> rules.• It is accessible as a tab within Protégé-<strong>OWL</strong>.4-43<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-44<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition11


RIF – use of frames4-49<strong>Rules</strong> & <strong>Ontologies</strong>• An actor is a movie star ifhe has starred in more than3 successful movies,produced in a span of atleast 5 years.• A film is consideredsuccessful if it has receivedcritical acclaim (e.g. rating>8) or was financiallysuccessful (produced>$100M in ticket sales).• These rules should beevaluated against theDBpedia data set.A Semantic Web Primer, 3rd Edition4-50• The use of frames has a long tradition in OOlanguages and knowledge representation,– Has also been prominent in rule languages (e.g.F<strong>Logic</strong>).• The basic idea is to represent objects asframes, and their properties as slots.– E.g., a class professor with slots name, office, phone,department etc.oid[slot1 -> value1 … slotn -> valuen]<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-51Compatibility with RDF and <strong>OWL</strong>• The basic idea of combining RIF with RDF isto represent RDF triples using RIF frameformulas• A triple s p o is represented as s[p -> o]• Exampleex:GoneWithTheWind ex:FilmYear ex:1939ex:GoneWithTheWind[ex:FilmYear -> ex:1939]<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-52Inference in RIF and RDF• RIF rule: the Hollywood Production Code was in placebetween 1930 and 1968Group(Forall ?Film (If And( ex:?Film[ex:Year -> ?Year]External(pred:dateGreaterThan(?Year 1930))External(pred:dateGreaterThan(1968 ?Year)))Then ?Filmex:HollywoodProductionCode -> ex:True]))• Conclusionex:GoneWithTheWind[ex:HollywoodProductionCode -> ex:True]RIFex:GoneWithTheWind ex:HollywoodProductionCode ex:TrueRDF <strong>Rules</strong> & <strong>Ontologies</strong> A Semantic Web Primer, 3rd Edition13


4-53Rule Markup Language (RuleML)• RuleML is an effort to develop markup of rules on the Web.• It is a family of rule languages, corresponding to differentkinds of rule languages:– derivation rules, integrity constraints, reaction rules, …• The kernel of the RuleML family is Datalog– function-free Horn logic• RuleML is experimental– studies various features of rule languages that are far from beingstandardized (e.g. nonmonotonic rules)• These efforts may feed into future standards– RuleML results were important in the development of RIF<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition4-54discountcustomerproduct7.5 percentpremiumcustomerluxuryproduct<strong>Rules</strong> & <strong>Ontologies</strong>The discount for acustomer buyinga product is 7.5%if the customer ispremium and theproduct is luxuryA Semantic Web Primer, 3rd EditionSW<strong>RL</strong> andRuleML• SW<strong>RL</strong> is anextension ofRuleMLbrother(X,Y) childOf(Z,Y) uncle(X,Z)4-55<strong>Rules</strong> & <strong>Ontologies</strong>A Semantic Web Primer, 3rd Edition14

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!