equal
deleted
inserted
replaced
18 -> local_theory |
18 -> local_theory |
19 -> Proof.state |
19 -> Proof.state |
20 |
20 |
21 val termination_proof : term option -> local_theory -> Proof.state |
21 val termination_proof : term option -> local_theory -> Proof.state |
22 val termination_proof_cmd : string option -> local_theory -> Proof.state |
22 val termination_proof_cmd : string option -> local_theory -> Proof.state |
23 val termination : term option -> local_theory -> Proof.state |
|
24 val termination_cmd : string option -> local_theory -> Proof.state |
|
25 |
23 |
26 val setup : theory -> theory |
24 val setup : theory -> theory |
27 val get_congs : Proof.context -> thm list |
25 val get_congs : Proof.context -> thm list |
28 end |
26 end |
29 |
27 |
117 lthy |
115 lthy |
118 |> Local_Theory.declaration false (add_function_data o morph_function_data cdata) |
116 |> Local_Theory.declaration false (add_function_data o morph_function_data cdata) |
119 end |
117 end |
120 in |
118 in |
121 lthy |
119 lthy |
122 |> is_external ? Local_Theory.set_group (serial ()) |
|
123 |> Proof.theorem_i NONE afterqed [[(Logic.unprotect (concl_of goalstate), [])]] |
120 |> Proof.theorem_i NONE afterqed [[(Logic.unprotect (concl_of goalstate), [])]] |
124 |> Proof.refine (Method.primitive_text (fn _ => goalstate)) |> Seq.hd |
121 |> Proof.refine (Method.primitive_text (fn _ => goalstate)) |> Seq.hd |
125 end |
122 end |
126 |
123 |
127 val add_function = gen_add_function false Specification.check_spec (TypeInfer.anyT HOLogic.typeS) |
124 val add_function = gen_add_function false Specification.check_spec (TypeInfer.anyT HOLogic.typeS) |
168 [((Binding.name "termination", [Context_Rules.intro_bang (SOME 0)]), |
165 [((Binding.name "termination", [Context_Rules.intro_bang (SOME 0)]), |
169 [([Goal.norm_result termination], [])])] |> snd |
166 [([Goal.norm_result termination], [])])] |> snd |
170 |> Proof.theorem_i NONE afterqed [[(goal, [])]] |
167 |> Proof.theorem_i NONE afterqed [[(goal, [])]] |
171 end |
168 end |
172 |
169 |
173 val termination_proof = gen_termination_proof Syntax.check_term; |
170 val termination_proof = gen_termination_proof Syntax.check_term |
174 val termination_proof_cmd = gen_termination_proof Syntax.read_term; |
171 val termination_proof_cmd = gen_termination_proof Syntax.read_term |
175 |
|
176 fun termination term_opt lthy = |
|
177 lthy |
|
178 |> Local_Theory.set_group (serial ()) |
|
179 |> termination_proof term_opt; |
|
180 |
|
181 fun termination_cmd term_opt lthy = |
|
182 lthy |
|
183 |> Local_Theory.set_group (serial ()) |
|
184 |> termination_proof_cmd term_opt; |
|
185 |
172 |
186 |
173 |
187 (* Datatype hook to declare datatype congs as "function_congs" *) |
174 (* Datatype hook to declare datatype congs as "function_congs" *) |
188 |
175 |
189 |
176 |
215 local structure P = OuterParse and K = OuterKeyword in |
202 local structure P = OuterParse and K = OuterKeyword in |
216 |
203 |
217 val _ = |
204 val _ = |
218 OuterSyntax.local_theory_to_proof "function" "define general recursive functions" K.thy_goal |
205 OuterSyntax.local_theory_to_proof "function" "define general recursive functions" K.thy_goal |
219 (function_parser default_config |
206 (function_parser default_config |
220 >> (fn ((config, fixes), statements) => add_function_cmd fixes statements config)); |
207 >> (fn ((config, fixes), statements) => add_function_cmd fixes statements config)) |
221 |
208 |
222 val _ = |
209 val _ = |
223 OuterSyntax.local_theory_to_proof "termination" "prove termination of a recursive function" K.thy_goal |
210 OuterSyntax.local_theory_to_proof "termination" "prove termination of a recursive function" K.thy_goal |
224 (Scan.option P.term >> termination_cmd); |
211 (Scan.option P.term >> termination_proof_cmd) |
225 |
|
226 end; |
|
227 |
|
228 |
212 |
229 end |
213 end |
|
214 |
|
215 |
|
216 end |