Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed Nov 15, 2010
1 parent 5ffcda3 commit 53ec09b
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 119 deletions.
136 changes: 50 additions & 86 deletions README
@@ -1,7 +1,5 @@
---+ Thea2 : Prolog Modules for OWL2

%TOC%

A collection of modules for parsing and manipulating OWL2 ontologies
in Prolog. It is developed with SWI-Prolog in mind, but the goal is to
maximize portability with other prologs, such as Yap and XSB.
Expand All @@ -14,43 +12,66 @@ See INSTALL.txt

---++ Overview

The model is based on Structural Specification and Functional-Style
Syntax for OWL2 (http://www.w3.org/TR/owl2-syntax), and can be found
in owl2_model.pl
The module owl2_io.pl provides a means of loading and saving OWL2
axioms in a prolog model using predicates such as load_axioms/3 and
save_axioms/3. For example =|load_axioms('pizza.owl').|=

Predicates such as subClassOf/2 can be used to query in-memory axioms
The model is documented in owl2_model.pl, and is based on Structural
Specification and Functional-Style Syntax for OWL2
(http://www.w3.org/TR/owl2-syntax). Predicate names such as
subClassOf2/, equivalent_to/2 and class/1 can be used to query an
in-memory prolog database.

There are a variety of surface forms for OWL2. The goal is to
eventually support all of these for both parsing and writing. So far
we have parsers and writers for:
For example:

* RDF - owl2_from_rdf.pl
* OWL-XML - owl2_xml.pl
==
:- use_module(library(thea2/owl2_io)).
:- use_module(library(thea2/owl2_model)).

We also allow for reading and writing from prolog factfiles.
show_superclasses(OntFile,Class) :-
load_axioms(OntFile),
forall(subClassOf(Class,Super),
writeln(Super)).
==

The module owl2_io.pl is used for reading and writing other formats
and languages. For example:
The database can be manipulated via assert_axiom/2 and
retract_axiom/2. For more advanced OWL pattern matching and
replacement, see owl2_popl.pl

==
swipl -g "[library('thea2/owl2_io')],load_axioms('testfiles/wine.owl',owl)"
==
The Semantic Web Rule Language (SWRL) is also supported via swrl.pl

A number of different reasoners can be used - the module
owl2_reasoner.pl provides predicates such as reasoner_ask/2, which can
be used to query over an entailed knowledge base. A variety of
reasoners can be plugged in, both native prolog and non-prolog (the
latter accessed seamlessly via either owl2_owllink.pl or
owl2_java_owlapi.pl).

See

* Cookbook.txt
---++ Further Reading

For some handy recipes
* Cookbook.txt - a collection of recipes for various tasks
* Reasoning_using_Thea.txt - how to use reasoners

---++ SWRL support
See also the apps/ directory for example applications.

The module swrl.pl provides support for the Semantic Web Rules Language
---++ Module Manifest

SWRL rules are treated as axioms, extending owl2_model.pl
* owl2_io.pl -- reading/writing OWL from different sources, including:
* owl2_from_rdf.pl -- requires library(semweb)
* owl2_export_rdf.pl -- requires library(semweb)
* owl2_xml.pl -- support for OWL-XML
* owl2_manchester_paser.pl -- incomplete support for Manchester syntax
* owl2_plsyn.pl -- infix prolog syntax for OWL
* owl2_model.pl
* swrl.pl
* owl2_model.pl
* owl2_reasoner.pl
* owl2_rl_rules.pl
* owl2_graph_reasoner.pl
* owl2_java_owlapi.pl (requires JPL)
* owl2_owllink.pl

In addition, we allow for representation of rules as prolog terms and
prolog programs - there is a partial converter from prolog programs to
OWL2+SWRL

---++ Reasoning support

Expand All @@ -73,13 +94,6 @@ owl2_owlapi_java.pl

For more information see Reasoning_using_Thea.txt

---++ Utilities

Currently the owl2_util.pl is a grab-bag of ad-hoc utility
predicates. Browse this to get an idea of some of the capabilities.

For example, one useful predicate is use_labels_for_IRIs/0

---++ Relationship to SWI-Prolog SemWeb Library

Currently we use rdf_db.pl to translate from OWL RDF-XML to OWL
Expand All @@ -88,7 +102,7 @@ would like a dynamic view over an RDF database, although this will be
difficult due to the non-monotonic nature of the mapping between RDF
and OWL.

---++ On namespaces
---+++ On namespaces

Currently all IRIs are treated as Prolog atoms. This makes for
slightly verbose axioms, especially if long URLs are used.
Expand All @@ -104,56 +118,7 @@ be used, Thea allows you to use any unique atom to identify an
entity. See remove_namespaces/0 in owl2_util.pl for details. Of course,
care must be taken when doing this.

---++ Optional Extras

The core modules are

* owl2_model.pl -- for representing and manipulating axioms and expressions in OWL ontologies
* owl2_io.pl -- for reading/writing axioms

However, there are various additional modules that are not required
but may be useful for specific purposes. Here is an overview of what
is currently distributed (some of these may move to separate
distributions):


---+++ Integration with other LP systems

Pure prolog, disjunctive datalog, description logics etc are all
related families of languages constituting some subset of first-order
logic. Each offers its own inference procedures including the prolog
WAM, SLG resolution, DL reasoners, ILP etc. Navigating this territory
can be difficult due to a lack of standards. Thea aims to make this
easier.

See Cookbook.txt for some recipes

---+++ Integration with exteral tools

---++++ OWLAPI

If you have JPL installed you can use a bridge module to access
all the capabilities of the OWLAPI. This includes reasoners such as
Pellet and FaCT++.

* owl2_java_owlapi.pl

Requires JPL

---++++ OWLGRES

Owlgres is an open source, database-backed scalable reasoner for
OWL2.

* owl2_sqlmap_owlgres.pl - allows ABox axiom predicates to be mapped
to an OWLGRES database

Requirements:

* ODBC
* sql_compiler.pro (currently distributed as part of blipkit)

---++ Compatibility
---++ Prolog Compatibility

The goal is to keep the core ISO compliant and usable across prolog
systems but this is difficult due to the different implementations of
Expand Down Expand Up @@ -185,7 +150,6 @@ There is the beginnings of a primitive web front end:

* apps/mireot/mireot.pl


---++ Authors

This module is a continuation of Thea1, developed by VV.
Expand All @@ -194,4 +158,4 @@ Some of the code was developed by CJM

Contributions from:

* Martin Günther
* Martin Güther
2 changes: 1 addition & 1 deletion Reasoning_using_Thea.txt
Expand Up @@ -104,7 +104,7 @@ has backwards chaining rules. Caveat emptor: this module is
experimental, liable to change and could be non-terminating. See the
module docs for details.

[VV] Another implementation is provided in owl2_rl_rules.pl. The module
Another implementation is provided in owl2_rl_rules.pl. The module
implements OWL RL Rules with simple forward and backward chaining engines
See more in module documentation

Expand Down
45 changes: 29 additions & 16 deletions owl2_model.pl
Expand Up @@ -106,6 +106,7 @@
assert_axiom/1,
assert_axiom/2,
retract_axiom/1,
retract_axiom/2,
retract_all_axioms/0,
owl2_model_init/0,
consult_axioms/1,
Expand Down Expand Up @@ -324,6 +325,7 @@
axiom_arguments(propertyAxiom,[axiom]).
valid_axiom(propertyAxiom(A)) :- subsumed_by([A],[axiom]).


%% subPropertyOf(?Sub:PropertyExpression, ?Super:ObjectPropertyExpression)
% subproperty axioms are analogous to subclass axioms
% (extensional predicate - can be asserted)
Expand Down Expand Up @@ -1183,6 +1185,17 @@
retractall(ontologyAxiom(_,Axiom)),
!.

%% retract_axiom(+Axiom:axiom,+Ontology)
% retracts axioms from a specified ontology
retract_axiom(Axiom,Ontology) :-
\+ var(Ontology),
retractall(ontologyAxiom(Ontology,Axiom)),
( \+ \+ ontologyAxiom(_,Axiom)
-> retractall(Axiom)
; true), % still exists in other ontology..
!.


retract_all_axioms :-
findall(A,axiom(A),Axioms),
maplist(retract,Axioms),
Expand Down Expand Up @@ -1215,6 +1228,18 @@
disjointClasses([herbivore,carnivore]).
==
Example of use:
==
:- use_module(library(thea2/owl2_io)).
:- use_module(library(thea2/owl2_model)).
show_superclasses(OntFile,Class) :-
load_axioms(OntFile),
forall(subClassOf(Class,Super),
writeln(Super)).
==
---+ Details
This module is a prolog model of the OWL2 language. It consists of predicates for both OWL2 axioms and expressions.
Expand Down Expand Up @@ -1276,16 +1301,6 @@
axiomAnnotation(SubClassOf(cat,mammal),author,linnaeus).
==
---+++ Punning
OWL2 allows classes to act as individuals, so this is legal (TODO: check!):
==
class(polarBear).
class(endangered).
classAssertion(endangered,polarBear).
==
---++ Ontologies
Expand All @@ -1303,14 +1318,12 @@
By default there is no type checking of IRIs, so =|class(polarBear)|=
is allowed, even though "polarBear" is not an IRI - this makes for
convenience in working with example ontologies
---+ Open Issues
convenience in working with example ontologies.
---++ Structure Sharing
See prefix_IRIs/1 in owl2_util.pl for converting between short names
and valid IRIs.
Should we allow bnode IDs as arguments of predicate axioms for
expressions? I don't think this is necessary.
---+ Open Issues
---++ Enumeration of expressions
Expand Down
28 changes: 12 additions & 16 deletions swrl.pl
Expand Up @@ -116,8 +116,8 @@
normalize_swrl_atom(A, A).


%% swrl_to_owl_axioms(+SWRLRule,?Axioms) is semidet
% true if SWRLRule can be translated into Axiom.
%% swrl_to_owl_axioms(+SWRLRule,?OWLAxioms) is semidet
% true if SWRLRule can be translated into OWLAxiom.
%
% a subset of OWL-DL can be recapitulated as rules; however, it
% if often best to treat these rules as OWL Axioms if an OWL
Expand All @@ -128,8 +128,8 @@
% * subClassOf/2 between a class and an intersectionOf class description
% * subPropertyOf/2 between property IDs
% * subPropertyOf/2 involving role chains
% * classAssertion/1 based on antecedent-free rules
% * propertyAssertion/1 based on antecedent-free rules
% * classAssertion/2 based on antecedent-free rules
% * propertyAssertion/3 based on antecedent-free rules
swrl_to_owl_axioms(Rule, Axioms) :-
normalize_swrl_rule(Rule,implies(A,Cs)),
findall(Axiom,
Expand Down Expand Up @@ -273,12 +273,13 @@

%% prolog_clause_to_swrl_rule( +Term, ?SWRLAtom:swrlAtom )
%
% Prolog Terms are clauses of the form
% Prolog clause terms are clauses of the form
%==
% hasUncle(X1,X3):- hasParent(X1,X2),hasBrother(X2,X3)
%==
%
% These are translated to SWRL Rules
% Are translated to embedded swrl.pl rule terms, using
% the implies/2 functor.
%
% complex atoms still require wrapping:
%==
Expand Down Expand Up @@ -449,26 +450,21 @@
---+ Synopsis
Example SWRL Rule set in prolog:
Example SWRL Rule embedded as prolog swrl.pl fact:
==
implies([hasParent(v(x),v(y)),hasBrother(v(y),v(z))],[hasUncle(v(x),v(z))]).
==
---+ Details
This extends the owl2_model.pl collection of allowed axioms (see axiom/1) with the implies/2 axiom.
This extends the owl2_model.pl collection of allowed axioms (see axiom/1) with the implies/2 axiom.
http://www.w3.org/Submission/SWRL/
This module also intends to allow for easy conversion between a natural prolog style and SWRL axioms.
See for example prolog_clause_to_swrl_rule/2
---+ Additional Information
@author Chris Mungall
@version $Revision$
@see README
@license License
See for example prolog_clause_to_swrl_rule/2
*/

0 comments on commit 53ec09b

Please sign in to comment.