src/Pure/Isar/code_unit.ML
changeset 31092 27a6558e64b6
parent 31090 3be41b271023
child 31138 a51ce445d498
equal deleted inserted replaced
31091:8316d22f10f5 31092:27a6558e64b6
   354       | check 0 (Var _) = ()
   354       | check 0 (Var _) = ()
   355       | check _ (Var _) = bad_thm
   355       | check _ (Var _) = bad_thm
   356           ("Variable with application on left hand side of equation\n"
   356           ("Variable with application on left hand side of equation\n"
   357             ^ Display.string_of_thm thm)
   357             ^ Display.string_of_thm thm)
   358       | check n (t1 $ t2) = (check (n+1) t1; check 0 t2)
   358       | check n (t1 $ t2) = (check (n+1) t1; check 0 t2)
   359       | check n (Const (_, ty)) = if n <> (length o fst o strip_type) ty
   359       | check n (Const (c_ty as (c, ty))) = if n = (length o fst o strip_type) ty
   360           then bad_thm
   360           then if not proper orelse is_constr_pat (AxClass.unoverload_const thy c_ty)
   361             ("Partially applied constant on left hand side of equation\n"
   361             then ()
   362                ^ Display.string_of_thm thm)
   362             else bad_thm (quote c ^ " is not a constructor, on left hand side of equation\n"
   363           else ();
   363               ^ Display.string_of_thm thm)
       
   364           else bad_thm
       
   365             ("Partially applied constant " ^ quote c ^ " on left hand side of equation\n"
       
   366                ^ Display.string_of_thm thm);
   364     val _ = map (check 0) args;
   367     val _ = map (check 0) args;
   365     val _ = (map o map_aterms) (fn t as Const (c, _) => if is_constr_pat c then t
       
   366           else bad_thm (quote c ^ "is not a constructor, on left hand side of equation\n"
       
   367             ^ Display.string_of_thm thm)
       
   368       | t => t) args;
       
   369     val _ = if not proper orelse is_linear thm then ()
   368     val _ = if not proper orelse is_linear thm then ()
   370       else bad_thm ("Duplicate variables on left hand side of equation\n"
   369       else bad_thm ("Duplicate variables on left hand side of equation\n"
   371         ^ Display.string_of_thm thm);
   370         ^ Display.string_of_thm thm);
   372     val _ = if (is_none o AxClass.class_of_param thy) c
   371     val _ = if (is_none o AxClass.class_of_param thy) c
   373       then ()
   372       then ()
   384            ^ Display.string_of_thm thm
   383            ^ Display.string_of_thm thm
   385            ^ "\nis incompatible with declared function type\n"
   384            ^ "\nis incompatible with declared function type\n"
   386            ^ string_of_typ thy ty_decl)
   385            ^ string_of_typ thy ty_decl)
   387   in (thm, proper) end;
   386   in (thm, proper) end;
   388 
   387 
   389 fun assert_eqn thy is_constr = gen_assert_eqn thy is_constr is_constr;
   388 fun assert_eqn thy is_constr = error_thm (gen_assert_eqn thy is_constr is_constr);
   390 
   389 
   391 val const_typ_eqn = dest_Const o fst o strip_comb o fst o Logic.dest_equals o Thm.plain_prop_of;
   390 val const_typ_eqn = dest_Const o fst o strip_comb o fst o Logic.dest_equals o Thm.plain_prop_of;
   392 
   391 
   393 fun typscheme_eqn thy = typscheme thy o const_typ_eqn;
   392 fun typscheme_eqn thy = typscheme thy o const_typ_eqn;
   394 
   393