2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
14 module Index(B : Terms.Blob) = struct
15 module U = FoUtils.Utils(B)
19 type t = Terms.direction * B.t Terms.unit_clause
21 let compare (d1,uc1) (d2,uc2) =
22 let c = Pervasives.compare d1 d2 in
23 if c <> 0 then c else U.compare_unit_clause uc1 uc2
28 Set.S with type elt = Terms.direction * B.t Terms.unit_clause
31 open Discrimination_tree
33 module FotermIndexable : Indexable with
34 type constant_name = B.t and
35 type input = B.t Terms.foterm
39 type input = B.t Terms.foterm
40 type constant_name = B.t
43 let rec aux arity = function
44 | Terms.Leaf a -> [Constant (a, arity)]
45 | Terms.Var i -> assert (arity = 0); [Variable]
46 | Terms.Node (Terms.Var _::_) ->
47 (* FIXME : should this be allowed or not ? *)
49 | Terms.Node ([] | [ _ ] ) -> assert false
50 | Terms.Node (Terms.Node _::_) -> assert false
51 | Terms.Node (hd::tl) ->
52 aux (List.length tl) hd @ List.flatten (List.map (aux 0) tl)
59 | Constant (a1,ar1), Constant (a2,ar2) ->
60 let c = B.compare a1 a2 in
61 if c <> 0 then c else Pervasives.compare ar1 ar2
62 | Variable, Variable -> 0
63 | Constant _, Variable -> ~-1
64 | Variable, Constant _ -> 1
65 | Proposition, _ | _, Proposition
66 | Datatype, _ | _, Datatype
68 | Bound _, _ | _, Bound _ -> assert false
71 let string_of_path l = String.concat "." (List.map (fun _ -> "*") l) ;;
75 module DT : DiscriminationTree with
76 type constant_name = B.t and
77 type input = B.t Terms.foterm and
78 type data = ClauseSet.elt and
79 type dataset = ClauseSet.t
80 = Make(FotermIndexable)(ClauseSet)