+and eat_prods ~subst ~metasenv context he ty_he args_with_ty =
+ let rec aux ty_he = function
+ | [] -> ty_he
+ | (arg, ty_arg)::tl ->
+ match R.whd ~subst context ty_he with
+ | C.Prod (_,s,t) ->
+ if R.are_convertible ~subst get_relevance context ty_arg s then
+ aux (S.subst ~avoid_beta_redexes:true arg t) tl
+ else
+ raise
+ (TypeCheckerFailure
+ (lazy (Printf.sprintf
+ ("Appl: wrong application of %s: the parameter %s has type"^^
+ "\n%s\nbut it should have type \n%s\nContext:\n%s\n")
+ (PP.ppterm ~subst ~metasenv ~context he)
+ (PP.ppterm ~subst ~metasenv ~context arg)
+ (PP.ppterm ~subst ~metasenv ~context ty_arg)
+ (PP.ppterm ~subst ~metasenv ~context s)
+ (PP.ppcontext ~subst ~metasenv context))))
+ | _ ->
+ raise
+ (TypeCheckerFailure
+ (lazy (Printf.sprintf
+ "Appl: %s is not a function, it cannot be applied"
+ (PP.ppterm ~subst ~metasenv ~context
+ (let res = List.length tl in
+ let eaten = List.length args_with_ty - res in
+ (C.Appl
+ (he::List.map fst
+ (fst (HExtlib.split_nth eaten args_with_ty)))))))))
+ in
+ aux ty_he args_with_ty
+
+and is_non_recursive_singleton (Ref.Ref (uri,_)) iname ity cty =
+ let ctx = [iname, C.Decl ity] in
+ let cty = debruijn uri 1 [] cty in
+ let len = List.length ctx in
+ let rec aux ctx n nn t =
+ match R.whd ctx t with
+ | C.Prod (name, src, tgt) ->
+ does_not_occur ~subst:[] ctx n nn src &&
+ aux ((name, C.Decl src) :: ctx) (n+1) (nn+1) tgt
+ | C.Rel k | C.Appl (C.Rel k :: _) when k = nn -> true
+ | _ -> assert false
+ in
+ aux ctx (len-1) len cty
+
+and is_non_informative paramsno c =
+ let rec aux context c =
+ match R.whd context c with
+ | C.Prod (n,so,de) ->
+ let s = typeof ~metasenv:[] ~subst:[] context so in
+ s = C.Sort C.Prop && aux ((n,(C.Decl so))::context) de
+ | _ -> true in
+ let context',dx = split_prods ~subst:[] [] paramsno c in
+ aux context' dx
+
+and check_mutual_inductive_defs uri ~metasenv ~subst leftno tyl =