- (* let's check if the types of the inductive constructors *)
- (* are well formed. *)
- (* In order not to use type_of_aux we put the types of the *)
- (* mutual inductive types at the head of the types of the *)
- (* constructors using Prods *)
- let len = List.length itl in
- let tys =
- List.map (fun (n,_,ty,_) -> Some (Cic.Name n,(Cic.Decl ty))) itl in
- let _ =
- List.fold_right
- (fun (_,_,_,cl) i ->
- List.iter
- (fun (name,te) ->
- let debrujinedte = debrujin_constructor uri len te in
- let augmented_term =
- List.fold_right
- (fun (name,_,ty,_) i -> Cic.Prod (Cic.Name name, ty, i))
- itl debrujinedte
- in
- let _ = type_of augmented_term in
- (* let's check also the positivity conditions *)
- if
- not
- (are_all_occurrences_positive tys uri indparamsno i 0 len
- debrujinedte)
- then
- raise (NotPositiveOccurrences (U.string_of_uri uri))
- ) cl ;
- (i + 1)
- ) itl 1
- in
- ()
- | _ ->
- raise (WrongUriToMutualInductiveDefinitions (U.string_of_uri uri))
+ (* let's check if the types of the inductive constructors *)
+ (* are well formed. *)
+ (* In order not to use type_of_aux we put the types of the *)
+ (* mutual inductive types at the head of the types of the *)
+ (* constructors using Prods *)
+ let len = List.length itl in
+ let tys =
+ List.map (fun (n,_,ty,_) -> Some (Cic.Name n,(Cic.Decl ty))) itl in
+ let _ =
+ List.fold_right
+ (fun (_,_,_,cl) i ->
+ List.iter
+ (fun (name,te) ->
+ let debrujinedte = debrujin_constructor uri len te in
+ let augmented_term =
+ List.fold_right
+ (fun (name,_,ty,_) i -> Cic.Prod (Cic.Name name, ty, i))
+ itl debrujinedte
+ in
+ let _ = type_of augmented_term in
+ (* let's check also the positivity conditions *)
+ if
+ not
+ (are_all_occurrences_positive tys uri indparamsno i 0 len
+ debrujinedte)
+ then
+ raise (NotPositiveOccurrences (U.string_of_uri uri))
+ ) cl ;
+ (i + 1)
+ ) itl 1
+ in
+ ()
+
+(* Main function to checks the correctness of a mutual *)
+(* inductive block definition. *)
+and check_mutual_inductive_defs uri =
+ function
+ Cic.InductiveDefinition (itl, params, indparamsno) ->
+ typecheck_mutual_inductive_defs uri (itl,params,indparamsno)
+ | _ ->
+ raise (WrongUriToMutualInductiveDefinitions (UriManager.string_of_uri uri))