Chris@0
|
1 /* $Id$
|
Chris@0
|
2
|
Chris@0
|
3 Part of SWI-Prolog
|
Chris@0
|
4
|
Chris@0
|
5 Author: Jan Wielemaker
|
Chris@0
|
6 E-mail: jan@swi.psy.uva.nl
|
Chris@0
|
7 WWW: http://www.swi-prolog.org
|
Chris@0
|
8 Copyright (C): 1985-2004, University of Amsterdam
|
Chris@0
|
9
|
Chris@0
|
10 This program is free software; you can redistribute it and/or
|
Chris@0
|
11 modify it under the terms of the GNU General Public License
|
Chris@0
|
12 as published by the Free Software Foundation; either version 2
|
Chris@0
|
13 of the License, or (at your option) any later version.
|
Chris@0
|
14
|
Chris@0
|
15 This program is distributed in the hope that it will be useful,
|
Chris@0
|
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@0
|
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@0
|
18 GNU General Public License for more details.
|
Chris@0
|
19
|
Chris@0
|
20 You should have received a copy of the GNU Lesser General Public
|
Chris@0
|
21 License along with this library; if not, write to the Free Software
|
Chris@0
|
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Chris@0
|
23
|
Chris@0
|
24 As a special exception, if you link this library with other files,
|
Chris@0
|
25 compiled with a Free Software compiler, to produce an executable, this
|
Chris@0
|
26 library does not by itself cause the resulting executable to be covered
|
Chris@0
|
27 by the GNU General Public License. This exception does not however
|
Chris@0
|
28 invalidate any other reasons why the executable file might be covered by
|
Chris@0
|
29 the GNU General Public License.
|
Chris@0
|
30 */
|
Chris@0
|
31
|
Chris@0
|
32 :- module(rdfslite_entailment,
|
Chris@0
|
33 [
|
Chris@0
|
34 ]).
|
Chris@0
|
35 :- use_module(rdfql_runtime). % runtime tests
|
Chris@0
|
36 :- use_module(library('semweb/rdf_db'),
|
Chris@0
|
37 [ rdf_global_id/2,
|
Chris@0
|
38 rdf_reachable/3,
|
Chris@0
|
39 rdf_has/3,
|
Chris@0
|
40 rdf_subject/1,
|
Chris@0
|
41 rdf_equal/2
|
Chris@0
|
42 ]).
|
Chris@0
|
43 :- use_module(library('semweb/rdfs'),
|
Chris@0
|
44 [ rdfs_subclass_of/2,
|
Chris@0
|
45 rdfs_subproperty_of/2,
|
Chris@0
|
46 rdfs_individual_of/2
|
Chris@0
|
47 ]).
|
Chris@0
|
48
|
Chris@0
|
49 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
Chris@0
|
50 The function of an entailment module is to provide an implementation of
|
Chris@0
|
51 rdf/3 that extends basic triple-lookup using the entailment rules of the
|
Chris@0
|
52 semantic web sub language of RDF.
|
Chris@0
|
53
|
Chris@0
|
54 This entailment module does an efficient part of RDFS. Notably it does
|
Chris@0
|
55 *not* do type-reasoning on the basis of domains/ranges of properties. It
|
Chris@0
|
56 does:
|
Chris@0
|
57
|
Chris@0
|
58 * Use the property hierarchy
|
Chris@0
|
59 * Define the serql special relations
|
Chris@0
|
60 * Handle rdfs:subClassOf as transitive
|
Chris@0
|
61 * Handle rdf:type using subProperties and rdfs:subClassOf
|
Chris@0
|
62 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
Chris@0
|
63
|
Chris@0
|
64 term_expansion((rdf(S0, P0, O0) :- Body),
|
Chris@0
|
65 (rdf(S, P, O) :- Body)) :-
|
Chris@0
|
66 rdf_global_id(S0, S),
|
Chris@0
|
67 rdf_global_id(P0, P),
|
Chris@0
|
68 rdf_global_id(O0, O).
|
Chris@0
|
69
|
Chris@0
|
70 rdf(literal(L), _, _) :- % should move to compiler
|
Chris@0
|
71 nonvar(L), !, fail.
|
Chris@0
|
72 rdf(_, literal(L), _) :- % idem
|
Chris@0
|
73 nonvar(L), !, fail.
|
Chris@0
|
74 rdf(S, P, O) :-
|
Chris@0
|
75 var(P), !,
|
Chris@0
|
76 rdf(S,P,O).
|
Chris@0
|
77 rdf(S, serql:directSubClassOf, O) :- !,
|
Chris@0
|
78 rdf_has(S, rdfs:subClassOf, O).
|
Chris@0
|
79 rdf(S, serql:directType, O) :- !,
|
Chris@0
|
80 rdf_has(S, rdf:type, O).
|
Chris@0
|
81 rdf(S, serql:directSubPropertyOf, O) :- !,
|
Chris@0
|
82 rdf_has(S, rdfs:subPropertyOf, O).
|
Chris@0
|
83 rdf(S, rdfs:subClassOf, O) :- !,
|
Chris@0
|
84 rdf_reachable(S, rdfs:subClassOf, O).
|
Chris@0
|
85 rdf(S, rdf:type, O) :- !,
|
Chris@0
|
86 ( var(S), var(O)
|
Chris@0
|
87 -> rdf_subject(S)
|
Chris@0
|
88 ; true
|
Chris@0
|
89 ),
|
Chris@0
|
90 rdfs_individual_of(S, O).
|
Chris@0
|
91 rdf(S, P, O) :-
|
Chris@0
|
92 rdf_has(S, P, O).
|
Chris@0
|
93
|
Chris@0
|
94
|
Chris@0
|
95 /*******************************
|
Chris@0
|
96 * REGISTER *
|
Chris@0
|
97 *******************************/
|
Chris@0
|
98
|
Chris@0
|
99 :- multifile
|
Chris@0
|
100 serql:entailment/2.
|
Chris@0
|
101
|
Chris@0
|
102 serql:entailment(rdfslite, rdfslite_entailment).
|