53 val saved_psimps = flat (map snd (flat saved_spec_psimps)) |
53 val saved_psimps = flat (map snd (flat saved_spec_psimps)) |
54 |
54 |
55 val psimps_by_f = FundefMutual.sort_by_function mutual_info fnames saved_psimps |
55 val psimps_by_f = FundefMutual.sort_by_function mutual_info fnames saved_psimps |
56 |
56 |
57 fun add_for_f fname psimps = |
57 fun add_for_f fname psimps = |
58 LocalTheory.note ((NameSpace.append fname label, Attrib.internal Simplifier.simp_add :: moreatts), psimps) #> snd |
58 LocalTheory.note ((NameSpace.qualified fname label, Attrib.internal Simplifier.simp_add :: moreatts), psimps) #> snd |
59 in |
59 in |
60 (saved_psimps, |
60 (saved_psimps, |
61 fold2 add_for_f fnames psimps_by_f lthy) |
61 fold2 add_for_f fnames psimps_by_f lthy) |
62 end |
62 end |
63 |
63 |
66 let |
66 let |
67 val FundefConfig { domintros, ...} = config |
67 val FundefConfig { domintros, ...} = config |
68 val Prep {f, R, ...} = data |
68 val Prep {f, R, ...} = data |
69 val fundef_data = FundefMutual.mk_partial_rules_mutual lthy mutual_info data result |
69 val fundef_data = FundefMutual.mk_partial_rules_mutual lthy mutual_info data result |
70 val FundefMResult {psimps, subset_pinducts, simple_pinducts, termination, domintros, cases, ...} = fundef_data |
70 val FundefMResult {psimps, subset_pinducts, simple_pinducts, termination, domintros, cases, ...} = fundef_data |
71 val qualify = NameSpace.append defname |
71 val qualify = NameSpace.qualified defname |
72 |
72 |
73 val (((psimps', pinducts'), (_, [termination'])), lthy) = |
73 val (((psimps', pinducts'), (_, [termination'])), lthy) = |
74 lthy |
74 lthy |
75 |> PROFILE "adding_psimps" (add_simps "psimps" [] mutual_info fixes psimps spec) |
75 |> PROFILE "adding_psimps" (add_simps "psimps" [] mutual_info fixes psimps spec) |
76 ||>> PROFILE "adding pinduct" (LocalTheory.note ((qualify "pinduct", [Attrib.internal (InductAttrib.induct_set "")]), simple_pinducts)) |
76 ||>> PROFILE "adding pinduct" (LocalTheory.note ((qualify "pinduct", [Attrib.internal (InductAttrib.induct_set "")]), simple_pinducts)) |
139 |
139 |
140 (* FIXME: How to generate code from (possibly) local contexts |
140 (* FIXME: How to generate code from (possibly) local contexts |
141 val has_guards = exists ((fn (Const ("Trueprop", _) $ _) => false | _ => true) o prop_of) tsimps |
141 val has_guards = exists ((fn (Const ("Trueprop", _) $ _) => false | _ => true) o prop_of) tsimps |
142 val allatts = if has_guards then [] else [Attrib.internal (RecfunCodegen.add NONE)] |
142 val allatts = if has_guards then [] else [Attrib.internal (RecfunCodegen.add NONE)] |
143 *) |
143 *) |
144 val qualify = NameSpace.append defname; |
144 val qualify = NameSpace.qualified defname; |
145 in |
145 in |
146 lthy |
146 lthy |
147 |> PROFILE "adding tsimps" (add_simps "simps" [] mutual fixes tsimps spec) |> snd |
147 |> PROFILE "adding tsimps" (add_simps "simps" [] mutual fixes tsimps spec) |> snd |
148 |> PROFILE "adding tinduct" (LocalTheory.note ((qualify "induct", []), tinduct)) |> snd |
148 |> PROFILE "adding tinduct" (LocalTheory.note ((qualify "induct", []), tinduct)) |> snd |
149 end |
149 end |