src/Pure/theory.ML
changeset 35987 7c728daf4876
parent 35985 0bbf0d2348f9
child 35988 76ca601c941e
equal deleted inserted replaced
35986:b7fcca3d9a44 35987:7c728daf4876
   157 fun cert_axm thy (b, raw_tm) =
   157 fun cert_axm thy (b, raw_tm) =
   158   let
   158   let
   159     val t = Sign.cert_prop thy raw_tm
   159     val t = Sign.cert_prop thy raw_tm
   160       handle TYPE (msg, _, _) => error msg
   160       handle TYPE (msg, _, _) => error msg
   161         | TERM (msg, _) => error msg;
   161         | TERM (msg, _) => error msg;
       
   162     val _ = Term.no_dummy_patterns t handle TERM (msg, _) => error msg;
       
   163 
       
   164     val bad_sorts =
       
   165       rev ((fold_types o fold_atyps_sorts) (fn (_, []) => I | (T, _) => insert (op =) T) t []);
       
   166     val _ = null bad_sorts orelse
       
   167       error ("Illegal sort constraints in primitive specification: " ^
       
   168         commas (map (setmp_CRITICAL show_sorts true (Syntax.string_of_typ_global thy)) bad_sorts));
   162   in
   169   in
   163     Term.no_dummy_patterns t handle TERM (msg, _) => error msg;
       
   164     (b, Sign.no_vars (Syntax.pp_global thy) t)
   170     (b, Sign.no_vars (Syntax.pp_global thy) t)
   165   end;
   171   end handle ERROR msg =>
       
   172     cat_error msg ("The error(s) above occurred in axiom " ^ quote (Binding.str_of b));
   166 
   173 
   167 fun add_axiom raw_axm thy = thy |> map_axioms (fn axioms =>
   174 fun add_axiom raw_axm thy = thy |> map_axioms (fn axioms =>
   168   let
   175   let
   169     val axm = apsnd Logic.varify_global (cert_axm thy raw_axm);
   176     val axm = apsnd Logic.varify_global (cert_axm thy raw_axm);
   170     val (_, axioms') = Name_Space.define true (Sign.naming_of thy) axm axioms;
   177     val (_, axioms') = Name_Space.define true (Sign.naming_of thy) axm axioms;