X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fng_kernel%2FnCicUtils.ml;h=3d3c2d90e243f145f8c887a1676d90ec342f6197;hb=15bc0d34ae5f72cb31ec383e1ac48ad53f06a725;hp=707ea93b6f4a501c06d7d1535c99611751e1cfb1;hpb=5ba3b166fff4398b031774b52bd7c1ae1e5be09b;p=helm.git diff --git a/helm/software/components/ng_kernel/nCicUtils.ml b/helm/software/components/ng_kernel/nCicUtils.ml index 707ea93b6..3d3c2d90e 100644 --- a/helm/software/components/ng_kernel/nCicUtils.ml +++ b/helm/software/components/ng_kernel/nCicUtils.ml @@ -9,7 +9,7 @@ \ / This software is distributed as is, NO WARRANTY. V_______________________________________________________________ *) -(* $Id: nCicSubstitution.ml 8135 2008-02-13 15:35:43Z tassi $ *) +(* $Id$ *) exception Subst_not_found of int exception Meta_not_found of int @@ -30,10 +30,10 @@ let lookup_subst n subst = with Not_found -> raise (Subst_not_found n) ;; -let lookup_meta index metasenv = +let lookup_meta n metasenv = try - List.find (fun (index', _, _, _) -> index = index') metasenv - with Not_found -> raise (Meta_not_found index) + List.assoc n metasenv + with Not_found -> raise (Meta_not_found n) ;; let fold g k f acc = function @@ -50,18 +50,6 @@ let fold g k f acc = function | NCic.Match (_,oty,t,pl) -> List.fold_left (f k) (f k (f k acc oty) t) pl ;; -let sharing_map f l = - let unchanged = ref true in - let rec aux b = function - | [] as t -> unchanged := b; t - | he::tl -> - let he1 = f he in - he1 :: aux (b && he1 == he) tl - in - let l1 = aux true l in - if !unchanged then l else l1 -;; - let map g k f = function | NCic.Meta _ -> assert false | NCic.Implicit _ @@ -70,7 +58,7 @@ let map g k f = function | NCic.Rel _ as t -> t | NCic.Appl [] | NCic.Appl [_] -> assert false | NCic.Appl l as orig -> - (match sharing_map (f k) l with + (match HExtlib.sharing_map (f k) l with | NCic.Appl l :: tl -> NCic.Appl (l@tl) | l1 when l == l1 -> orig | l1 -> NCic.Appl l1) @@ -79,28 +67,13 @@ let map g k f = function if t1 == t && s1 == s then orig else NCic.Prod (n,s1,t1) | NCic.Lambda (n,s,t) as orig -> let s1 = f k s in let t1 = f (g (n,NCic.Decl s) k) t in - if t1 == t && s1 == s then orig else NCic.Prod (n,s1,t1) + if t1 == t && s1 == s then orig else NCic.Lambda (n,s1,t1) | NCic.LetIn (n,ty,t,b) as orig -> let ty1 = f k ty in let t1 = f k t in let b1 = f (g (n,NCic.Def (t,ty)) k) b in if ty1 == ty && t1 == t && b1 == b then orig else NCic.LetIn (n,ty1,t1,b1) | NCic.Match (r,oty,t,pl) as orig -> - let oty1 = f k oty in let t1 = f k t in let pl1 = sharing_map (f k) pl in + let oty1 = f k oty in let t1 = f k t in let pl1 = HExtlib.sharing_map (f k) pl in if oty1 == oty && t1 == t && pl1 == pl then orig else NCic.Match(r,oty1,t1,pl1) ;; - -exception NotClosed - -let is_closed t = - try - let rec aux k _ = function - | NCic.Rel n when n > k -> raise NotClosed - | NCic.Meta (_, (s, NCic.Irl n)) when not (n+s <= k) -> raise NotClosed - | NCic.Meta (_, (s, NCic.Ctx l)) -> List.iter (aux (k+s) ()) l - | _ -> fold (fun _ k -> k + 1) k aux () t - in - aux 0 () t; true - with NotClosed -> false -;; -