Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

pl:dydaktyka:semweb:reasoning [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +====== Reasoning on the Semantic Web ======
 +===== Before the lab =====
  
 +Software:
 +  * [[http://​protege.stanford.edu/​|Protege]] Ontology Editor
 +  * [[http://​snoggle.semwebcentral.org/​|Snoggle]] - A Graphical, SWRL-based Ontology Mapper
 +
 +===== Introduction =====
 +Lecture:
 +  * [[http://​home.agh.edu.pl/​~wta/​semweb/​geist-semweb-reasoning.pdf|Semantic Web: 5 - Reasoning, Logic and Rules]]
 +
 +===== Lab instructions =====
 +==== - OWL Reasoning - Class Inference ====
 +  * In Description Logics on which the OWL language is based there are the following reasoning tasks for classes (terminology,​ TBox):
 +    - Class subsumption (Structuring the knowledge base)
 +    - Class equivalence (Are two classes in fact the same class?)
 +    - Class disjointness (Do classes A and B common members?)
 +    - Class consistency (Isn't class A empty?)
 +
 +  - Model the following ontology axioms in Protege:<​code>​
 +Class: bus_driver
 +    EquivalentTo: ​
 +        person
 +        that drives some bus
 +
 +Class: driver
 +    EquivalentTo: ​
 +        person
 +        that drives some vehicle
 +
 +Class: bus
 +    SubClassOf: ​
 +        vehicle
 +</​code>​ \\ Hints:
 +    - To build the first axiom: ​
 +      - Create appropriate classes \\ {{:​pl:​dydaktyka:​semantic_web:​protege-reasoning1.png?​w200|}} \\
 +      - and ObjectProperties:​ \\ {{:​pl:​dydaktyka:​semantic_web:​protege-reasoning2.png?​w200|}} \\
 +      - Define the BusDriver class with ''​Equivalent classes''​ button \\ {{:​pl:​dydaktyka:​semantic_web:​protege-reasoning3.png?​w200|}}
 +    - Build the second axiom analogously:​ \\ {{:​pl:​dydaktyka:​semantic_web:​protege-reasoning4.png?​w200|}} \\
 +    - Build the third axiom using the ''​Superclasses''​ button: \\ {{:​pl:​dydaktyka:​semantic_web:​protege-reasoning5.png?​w200|}} \\
 +  - Start the reasoner (''​Reasoner -> start reasoner''​) and observe the inferred class hierarchy. What conclusions have been drawn? \\ {{:​pl:​dydaktyka:​semantic_web:​protege-reasoning6.png?​w200|}} \\
 +    - 8-) Include the modified ontology in the report.
 +    - 8-) Explain the inferred relations and conclusions.
 +  - Analyze the reasoning examples given [[http://​mowl-power.cs.man.ac.uk/​2009/​07/​sssw/​people.html#​people-class|here]] in "Class Inferences"​ section.
 +
 +==== - OWL Reasoning - Instance Inferences ====
 +  * In Description Logics on which the OWL language is based there are the following reasoning tasks for instances (world description,​ ABox):
 +    - Class membership (is instance //a// contained in class //C//?)
 +    - Instance retrieval (find all (known) individuals belonging to a given class)
 +  * and for the whole Knowledge Base (ABox+TBox):​
 +    - Global consistency of a knowledge base (Is the knowledge base meaningful?​)
 +
 +  - Download the {{:​pl:​dydaktyka:​semantic_web:​people-prep.owl|pre-prepared ontology}} and load it in Protege (**NB:** the ontology classes and those on screenshots may differ a little).
 +  - Model the following ontology axioms in Protege:<​code>​
 +Individual: Daily_Mirror
 +    Types: ​
 +        owl:Thing
 +
 +Individual: Q123ABC
 +    Types: ​
 +        van,
 +        white_thing
 +
 +Individual: Mick
 +    Types: ​
 +        male
 +    Facts: ​
 +        reads  Daily_Mirror,​
 +        drives ​ Q123ABC
 +
 +Class: white_van_man
 +    EquivalentTo: ​
 +        man
 +        that drives some (van
 +        and white_thing)
 +    SubClassOf: ​
 +        reads only tabloid
 +</​code>​ \\ //For those not familiar with UK culture, White Van Man is a stereotype used to describe a particular kind of driver. [[http://​en.wikipedia.org/​wiki/​White_van_man|Wikipedia]] provides an entry with some additional information and references.//​ \\ Hints:
 +    - Create appropriate instances in ''​Individuals''​ tab \\ {{:​pl:​dydaktyka:​semantic_web:​protege-reasoning7.png?​w200|}}
 +    - If the instance is of 2 types, create it only once and then add the second type: \\ {{:​pl:​dydaktyka:​semantic_web:​protege-reasoning8.png?​w200|}}
 +    - Add object properties to connect individuals:​ \\ {{:​pl:​dydaktyka:​semantic_web:​protege-reasoning9.png?​w200|}}
 +    - Define the class: \\ {{:​pl:​dydaktyka:​semantic_web:​protege-reasoning10.png?​w200|}}
 +  - Start the reasoner (''​Reasoner -> start reasoner''​) and observe the inferred class hierarchy. What conclusions have been drawn? ​
 +    - 8-) Include the modified ontology in the report.
 +    - 8-) Explain the inferred relations and conclusions.
 +  - Analyze the reasoning examples given [[http://​mowl-power.cs.man.ac.uk/​2009/​07/​sssw/​people.html#​people-instance|here]] in "​Instance Inferences"​ section.
 +
 +==== - OWL Reasoning - Reasoners ====
 +DL reasoners may be integrated with other tools - as in the case of Protege presented before - as well as run independently via various interfaces. Popular DL reasoners include: FaCT++, Pellet, HermiT, RacerPro and many others.
 +
 +We will use the [[http://​clarkparsia.com/​pellet/​download|Pellet]] reasoner.
 +  - On charon: enter ''/​usr/​local/​pellet/''​.
 +  - Run ''​pellet.sh help''​ to get familiar with available commands.
 +  - Try ''​pellet.sh consistency <​ontology>''​ where the ''<​ontology>''​ is:
 +    - Your ontology from [[.:​new-semweb-owl|previous lab]]
 +    - ''​people+pets.owl''​ ontology provided with Pellet in ''​examples/​data/''​ directory \\ and observe the results. ​
 +  - Try ''​pellet.sh classify <​ontology>''​ with the two above mentioned ontologies and observe the results.
 +    - 8-) What are the results? Write them down or provide a screenshot of the answer in the report.
 +
 +==== - Forward-chaining vs. Backward-chaining Inference ====
 +=== A quick reminder ===
 +
 +As given in [[http://​www.cs.bham.ac.uk/​~mmk/​Teaching/​AI/​l2.html|Introduction to AI]] [[http://​www.cs.bham.ac.uk/​~mmk/​|Dr Manfred Kerber]]'​s course: ((
 +
 +See also: 
 +  * [[http://​intsys.mgt.qub.ac.uk/​notes/​kreprule.html#​2.4|Rules]] (//from an Intelligent Systems course//)
 +))
 +  * //Forward chaining// or //​data-driven//​ inference works from an initial state, and by looking at the premises of the rules (IF-part), perform the actions (THEN-part),​ possibly updating the knowledge base or working memory. This continues until no more rules can be applied or some cycle limit is met, e.g. \\ {{http://​www.cs.bham.ac.uk/​~mmk/​Teaching/​AI/​figures/​forward-rules.jpg?​w400}}
 +    * **Problem with forward chaining:** many rules may be applicable. The whole process is not directed towards a goal.
 +  * //Backward chaining// or //​goal-driven//​ inference works towards a final state, and by looking at the working memory to see if goal already there. If not look at the actions (THEN-parts) of rules that will establish goal, and set up subgoals for achieving premises of the rules (IF-part). This continues until some rule can be applied, apply to achieve goal state. \\ {{http://​www.cs.bham.ac.uk/​~mmk/​Teaching/​AI/​figures/​backward-rules.jpg?​w400}}
 +    * **Advantage of backward chaining:** search is directed
 +    * **Disadvantage of backward chaining:** goal has to be known
 +  * __Forward or Backward Reasoning?​__ - Four major factors
 +    - More possible start states or goal states? Move from smaller set of states to the larger
 +    - Has program to justify reasoning? Prefer direction that corresponds more closely to the way users think.
 +    - What kind of events triggers problem-solving?​ If it is arrival of a new fact, forward chaining makes sense. If it is a query to which a response is required, backward chaining is more natural.
 +    - In which direction is branching factor greatest? Go in direction with lower branching factor, ​
 +      - backward chaining better: \\ {{http://​www.cs.bham.ac.uk/​~mmk/​Teaching/​AI/​figures/​forward-branching.jpg?​w200}}
 +      - forward chaining better: \\ {{http://​www.cs.bham.ac.uk/​~mmk/​Teaching/​AI/​figures/​backward-branching.jpg?​w200}}
 +
 +=== How about the Semantic Web? ===
 +As given in [[http://​www.amazon.com/​dp/​047041801X?​tag=semawebprog-20&​camp=14573&​creative=327641&​linkCode=as1&​creativeASIN=047041801X&​adid=0BCWVHCAAQBZANCXVBMG&​|Semantic Web Programming]]:​
 +  * Choosing the right inference method is often a matter of assessing requirements and constraints and determining which method works best for a given application
 +  * Most frameworks provide forward-chaining knowledgebases ​
 +    * they are easier to implement,
 +    * additional requirements during insertions and removel operations are acceptable
 +    * forward chaining prioritizes query performance over insertion and removal ones - in most applications **queries** are the most common operation
 +  * Backward chaining is often desirable when ontologies are volatile or when KB modifications (incl. statement removal ) are frequent.
 +    * backward chaining may be necessary when working with distributed reasoning systems with no centralized KB -> there is no place to store new entailments,​ queries must be expanded and distributed using a backward chaining-based approach.
 +
 +
 +==== - Semantic Web Rule Languages ====
 +=== Motivation for using rules beyond ontologies ===
 +Rules are popular and intuitive knowledge representation method.
 +There are some things impossible to express with ontologies or only in a very complicated manner.
 +
 +Some reasons for rules on the Semantic Web are the following:
 +  - No support for Property composition in OWL 1 (this is partially solved in OWL 2 RL)
 +    - e.g. it was not possible to express relations as: ''​hasUncle(?​nephew , ?uncle) ← hasParent (?nephew , ?parent ) ∧ hasBrother (?parent , ?​uncle)''​
 +  - Use od Built-ins
 +    - Built-ins allow for common transformations of data (e.g. mathematical operations, conditional checks, datatype/​unit conversions)
 +  - Ontological Mediation
 +    - Mapping resources between different ontologies
 +  - Limiting Assumptions
 +    - Rules can be used to limit OWL's open world assumption or to support unique name assumption. Both CWA and UNA are often needed in various applications.
 +
 +
 +
 +
 +=== Semantic Web Rule Language (SWRL)===
 +[[http://​www.w3.org/​Submission/​SWRL/​|SWRL]] is a rule language based on OWL using a subset of [[http://​ruleml.org/​|RuleML]] rules modeled on Horn clauses.
 +SWRL is undecidable in a general case. There are various subsets of SWRL defined to regain tractability.
 +
 +  - Download and analyze the [[http://​swrl.stanford.edu/​ontologies/​examples/​family.swrl.owl|family.swrl]] ontology.
 +  - Open it in Protege.
 +  - Enable the rule view (''​Window -> Views -> Ontology views -> Rules''​) and read the SWRL rules. \\ {{:​pl:​dydaktyka:​semantic_web:​protege-swrl.png?​w400|}}
 +  - 8-) Propose an application that would use this or similar set of rules. Describe the system in a few sentences.
 +
 +==== - Mapping ontologies with SWRL Rules ====
 +Rules can be also used to align two or more ontologies. If you want to make your data compatible with ontologies used worldwide (and this way enable external tools to use your data), you may sometimes need to map the concepts of your ontology to an external one.
 +
 +An example tool supporting ontology mapping is [[http://​snoggle.semwebcentral.org/​|Snoggle]] which is "a graphical, SWRL-based ontology mapper to assist in the task of OWL ontology alignment. It allows users to visualize ontologies and then draw mappings from one to another on a graphical canvas. Users draw mappings as they see them in their head, and then Snoggle turns these mappings into SWRL/RDF or SWRL/XML for use in a knowledge base."
 +
 +Here only a small example of using Snoggle will be presented:
 +
 +  - Run Snoggle. <​code>​ java -jar /​usr/​local/​snoggle/​snoggle.jar</​code>​
 +  - Load two ontologies (''​people+pets''​ and ''​foaf''​):​
 +    - Ontology -> From Ontology -> Load Ontology: http://​www.cs.man.ac.uk/​~horrocks/​ISWC2003/​Tutorial/​people+pets.owl.rdf
 +    - Ontology -> To Ontology -> Load Ontology: http://​xmlns.com/​foaf/​spec/​index.rdf
 +  - State that //anyone who is an ''​ns0:​person''​ is also a ''​foaf:​Person''//​
 +    - Drag the ''​ns0:​person''​ item and drop it in the center canvas in the body.
 +    - Drag the ''​foaf:​Person''​ item and drop it in the center canvas in the head.
 +    - Click and drag the small square at the center of the ''​ns0:​person''​ element to the center of the ''​foaf:​Person''​ element.
 +  - Create a more complex rule: //Anyone who is a ''​ns0:​elderly''​ that ''​ns0:​has_pet''​ ''​var1''​ (Snoggle convention for referencing variables) is a ''​foaf:​Person''​ who has ''​foaf:​interest''​ in ''​var1'',​ has a ''​foaf:​nick''​ ''​PetLady''​[1a] (you can change the variable name [1b]) and has ''​foaf:​gender''​ "​Female"​ (a string) [2]// \\ {{:​pl:​dydaktyka:​semantic_web:​snoggle.png?​w400|}}
 +  - See the generated SWRL rules (''​File -> Preview''​).
 +  - 8-) Save the file and put it in the report archive.
 +
 +
 +
 +
 +
 +===== If you want to know more =====
 +Reading:
 +  * [[http://​owl.cs.manchester.ac.uk/​2009/​07/​sssw/​|OWL Reasoning Examples and Hands-On Session]]
 +  * [[http://​www.amazon.com/​dp/​047041801X?​tag=semawebprog-20&​camp=14573&​creative=327641&​linkCode=as1&​creativeASIN=047041801X&​adid=0BCWVHCAAQBZANCXVBMG&​|Semantic Web Programming]]: ​
 +    * Chapter 5: Modeling Knowledge in the Real World
 +    * Chapter 7: Adding Rules
 +  * Article (short): {{:​pl:​dydaktyka:​semantic_web:​wtf-cms.pdf|Rule Representation for the Semantic Web}} by WTF
 +  * Report (extended): {{http://​cslab.ia.agh.edu.pl/​_media/​csltr:​csltr-2-2010.pdf?​id=csltr%3Alistaraportow&​cache=cache|Overview of selected approaches to rule representation on the Semantic Web}} by WTA,​GJN,​KKR&​MNG
 +
 +Slides:
 +  * [[http://​ai.ia.agh.edu.pl/​wiki/​_media/​pl:​dydaktyka:​piw:​2010:​sw:​rulesonthesw-2009-tutorial2.pdf|Semantic Web Rule Languages]]
 +  * [[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/semweb/reasoning.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0