Permalink
Browse files

popl

  • Loading branch information...
cmungall committed Jul 9, 2010
1 parent 281198f commit 8f52a111a53b3b192c504c9e0922a15e0d4f7e81
Showing with 89 additions and 18 deletions.
  1. +1 −1 .gitignore
  2. +9 −2 bin/thea-owl-i
  3. +3 −3 owl2_model.pl
  4. +10 −1 owl2_plsyn.pl
  5. +55 −7 owl2_popl.pl
  6. +10 −4 owl2_reasoner.pl
  7. +1 −0 testfiles/epithelium.popl
View
@@ -1,7 +1,7 @@
*~
\#*
.\#*
-./Makefile
+Makefile
config.log
config.stats
autom4te.cache
View
@@ -47,8 +47,10 @@ main :-
; true),
forall(member(goal(G),Opts),
G),
+ forall(member(popl_file(F),Opts),
+ execute_popl_file(F,[syntax(plsyn)])),
forall(member(popl(G),Opts),
- popl_translate(G)),
+ popl_translate(G,[syntax(plsyn)])),
( member(statistics(true),Opts)
-> statistics
; true),
@@ -197,7 +199,12 @@ parse_arg(['--popl',GA|L],L,popl(G)) :-
ensure_loaded(library(thea2/owl2_popl)),
ensure_loaded(library(thea2/owl2_plsyn)),
atom_to_term(GA,G,_).
-arg_info(popl,term,'process using POPL expression').
+arg_info(popl,term,'process using POPL directive').
+
+parse_arg(['--popl-file',F|L],L,popl_file(F)) :-
+ ensure_loaded(library(thea2/owl2_popl)),
+ ensure_loaded(library(thea2/owl2_plsyn)).
+arg_info(popl-file,file,'file containing POPL directives').
parse_arg(['--query',select,TA,where,GA|L],L,query(T,G)) :- sformat(A,'q((~w),(~w))',[TA,GA]),atom_to_term(A,q(T,G),_).
parse_arg(['--query',GA|L],L,query(T,G)) :- atom_to_term(GA,G-T,_).
View
@@ -1015,8 +1015,6 @@
anyPropertyAssertion('http://www.w3.org/2000/01/rdf-schema#label', X, literal(lang(_,Val))),atom(Val).
labelAnnotation_value(X,Val) :-
anyPropertyAssertion('http://www.w3.org/2000/01/rdf-schema#label', X, literal(Val)),atom(Val).
-labelAnnotation_value(X,Val) :-
- anyPropertyAssertion('http://www.w3.org/2000/01/rdf-schema#label', X, literal(lang(_,Val))),atom(Val).
/****************************************
META-PREDICATES
@@ -1097,7 +1095,9 @@
!.
assert_axiom(Axiom) :-
assert(Axiom),
- ( nb_current(current_ontology,O) -> assert(ontologyAxiom(O,Axiom)) ; true),
+ ( nb_current(current_ontology,O)
+ -> assert(ontologyAxiom(O,Axiom))
+ ; true),
!.
%% assert_axiom(+Axiom:axiom,+Ontology:ontology) is det
View
@@ -8,6 +8,7 @@
plsyn_owl/3,
op(1200,xfy,(--)),
+ op(1150,xfy,\^), % disjoint classes
%op(1150,fx,class),
op(1150,fx,individual),
op(1150,xfy,disjointUnion),
@@ -43,6 +44,8 @@
:- op(1150,xfy,disjointUnion).
+:- op(1150,xfy,\^). % disjoint classes
+
:- op(1150,fx,functional).
:- op(1150,fx,transitive).
:- op(1150,fx,symmetric).
@@ -166,6 +169,9 @@
plsyn2owl(A and B,intersectionOf(ECs)) :-
!,
plsyn2owl_ec(A and B,and,ECs).
+plsyn2owl(A \^ B,disjointClasses(ECs)) :-
+ !,
+ plsyn2owl_ec(A \^ B,\^,ECs).
plsyn2owl(A or B,unionOf(ECs)) :-
!,
plsyn2owl_ec(A or B,or,ECs).
@@ -210,6 +216,9 @@
owl2plsyn(intersectionOf(Args),Pl) :-
maplist(owl2plsyn,Args,Args2),
list_to_chain(Args2,and,Pl).
+owl2plsyn(disjointClasses(Args),Pl) :-
+ maplist(owl2plsyn,Args,Args2),
+ list_to_chain(Args2,\^,Pl).
owl2plsyn(unionOf(Args),Pl) :-
maplist(owl2plsyn,Args,Args2),
list_to_chain(Args2,or,Pl).
@@ -283,7 +292,7 @@
plpred2owlpred(@<,subPropertyOf).
plpred2owlpred_list(\=,differentIndividuals).
-plpred2owlpred_list(\=,disjointClasses).
+%plpred2owlpred_list(\=,disjointClasses).
View
@@ -11,20 +11,34 @@
popl_translate/1,
popl_translate/2,
+ execute_popl_file/1,
+ execute_popl_file/2,
- op(700,xfy,===>),
- op(800,xfy,where),
- op(600,fx,add)
+ op(1100,xfy,===>),
+ op(1000,xfy,where),
+ op(950,fx,add)
]).
-:- op(700,xfy,===>).
-:- op(800,xfy,where).
-:- op(600,fx,add).
+:- op(1100,xfy,===>).
+:- op(1000,xfy,where).
+:- op(950,fx,add).
+%% popl_translate(+Directive) is det
+% see popl_translate/2
popl_translate(T) :-
popl_translate(T, []).
+%% popl_translate(+Directive,+Opts:list) is det
+%
+% Directive can be one of:
+% * InExpression ===> OutExpression
+% * InExpression ===> OutExpression where Goal
+% * add Expression where Goal
+%
+% Opts can be:
+% * syntax(Syntax)
+% currently only val allowed is plsyn
popl_translate( X1 ===> X2, Opts) :-
replace_matching_axioms(X1,X2,Opts),
replace_expression_in_all_axioms(X1,X2,Opts).
@@ -37,6 +51,17 @@
replace_matching_axioms_where(true,X2,G,Opts),
replace_expression_in_all_axioms_where(true,X2,G,Opts).
+%% execute_popl_file(+File)
+% see execute_popl_file/2,
+execute_popl_file(F) :-
+ execute_popl_file(F, []).
+
+
+%% execute_popl_file(+File, +Opts:list)
+execute_popl_file(F, Opts) :-
+ read_file_to_terms(F,Directives,[]),
+ forall(member(Directive,Directives),
+ popl_translate(Directive, Opts)).
%% replace_matching_axioms(+AxiomTemplateOld,+AxiomTemplateNew,+Opts:list) is det
% replace all occurrences of AxiomTemplateOld with AxiomTemplateNew.
@@ -91,7 +116,7 @@
plsyn_owl(Ax1a,Ax1),
plsyn_owl(Ax2a,Ax2),
replace_axiom(Ax1,Ax2,Opts2).
-replace_axiom(null,Ax2,_Opts) :-
+replace_axiom(true,Ax2,_Opts) :-
!,
assert_axiom(Ax2).
replace_axiom(Ax1,Ax2,Opts) :-
@@ -279,9 +304,32 @@ BEGIN
---++ Command Line examples
+Make every sibling pair disjoint:
==
thea --popl "add disjointClasses(X,Y) where (subClassOf(X,A),subClassOf(Y,A),X\=Y)" testfiles/caro.owl --to owl
==
+
+What if we want to restrict this to a certain set of classes - for
+example, all asserted sibling pairs anywhere under "epithelium". We
+can use a reasoner to find all subclasses of epithelium.
+
+The following invokes pellet via the OWL API:
+
+==
+thea-jpl --reasoner pellet --popl "add disjointClasses([X,Y]) where (labelAnnotation_value(E,epithelium),reasoner_ask(reflexiveSubClassOf(A,E)),subClassOf(X,A),subClassOf(Y,A),X\=Y)" testfiles/caro.owl --to owlpl
+==
+
+The above makes pairwise disjointness axioms - with OWL2 we can state this as a list. This is even easier:
+
+==
+thea-jpl --reasoner pellet --popl "add disjointClasses(L) where labelAnnotation_value(E,epithelium),reasoner_ask(reflexiveSubClassOf(A,E)),setof(X,subClassOf(X,A),L)" testfiles/caro.owl --to owlpl
+==
+
+You can also load all directives into a file:
+
+==
+thea-jpl --reasoner pellet --popl-file testfiles/epithelium.popl testfiles/caro.owl --to owlpl
+==
---+ TODO
View
@@ -55,19 +55,25 @@
%% reasoner_ask(+Reasoner,?Axiom)
% in general Axiom should be one of
-% * subClassOf
-% * classAssertion
+% * subClassOf/2
+% * classAssertion/2
+% * propertyAssertion/3
% with arguments that are either ground atoms or
% variables.
% some reasoners may be able to give results for class expressions
% that contain variables.
% TODO - isConsistent
+reasoner_ask(Reasoner,reflexiveSubClassOf(X,Y)) :-
+ reasoner_ask(Reasoner,subClassOf(X,Y)).
+reasoner_ask(_,reflexiveSubClassOf(X,X)) :-
+ class(X).
+
reasoner_ask(Reasoner,Axiom) :-
debug(reasoner,'Reasoner query: ~w',[Axiom]),
reasoner_ask_hook(Reasoner,Axiom).
-reasoner_ask(Axiom) :-
- nb_getval(reasoner,Reasoner),
+reasoner_ask(Axiom) :-
+ nb_current(reasoner,Reasoner),
reasoner_ask(Reasoner,Axiom).
@@ -0,0 +1 @@
+add disjointClasses(L) where labelAnnotation_value(E,epithelium),reasoner_ask(reflexiveSubClassOf(A,E)),setof(X,subClassOf(X,A),L).

0 comments on commit 8f52a11

Please sign in to comment.