X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fng_kernel%2FnCicUtils.ml;h=a99ae0407f638b65e2932239b6bafac51f13bc2e;hb=5d0d8107649b9264ebe7d8ff2c69bf777179b0d2;hp=74d1a78344f3a9862000723b014cc19ff80750e6;hpb=9bd50f57560e6877c3829b788bab2c8c063678a4;p=helm.git diff --git a/helm/software/components/ng_kernel/nCicUtils.ml b/helm/software/components/ng_kernel/nCicUtils.ml index 74d1a7834..a99ae0407 100644 --- a/helm/software/components/ng_kernel/nCicUtils.ml +++ b/helm/software/components/ng_kernel/nCicUtils.ml @@ -17,6 +17,9 @@ module Ref = NReference exception Subst_not_found of int exception Meta_not_found of int +let head_beta_reduce = ref (fun ~upto:_ _ -> assert false);; +let set_head_beta_reduce = (:=) head_beta_reduce;; + let expand_local_context = function | C.Irl len -> let rec aux acc = function @@ -61,10 +64,18 @@ let map g k f = function | C.Rel _ as t -> t | C.Appl [] | C.Appl [_] -> assert false | C.Appl l as orig -> - (match HExtlib.sharing_map (f k) l with + let fire_beta, upto = + match l with C.Meta _ :: _ -> true, List.length l - 1 | _ -> false, 0 + in + let l1 = HExtlib.sharing_map (f k) l in + if l == l1 then orig else + let t = + match l1 with | C.Appl l :: tl -> C.Appl (l@tl) - | l1 when l == l1 -> orig - | l1 -> C.Appl l1) + | l1 -> C.Appl l1 + in + if fire_beta then !head_beta_reduce ~upto t + else t | C.Prod (n,s,t) as orig -> let s1 = f k s in let t1 = f (g (n,C.Decl s) k) t in if t1 == t && s1 == s then orig else C.Prod (n,s1,t1) @@ -80,39 +91,3 @@ let map g k f = function if oty1 == oty && t1 == t && pl1 == pl then orig else C.Match(r,oty1,t1,pl1) ;; - -let map_term_fold_a g k f a = function - | C.Meta _ -> assert false - | C.Implicit _ - | C.Sort _ - | C.Const _ - | C.Rel _ as t -> a,t - | C.Appl [] | C.Appl [_] -> assert false - | C.Appl l as orig -> - let a,l = - (* sharing fold? *) - List.fold_right (fun t (a,l) -> let a,t = f k a t in a, t :: l) l (a,[]) - in - a, (match l with - | C.Appl l :: tl -> C.Appl (l@tl) - | l1 when l == l1 -> orig - | l1 -> C.Appl l1) - | C.Prod (n,s,t) as orig -> - let a,s1 = f k a s in let a,t1 = f (g (n,C.Decl s) k) a t in - a, if t1 == t && s1 == s then orig else C.Prod (n,s1,t1) - | C.Lambda (n,s,t) as orig -> - let a,s1 = f k a s in let a,t1 = f (g (n,C.Decl s) k) a t in - a, if t1 == t && s1 == s then orig else C.Lambda (n,s1,t1) - | C.LetIn (n,ty,t,b) as orig -> - let a,ty1 = f k a ty in let a,t1 = f k a t in - let a,b1 = f (g (n,C.Def (t,ty)) k) a b in - a, if ty1 == ty && t1 == t && b1 == b then orig else C.LetIn (n,ty1,t1,b1) - | C.Match (r,oty,t,pl) as orig -> - let a,oty1 = f k a oty in let a,t1 = f k a t in - let a,pl1 = - (* sharing fold? *) - List.fold_right (fun t (a,l) -> let a,t = f k a t in a,t::l) pl (a,[]) - in - a, if oty1 == oty && t1 == t && pl1 == pl then orig - else C.Match(r,oty1,t1,pl1) -;;