+ module ClauseOT =
+ struct
+ type t = Terms.direction * (* direction if it is an equality *)
+ bool * (* true if indexed literal is positive *)
+ int * (* position of literal in clause *)
+ B.t Terms.clause
+
+ let compare (d1,p1,pos1,uc1) (d2,p2,pos2,uc2) =
+ let c = Pervasives.compare (d1,p1,pos1) (d2,p2,pos2) in
+ if c <> 0 then c else Clauses.compare_clause uc1 uc2
+ ;;
+ end
+
+ module ClauseSet :
+ Set.S with type elt = Terms.direction * (* direction if it is an equality *)
+ bool * (* true if indexed literal is positive *)
+ int * (* position of literal in clause *)
+ B.t Terms.clause
+ = Set.Make(ClauseOT)
+
+ open Discrimination_tree
+
+ module FotermIndexable : Indexable with
+ type constant_name = B.t and
+ type input = B.t Terms.foterm
+ =
+ struct
+
+ type input = B.t Terms.foterm
+ type constant_name = B.t
+
+ let path_string_of =
+ let rec aux arity = function
+ | Terms.Leaf a -> [Constant (a, arity)]
+ | Terms.Var i -> assert (arity = 0); [Variable]
+ | 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 (hd::tl) ->
+ aux (List.length tl) hd @ List.flatten (List.map (aux 0) tl)
+ in
+ aux 0
+ ;;
+
+ let compare e1 e2 =
+ match e1,e2 with
+ | Constant (a1,ar1), Constant (a2,ar2) ->
+ let c = B.compare a1 a2 in
+ if c <> 0 then c else Pervasives.compare ar1 ar2
+ | Variable, Variable -> 0
+ | Constant _, Variable -> ~-1
+ | Variable, Constant _ -> 1
+ | Proposition, _ | _, Proposition
+ | Datatype, _ | _, Datatype
+ | Dead, _ | _, Dead
+ | Bound _, _ | _, Bound _ -> assert false
+ ;;