621 val plugins = get_first (fn Plugins_Option f => SOME (f lthy) | _ => NONE) (rev opts) |
621 val plugins = get_first (fn Plugins_Option f => SOME (f lthy) | _ => NONE) (rev opts) |
622 |> the_default Plugin_Name.default_filter; |
622 |> the_default Plugin_Name.default_filter; |
623 val nonexhaustive = exists (can (fn Nonexhaustive_Option => ())) opts; |
623 val nonexhaustive = exists (can (fn Nonexhaustive_Option => ())) opts; |
624 val transfer = exists (can (fn Transfer_Option => ())) opts; |
624 val transfer = exists (can (fn Transfer_Option => ())) opts; |
625 |
625 |
626 val code_attrs = if plugins code_plugin then [Code.add_default_eqn_attrib Code.Equation] else []; |
|
627 |
|
628 val (fixes, specs) = fst (prep_spec raw_fixes raw_specs lthy); |
626 val (fixes, specs) = fst (prep_spec raw_fixes raw_specs lthy); |
629 |
627 |
630 val mk_notes = |
628 val mk_notes = |
631 flat oooo @{map 4} (fn js => fn prefix => fn qualify => fn thms => |
629 flat oooo @{map 4} (fn js => fn prefix => fn qualify => fn thms => |
632 let |
630 let |
633 val (bs, attrss) = map_split (fst o nth specs) js; |
631 val (bs, attrss) = map_split (fst o nth specs) js; |
634 val notes = |
632 val notes = |
635 @{map 3} (fn b => fn attrs => fn thm => |
633 @{map 3} (fn b => fn attrs => fn thm => |
636 ((Binding.qualify false prefix b, code_attrs @ nitpicksimp_simp_attrs @ attrs), |
634 ((Binding.qualify false prefix b, nitpicksimp_simp_attrs @ attrs), |
637 [([thm], [])])) |
635 [([thm], [])])) |
638 bs attrss thms; |
636 bs attrss thms; |
639 in |
637 in |
640 ((qualify (Binding.qualify true prefix (Binding.name simpsN)), []), [(thms, [])]) :: notes |
638 ((qualify (Binding.qualify true prefix (Binding.name simpsN)), []), [(thms, [])]) :: notes |
641 end); |
639 end); |
643 lthy |
641 lthy |
644 |> primrec_simple0 int plugins nonexhaustive transfer fixes (map snd specs) |
642 |> primrec_simple0 int plugins nonexhaustive transfer fixes (map snd specs) |
645 |-> (fn ((names, qualifys), (ts, defs, (jss, simpss))) => |
643 |-> (fn ((names, qualifys), (ts, defs, (jss, simpss))) => |
646 Spec_Rules.add Spec_Rules.Equational (ts, flat simpss) |
644 Spec_Rules.add Spec_Rules.Equational (ts, flat simpss) |
647 #> Local_Theory.notes (mk_notes jss names qualifys simpss) |
645 #> Local_Theory.notes (mk_notes jss names qualifys simpss) |
648 #>> (fn notes => (ts, defs, map_filter (fn ("", _) => NONE | (_, thms) => SOME thms) notes))) |
646 #-> (fn notes => |
|
647 plugins code_plugin ? Code.declare_default_eqns (map (rpair true) (maps snd notes)) |
|
648 #> pair (ts, defs, map_filter (fn ("", _) => NONE | (_, thms) => SOME thms) notes))) |
649 end |
649 end |
650 handle OLD_PRIMREC () => |
650 handle OLD_PRIMREC () => |
651 old_primrec int raw_fixes raw_specs lthy |
651 old_primrec int raw_fixes raw_specs lthy |
652 |>> (fn (ts, thms) => (ts, [], [thms])); |
652 |>> (fn (ts, thms) => (ts, [], [thms])); |
653 |
653 |