+ let types_times_kl,ugraph1 =
+ (* WAS: list rev list map *)
+ List.fold_left
+ (fun (l,ugraph) (n,k,ty,_) ->
+ let _,ugraph1 = type_of_aux ~logger context ty ugraph in
+ ((Some (C.Name n,(C.Decl ty)),k)::l,ugraph1)
+ ) ([],ugraph) fl
+ in
+ let (types,kl) = List.split types_times_kl in
+ let len = List.length types in
+ let ugraph2 =
+ List.fold_left
+ (fun ugraph (name,x,ty,bo) ->
+ let ty_bo,ugraph1 =
+ type_of_aux ~logger (types@context) bo ugraph
+ in
+ let b,ugraph2 =
+ R.are_convertible ~subst ~metasenv (types@context)
+ ty_bo (CicSubstitution.lift len ty) ugraph1 in
+ if b then
+ begin
+ let (m, eaten, context') =
+ eat_lambdas ~subst (types @ context) (x + 1) bo
+ in
+ (*
+ let's control the guarded by
+ destructors conditions D{f,k,x,M}
+ *)
+ if not (guarded_by_destructors context' eaten
+ (len + eaten) kl 1 [] m) then
+ raise
+ (TypeCheckerFailure
+ ("Fix: not guarded by destructors"))
+ else
+ ugraph2
+ end
+ else
+ raise (TypeCheckerFailure ("Fix: ill-typed bodies"))
+ ) ugraph1 fl in
+ (*CSC: controlli mancanti solo su D{f,k,x,M} *)
+ let (_,_,ty,_) = List.nth fl i in
+ ty,ugraph2
+ | C.CoFix (i,fl) ->
+ let types,ugraph1 =
+ List.fold_left
+ (fun (l,ugraph) (n,ty,_) ->
+ let _,ugraph1 =
+ type_of_aux ~logger context ty ugraph in
+ (Some (C.Name n,(C.Decl ty))::l,ugraph1)
+ ) ([],ugraph) fl