]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/ng_paramodulation/index.ml
Branched paramodulation for CNF (Horn clauses)
[helm.git] / helm / software / components / ng_paramodulation / index.ml
index d07fba8a44a78b180a5578912e03c1e43c0080f0..c7a0edcca2bff6e43d7d8165278ae0668f7ebcd4 100644 (file)
 
 (* $Id$ *)
 
-module Index(B : Terms.Blob) = struct
-  module U = Terms.Utils(B)
+module Index(B : Orderings.Blob) = struct
+  module U = FoUtils.Utils(B)
 
   module ClauseOT =
     struct 
-      type t = Terms.direction * B.t Terms.unit_clause
+      type t = Terms.direction * B.t Terms.clause
  
       let compare (d1,uc1) (d2,uc2) = 
         let c = Pervasives.compare d1 d2 in
-        if c <> 0 then c else U.compare_unit_clause uc1 uc2
+        if c <> 0 then c else U.compare_clause uc1 uc2
       ;;
     end
 
   module ClauseSet : 
-    Set.S with type elt = Terms.direction * B.t Terms.unit_clause
+    Set.S with type elt = Terms.direction * B.t Terms.clause
     = Set.Make(ClauseOT)
 
   open Discrimination_tree
@@ -43,9 +43,11 @@ module Index(B : Terms.Blob) = struct
         let rec aux arity = function
           | Terms.Leaf a -> [Constant (a, arity)]
           | Terms.Var i -> assert (arity = 0); [Variable]
-          | Terms.Node (Terms.Var _::_) -> assert false
+          | Terms.Node (Terms.Var _::_) ->
+             (* FIXME : should this be allowed or not ? *)
+             assert false
           | Terms.Node ([] | [ _ ] ) -> assert false
-          | Terms.Node (Terms.Node _::_) -> assert false
+          | Terms.Node (Terms.Node _::_) -> assert false             
           | Terms.Node (hd::tl) ->
               aux (List.length tl) hd @ List.flatten (List.map (aux 0) tl) 
         in 
@@ -77,4 +79,20 @@ module Index(B : Terms.Blob) = struct
       type dataset = ClauseSet.t
     = Make(FotermIndexable)(ClauseSet)
 
+  let index_clause t = function
+    | (_,Terms.Equation (l,_,_,Terms.Gt),_,_) as c -> 
+          DT.index t l (Terms.Left2Right, c)
+    | (_,Terms.Equation (_,r,_,Terms.Lt),_,_) as c -> 
+          DT.index t r (Terms.Right2Left, c)
+    | (_,Terms.Equation (l,r,_,Terms.Incomparable),_,_) as c ->  
+          DT.index  
+           (DT.index t l (Terms.Left2Right, c))
+           r (Terms.Right2Left, c)
+    | (_,Terms.Equation (_,r,_,Terms.Eq),_,_)  -> assert false
+    | (_,Terms.Predicate p,_,_) as c ->
+          DT.index t p (Terms.Nodir, c)
+  ;;
+
+  type active_set = B.t Terms.clause list * DT.t
+
 end