12 (Attrib.binding * term) list -> Function_Common.function_config -> |
12 (Attrib.binding * term) list -> Function_Common.function_config -> |
13 (Proof.context -> tactic) -> local_theory -> info * local_theory |
13 (Proof.context -> tactic) -> local_theory -> info * local_theory |
14 |
14 |
15 val add_function_cmd: (binding * string option * mixfix) list -> |
15 val add_function_cmd: (binding * string option * mixfix) list -> |
16 (Attrib.binding * string) list -> Function_Common.function_config -> |
16 (Attrib.binding * string) list -> Function_Common.function_config -> |
17 (Proof.context -> tactic) -> local_theory -> info * local_theory |
17 (Proof.context -> tactic) -> bool -> local_theory -> info * local_theory |
18 |
18 |
19 val function: (binding * typ option * mixfix) list -> |
19 val function: (binding * typ option * mixfix) list -> |
20 (Attrib.binding * term) list -> Function_Common.function_config -> |
20 (Attrib.binding * term) list -> Function_Common.function_config -> |
21 local_theory -> Proof.state |
21 local_theory -> Proof.state |
22 |
22 |
23 val function_cmd: (binding * string option * mixfix) list -> |
23 val function_cmd: (binding * string option * mixfix) list -> |
24 (Attrib.binding * string) list -> Function_Common.function_config -> |
24 (Attrib.binding * string) list -> Function_Common.function_config -> |
25 local_theory -> Proof.state |
25 bool -> local_theory -> Proof.state |
26 |
26 |
27 val prove_termination: term option -> tactic -> local_theory -> |
27 val prove_termination: term option -> tactic -> local_theory -> |
28 info * local_theory |
28 info * local_theory |
29 val prove_termination_cmd: string option -> tactic -> local_theory -> |
29 val prove_termination_cmd: string option -> tactic -> local_theory -> |
30 info * local_theory |
30 info * local_theory |
74 #> snd |
74 #> snd |
75 in |
75 in |
76 (saved_simps, fold2 add_for_f fnames simps_by_f lthy) |
76 (saved_simps, fold2 add_for_f fnames simps_by_f lthy) |
77 end |
77 end |
78 |
78 |
79 fun prepare_function is_external prep default_constraint fixspec eqns config lthy = |
79 fun prepare_function do_print prep default_constraint fixspec eqns config lthy = |
80 let |
80 let |
81 val constrn_fxs = map (fn (b, T, mx) => (b, SOME (the_default default_constraint T), mx)) |
81 val constrn_fxs = map (fn (b, T, mx) => (b, SOME (the_default default_constraint T), mx)) |
82 val ((fixes0, spec0), ctxt') = prep (constrn_fxs fixspec) eqns lthy |
82 val ((fixes0, spec0), ctxt') = prep (constrn_fxs fixspec) eqns lthy |
83 val fixes = map (apfst (apfst Binding.name_of)) fixes0; |
83 val fixes = map (apfst (apfst Binding.name_of)) fixes0; |
84 val spec = map (fn (bnd, prop) => (bnd, [prop])) spec0; |
84 val spec = map (fn (bnd, prop) => (bnd, [prop])) spec0; |
123 |
123 |
124 val info = { add_simps=addsmps, case_names=cnames, psimps=psimps', |
124 val info = { add_simps=addsmps, case_names=cnames, psimps=psimps', |
125 pinducts=snd pinducts', simps=NONE, inducts=NONE, termination=termination', |
125 pinducts=snd pinducts', simps=NONE, inducts=NONE, termination=termination', |
126 fs=fs, R=R, defname=defname, is_partial=true } |
126 fs=fs, R=R, defname=defname, is_partial=true } |
127 |
127 |
128 val _ = Proof_Display.print_consts is_external lthy (K false) (map fst fixes) |
128 val _ = Proof_Display.print_consts do_print lthy (K false) (map fst fixes) |
129 in |
129 in |
130 (info, |
130 (info, |
131 lthy |> Local_Theory.declaration false (add_function_data o morph_function_data info)) |
131 lthy |> Local_Theory.declaration false (add_function_data o morph_function_data info)) |
132 end |
132 end |
133 in |
133 in |
134 ((goal_state, afterqed), lthy') |
134 ((goal_state, afterqed), lthy') |
135 end |
135 end |
136 |
136 |
137 fun gen_add_function is_external prep default_constraint fixspec eqns config tac lthy = |
137 fun gen_add_function do_print prep default_constraint fixspec eqns config tac lthy = |
138 let |
138 let |
139 val ((goal_state, afterqed), lthy') = |
139 val ((goal_state, afterqed), lthy') = |
140 prepare_function is_external prep default_constraint fixspec eqns config lthy |
140 prepare_function do_print prep default_constraint fixspec eqns config lthy |
141 val pattern_thm = |
141 val pattern_thm = |
142 case SINGLE (tac lthy') goal_state of |
142 case SINGLE (tac lthy') goal_state of |
143 NONE => error "pattern completeness and compatibility proof failed" |
143 NONE => error "pattern completeness and compatibility proof failed" |
144 | SOME st => Goal.finish lthy' st |
144 | SOME st => Goal.finish lthy' st |
145 in |
145 in |
147 |> afterqed [[pattern_thm]] |
147 |> afterqed [[pattern_thm]] |
148 end |
148 end |
149 |
149 |
150 val add_function = |
150 val add_function = |
151 gen_add_function false Specification.check_spec (Type_Infer.anyT HOLogic.typeS) |
151 gen_add_function false Specification.check_spec (Type_Infer.anyT HOLogic.typeS) |
152 val add_function_cmd = gen_add_function true Specification.read_spec "_::type" |
152 fun add_function_cmd a b c d int = gen_add_function int Specification.read_spec "_::type" a b c d |
153 |
153 |
154 fun gen_function is_external prep default_constraint fixspec eqns config lthy = |
154 fun gen_function do_print prep default_constraint fixspec eqns config lthy = |
155 let |
155 let |
156 val ((goal_state, afterqed), lthy') = |
156 val ((goal_state, afterqed), lthy') = |
157 prepare_function is_external prep default_constraint fixspec eqns config lthy |
157 prepare_function do_print prep default_constraint fixspec eqns config lthy |
158 in |
158 in |
159 lthy' |
159 lthy' |
160 |> Proof.theorem NONE (snd oo afterqed) [[(Logic.unprotect (concl_of goal_state), [])]] |
160 |> Proof.theorem NONE (snd oo afterqed) [[(Logic.unprotect (concl_of goal_state), [])]] |
161 |> Proof.refine (Method.primitive_text (K goal_state)) |> Seq.hd |
161 |> Proof.refine (Method.primitive_text (K goal_state)) |> Seq.hd |
162 end |
162 end |
163 |
163 |
164 val function = |
164 val function = |
165 gen_function false Specification.check_spec (Type_Infer.anyT HOLogic.typeS) |
165 gen_function false Specification.check_spec (Type_Infer.anyT HOLogic.typeS) |
166 val function_cmd = gen_function true Specification.read_spec "_::type" |
166 fun function_cmd a b c int = gen_function int Specification.read_spec "_::type" a b c |
167 |
167 |
168 fun prepare_termination_proof prep_term raw_term_opt lthy = |
168 fun prepare_termination_proof prep_term raw_term_opt lthy = |
169 let |
169 let |
170 val term_opt = Option.map (prep_term lthy) raw_term_opt |
170 val term_opt = Option.map (prep_term lthy) raw_term_opt |
171 val info = the (case term_opt of |
171 val info = the (case term_opt of |