forked from vangelisv/thea
-
Notifications
You must be signed in to change notification settings - Fork 3
/
swrl.plt
121 lines (79 loc) · 3.66 KB
/
swrl.plt
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* -*- Mode: Prolog -*- */
:- use_module(swrl).
:- use_module(owl2_model).
:- use_module(owl2_from_rdf).
:- use_module(swrl_rdf_hooks).
:- begin_tests(family,[setup(load_swrlfile),cleanup(retract_all_axioms)]).
load_swrlfile :-
owl_parse_rdf('testfiles/family.owl').
test(expected) :-
forall(expected(Ax),
( writeln(Ax),
Ax)).
test(loaded_implies) :-
\+ \+ implies(_,_).
expected(implies(['http://www.owl-ontologies.com/Ontology1172270693.owl#has_foster_grandfather'(i('http://www.owl-ontologies.com/Ontology1172270693.owl#a'), i('http://www.owl-ontologies.com/Ontology1172270693.owl#b')), 'http://www.owl-ontologies.com/Ontology1172270693.owl#has_health_state'(i('http://www.owl-ontologies.com/Ontology1172270693.owl#b'), i('http://www.owl-ontologies.com/Ontology1172270693.owl#c'))], ['http://www.owl-ontologies.com/Ontology1172270693.owl#has_fam_hx_in_foster_grandfather'(i('http://www.owl-ontologies.com/Ontology1172270693.owl#a'), i('http://www.owl-ontologies.com/Ontology1172270693.owl#c'))])).
:- end_tests(family).
:- begin_tests(ancestor,[setup(load_swrlfile),cleanup(retract_all_axioms)]).
load_swrlfile :-
owl_parse_rdf('testfiles/dl-safe-ancestor.owl').
test(expected) :-
forall(expected(Ax),
( writeln(Ax),
Ax)).
test(loaded_implies) :-
\+ \+ implies(_,_).
expected(implies(['http://www.cs.man.ac.uk/~bparsia/2007/examples/dl-safe-ancestor.owl#ancestorOf'(i('http://www.cs.man.ac.uk/~bparsia/2007/examples/dl-safe-ancestor.owl#x'), i('http://www.cs.man.ac.uk/~bparsia/2007/examples/dl-safe-ancestor.owl#y')),
'http://www.cs.man.ac.uk/~bparsia/2007/examples/dl-safe-ancestor.owl#ancestorOf'(i('http://www.cs.man.ac.uk/~bparsia/2007/examples/dl-safe-ancestor.owl#y'), i('http://www.cs.man.ac.uk/~bparsia/2007/examples/dl-safe-ancestor.owl#z'))],
['http://www.cs.man.ac.uk/~bparsia/2007/examples/dl-safe-ancestor.owl#ancestorOf'(i('http://www.cs.man.ac.uk/~bparsia/2007/examples/dl-safe-ancestor.owl#x'), i('http://www.cs.man.ac.uk/~bparsia/2007/examples/dl-safe-ancestor.owl#z'))])).
:- end_tests(ancestor).
:- begin_tests(pl2swrl,[]).
:- op(1100,xfy,<==>).
subClassOf(ab, unionOf([a, b])) <==>
( ( a(X) ; b(X)) :- ab(X)).
subClassOf(x, y) <==> ( y(X):- x(X)).
subClassOf(unionOf([a, b]), ab) <==>
( ab(X):- ( a(X) ; b(X))).
subPropertyOf(r, s) <==>
( r(X,Y):- s(X,Y)).
subPropertyOf(r, inverseOf(t)) <==>
( r(X,Y):- t(Y,X)).
subPropertyOf(r, propertyChain([s, t])) <==>
( r(X,Y):- s(X,V1),t(V1,Y)).
subPropertyOf(r, propertyChain([s, t, u, v, inverseOf(w), x])) <==>
( r(X,Y):- s(X,V1),t(V1,V2),u(V2,V3),v(V3,V4),w(V5,V4),x(V5,Y)).
subPropertyOf(r, propertyChain([s, u, w])) <==>
( r(X,Y):- s(X,V1),u(V1,V2),w(V2,Y)).
subPropertyOf(r, propertyChain([s, inverseOf(t)])) <==>
( r(X,Y):- s(X,V1),t(Y,V1)).
% TODO: equivalent classes involves checking combinations of rules
(equivalentClasses([ab,unionOf([a,b])]) <==>
( ab(X) :- (a(X);b(X)))).
equivalentClasses([efg, intersectionOf([e, f, g])])
<==>
[( e(X):- efg(X)),
( f(X):- efg(X)),
( g(X):- efg(X)),
( efg(X):- e(X),f(X),g(X))].
test(pl2owl) :-
forall( (Axiom <==> Pl),
pl2owl(Pl,Axiom)).
pl2owl(Pl,Axiom) :-
prolog_clause_to_swrl_rule(Pl,Rule),
swrl_to_owl_axioms(Rule,[Axiom]).
check(Axiom,Pl) :-
prolog_clause_to_swrl_rule(Pl,Rule),
swrl_to_owl_axioms(Rule,[Axiom]).
:- end_tests(pl2swrl).
/** <module> tests for SWRL
---+ Synopsis
Command line:
==
swipl
?- [swrl].
?- load_test_files([]).
?- run_tests.
==
---+ Details
This is a test module for the module swrl.pl
*/