src/HOL/Tools/inductive.ML
changeset 45652 18214436e1d3
parent 45651 172aa230ce69
child 45740 132a3e1c0fe5
equal deleted inserted replaced
45651:172aa230ce69 45652:18214436e1d3
   185   end;
   185   end;
   186 
   186 
   187 type inductive_info = {names: string list, coind: bool} * inductive_result;
   187 type inductive_info = {names: string list, coind: bool} * inductive_result;
   188 
   188 
   189 val empty_equations =
   189 val empty_equations =
   190   Item_Net.init
   190   Item_Net.init Thm.eq_thm_prop
   191     (op aconv o pairself Thm.prop_of)
   191     (single o fst o HOLogic.dest_eq o HOLogic.dest_Trueprop o Thm.prop_of);
   192     (single o fst o HOLogic.dest_eq o HOLogic.dest_Trueprop o Thm.prop_of);  (* FIXME fragile wrt. morphisms *)
       
   193 
   192 
   194 datatype data = Data of
   193 datatype data = Data of
   195  {infos: inductive_info Symtab.table,
   194  {infos: inductive_info Symtab.table,
   196   monos: thm list,
   195   monos: thm list,
   197   equations: thm Item_Net.T};
   196   equations: thm Item_Net.T};
   271 
   270 
   272 (* equations *)
   271 (* equations *)
   273 
   272 
   274 val get_equations = #equations o rep_data;
   273 val get_equations = #equations o rep_data;
   275 
   274 
   276 val equation_add =
   275 val equation_add_permissive =
   277   Thm.declaration_attribute (fn thm =>
   276   Thm.declaration_attribute (fn thm =>
   278     map_data (fn (infos, monos, equations) => (infos, monos, Item_Net.update thm equations)));
   277     map_data (fn (infos, monos, equations) =>
       
   278       (infos, monos, perhaps (try (Item_Net.update thm)) equations)));
   279 
   279 
   280 
   280 
   281 
   281 
   282 (** process rules **)
   282 (** process rules **)
   283 
   283 
   883           map (Attrib.internal o K) (#2 induct)), [rulify (#1 induct)]);
   883           map (Attrib.internal o K) (#2 induct)), [rulify (#1 induct)]);
   884 
   884 
   885     val (eqs', lthy3) = lthy2 |>
   885     val (eqs', lthy3) = lthy2 |>
   886       fold_map (fn (name, eq) => Local_Theory.note
   886       fold_map (fn (name, eq) => Local_Theory.note
   887           ((Binding.qualify true (Long_Name.base_name name) (Binding.name "simps"),
   887           ((Binding.qualify true (Long_Name.base_name name) (Binding.name "simps"),
   888             [Attrib.internal (K equation_add)]), [eq])
   888             [Attrib.internal (K equation_add_permissive)]), [eq])
   889           #> apfst (hd o snd))
   889           #> apfst (hd o snd))
   890         (if null eqs then [] else (cnames ~~ eqs))
   890         (if null eqs then [] else (cnames ~~ eqs))
   891     val (inducts, lthy4) =
   891     val (inducts, lthy4) =
   892       if no_ind orelse coind then ([], lthy3)
   892       if no_ind orelse coind then ([], lthy3)
   893       else
   893       else