src/Pure/Isar/code.ML
changeset 54886 3774542df61b
parent 54884 81b3194defe0
child 54887 83bf0ae03c50
equal deleted inserted replaced
54885:3a478d0a0e87 54886:3774542df61b
   292 
   292 
   293 val the_exec : theory -> spec = fst o Code_Data.get;
   293 val the_exec : theory -> spec = fst o Code_Data.get;
   294 
   294 
   295 fun map_exec_purge f = Code_Data.map (fn (exec, _) => (f exec, empty_dataref ()));
   295 fun map_exec_purge f = Code_Data.map (fn (exec, _) => (f exec, empty_dataref ()));
   296 
   296 
   297 fun change_fun_spec delete c f = (map_exec_purge o map_functions
   297 fun change_fun_spec c f = (map_exec_purge o map_functions
   298   o (if delete then Symtab.map_entry c else Symtab.map_default (c, ((false, empty_fun_spec), [])))
   298   o (Symtab.map_default (c, ((false, empty_fun_spec), [])))
   299     o apfst) (fn (_, spec) => (true, f spec));
   299     o apfst) (fn (_, spec) => (true, f spec));
   300 
   300 
   301 
   301 
   302 (* tackling equation history *)
   302 (* tackling equation history *)
   303 
   303 
  1055     fun add_eqn' true (Default (eqns, _)) = Default (natural_order ((thm, proper) :: eqns))
  1055     fun add_eqn' true (Default (eqns, _)) = Default (natural_order ((thm, proper) :: eqns))
  1056           (*this restores the natural order and drops syntactic redundancies*)
  1056           (*this restores the natural order and drops syntactic redundancies*)
  1057       | add_eqn' true fun_spec = fun_spec
  1057       | add_eqn' true fun_spec = fun_spec
  1058       | add_eqn' false (Eqns eqns) = Eqns (update_subsume true (thm, proper) eqns)
  1058       | add_eqn' false (Eqns eqns) = Eqns (update_subsume true (thm, proper) eqns)
  1059       | add_eqn' false _ = Eqns [(thm, proper)];
  1059       | add_eqn' false _ = Eqns [(thm, proper)];
  1060   in change_fun_spec false c (add_eqn' default) thy end;
  1060   in change_fun_spec c (add_eqn' default) thy end;
  1061 
  1061 
  1062 fun gen_add_abs_eqn raw_thm thy =
  1062 fun gen_add_abs_eqn raw_thm thy =
  1063   let
  1063   let
  1064     val (abs_thm, tyco) = apfst Thm.close_derivation raw_thm;
  1064     val (abs_thm, tyco) = apfst Thm.close_derivation raw_thm;
  1065     val c = const_abs_eqn thy abs_thm;
  1065     val c = const_abs_eqn thy abs_thm;
  1066   in change_fun_spec false c (K (Abstr (abs_thm, tyco))) thy end;
  1066   in change_fun_spec c (K (Abstr (abs_thm, tyco))) thy end;
  1067 
  1067 
  1068 fun add_eqn thm thy =
  1068 fun add_eqn thm thy =
  1069   gen_add_eqn false (mk_eqn thy (thm, true)) thy;
  1069   gen_add_eqn false (mk_eqn thy (thm, true)) thy;
  1070 
  1070 
  1071 fun add_nbe_eqn thm thy =
  1071 fun add_nbe_eqn thm thy =
  1099  of SOME (thm, _) => let
  1099  of SOME (thm, _) => let
  1100         fun del_eqn' (Default _) = empty_fun_spec
  1100         fun del_eqn' (Default _) = empty_fun_spec
  1101           | del_eqn' (Eqns eqns) =
  1101           | del_eqn' (Eqns eqns) =
  1102               Eqns (filter_out (fn (thm', _) => Thm.eq_thm_prop (thm, thm')) eqns)
  1102               Eqns (filter_out (fn (thm', _) => Thm.eq_thm_prop (thm, thm')) eqns)
  1103           | del_eqn' spec = spec
  1103           | del_eqn' spec = spec
  1104       in change_fun_spec true (const_eqn thy thm) del_eqn' thy end
  1104       in change_fun_spec (const_eqn thy thm) del_eqn' thy end
  1105   | NONE => thy;
  1105   | NONE => thy;
  1106 
  1106 
  1107 fun del_eqns c = change_fun_spec true c (K empty_fun_spec);
  1107 fun del_eqns c = change_fun_spec c (K empty_fun_spec);
  1108 
  1108 
  1109 
  1109 
  1110 (* cases *)
  1110 (* cases *)
  1111 
  1111 
  1112 fun case_cong thy case_const (num_args, (pos, _)) =
  1112 fun case_cong thy case_const (num_args, (pos, _)) =
  1215     val (tyco, (vs, (abs_ty as (abs, (_, ty)), (rep, cert)))) =
  1215     val (tyco, (vs, (abs_ty as (abs, (_, ty)), (rep, cert)))) =
  1216       error_abs_thm (check_abstype_cert thy) thy proto_thm;
  1216       error_abs_thm (check_abstype_cert thy) thy proto_thm;
  1217   in
  1217   in
  1218     thy
  1218     thy
  1219     |> register_type (tyco, (vs, Abstractor (abs_ty, (rep, cert))))
  1219     |> register_type (tyco, (vs, Abstractor (abs_ty, (rep, cert))))
  1220     |> change_fun_spec false rep
  1220     |> change_fun_spec rep
  1221       (K (Proj (Logic.varify_types_global (mk_proj tyco vs ty abs rep), tyco)))
  1221       (K (Proj (Logic.varify_types_global (mk_proj tyco vs ty abs rep), tyco)))
  1222     |> Abstype_Interpretation.data (tyco, serial ())
  1222     |> Abstype_Interpretation.data (tyco, serial ())
  1223   end;
  1223   end;
  1224 
  1224 
  1225 
  1225