src/HOL/Tools/refute.ML
changeset 20854 f9cf9e62d11c
parent 20548 8ef25fe585a8
child 21056 2cfe839e8d58
equal deleted inserted replaced
20853:3ff5a2e05810 20854:f9cf9e62d11c
   783 									raise REFUTE ("ground_types", "datatype argument (for type " ^ Sign.string_of_typ (sign_of thy) (Type (s, Ts)) ^ ") is not a variable")
   783 									raise REFUTE ("ground_types", "datatype argument (for type " ^ Sign.string_of_typ (sign_of thy) (Type (s, Ts)) ^ ") is not a variable")
   784 								else
   784 								else
   785 									())
   785 									())
   786 							(* if the current type is a recursive IDT (i.e. a depth is required), add it to 'acc' *)
   786 							(* if the current type is a recursive IDT (i.e. a depth is required), add it to 'acc' *)
   787 							val acc' = (if Library.exists (fn (_, ds) => Library.exists DatatypeAux.is_rec_type ds) constrs then
   787 							val acc' = (if Library.exists (fn (_, ds) => Library.exists DatatypeAux.is_rec_type ds) constrs then
   788 									T ins acc
   788 									insert (op =) T acc
   789 								else
   789 								else
   790 									acc)
   790 									acc)
   791 							(* collect argument types *)
   791 							(* collect argument types *)
   792 							val acc_args = foldr collect_types acc' Ts
   792 							val acc_args = foldr collect_types acc' Ts
   793 							(* collect constructor types *)
   793 							(* collect constructor types *)
   794 							val acc_constrs = foldr collect_types acc_args (List.concat (map (fn (_, ds) => map (typ_of_dtyp descr typ_assoc) ds) constrs))
   794 							val acc_constrs = foldr collect_types acc_args (List.concat (map (fn (_, ds) => map (typ_of_dtyp descr typ_assoc) ds) constrs))
   795 						in
   795 						in
   796 							acc_constrs
   796 							acc_constrs
   797 						end
   797 						end
   798 					| NONE =>  (* not an inductive datatype, e.g. defined via "typedef" or "typedecl" *)
   798 					| NONE =>  (* not an inductive datatype, e.g. defined via "typedef" or "typedecl" *)
   799 						T ins (foldr collect_types acc Ts))
   799 						insert (op =) T (foldr collect_types acc Ts))
   800 				| TFree _                => T ins acc
   800 				| TFree _                => insert (op =) T acc
   801 				| TVar _                 => T ins acc)
   801 				| TVar _                 => insert (op =) T acc)
   802 	in
   802 	in
   803 		it_term_types collect_types (t, [])
   803 		it_term_types collect_types (t, [])
   804 	end;
   804 	end;
   805 
   805 
   806 (* ------------------------------------------------------------------------- *)
   806 (* ------------------------------------------------------------------------- *)