1 (* Copyright (C) 2005, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
28 module type EqualityIndex =
30 module PosEqSet : Set.S with type elt = Utils.pos * Equality.equality
31 type t = Discrimination_tree.DiscriminationTreeIndexing(PosEqSet).t
33 val retrieve_generalizations : t -> Cic.term -> PosEqSet.t
34 val retrieve_unifiables : t -> Cic.term -> PosEqSet.t
35 val init_index : unit -> unit
36 val remove_index : t -> Equality.equality -> t
37 val index : t -> Equality.equality -> t
38 val in_index : t -> Equality.equality -> bool
43 module OrderedPosEquality = struct
44 type t = Utils.pos * Equality.equality
45 let compare (p1,e1) (p2,e2) =
46 let rc = Pervasives.compare p1 p2 in
47 if rc = 0 then Equality.compare e1 e2 else rc
50 module PosEqSet = Set.Make(OrderedPosEquality);;
52 include Discrimination_tree.DiscriminationTreeIndexing(PosEqSet)
55 (* DISCRIMINATION TREES *)
56 let init_index () = () ;;
58 let remove_index tree equality =
59 let _, _, (_, l, r, ordering), _,_ = Equality.open_equality equality in
61 | Utils.Gt -> remove_index tree l (Utils.Left, equality)
62 | Utils.Lt -> remove_index tree r (Utils.Right, equality)
64 let tree = remove_index tree r (Utils.Right, equality) in
65 remove_index tree l (Utils.Left, equality)
67 let index tree equality =
68 let _, _, (_, l, r, ordering), _,_ = Equality.open_equality equality in
70 | Utils.Gt -> index tree l (Utils.Left, equality)
71 | Utils.Lt -> index tree r (Utils.Right, equality)
73 let tree = index tree r (Utils.Right, equality) in
74 index tree l (Utils.Left, equality)
77 let in_index tree equality =
78 let _, _, (_, l, r, ordering), _,_ = Equality.open_equality equality in
79 let meta_convertibility (pos,equality') =
80 Equality.meta_convertibility_eq equality equality'
82 in_index tree l meta_convertibility || in_index tree r meta_convertibility
88 module OrderedPosEquality = struct
89 type t = Utils.pos * Equality.equality
90 let compare (p1,e1) (p2,e2) =
91 let rc = Pervasives.compare p1 p2 in
92 if rc = 0 then Equality.compare e1 e2 else rc
95 module PosEqSet = Set.Make(OrderedPosEquality);;
97 include Discrimination_tree.DiscriminationTreeIndexing(PosEqSet)
100 (* DISCRIMINATION TREES *)
101 let init_index () = () ;;
103 let remove_index tree equality =
104 let _, _, (_, l, r, ordering), _,_ = Equality.open_equality equality in
106 | Utils.Gt -> remove_index tree l (Utils.Left, equality)
107 | Utils.Lt -> remove_index tree r (Utils.Right, equality)
109 let tree = remove_index tree r (Utils.Right, equality) in
110 remove_index tree l (Utils.Left, equality)
112 let index tree equality =
113 let _, _, (_, l, r, ordering), _,_ = Equality.open_equality equality in
115 | Utils.Gt -> index tree l (Utils.Left, equality)
116 | Utils.Lt -> index tree r (Utils.Right, equality)
118 let tree = index tree r (Utils.Right, equality) in
119 index tree l (Utils.Left, equality)
122 let in_index tree equality =
123 let _, _, (_, l, r, ordering), _,_ = Equality.open_equality equality in
124 let meta_convertibility (pos,equality') =
125 Equality.meta_convertibility_eq equality equality'
127 in_index tree l meta_convertibility || in_index tree r meta_convertibility