- | NCic.Meta _ -> assert false
- | NCic.Implicit _
- | NCic.Sort _
- | NCic.Const _
- | NCic.Rel _ as t -> t
- | NCic.Appl [] | NCic.Appl [_] -> assert false
- | NCic.Appl l as orig ->
- (match sharing_map (f k) l with
- | NCic.Appl l :: tl -> NCic.Appl (l@tl)
- | l1 when l == l1 -> orig
- | l1 -> NCic.Appl l1)
- | NCic.Prod (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)
- | 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.Lambda (n,s1,t1)
- | NCic.LetIn (n,ty,t,b) as orig ->
+ | C.Meta _ -> assert false
+ | C.Implicit _
+ | C.Sort _
+ | C.Const _
+ | C.Rel _ as t -> t
+ | C.Appl [] | C.Appl [_] -> assert false
+ | C.Appl l as orig ->
+ 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 -> 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)
+ | C.Lambda (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.Lambda (n,s1,t1)
+ | C.LetIn (n,ty,t,b) as orig ->