1 / 58

Reasoning with Rules SWRL as Example

Reasoning with Rules SWRL as Example. Jan Pettersen Nytun, UIA. What is a rule?. Consist of premise and a conclusion. Meaning: In any situation where the premise applies the conclusion must also hold. premise  conclusion. Different Types of Reasoning Inductive reasoning

holmess
Download Presentation

Reasoning with Rules SWRL as Example

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Reasoning with RulesSWRL as Example Jan Pettersen Nytun, UIA

  2. JPN, UiA

  3. What is a rule? • Consist of premise and a conclusion. • Meaning: In any situation where the premise applies the conclusion must also hold. premise  conclusion JPN, UiA

  4. Different Types of Reasoning • Inductive reasoning • Deductive reasoning • Abductive reasoning Why rules? The Semantic Web Rule Language (SWRL) SWRL Types of Atoms SWRL Example SWRL Exercise Agenda

  5. Inductive ReasoningFrom Wikipedia, the free encyclopedia …the premises are viewed as supplying strong evidence for the truth of the conclusion. … conclusion of a deductive argument is certain, the truth of the conclusion of an inductive argument is probable, based upon the evidence given. … premise  conclusion Not as strong as for deductive reasoning JPN, UiA

  6. Inductive ReasoningFrom Wikipedia, the free encyclopedia …the premises of an inductive logical argument indicate some degree of support for the conclusion but do not entail it... derives general principles from specific observations based on observations premise  conclusion Likely to be true JPN, UiA

  7. Inductive Reasoning Example Many observations indicate that humans eventually dies, i.e., humans are mortals. Human(x) Mortal(x) JPN, UiA

  8. Deductive Reasoningalso Called Deductive Logic, Logical Deduction From Wikipedia, the free encyclopedia • If all premises are true, and the rules of deductive logic are followed, then the conclusion reached is necessarily true. • In inductive reasoning, the conclusion is reached by generalizing or extrapolating from specific cases to general rules, i.e., there is … uncertainty. • However, induction used in mathematical proofs is actually a form of deductive reasoning. JPN, UiA

  9. Deductive Reasoning Example All men are mortal. Socrates is a man. ------------------------------ Therefore, Socrates is mortal. JPN, UiA

  10. Deductive Reasoning Example in First Order Predicate Logic All men are mortal. Socrates is a man. ------------------------------ Therefore, Socrates is mortal. ∀x.Man(x)  Mortal(x) -- All men are mortal • Man(Socrates) -- Socrates is a man • -------------------------------------------------------------------------- • Man(Socrates)  Mortal(Socrates). -- Socrates is mortal JPN, UiA

  11. From Wikipedia, the free encyclopedia JPN, UiA

  12. [https://explorable.com/inductive-reasoning] Theories have to be tested and hypotheses answered before the scientific community accepts them as truth. JPN, UiA

  13. Abductive Reasoning From Wikipedia, the free encyclopedia Example: The grass is wet; if it rained last night, then it would be unsurprising that the grass is wet. Therefore, by abductive reasoning, the possibility that it rained last night is reasonable. Some other process could have also resulted in a wet grass, such as sprinklers. Consequently, abducing that it rained last night from the observation of wet grass can lead to a false conclusion. RaindLastNight GrassIsWeet SprinklerWasOnGrassIsWeet JPN, UiA

  14. Abductive Reasoning Continues… • Inference to the best explanation. • Given a true conclusion and a rule, it attempts to select some possible premises that, if true also, can support the conclusion, though not uniquely. • Can be used to develop a hypothesis, which in turn can be tested by additional reasoning or data. RaindLastNight GrassIsWeet SprinklerWasOn GrassIsWeet JPN, UiA

  15. Abductive Reasoning Exampleref.: https://www.quora.com/What-is-a-good-example-of-abductive-reasoning • The doctor hears her patients symptoms, including the regular shortness of breath on cold days and when exercising and abduces that the best explanation of these symptoms is that her patient is an asthma sufferer. • The scientist observes the test tube and sees the chemical turn purple. She abduces that either there is potassium in the sample or her colleague is playing yet another prank on her. JPN, UiA

  16. Different Types of Reasoning • Inductive reasoning • Deductive reasoning • Abductive reasoning Why rules? The Semantic Web Rule Language (SWRL) SWRL Types of Atoms SWRL Example SWRL Exercise Agenda

  17. In some cases we need bothStructure and Rules JPN, UiA

  18. Example of rule using TheSemantic Web Rule Language (SWRL): hasParent(?x,?parent) ∧ hasBrother(?parent,?uncle) ⇒ hasUncle(?x,?uncle) • Some statements cannot be expressed in OWL. • Modeling constructs of OWL not always adequate or most desirable. Knowledge Representation, Part II, JPN, UiA

  19. Different Types of Reasoning • Inductive reasoning • Deductive reasoning • Abductive reasoning Why rules? The Semantic Web Rule Language (SWRL) SWRL Types of Atoms SWRL Example SWRL Exercise Agenda

  20. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ • The Semantic Web Rule Language (SWRL) • An expressive OWL-based rule language. • SWRL allows users to write rules that can be expressed in terms of OWL concepts to provide more powerful deductive reasoning capabilities than OWL alone. JPN, UiA

  21. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ SWRL Rule • head • body • atom ^ atom .... → atom ^ atom body and head consist of positive conjunctions of atoms(only AND between atoms) Atom • p(arg1, arg2, ... argn) • pis a predicate symbol; arg1, arg2, ..., argn are the terms of the expression. JPN, UiA

  22. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ All variables in SWRL are treated as universally quantified (), with their scope limited to a given rule. E.g., given: hasParent(?x,?parent) ∧ hasBrother(?parent,?uncle) ⇒ hasUncle(?x,?uncle) This rule applies for all ?x, all ?parent and all ?uncle. JPN, UiA

  23. Different Types of Reasoning • Inductive reasoning • Deductive reasoning • Abductive reasoning Why rules? The Semantic Web Rule Language (SWRL) SWRL Types of Atoms SWRL Example SWRL Exercise Agenda

  24. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ • SWRL provides seven types of atoms: • Class Atoms • Individual Property atoms • Data Valued Property atoms • Different Individuals atoms • Same Individual atoms • Built-in atoms • Data Range atoms JPN, UiA

  25. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ Class AtomOWL named class or class expression and a single argument representing an OWL individual Examples: Person(?p) Man(Fred) Man(?p) -> Person(?p) JPN, UiA

  26. Example of Class Expression (hasChild >= 1)(?x) -> Parent(?x) JPN, UiA

  27. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ Individual Property Atom OWL object property and two arguments representing OWL individuals. Examples: hasBrother(?x, ?y)hasSibling(Fred, ?y) Person(?p) ^ hasSibling(?p,?s) ^ Man(?s) -> hasBrother(?p,?s) JPN, UiA

  28. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ Data Valued Property OWL data property and two arguments, the first representing an OWL individual, and the second a data value. Examples: hasAge(?x, ?age)hasHeight(Fred, ?h) hasAge(?x, 232) hasName(?x, "Fred") Person(?p) ^ hasCar(?p, true) -> Driver(?p) Person(Fred) ^ hasCar(Fred, true) -> Driver(Fred) JPN, UiA

  29. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ Different Individuals Atom Arguments representing OWL individuals. Examples: differentFrom(?x, ?y)differentFrom(Fred, Joe) Same Individual Atom Arguments representing OWL individuals. Examples: sameAs(?x, ?y) sameAs(Fred, Freddy) JPN, UiA

  30. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ Data Range Atom A datatype name or a set of literals and a single argument representing a data value. Examples: xsd:int(?x) [3, 4, 5](?x) ?x is a variable representing a data value. JPN, UiA

  31. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ Built-In Atom SWRL support user-defined built-ins. A built-in is a predicate that takes one or more arguments and evaluates to true if the arguments satisfy the predicate. SWRL contained many built-ins. Example - Person with an age of greater than 17 is an adult is:: Person(?p) ^ hasAge(?p, ?age) ^ swrlb:greaterThan(?age, 17) -> Adult(?p) (swrlb is a namespace) JPN, UiA

  32. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ A rule that uses a core SWRL string built-in to determine if a person's telephone number starts with the international access code "+" can be written as follows: Person(?p) ^ hasNumber(?p, ?number) ^ swrlb:startsWith(?number, "+") hasInternationalNumber(?p, true) JPN, UiA

  33. Ref.: https://github.com/protegeproject/swrlapi/wiki/SWRLLanguageFAQ • Rectangle(?r) ^ • hasWidthInMeters(?r, ?w) ^ • hasHeightInMeters(?r, ?h) ^ • swrlb:multiply(?areaInSquareMeters, ?w, ?h) •  • hasAreaInSquareMeters(?r, ?areaInSquareMeters) JPN, UiA

  34. Different Types of Reasoning • Inductive reasoning • Deductive reasoning • Abductive reasoning Why rules? The Semantic Web Rule Language (SWRL) SWRL Types of Atoms SWRL Example SWRL Exercise Agenda

  35. DL and SWRL has a big overlap Example:If a person is the author of a book then she is a (member of the class) book author. First Order Predicate Logic: ∀x.Person(x) ∧ ∃y.authorOf(x,y) ∧ Book(y) →Bookauthor(x) Description Logic: Person andauthorOfsome Book SWRL: Person(?x) ^ authorOf(?x, ?y) ^Book(?y) -> BookAuthor(?x) JPN, UiA

  36. Examplein Protégé JPN, UiA

  37. :authorOfrdf:typeowl:ObjectProperty . :Book rdf:typeowl:Class . :Person rdf:typeowl:Class . :BookAuthorrdf:typeowl:Class ; owl:equivalentClass [ owl:intersectionOf ( :Person [ rdf:typeowl:Restriction ; owl:onProperty :authorOf ; owl:someValuesFrom :Book ] ) ; rdf:typeowl:Class ] . :aDollsHouserdf:typeowl:NamedIndividual , :Book . :ibsenrdf:typeowl:NamedIndividual , :Person ; :authorOf :aDollsHouse , :peerGynt . :notAnAuthorPersonrdf:typeowl:NamedIndividual , :Person . :peerGyntrdf:typeowl:NamedIndividual , :Book . Ontology Used JPN, UiA

  38. DL reasoner infer that ibsen is a book author JPN, UiA

  39. Make SWRL rule in Protégé JPN, UiA

  40. JPN, UiA

  41. Transfer SWRL rule to rule engine Afterpressing JPN, UiA

  42. Run SWRL rule JPN, UiA

  43. See result of reasoning JPN, UiA

  44. Result of SWRL reasoning JPN, UiA

  45. Different Types of Reasoning • Inductive reasoning • Deductive reasoning • Abductive reasoning Why rules? The Semantic Web Rule Language (SWRL) SWRL Types of Atoms SWRL Example SWRL Exercise Agenda

  46. @prefix : <http://www.uia.no/veggi#> . @prefixowl: <http://www.w3.org/2002/07/owl#> . @prefixrdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefixxml: <http://www.w3.org/XML/1998/namespace> . @prefixxsd: <http://www.w3.org/2001/XMLSchema#> . @prefixrdfs: <http://www.w3.org/2000/01/rdf-schema#> . @base <http://www.uia.no/veggi> . <http://www.uia.no/veggi> rdf:typeowl:Ontology . ################################################################# # Object Properties ################################################################# ### http://www.uia.no/veggi#contains :containsrdf:typeowl:ObjectProperty . ### http://www.uia.no/veggi#dislikes :dislikesrdf:typeowl:ObjectProperty . ### http://www.uia.no/veggi#ordered :orderedrdf:typeowl:ObjectProperty . ################################################################# # Classes ################################################################# ### http://www.uia.no/veggi#BakedSalmon :BakedSalmonrdf:typeowl:Class ; rdfs:subClassOf :Dish , [ rdf:typeowl:Restriction ; owl:onProperty :contains ; owl:someValuesFrom :SalmonProduct ] . ### http://www.uia.no/veggi#Chickpeas :Chickpeasrdf:typeowl:Class ; rdfs:subClassOf :VeggiProduct . ### http://www.uia.no/veggi#Dish :Dishrdf:typeowl:Class . ### http://www.uia.no/veggi#Falafel :Falafelrdf:typeowl:Class ; rdfs:subClassOf :Dish , [ rdf:typeowl:Restriction ; owl:onProperty :contains ; owl:someValuesFrom :Chickpeas ] . ### http://www.uia.no/veggi#FishProduct :FishProductrdf:typeowl:Class ; rdfs:subClassOf :Product . ### http://www.uia.no/veggi#Person :Person rdf:typeowl:Class . ### http://www.uia.no/veggi#Product :Product rdf:typeowl:Class . ### http://www.uia.no/veggi#SalmonProduct :SalmonProductrdf:typeowl:Class ; rdfs:subClassOf :FishProduct . ### http://www.uia.no/veggi#Unhappy :Unhappyrdf:typeowl:Class . ### http://www.uia.no/veggi#Vegetarian :Vegetarianrdf:typeowl:Class . ### http://www.uia.no/veggi#VeggiProduct :VeggiProductrdf:typeowl:Class ; rdfs:subClassOf :Product . ################################################################# # Individuals ################################################################# ### http://www.uia.no/veggi#chickpeas1 :chickpeas1 rdf:typeowl:NamedIndividual , :Chickpeas . ### http://www.uia.no/veggi#dish1BakedSalmon :dish1BakedSalmon rdf:typeowl:NamedIndividual , :BakedSalmon ; :contains :salmon1 . ### http://www.uia.no/veggi#disk2BakedSalmon :disk2BakedSalmon rdf:typeowl:NamedIndividual , :BakedSalmon ; :contains :salmon2 . ### http://www.uia.no/veggi#disk3Falafel :disk3Falafel rdf:typeowl:NamedIndividual , :Falafel ; :contains :chickpeas1 . ### http://www.uia.no/veggi#janeNotVeggi :janeNotVeggirdf:typeowl:NamedIndividual , :Person ; :ordered :dish1BakedSalmon . ### http://www.uia.no/veggi#salmon1 :salmon1 rdf:typeowl:NamedIndividual , :SalmonProduct . ### http://www.uia.no/veggi#salmon2 :salmon2 rdf:typeowl:NamedIndividual , :SalmonProduct . ### http://www.uia.no/veggi#tomVeggi :tomVeggirdf:typeowl:NamedIndividual , :Person , :Vegetarian ; :ordered :disk2BakedSalmon , :disk3Falafel . ### Generated by the OWL API (version 4.2.5.20160517-0735) https://github.com/owlcs/owlapi Exercise this ontology is given JPN, UiA

  47. Ontology loaded into Protégé JPN, UiA

  48. JPN, UiA

  49. JPN, UiA

  50. JPN, UiA

More Related