Reasoning on the Semantic Web
Before the lab
Software:
-
Snoggle - A Graphical, SWRL-based Ontology Mapper
Introduction
Lab instructions
1 OWL Reasoning - Class Inference
Model the following ontology axioms in Protege:
Class: bus_driver
EquivalentTo:
person
that drives some bus
Class: driver
EquivalentTo:
person
that drives some vehicle
Class: bus
SubClassOf:
vehicle
Hints:
To build the first axiom:
Create appropriate classes
and ObjectProperties:
Define the BusDriver class with
Equivalent classes
button
![](/_media/pl:dydaktyka:semantic_web:protege-reasoning3.png?w=200&tok=07957e)
Build the second axiom analogously:
Build the third axiom using the
Superclasses
button:
Start the reasoner (
Reasoner → start reasoner
) and observe the inferred class hierarchy. What conclusions have been drawn?
![8-)](/lib/images/smileys/icon_cool.gif)
Include the modified ontology in the report.
![8-)](/lib/images/smileys/icon_cool.gif)
Explain the inferred relations and conclusions.
Analyze the reasoning examples given
here in „Class Inferences” section.
2 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
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:
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
For those not familiar with UK culture, White Van Man is a stereotype used to describe a particular kind of driver. Wikipedia provides an entry with some additional information and references.
Hints:
Create appropriate instances in
Individuals
tab
![](/_media/pl:dydaktyka:semantic_web:protege-reasoning7.png?w=200&tok=88c802)
If the instance is of 2 types, create it only once and then add the second type:
![](/_media/pl:dydaktyka:semantic_web:protege-reasoning8.png?w=200&tok=ff50eb)
Add object properties to connect individuals:
![](/_media/pl:dydaktyka:semantic_web:protege-reasoning9.png?w=200&tok=873ba2)
Define the class:
![](/_media/pl:dydaktyka:semantic_web:protege-reasoning10.png?w=200&tok=3c9df3)
Start the reasoner (Reasoner → start reasoner
) and observe the inferred class hierarchy. What conclusions have been drawn?
![8-)](/lib/images/smileys/icon_cool.gif)
Include the modified ontology in the report.
![8-)](/lib/images/smileys/icon_cool.gif)
Explain the inferred relations and conclusions.
Analyze the reasoning examples given
here in „Instance Inferences” section.
3 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 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:
-
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-)](/lib/images/smileys/icon_cool.gif)
What are the results? Write them down or provide a screenshot of the answer in the report.
4 Forward-chaining vs. Backward-chaining Inference
A quick reminder
How about the Semantic Web?
As given in 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.
5 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)
SWRL is a rule language based on OWL using a subset of RuleML rules modeled on Horn clauses.
SWRL is undecidable in a general case. There are various subsets of SWRL defined to regain tractability.
-
Open it in Protege.
Enable the rule view (
Window → Views → Ontology views → Rules
) and read the SWRL rules.
![](/_media/pl:dydaktyka:semantic_web:protege-swrl.png?w=400&tok=3c240d)
![8-)](/lib/images/smileys/icon_cool.gif)
Propose an application that would use this or similar set of rules. Describe the system in a few sentences.
6 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 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.
java -jar /usr/local/snoggle/snoggle.jar
Load two ontologies (people+pets
and foaf
):
-
-
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]
![](/_media/pl:dydaktyka:semantic_web:snoggle.png?w=400&tok=7731b5)
See the generated SWRL rules (File → Preview
).
![8-)](/lib/images/smileys/icon_cool.gif)
Save the file and put it in the report archive.
If you want to know more