-
Notifications
You must be signed in to change notification settings - Fork 1
/
builtins.pl
58 lines (44 loc) · 1.36 KB
/
builtins.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
:- module(builtins,[builtin/2]).
/**
* This modules provides anchors for builtin predicates.
* By registering a new builtin(Predicate,CorrespondingPrologPredicate)
* clause, proving Predicate using the n3_entailment
* module will call CorrespondingPrologPredicate.
*
* The file examples/list.n3 gives an illustration of that,
* and uses the list:member/2 SWI predicate.
*
* Copyright Yves Raimond (c) 2007
* Centre for Digital Music, Queen Mary, University of London
*/
:- use_module(library('semweb/rdf_db')).
:- use_module(library('semweb/rdfs')).
:- rdf_meta builtin(r,?).
:- multifile builtin/2.
/**
*
* Declaration of builtin predicates
*
*/
builtin('http://www.w3.org/2000/10/swap/list#in',builtin:member).
builtin('http://www.w3.org/2000/10/swap/list#nextto',builtin:nextto).
% Should be builtin(A,B) :- ... for namespace expansion
/**
* Each builtin is a binary predicate - first argument is the
* argument or the list of arguments used as a subject, second argument
* is the argument or the list of arguments used as an object
*/
builtin:member(A,B) :-
\+var(B),
member(A,B).
builtin:nextto([X,Y],L) :-
\+var(L),
getnext(X, Y, L).
getnext(X, Y, L) :-
nextto(X,Y,L).
getnext(X, X, L) :-
\+var(L),
last(L, X).
%Just illustrating a bug
%builtin('http://purl.org/ontology/swi/append',builtin:append).
%builtin:append([[a,b],[c]],[a,b,c]).