Permalink
Browse files

owl2rl_rules fg and bg reasoning tested

  • Loading branch information...
1 parent 7a929b7 commit da69462c2721dba719097047bb519ac292fb6add Vangelis Vassiliadis committed Dec 27, 2009
Showing with 1,147 additions and 1,177 deletions.
  1. +50 −80 owl2rl_rules.pl
  2. +1,097 −1,097 owl_parser.pl
View
@@ -43,8 +43,6 @@
% axioms
%
-
-
% transitivity of subprop
entails(scm-spo, [subPropertyOf(X,Z),subPropertyOf(Z,Y)],[subPropertyOf(X,Y)]).
@@ -56,66 +54,6 @@
entails(cls-hv1, [classAssertion(hasValue(P,V),I)],[propertyAssertion(P,I,V)]).
-
-
-/*
-someValuesFrom_propchain(_,[]).
-someValuesFrom_propchain(X,[P|PL]):-
- subClassOf(X,someValuesFrom(P,Y)),
- someValuesFrom_propchain(Y,PL).
-
-subClassOf(X,allValuesFrom(P,D)) :-
- subClassOf(X,allValuesFrom(P,D1)),
- subClassOf(D1,D).
-
-subClassOf_all(_,[]).
-subClassOf_all(X,[D|L]):-
- subClassOf(X,D),
- subClassOf_all(X,L).
-
-pairwise_equivalent_class(X,Y) :- equivalentClasses(L),member(X,L),member(Y,L).
-pairwise_equivalent_class(X,Y) :- subClassOf(X,Y),subClassOf(Y,X).
-
-pairwise_disjoint_class(X,Y) :- disjointClasses(L),member(X,L),member(Y,L).
-pairwise_disjoint_class(X,Y) :- subClassOf(X,Y),subClassOf(Y,X).
-
-% TODO: make subClassOf nothing?
-unsatisfiable(X) :-
- pairwise_disjoint_class(A,B),
- subClassOf(X,A),
- subClassOf(X,B).
-*/
-
-% ----------------------------------------
-% ABox Reasoning
-% ----------------------------------------
-
-% reified version of Grosof
-/*
-classAssertion(C,I) :- classAssertion(C2,I),subClassOf(C2,C).
-
-classAssertion(C,I) :- propertyDomain(P,C),propertyAssertion(P,I,_).
-classAssertion(C,I) :- propertyRange(P,C),propertyAssertion(P,_,I).
-
-propertyAssertion(P,A,B) :- transitiveProperty(P),propertyAssertion(P,A,C),propertyAssertion(P,C,B).
-propertyAssertion(P,A,B) :- symmetricProperty(P),propertyAssertion(P,B,A).
-propertyAssertion(P,A,B) :- inverseProperties(P,Q),propertyAssertion(Q,B,A).
-propertyAssertion(Q,A,B) :- subPropertyOf(P,Q),propertyAssertion(P,A,B).
-
-% role chains
-propertyAssertion(P,A,B) :- subPropertyOf(propertyChain([P1|PL]),P),propertyAssertion(P,A,C),propertyAssertion_chain(PL,C,B).
-
-propertyAssertion_chain([],_,_).
-propertyAssertion_chain([P|PL],A,B) :- propertyAssertion(P,A,C),propertyAssertion_chain(PL,C,B).
-
-% todo: translate to sameIndividuals/1
-sameAs(A,B) :- propertyAssertion(P,X,A),functionalProperty(P),propertyAssertion(P,X,B).
-sameAs(A,B) :- propertyAssertion(P,A,X),inverseFunctionalProperty(P),propertyAssertion(P,B,X).
-
-illegal(P) :- propertyAssertion(P,A,A),irreflexiveProperty(P).
-illegal(P) :- propertyAssertion(P,A,B),asymmetricProperty(P),propertyAssertion(P,B,A).
-*/
-
% ----------------------------------------
% Rule engine
% ----------------------------------------
@@ -125,9 +63,9 @@
% execute all possible entailments in backtracking
fire_cycle :-
- aggregate_all(count,inferred(_,_,_),C),print('# of inferred before'-C),nl,
+ aggregate_all(count,entailed(_,_,_),C),print('# of inferred before'-C),nl,
fire,
- aggregate_all(count,inferred(_,_,_),C1),print('# of inferred after'-C1),nl,read(_),
+ aggregate_all(count,entailed(_,_,_),C1),print('# of inferred after'-C1),nl,read(_),
( C1 = C -> true ; fire_cycle ).
fire :-
@@ -140,12 +78,15 @@
assert_u(Fact) :- call(Fact),!.
assert_u(Fact) :- assert(Fact).
-holds(Axiom) :-
- axiom(Axiom) ; entailed(Axiom,_,_).
+
+holds(Axiom,axiom1(Axiom)) :-
+ axiom(Axiom).
+holds(Axiom,entailed(Rule,Expl)):-
+ entailed(Axiom,Rule,Expl).
hold([]).
hold([Antecedent|Rest]) :-
- holds(Antecedent),
+ holds(Antecedent,_),
hold(Rest).
@@ -156,21 +97,22 @@
load_owl :-
owl_parse_rdf('testfiles/wine.owl',[clear(complete)]).
+is_entailed(holds(Axiom),Expl) :-
+ holds(Axiom,Expl).
-is_entailed(Axiom,axiom(Axiom)) :-
- axiom1(Axiom).
-
-is_entailed(Axiom,entailed(Rule,Expl)) :-
- entailed(Axiom,Rule,Expl).
+is_entailed(Axiom,Expl) :-
+ holds(Axiom,Expl).
is_entailed(Axiom,entailed(Rule,Expl)) :-
not(entailed(Axiom,_,_)),
% find rules to be executed.
entails(Rule,Antecedants,Consequents), member(Axiom,Consequents),
+ hold_augment(Axiom,Antecedants,HoldedAntecedants),
% resolve rules, if resolution succeeds,
- are_entailed(Antecedants,Expl),
+ are_entailed(HoldedAntecedants,Expl),
% assert axiom if not already there
- not(entailed(Axiom,_,_)), % put this axiom once but generate all entailments for its children...
+ % not(entailed(Axiom,_,_)),not(axiom1(Axiom)),
+ not( holds(Axiom,_)), % put this axiom once but generate all entailments for its children...
assert_u(entailed(Axiom,Rule,Expl)). % backtrack to next rule.
@@ -179,13 +121,41 @@
is_entailed(Axiom,Expl),
are_entailed(Rest,RestExpl).
-entails(r1,[e(X,Y)],[s(X,Y)]).
-entails(r2,[e(X,Z),s(Z,Y)],[s(X,Y)]).
-axiom1(e(a,b)).
-axiom1(e(b,c)).
-axiom1(e(c,b)).
-axiom1(e(a,a)).
+hold_augment(_,[],[]):- !.
+hold_augment(Axiom,[Ant1|Rest],[holds(Ant1)|Rest]) :-
+ functor(Axiom,P,A),functor(Ant1,P,A),!.
+hold_augment(_,Antecedants,Antecedants).
+
+
+%entails(r1,[e(X,Y)],[s(X,Y)]).
+entails(r2,[s(X,Z),s(Z,Y)],[s(X,Y)]).
+
+axiom1(s(a,b)).
+axiom1(s(b,c)).
+axiom1(s(c,b)).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Oops, something went wrong.

0 comments on commit da69462

Please sign in to comment.