263 |-> (fn defs => `(fn lthy => (prefix, prove lthy defs))) |
263 |-> (fn defs => `(fn lthy => (prefix, prove lthy defs))) |
264 end; |
264 end; |
265 |
265 |
266 local |
266 local |
267 |
267 |
268 fun gen_primrec set_group prep_spec raw_fixes raw_spec lthy = |
268 fun gen_primrec prep_spec raw_fixes raw_spec lthy = |
269 let |
269 let |
270 val (fixes, spec) = fst (prep_spec raw_fixes raw_spec lthy); |
270 val (fixes, spec) = fst (prep_spec raw_fixes raw_spec lthy); |
271 fun attr_bindings prefix = map (fn ((b, attrs), _) => |
271 fun attr_bindings prefix = map (fn ((b, attrs), _) => |
272 (Binding.qualify false prefix b, Code.add_default_eqn_attrib :: attrs)) spec; |
272 (Binding.qualify false prefix b, Code.add_default_eqn_attrib :: attrs)) spec; |
273 fun simp_attr_binding prefix = |
273 fun simp_attr_binding prefix = |
274 (Binding.qualify true prefix (Binding.name "simps"), |
274 (Binding.qualify true prefix (Binding.name "simps"), |
275 map (Attrib.internal o K) [Simplifier.simp_add, Nitpick_Simps.add]); |
275 map (Attrib.internal o K) [Simplifier.simp_add, Nitpick_Simps.add]); |
276 in |
276 in |
277 lthy |
277 lthy |
278 |> set_group ? Local_Theory.set_group (serial ()) |
|
279 |> add_primrec_simple fixes (map snd spec) |
278 |> add_primrec_simple fixes (map snd spec) |
280 |-> (fn (prefix, simps) => fold_map Local_Theory.note (attr_bindings prefix ~~ simps) |
279 |-> (fn (prefix, simps) => fold_map Local_Theory.note (attr_bindings prefix ~~ simps) |
281 #-> (fn simps' => Local_Theory.note (simp_attr_binding prefix, maps snd simps'))) |
280 #-> (fn simps' => Local_Theory.note (simp_attr_binding prefix, maps snd simps'))) |
282 |>> snd |
281 |>> snd |
283 end; |
282 end; |
284 |
283 |
285 in |
284 in |
286 |
285 |
287 val add_primrec = gen_primrec false Specification.check_spec; |
286 val add_primrec = gen_primrec Specification.check_spec; |
288 val add_primrec_cmd = gen_primrec true Specification.read_spec; |
287 val add_primrec_cmd = gen_primrec Specification.read_spec; |
289 |
288 |
290 end; |
289 end; |
291 |
290 |
292 fun add_primrec_global fixes specs thy = |
291 fun add_primrec_global fixes specs thy = |
293 let |
292 let |