equal
deleted
inserted
replaced
219 val rewrites = map mk_meta_eq rec_rewrites @ map (snd o snd) defs; |
219 val rewrites = map mk_meta_eq rec_rewrites @ map (snd o snd) defs; |
220 fun tac _ = EVERY [rewrite_goals_tac rewrites, rtac refl 1]; |
220 fun tac _ = EVERY [rewrite_goals_tac rewrites, rtac refl 1]; |
221 val _ = message ("Proving equations for primrec function(s) " ^ commas_quote names); |
221 val _ = message ("Proving equations for primrec function(s) " ^ commas_quote names); |
222 in map (fn (name_attr, t) => (name_attr, [Goal.prove ctxt [] [] t tac])) end; |
222 in map (fn (name_attr, t) => (name_attr, [Goal.prove ctxt [] [] t tac])) end; |
223 |
223 |
224 fun gen_primrec prep_spec raw_fixes raw_spec lthy = |
224 fun gen_primrec set_group prep_spec raw_fixes raw_spec lthy = |
225 let |
225 let |
226 val (fixes, spec) = prepare_spec prep_spec lthy raw_fixes raw_spec; |
226 val (fixes, spec) = prepare_spec prep_spec lthy raw_fixes raw_spec; |
227 val eqns = fold_rev (process_eqn (fn v => Variable.is_fixed lthy v |
227 val eqns = fold_rev (process_eqn (fn v => Variable.is_fixed lthy v |
228 orelse exists (fn ((w, _), _) => v = w) fixes) o snd) spec []; |
228 orelse exists (fn ((w, _), _) => v = w) fixes) o snd) spec []; |
229 val tnames = distinct (op =) (map (#1 o snd) eqns); |
229 val tnames = distinct (op =) (map (#1 o snd) eqns); |
246 (space_implode "_" (map (Sign.base_name o #1) defs)); |
246 (space_implode "_" (map (Sign.base_name o #1) defs)); |
247 val simp_atts = map (Attrib.internal o K) |
247 val simp_atts = map (Attrib.internal o K) |
248 [Simplifier.simp_add, RecfunCodegen.add NONE]; |
248 [Simplifier.simp_add, RecfunCodegen.add NONE]; |
249 in |
249 in |
250 lthy |
250 lthy |
|
251 |> set_group ? LocalTheory.set_group (serial_string ()) |
251 |> fold_map (LocalTheory.define Thm.definitionK o make_def lthy fixes fs) defs |
252 |> fold_map (LocalTheory.define Thm.definitionK o make_def lthy fixes fs) defs |
252 |-> (fn defs => `(fn ctxt => prove_spec ctxt names1 rec_rewrites defs spec)) |
253 |-> (fn defs => `(fn ctxt => prove_spec ctxt names1 rec_rewrites defs spec)) |
253 |-> (fn simps => fold_map (LocalTheory.note Thm.theoremK) simps) |
254 |-> (fn simps => fold_map (LocalTheory.note Thm.theoremK) simps) |
254 |-> (fn simps' => LocalTheory.note Thm.theoremK |
255 |-> (fn simps' => LocalTheory.note Thm.theoremK |
255 ((qualify "simps", simp_atts), maps snd simps')) |
256 ((qualify "simps", simp_atts), maps snd simps')) |
259 of SOME eqn => "\nin\n" ^ quote (Syntax.string_of_term lthy eqn) |
260 of SOME eqn => "\nin\n" ^ quote (Syntax.string_of_term lthy eqn) |
260 | NONE => "")); |
261 | NONE => "")); |
261 |
262 |
262 in |
263 in |
263 |
264 |
264 val add_primrec = gen_primrec Specification.check_specification; |
265 val add_primrec = gen_primrec false Specification.check_specification; |
265 val add_primrec_cmd = gen_primrec Specification.read_specification; |
266 val add_primrec_cmd = gen_primrec true Specification.read_specification; |
266 |
267 |
267 end; |
268 end; |
268 |
269 |
269 |
270 |
270 (* outer syntax *) |
271 (* outer syntax *) |