Chris@0: /* $Id$ Chris@0: Chris@0: Part of SWI-Prolog Chris@0: Chris@0: Author: Jan Wielemaker Chris@0: E-mail: jan@swi.psy.uva.nl Chris@0: WWW: http://www.swi-prolog.org Chris@0: Copyright (C): 1985-2004, University of Amsterdam Chris@0: Chris@0: This program is free software; you can redistribute it and/or Chris@0: modify it under the terms of the GNU General Public License Chris@0: as published by the Free Software Foundation; either version 2 Chris@0: of the License, or (at your option) any later version. Chris@0: Chris@0: This program is distributed in the hope that it will be useful, Chris@0: but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: GNU General Public License for more details. Chris@0: Chris@0: You should have received a copy of the GNU Lesser General Public Chris@0: License along with this library; if not, write to the Free Software Chris@0: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Chris@0: Chris@0: As a special exception, if you link this library with other files, Chris@0: compiled with a Free Software compiler, to produce an executable, this Chris@0: library does not by itself cause the resulting executable to be covered Chris@0: by the GNU General Public License. This exception does not however Chris@0: invalidate any other reasons why the executable file might be covered by Chris@0: the GNU General Public License. Chris@0: */ Chris@0: Chris@0: :- module(rdf_entailment, Chris@0: [ rdf/3 Chris@0: ]). Chris@0: :- use_module(rdfql_runtime). % runtime tests Chris@0: :- use_module(library('semweb/rdf_db'), Chris@0: [ rdf_global_id/2, Chris@0: rdf_subject/1 Chris@0: ]). Chris@0: Chris@0: /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Chris@0: The function of an entailment module is to provide an implementation of Chris@0: rdf/3 that extends basic triple-lookup using the entailment rules of the Chris@0: semantic web sub language of RDF. This one does (still a lousy) job Chris@0: realising RDFS entailment on top of rdf_db.pl. Chris@0: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ Chris@0: Chris@0: term_expansion((rdf(S0, P0, O0) :- Body0), Chris@0: (rdf(S, P, O) :- rdf_db:Body)) :- Chris@0: rdf_global_id(S0, S), Chris@0: rdf_global_id(P0, P), Chris@0: rdf_global_id(O0, O), Chris@0: expand_goal(Body0, Body). Chris@0: Chris@0: rdf(S, P, O) :- Chris@0: rdf(S, P, O). Chris@0: rdf(S, rdf:type, rdf:'Property') :- Chris@0: rdf(_, S, _), Chris@0: \+ rdf(S, rdf:type, rdf:'Property'). Chris@0: rdf(S, rdf:type, rdfs:'Resource') :- Chris@0: rdf_subject(S), Chris@0: \+ rdf(S, rdf:type, rdfs:'Resource'). Chris@0: rdf(S, serql:directSubClassOf, O) :- !, Chris@0: rdf(S, rdfs:subClassOf, O). Chris@0: rdf(S, serql:directType, O) :- !, Chris@0: rdf(S, rdf:type, O). Chris@0: rdf(S, serql:directSubPropertyOf, O) :- !, Chris@0: rdf(S, rdfs:subPropertyOf, O). Chris@0: Chris@0: Chris@0: /******************************* Chris@0: * REGISTER * Chris@0: *******************************/ Chris@0: Chris@0: :- multifile Chris@0: serql:entailment/2. Chris@0: Chris@0: serql:entailment(rdf, rdf_entailment).