]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/ng_kernel/nCicUtils.ml
in the new kernel you can type Type[i] to mean Type_i, and Type is interpreted as
[helm.git] / helm / software / components / ng_kernel / nCicUtils.ml
index f4f77a3679783c3663931f13c6d3832c000463ec..a99ae0407f638b65e2932239b6bafac51f13bc2e 100644 (file)
@@ -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)