===== Before the Lab ===== Read: * [[http://www.cs.uu.nl/docs/vakken/smw/lectures/Reasoning%20on%20the%20Web.pdf|Reasoning on the Web]] * [[http://www.inf.unibz.it/~debruijn/teaching/swt/lecture-6-handouts.pdf|OWL vs. RDF, DL, DL rules, DLP]] * {{:pl:dydaktyka:piw:2010:sw:rulesonthesw-2009-tutorial2.pdf|Rules on the Semantic Web}} Reasoning on the Web - summary: * queries * SPARQL (see [[.:rdf2|RDF lab]]) * DL reasoning * more powerful than querying, DL reasoning tasks * example reasoner: http://clarkparsia.com/pellet/, demo: http://pellet.owldl.com/owlsight/ * rules over ontologies * [[http://ruleml.org/|RuleML]], [[http://www.w3.org/2005/rules/wiki/RIF_Working_Group|RIF]] - rule interchange formats * [[http://www.w3.org/Submission/SWRL/|SWRL]] Semantic Web Rule Language based on OWL * [[http://www.w3.org/TR/owl2-profiles/#OWL_2_RL|OWL 2 RL]] - new version of OWL, additional constructs for expressing rules in the ontology ===== Lab instruction ===== ==== DL Reasoning ==== * Analyze the [[http://owl.man.ac.uk/2003/why/latest/|reasoning examples in OWL DL]] * Use the [[http://www.co-ode.org/downloads/pizzafinder/|Manchester Pizza Finder]] to see the results of implementing your ontology from the [[.:owl|previous lab]] * Browse sample ontologies with [[http://pellet.owldl.com/owlsight/|OwlSight]] (using Pellet as a DL reasoner) * Find all inconsistencies of the example ontologies. * Read the explanations of the inconsistencies - how could one repair the ontologies? ==== SWRL ==== In this exercise we will use Protege editor with the [[http://protege.cim3.net/cgi-bin/wiki.pl?SWRLTab|SWRLTab plugin]]. Depending on the configurations, Pellet/Jess may be used to execute SWRL rules. === Family rules === - Read {{:prv:tasks:newsemweblabs:reasoning:swrl2009protegeconference.pdf|about SWRLTab in Protege}} - Download [[http://swrl.stanford.edu/ontologies/examples/family.swrl.owl|family ontology with rules]]. - Open it in Protege (run ''protege3''), in SWRLTab analyze the rules. Click on **J** button to enable Jess rule engine. Run the rules iteratively. Check the inferred axioms. === Implementing SWRL === - Open Protege editor and enable SWRL Tab (Project->Configure in Protege 3.4.4) - Implement an example [[https://ai.ia.agh.edu.pl/wiki/_media/pl:prolog:prolog_lab:animal_kb.pl?id=pl%3Aprolog%3Aprolog_lab%3Aprolog_lab_metaprog&cache=cache|expert system]] - an expert system for recognizing animals: - define Classes used in the system (look for ''isa'' predicate): Mammal, Bird, Carnivore, etc. - define characteristics of the animals (There Is More Than One Way To Do It!) * as Properties, e.g.: has * as Classes, e.g. Swims - Make assertions about individuals, e.g. has(dennis,hair). parent(dennis,diana). Swims(denzel). - Define rules of the system - Express the initial data as appropriate assertions - Run Pellet/Jess to execute the rules. Observe the inferred facts. Execute the rule engine iteratively, till no more information can be concluded. -**extra task**: add more rules to the system, use built-in SWRL predicates. ===Examples=== rule id1: [1: has(X,hair)] ==> [assert(isa(X,mammal)), retract(all)]. has(?x,"hair") -> Mammal(?x) rule id4: [1: flies(X), 2: lays_eggs(X)] ==> [assert(isa(X,bird)), retract(all)]. Flies(?x) ∧ Lays_eggs(?x) -> Bird(?x) ===Initial data=== initial_data([ has(dennis,hair), has(dennis,hoofs), has(dennis,black_stripes), parent(dennis,diana) ]). ==== Rules in OWL2RL ==== Read: [[http://www.semantic-web-book.org/page/KI_2009_Tutorial|OWL 2 and Rules]] slides Control questions: * How to express rules using ''owl:subClass'' relationships? * what is a property chain axiom? - Run Protege, version 4: ''protege4'' - Create a new ontology in Protege - Model the family ontology with rules using OWL 2 constructs ([[http://www.semantic-web-book.org/page/ESWC09_Tutorial|See OWL2 tutorials]]) - **extra task**: if there is enough time, model the animals expert system in OWL 2 RL ===== If you want to know more ===== Further reading: * [[http://www.debruijn.net/publications/deri-tr-2006-06-03.pdf|Logics for the Semantic Web]] - FOL, DL, LP & F-logic Test cases for OWL2 (incl.OWL2RL): * http://www.w3.org/2007/OWL/wiki/Test_Suite_Status ===== Komentarze ===== Z braku lepszego miejsca tutaj studenci wpisują komentarze natury ogólnej do tego lab. 8-) Za dużo materiału do przerobienia. Gdy wybiła godzina końca zajęć, ja dotarłem do Family Rules (podpunkt 3), czytając wcześniej jedynie Reasoning Examples in OWL DL (co zajęło ponad 45 minut).