| (C.Appl _, e, []) -> (e,safes,n,nn,x)
| (_,_,_) -> raise (Impossible 7)
-and drop_prods n te =
+and split_prods n te =
let module C = Cic in
let module R = CicReduction in
match (n, R.whd te) with
- (0, _) -> te
- | (n, C.Prod (_,_,ta)) when n > 0 -> drop_prods (n - 1) ta
+ (0, _) -> [],te
+ | (n, C.Prod (_,so,ta)) when n > 0 ->
+ let (l1,l2) = split_prods (n - 1) ta in
+ (so::l1,l2)
| (_, _) -> raise (Impossible 8)
and eat_lambdas n te =
C.InductiveDefinition (tl,_,paramsno) ->
let (_,isinductive,_,cl) = List.nth tl i in
let cl' =
- List.map (fun (id,ty,r) -> (id, drop_prods paramsno ty, r)) cl
+ List.map (fun (id,ty,r) -> (id, snd (split_prods paramsno ty), r)) cl
in
(isinductive,paramsno,cl')
| _ ->
C.InductiveDefinition (tl,_,paramsno) ->
let (_,isinductive,_,cl) = List.nth tl i in
let cl' =
- List.map (fun (id,ty,r) -> (id, drop_prods paramsno ty, r)) cl
+ List.map (fun (id,ty,r) -> (id, snd (split_prods paramsno ty), r)) cl
in
(isinductive,paramsno,cl')
| _ ->
C.InductiveDefinition (tl,_,paramsno) ->
let (_,isinductive,_,cl) = List.nth tl i in
let cl' =
- List.map (fun (id,ty,r) -> (id, drop_prods paramsno ty, r)) cl
+ List.map (fun (id,ty,r) -> (id, snd (split_prods paramsno ty), r)) cl
in
(isinductive,paramsno,cl')
| _ ->
C.InductiveDefinition (tl,_,paramsno) ->
let (_,isinductive,_,cl) = List.nth tl i in
let cl' =
- List.map (fun (id,ty,r) -> (id, drop_prods paramsno ty, r)) cl
+ List.map (fun (id,ty,r) -> (id, snd (split_prods paramsno ty), r)) cl
in
(isinductive,paramsno,cl')
| _ ->
| (C.Sort C.Set, C.Sort C.Set) when need_dummy -> true
| (C.Sort C.Set, C.Sort C.Type) when need_dummy ->
(match CicEnvironment.get_obj uri with
- C.InductiveDefinition (itl,_,_) ->
+ C.InductiveDefinition (itl,_,paramsno) ->
let (_,_,_,cl) = List.nth itl i in
- List.fold_right (fun (_,x,_) i -> i && is_small x) cl true
+ List.fold_right (fun (_,x,_) i -> i && is_small paramsno x) cl true
| _ ->
raise (WrongUriToMutualInductiveDefinitions (U.string_of_uri uri))
)
| C.Sort C.Set -> true
| C.Sort C.Type ->
(match CicEnvironment.get_obj uri with
- C.InductiveDefinition (itl,_,_) ->
+ C.InductiveDefinition (itl,_,paramsno) ->
let (_,_,_,cl) = List.nth itl i in
- List.fold_right (fun (_,x,_) i -> i && is_small x) cl true
+ List.fold_right
+ (fun (_,x,_) i -> i && is_small paramsno x) cl true
| _ ->
raise (WrongUriToMutualInductiveDefinitions
(U.string_of_uri uri))
(* is a small constructor? *)
(*CSC: ottimizzare calcolando staticamente *)
-and is_small c =
+and is_small paramsno c =
let rec is_small_aux env c =
let module C = Cic in
match CicReduction.whd c with
is_small_aux (so::env) de
| _ -> true (*CSC: we trust the type-checker *)
in
- is_small_aux [] c
+ let (sx,dx) = split_prods paramsno c in
+ is_small_aux sx dx
and type_of t =
type_of_aux' [] t