diff --git a/src/lib/CoAlgReasoner.ml b/src/lib/CoAlgReasoner.ml index 820ef5483d110849d6c11158484088c71332857f..58caaa08a50f6b5a830f97005f50c2801b36b341 100644 --- a/src/lib/CoAlgReasoner.ml +++ b/src/lib/CoAlgReasoner.ml @@ -9,6 +9,12 @@ module M = Minisat type sortTable = CoAlgMisc.sortTable +type nomTable = string -> CoAlgFormula.sort option + +type assumptions = CoAlgFormula.sortedFormula list + +type input = sortTable * nomTable * assumptions * CoAlgFormula.sortedFormula + (*****************************************************************************) (* Propagation of Satisfiability *) diff --git a/src/lib/CoAlgReasoner.mli b/src/lib/CoAlgReasoner.mli index d594e3d8cdd68070835ed564cdd8362535aa4054..941f510b1717ab39ee2cf9056ac4dfcb2c6ad544 100644 --- a/src/lib/CoAlgReasoner.mli +++ b/src/lib/CoAlgReasoner.mli @@ -5,6 +5,11 @@ type sortTable = (CoAlgMisc.functors * int list) array +type nomTable = string -> CoAlgFormula.sort option + +type assumptions = CoAlgFormula.sortedFormula list + +type input = sortTable * nomTable * assumptions * CoAlgFormula.sortedFormula val isSat : ?verbose:bool -> sortTable -> (string -> CoAlgFormula.sort option) -> CoAlgFormula.sortedFormula list -> CoAlgFormula.sortedFormula -> bool diff --git a/src/owl/OWL.ml b/src/owl/OWL.ml index c4c2491d36736c9b773e783bbb362e4eded02de8..940605121600f1a657c72a91ff6caf7ebfdac12f 100644 --- a/src/owl/OWL.ml +++ b/src/owl/OWL.ml @@ -2,6 +2,8 @@ open CoolUtils module L = List module CoAlg = CoAlgFormula +module R = CoAlgReasoner +module CM = CoAlgMisc exception ConversionError of string @@ -140,3 +142,21 @@ let coalg_global_assumption_of_owl (ax:axiom): CoAlgFormula.formula = | DISJOINTCLASSES l -> raise (ConversionError "not implemented yet") | DISJOINTUNION (c,l) -> raise (ConversionError "not implemented yet") +let to_coalg (uri,axioms): R.sortTable * R.nomTable * R.assumptions = + let assumptions = L.map coalg_global_assumption_of_owl axioms in + (* make assumptions of type CoAlgFormula.formula *) + let (assumptions, fnctor) = (* ofcourse functor leads to "Error: pattern expected".. *) + try + (L.map CoAlg.convertToK assumptions, CM.MultiModalK) + with CoAlg.ConversionException -> + (L.map CoAlg.convertToGML assumptions, CM.GML) + in + let sorts = [| (fnctor, [0]) |] in + let nomTable name = + assert (CoAlgFormula.isNominal name); + Some 0 + in + (* make assumptions "sorted" *) + let assumptions = L.map (fun f -> (0,f)) assumptions in + (sorts,nomTable,assumptions) + diff --git a/src/owl/OWL.mli b/src/owl/OWL.mli index 40aef6da3918b00993f4cc5a67f0c1a8cd2a6a53..a46fdf3e2ef50b40fc381a7a1e4ff0404c69f8c4 100644 --- a/src/owl/OWL.mli +++ b/src/owl/OWL.mli @@ -46,5 +46,9 @@ val string_of_ontology : ontology -> string val string_of_axiom : axiom -> string val string_of_class_exp : class_exp -> string +(* try to convert some OWL ontology to coalg formulas *) +(* first try to express it in pure K, then in GML *) +val to_coalg : ontology -> CoAlgReasoner.sortTable * CoAlgReasoner.nomTable * CoAlgReasoner.assumptions + val coalg_formula_of_owl : class_exp -> CoAlgFormula.formula val coalg_global_assumption_of_owl : axiom -> CoAlgFormula.formula diff --git a/src/owl/cool-owl.ml b/src/owl/cool-owl.ml index 3f7c0343c149e53e4c223c7dc54ae3636bfdb32f..72ed7e347bc3861f7724815a04e0764b60b28674 100644 --- a/src/owl/cool-owl.ml +++ b/src/owl/cool-owl.ml @@ -1,8 +1,12 @@ open OWL open CoolUtils module OWLFP = OWLFunctionalParser +module CF = CoAlgFormula +module CR = CoAlgReasoner module L = List +exception Exception of string + let string_of_stdin (): string = let buf = ref "" in (try @@ -33,6 +37,20 @@ let owlcat () = print_endline (OWLFP.string_of_tree (OWLFP.string_of_annotated id) t) *) +let consistency () = + let content = string_of_stdin () in + (* ignore prefixes and assume that there is exactly one ontology *) + let (_, ontology) = match OWLFP.parse content with + | (u, o :: _) -> (u,o) + | (_, []) -> raise (Exception "File needs to contain at least one ontology") + in + let (sorts,nomTable,axioms) = OWL.to_coalg ontology in + let cons = CR.isSat sorts nomTable axioms (0,CF.TRUE) in + let cons = if cons then "yes" else "no" in + let (ontoname, _) = ontology in + Printf.printf "%s consistent: %s\n" ontoname cons + + let rec printUsage () = let p = Printf.printf in @@ -47,6 +65,7 @@ and tmp_subcmds () = let s name func description = (name,func,description) in [ s "cat" owlcat "Reads a functional style OWL file from stdin and prints it" + ; s "consist" consistency "Checks the consistency of a OWL file from stdin" ; s "-h" printUsage "Prints this help screen" ; s "help" printUsage "Prints this help screen" ]