202 congs wfs name R eqs; |
202 congs wfs name R eqs; |
203 val rules = (map o map) fst (partition_eq (eq_snd (op = : int * int -> bool)) rules_idx); |
203 val rules = (map o map) fst (partition_eq (eq_snd (op = : int * int -> bool)) rules_idx); |
204 val simp_att = |
204 val simp_att = |
205 if null tcs then [Simplifier.simp_add, Nitpick_Simps.add, Code.add_default_eqn_attribute] |
205 if null tcs then [Simplifier.simp_add, Nitpick_Simps.add, Code.add_default_eqn_attribute] |
206 else []; |
206 else []; |
207 |
207 fun specs_of simps = |
|
208 let |
|
209 fun dest_eqn th = fst (strip_comb (fst (HOLogic.dest_eq (HOLogic.dest_Trueprop (prop_of th))))) |
|
210 val ts = distinct (op =) (map dest_eqn simps) |
|
211 in (ts, simps) end |
208 val ((simps' :: rules', [induct']), thy) = |
212 val ((simps' :: rules', [induct']), thy) = |
209 thy |
213 thy |
210 |> Sign.add_path bname |
214 |> Sign.add_path bname |
211 |> PureThy.add_thmss |
215 |> PureThy.add_thmss |
212 (((Binding.name "simps", flat rules), simp_att) :: ((eq_names ~~ rules) ~~ eq_atts)) |
216 (((Binding.name "simps", flat rules), simp_att) :: ((eq_names ~~ rules) ~~ eq_atts)) |
213 ||>> PureThy.add_thms [((Binding.name "induct", induct), [])]; |
217 ||>> PureThy.add_thms [((Binding.name "induct", induct), [])] |
|
218 ||> Spec_Rules.add_global Spec_Rules.Equational (specs_of (flat rules)); |
214 val result = {simps = simps', rules = rules', induct = induct', tcs = tcs}; |
219 val result = {simps = simps', rules = rules', induct = induct', tcs = tcs}; |
215 val thy = |
220 val thy = |
216 thy |
221 thy |
217 |> put_recdef name result |
222 |> put_recdef name result |
218 |> Sign.parent_path; |
223 |> Sign.parent_path; |