View source with raw comments or as raw
    1/*  Part of ClioPatria SeRQL and SPARQL server
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@cs.vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (C): 2004-2010, University of Amsterdam,
    7			      VU University Amsterdam
    8
    9    This program is free software; you can redistribute it and/or
   10    modify it under the terms of the GNU General Public License
   11    as published by the Free Software Foundation; either version 2
   12    of the License, or (at your option) any later version.
   13
   14    This program is distributed in the hope that it will be useful,
   15    but WITHOUT ANY WARRANTY; without even the implied warranty of
   16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17    GNU General Public License for more details.
   18
   19    You should have received a copy of the GNU General Public
   20    License along with this library; if not, write to the Free Software
   21    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22
   23    As a special exception, if you link this library with other files,
   24    compiled with a Free Software compiler, to produce an executable, this
   25    library does not by itself cause the resulting executable to be covered
   26    by the GNU General Public License. This exception does not however
   27    invalidate any other reasons why the executable file might be covered by
   28    the GNU General Public License.
   29*/
   30
   31
   32:- module(rdf_entailment,
   33	  [ rdf/3,
   34	    rdf/4
   35	  ]).   36:- use_module(rdfql(rdfql_runtime)).	% runtime tests
   37:- use_module(library(semweb/rdf_db),
   38	      [ rdf_global_id/2,
   39		rdf_subject/1,
   40		rdf_current_predicate/1,
   41		(rdf_meta)/1,
   42		op(_,_,_)
   43	      ]).

RDFS-Lite entailment

The function of an entailment module is to provide an implementation of rdf/3 that extends basic triple-lookup using the entailment rules of the semantic web sub language of RDF.

This entailment module does only the core RDF inferences:

   58:- rdf_meta
   59	rdf(r,r,o).   60
   61rdf(S, P, O) :-
   62	rdf_db:rdf(S, P, O).
   63rdf(S, rdf:type, rdf:'Property') :-
   64	var_or_resource(S),
   65	rdf_current_predicate(S),
   66	(   rdf_db:rdf(_, S, _)
   67	->  \+ rdf_db:rdf(S, rdf:type, rdf:'Property')
   68	).
   69rdf(S, rdf:type, rdfs:'Resource') :-
   70	var_or_resource(S),
   71	rdf_subject(S),
   72	\+ rdf_db:rdf(S, rdf:type, rdfs:'Resource').
   73rdf(S, serql:directSubClassOf, O) :- !,
   74	rdf_db:rdf(S, rdfs:subClassOf, O).
   75rdf(S, serql:directType, O) :- !,
   76	rdf_db:rdf(S, rdf:type, O).
   77rdf(S, serql:directSubPropertyOf, O) :- !,
   78	rdf_db:rdf(S, rdfs:subPropertyOf, O).
   79
   80var_or_resource(R) :-
   81	(   var(R)
   82	->  true
   83	;   atom(R)
   84	).
 rdf(?S, ?P, ?O, ?G)
   88rdf(S, P, O, G) :-
   89	rdf_db:rdf(S, P, O, G).
   90
   91
   92		 /*******************************
   93		 *	       REGISTER		*
   94		 *******************************/
   95
   96:- multifile
   97	cliopatria:entailment/2.   98
   99cliopatria:entailment(rdf, rdf_entailment)