42 inducts : thm list option, |
42 inducts : thm list option, |
43 termination: thm} |
43 termination: thm} |
44 |
44 |
45 end |
45 end |
46 |
46 |
47 structure Function_Common = |
47 signature FUNCTION_COMMON = |
|
48 sig |
|
49 include FUNCTION_DATA |
|
50 val profile : bool Unsynchronized.ref |
|
51 val PROFILE : string -> ('a -> 'b) -> 'a -> 'b |
|
52 val mk_acc : typ -> term -> term |
|
53 val function_name : string -> string |
|
54 val graph_name : string -> string |
|
55 val rel_name : string -> string |
|
56 val dom_name : string -> string |
|
57 val apply_termination_rule : Proof.context -> int -> tactic |
|
58 datatype function_result = FunctionResult of |
|
59 {fs: term list, |
|
60 G: term, |
|
61 R: term, |
|
62 psimps : thm list, |
|
63 simple_pinducts : thm list, |
|
64 cases : thm, |
|
65 termination : thm, |
|
66 domintros : thm list option} |
|
67 val transform_function_data : info -> morphism -> info |
|
68 val get_function : Proof.context -> (term * info) Item_Net.T |
|
69 val import_function_data : term -> Proof.context -> info option |
|
70 val import_last_function : Proof.context -> info option |
|
71 val add_function_data : info -> Context.generic -> Context.generic |
|
72 structure Termination_Simps: NAMED_THMS |
|
73 val set_termination_prover : (Proof.context -> tactic) -> Context.generic -> Context.generic |
|
74 val get_termination_prover : Proof.context -> tactic |
|
75 datatype function_config = FunctionConfig of |
|
76 {sequential: bool, |
|
77 default: string option, |
|
78 domintros: bool, |
|
79 partials: bool} |
|
80 val default_config : function_config |
|
81 val split_def : Proof.context -> (string -> 'a) -> term -> |
|
82 string * (string * typ) list * term list * term list * term |
|
83 val check_defs : Proof.context -> ((string * typ) * 'a) list -> term list -> unit |
|
84 type fixes = ((string * typ) * mixfix) list |
|
85 type 'a spec = (Attrib.binding * 'a list) list |
|
86 type preproc = function_config -> Proof.context -> fixes -> term spec -> |
|
87 (term list * (thm list -> thm spec) * (thm list -> thm list list) * string list) |
|
88 val fname_of : term -> string |
|
89 val mk_case_names : int -> string -> int -> string list |
|
90 val empty_preproc : (Proof.context -> ((string * typ) * mixfix) list -> term list -> 'c) -> preproc |
|
91 val get_preproc: Proof.context -> preproc |
|
92 val set_preproc: preproc -> Context.generic -> Context.generic |
|
93 val function_parser : function_config -> |
|
94 ((function_config * (binding * string option * mixfix) list) * (Attrib.binding * string) list) parser |
|
95 end |
|
96 |
|
97 structure Function_Common : FUNCTION_COMMON = |
48 struct |
98 struct |
49 |
99 |
50 open Function_Data |
100 open Function_Data |
51 |
101 |
52 local open Function_Lib in |
102 local open Function_Lib in |
53 |
103 |
54 (* Profiling *) |
104 (* Profiling *) |
55 val profile = Unsynchronized.ref false; |
105 val profile = Unsynchronized.ref false; |
56 |
106 |
57 fun PROFILE msg = if !profile then timeap_msg msg else I |
107 fun PROFILE msg = if !profile then timeap_msg msg else I |
58 |
|
59 |
108 |
60 val acc_const_name = @{const_name accp} |
109 val acc_const_name = @{const_name accp} |
61 fun mk_acc domT R = |
110 fun mk_acc domT R = |
62 Const (acc_const_name, (domT --> domT --> HOLogic.boolT) --> domT --> HOLogic.boolT) $ R |
111 Const (acc_const_name, (domT --> domT --> HOLogic.boolT) --> domT --> HOLogic.boolT) $ R |
63 |
112 |
304 fun mk_case_names i "" k = mk_case_names i (string_of_int (i + 1)) k |
353 fun mk_case_names i "" k = mk_case_names i (string_of_int (i + 1)) k |
305 | mk_case_names _ n 0 = [] |
354 | mk_case_names _ n 0 = [] |
306 | mk_case_names _ n 1 = [n] |
355 | mk_case_names _ n 1 = [n] |
307 | mk_case_names _ n k = map (fn i => n ^ "_" ^ string_of_int i) (1 upto k) |
356 | mk_case_names _ n k = map (fn i => n ^ "_" ^ string_of_int i) (1 upto k) |
308 |
357 |
309 fun empty_preproc check _ ctxt fixes spec = |
358 fun empty_preproc check (_: function_config) (ctxt: Proof.context) (fixes: fixes) spec = |
310 let |
359 let |
311 val (bnds, tss) = split_list spec |
360 val (bnds, tss) = split_list spec |
312 val ts = flat tss |
361 val ts = flat tss |
313 val _ = check ctxt fixes ts |
362 val _ = check ctxt fixes ts |
314 val fnames = map (fst o fst) fixes |
363 val fnames = map (fst o fst) fixes |