274 |
274 |
275 fun gen_primrec prep_spec int raw_fixes raw_spec lthy = |
275 fun gen_primrec prep_spec int raw_fixes raw_spec lthy = |
276 let |
276 let |
277 val (fixes, spec) = fst (prep_spec raw_fixes raw_spec lthy); |
277 val (fixes, spec) = fst (prep_spec raw_fixes raw_spec lthy); |
278 fun attr_bindings prefix = map (fn ((b, attrs), _) => |
278 fun attr_bindings prefix = map (fn ((b, attrs), _) => |
279 (Binding.qualify false prefix b, Code.add_default_eqn_attrib Code.Equation :: attrs)) spec; |
279 (Binding.qualify false prefix b, attrs)) spec; |
280 fun simp_attr_binding prefix = |
280 fun simp_attr_binding prefix = |
281 (Binding.qualify true prefix (Binding.name "simps"), @{attributes [simp, nitpick_simp]}); |
281 (Binding.qualify true prefix (Binding.name "simps"), @{attributes [simp, nitpick_simp]}); |
282 in |
282 in |
283 lthy |
283 lthy |
284 |> primrec_simple int fixes (map snd spec) |
284 |> primrec_simple int fixes (map snd spec) |
285 |-> (fn (prefix, (ts, simps)) => |
285 |-> (fn (prefix, (ts, simps)) => |
286 Spec_Rules.add Spec_Rules.Equational (ts, simps) |
286 Spec_Rules.add Spec_Rules.Equational (ts, simps) |
287 #> fold_map Local_Theory.note (attr_bindings prefix ~~ map single simps) |
287 #> fold_map Local_Theory.note (attr_bindings prefix ~~ map single simps) |
288 #-> (fn simps' => Local_Theory.note (simp_attr_binding prefix, maps snd simps') |
288 #-> (fn simps' => Local_Theory.note (simp_attr_binding prefix, maps snd simps') |
289 #>> (fn (_, simps'') => (ts, simps'')))) |
289 #-> (fn (_, simps'') => |
|
290 Code.declare_default_eqns (map (rpair true) simps'') |
|
291 #> pair (ts, simps'')))) |
290 end; |
292 end; |
291 |
293 |
292 in |
294 in |
293 |
295 |
294 val primrec = gen_primrec Specification.check_multi_specs; |
296 val primrec = gen_primrec Specification.check_multi_specs; |