X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fparamodulation%2Fdiscrimination_tree.ml;h=56e8bd44af404f5596fb6586e540e403c77af3dc;hb=33a02e0b639217093eb63f30169aaa6ac8c78907;hp=443c5c63bc043d12a61d4ff67f881611120a7307;hpb=97b887beb8b28738303ae32bcd5bd5c9c87eb606;p=helm.git diff --git a/helm/ocaml/paramodulation/discrimination_tree.ml b/helm/ocaml/paramodulation/discrimination_tree.ml index 443c5c63b..56e8bd44a 100644 --- a/helm/ocaml/paramodulation/discrimination_tree.ml +++ b/helm/ocaml/paramodulation/discrimination_tree.ml @@ -41,59 +41,6 @@ module PosEqSet = Set.Make(OrderedPosEquality);; module DiscriminationTree = Trie.Make(PSMap);; - -(* -module DiscriminationTree = struct - type key = path_string - type t = Node of PosEqSet.t option * (t PSMap.t) - - let empty = Node (None, PSMap.empty) - - let rec find l t = - match (l, t) with - | [], Node (None, _) -> raise Not_found - | [], Node (Some v, _) -> v - | x::r, Node (_, m) -> find r (PSMap.find x m) - - let rec mem l t = - match (l, t) with - | [], Node (None, _) -> false - | [], Node (Some _, _) -> true - | x::r, Node (_, m) -> try mem r (PSMap.find x m) with Not_found -> false - - let add l v t = - let rec ins = function - | [], Node (_, m) -> Node (Some v, m) - | x::r, Node (v, m) -> - let t' = try PSMap.find x m with Not_found -> empty in - let t'' = ins (r, t') in - Node (v, PSMap.add x t'' m) - in - ins (l, t) - - let rec remove l t = - match (l, t) with - | [], Node (_, m) -> Node (None, m) - | x::r, Node (v, m) -> - try - let t' = remove r (PSMap.find x m) in - let m' = if t' = empty then PSMap.remove x m else PSMap.add x t' m in - Node (v, m') - with Not_found -> - t - - let rec fold f t acc = - let rec traverse revp t acc = match t with - | Node (None, m) -> - PSMap.fold (fun x -> traverse (x::revp)) m acc - | Node (Some v, m) -> - f (List.rev revp) v (PSMap.fold (fun x -> traverse (x::revp)) m acc) - in - traverse [] t acc - -end -*) - let string_of_discrimination_tree tree = let rec to_string level = function @@ -126,7 +73,7 @@ let string_of_discrimination_tree tree = let index tree equality = - let _, (_, l, r, ordering), _, _ = equality in + let _, _, (_, l, r, ordering), _, _ = equality in let psl = path_string_of_term l and psr = path_string_of_term r in let index pos tree ps = @@ -146,7 +93,7 @@ let index tree equality = let remove_index tree equality = - let _, (_, l, r, ordering), _, _ = equality in + let _, _, (_, l, r, ordering), _, _ = equality in let psl = path_string_of_term l and psr = path_string_of_term r in let remove_index pos tree ps = @@ -170,7 +117,7 @@ let remove_index tree equality = let in_index tree equality = - let _, (_, l, r, ordering), _, _ = equality in + let _, _, (_, l, r, ordering), _, _ = equality in let psl = path_string_of_term l and psr = path_string_of_term r in let meta_convertibility = Inference.meta_convertibility_eq equality in @@ -198,7 +145,8 @@ let rec subterm_at_pos pos term = | index::pos -> match term with | Cic.Appl l -> - (try subterm_at_pos pos (List.nth l index) with _ -> raise Not_found) + (try subterm_at_pos pos (List.nth l index) + with Failure _ -> raise Not_found) | _ -> raise Not_found ;; @@ -251,7 +199,7 @@ let retrieve_generalizations tree term = in try let n = PSMap.find (Cic.Implicit None) map in - let newpos = try after_t pos term with _ -> [-1] in + let newpos = try after_t pos term with Not_found -> [-1] in if newpos = [-1] then match n with | DiscriminationTree.Node (Some s, _) -> PosEqSet.union s res @@ -317,7 +265,7 @@ let retrieve_unifiables tree term = in try let n = PSMap.find (Cic.Implicit None) map in - let newpos = try after_t pos term with _ -> [-1] in + let newpos = try after_t pos term with Not_found -> [-1] in if newpos = [-1] then match n with | DiscriminationTree.Node (Some s, _) -> PosEqSet.union s res