rdf-mt/commit

Added reasoning framework

authorJan Wielemaker
Fri Dec 13 14:33:14 2013 +0100
committerJan Wielemaker
Fri Dec 13 14:33:14 2013 +0100
commitf28d1d30a94040979ee861a6869503ae3e69e5f6
tree2afa0f65e78a0cc26c32ddebe722ad0b5bcbbb94
parent2428acec05a7c1bf3d7d2fe03f9dd79c9fdaa07e
Diff style: patch stat
diff --git a/lib/rdf_mt/mt_rdf.pl b/lib/rdf_mt/mt_rdf.pl
new file mode 100644
index 0000000..5732095
--- /dev/null
+++ b/lib/rdf_mt/mt_rdf.pl
@@ -0,0 +1,35 @@
+/*  Part of ClioPatria SeRQL and SPARQL server
+
+    Author:        Jan Wielemaker
+    E-mail:        J.Wielemaker@cs.vu.nl
+    WWW:           http://www.swi-prolog.org
+    Copyright (C): 2013, University of Amsterdam,
+		   VU University Amsterdam
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    as published by the Free Software Foundation; either version 2
+    of the License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    As a special exception, if you link this library with other files,
+    compiled with a Free Software compiler, to produce an executable, this
+    library does not by itself cause the resulting executable to be covered
+    by the GNU General Public License. This exception does not however
+    invalidate any other reasons why the executable file might be covered by
+    the GNU General Public License.
+*/
+
+:- module(mt_rdf, []).
+:- use_module(library(semweb/rdf_db)).
+
+:- multifile rdf_reasoner:entailment_module/2.
+rdf_reasoner:entailment_module(rdf, mt_rdf).
diff --git a/lib/rdf_mt/mt_rdfs.pl b/lib/rdf_mt/mt_rdfs.pl
new file mode 100644
index 0000000..9447e9e
--- /dev/null
+++ b/lib/rdf_mt/mt_rdfs.pl
@@ -0,0 +1,41 @@
+/*  Part of ClioPatria SeRQL and SPARQL server
+
+    Author:        Jan Wielemaker
+    E-mail:        J.Wielemaker@cs.vu.nl
+    WWW:           http://www.swi-prolog.org
+    Copyright (C): 2013, University of Amsterdam,
+		   VU University Amsterdam
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    as published by the Free Software Foundation; either version 2
+    of the License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    As a special exception, if you link this library with other files,
+    compiled with a Free Software compiler, to produce an executable, this
+    library does not by itself cause the resulting executable to be covered
+    by the GNU General Public License. This exception does not however
+    invalidate any other reasons why the executable file might be covered by
+    the GNU General Public License.
+*/
+
+:- module(mt_rdfs, []).
+:- use_module(library(semweb/rdf_db)).
+:- use_module(library(xmlrdf/rdf_rewrite)).
+
+:- multifile rdf_reasoner:entailment_module/2.
+rdf_reasoner:entailment_module(rdfs, mt_rdfs).
+
+transitive @@
+{ S1, rdfs:subClassOf, S2 },
+{ S2, rdfs:subClassOf, S3 } ==>
+	{ S1, rdfs:subClassOf, S3 }.
diff --git a/lib/rdf_mt/mt_simple.pl b/lib/rdf_mt/mt_simple.pl
new file mode 100644
index 0000000..ce62aee
--- /dev/null
+++ b/lib/rdf_mt/mt_simple.pl
@@ -0,0 +1,35 @@
+/*  Part of ClioPatria SeRQL and SPARQL server
+
+    Author:        Jan Wielemaker
+    E-mail:        J.Wielemaker@cs.vu.nl
+    WWW:           http://www.swi-prolog.org
+    Copyright (C): 2013, University of Amsterdam,
+		   VU University Amsterdam
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    as published by the Free Software Foundation; either version 2
+    of the License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    As a special exception, if you link this library with other files,
+    compiled with a Free Software compiler, to produce an executable, this
+    library does not by itself cause the resulting executable to be covered
+    by the GNU General Public License. This exception does not however
+    invalidate any other reasons why the executable file might be covered by
+    the GNU General Public License.
+*/
+
+:- module(mt_simple, []).
+:- use_module(library(semweb/rdf_db)).
+
+:- multifile rdf_reasoner:entailment_module/2.
+rdf_reasoner:entailment_module(simple, mt_simple).
diff --git a/lib/rdf_mt/rdf_reasoner.pl b/lib/rdf_mt/rdf_reasoner.pl
new file mode 100644
index 0000000..632323e
--- /dev/null
+++ b/lib/rdf_mt/rdf_reasoner.pl
@@ -0,0 +1,59 @@
+/*  Part of ClioPatria SeRQL and SPARQL server
+
+    Author:        Jan Wielemaker
+    E-mail:        J.Wielemaker@cs.vu.nl
+    WWW:           http://www.swi-prolog.org
+    Copyright (C): 2013, University of Amsterdam,
+		   VU University Amsterdam
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    as published by the Free Software Foundation; either version 2
+    of the License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    As a special exception, if you link this library with other files,
+    compiled with a Free Software compiler, to produce an executable, this
+    library does not by itself cause the resulting executable to be covered
+    by the GNU General Public License. This exception does not however
+    invalidate any other reasons why the executable file might be covered by
+    the GNU General Public License.
+*/
+
+:- module(rdf_reasoner,
+	  [ compute_closure/2
+	  ]).
+:- use_module(library(semweb/rdf_db)).
+:- use_module(library(xmlrdf/rdf_rewrite)).
+:- use_module(library(option)).
+:- use_module(library(debug)).
+
+:- multifile entailment_module/2.	% +Regime, -Module
+
+/** <module> Compute the closure over some entailment rules
+*/
+
+%%	compute_closure(+Regime, +Options)
+%
+%	Compute the closure using Regime.
+
+compute_closure(Regime, Options) :-
+	entailment_module(Regime, Module), !,
+	debug(mt(regime), 'Regime ~w: rewriting', [Regime]),
+	option(graph(Graph), Options, data),
+	fixed_point(Module:Graph).
+compute_closure(Regime, _) :-
+	debug(mt(regime), 'Regime ~w not implemented', [Regime]).
+
+fixed_point(Graph) :-
+	rdf_rewrite(Graph), !,
+	fixed_point(Graph).
+fixed_point(_).