Added check whether argument types of inductive set agree with types of declared
authorberghofe
Fri, 03 Apr 2009 10:08:47 +0200
changeset 30860 e5f9477aed50
parent 30851 a218363290c3
child 30861 294e8ee163ea
Added check whether argument types of inductive set agree with types of declared parameters to avoid low-level error messages.
src/HOL/Tools/inductive_set_package.ML
--- a/src/HOL/Tools/inductive_set_package.ML	Thu Apr 02 14:39:29 2009 +0200
+++ b/src/HOL/Tools/inductive_set_package.ML	Fri Apr 03 10:08:47 2009 +0200
@@ -435,12 +435,19 @@
        | NONE => (x, (x, (x, x))))) params;
     val (params1, (params2, params3)) =
       params' |> map snd |> split_list ||> split_list;
+    val paramTs = map fastype_of params;
 
     (* equations for converting sets to predicates *)
     val ((cs', cs_info), eqns) = cs |> map (fn c as Free (s, T) =>
       let
         val fs = the_default [] (AList.lookup op = new_arities c);
-        val (_, U) = split_last (binder_types T);
+        val (Us, U) = split_last (binder_types T);
+        val _ = Us = paramTs orelse error (Pretty.string_of (Pretty.chunks
+          [Pretty.str "Argument types",
+           Pretty.block (Pretty.commas (map (Syntax.pretty_typ ctxt) Us)),
+           Pretty.str ("of " ^ s ^ " do not agree with types"),
+           Pretty.block (Pretty.commas (map (Syntax.pretty_typ ctxt) paramTs)),
+           Pretty.str "of declared parameters"]));
         val Ts = HOLogic.prodT_factors' fs U;
         val c' = Free (s ^ "p",
           map fastype_of params1 @ Ts ---> HOLogic.boolT)