40 -> local_theory -> (bstring * thm list) list * local_theory |
40 -> local_theory -> (bstring * thm list) list * local_theory |
41 val theorems_i: string -> ((bstring * Attrib.src list) * (thm list * Attrib.src list) list) list |
41 val theorems_i: string -> ((bstring * Attrib.src list) * (thm list * Attrib.src list) list) list |
42 -> local_theory -> (bstring * thm list) list * local_theory |
42 -> local_theory -> (bstring * thm list) list * local_theory |
43 val theorem: string -> Method.text option -> (thm list list -> local_theory -> local_theory) -> |
43 val theorem: string -> Method.text option -> (thm list list -> local_theory -> local_theory) -> |
44 string * Attrib.src list -> Element.context Locale.element list -> Element.statement -> |
44 string * Attrib.src list -> Element.context Locale.element list -> Element.statement -> |
45 local_theory -> Proof.state |
45 bool -> local_theory -> Proof.state |
46 val theorem_i: string -> Method.text option -> (thm list list -> local_theory -> local_theory) -> |
46 val theorem_i: string -> Method.text option -> (thm list list -> local_theory -> local_theory) -> |
47 string * Attrib.src list -> Element.context_i Locale.element list -> Element.statement_i -> |
47 string * Attrib.src list -> Element.context_i Locale.element list -> Element.statement_i -> |
48 local_theory -> Proof.state |
48 bool -> local_theory -> Proof.state |
|
49 val add_theorem_hook: (bool -> Proof.state -> Proof.state) -> Context.generic -> Context.generic |
49 end; |
50 end; |
50 |
51 |
51 structure Specification: SPECIFICATION = |
52 structure Specification: SPECIFICATION = |
52 struct |
53 struct |
53 |
54 |
242 |> fold_map assume_case (obtains ~~ propp) |
243 |> fold_map assume_case (obtains ~~ propp) |
243 |-> (fn ths => ProofContext.note_thmss_i Thm.assumptionK |
244 |-> (fn ths => ProofContext.note_thmss_i Thm.assumptionK |
244 [((Obtain.thatN, []), [(ths, [])])] #> #2 #> pair ths); |
245 [((Obtain.thatN, []), [(ths, [])])] #> #2 #> pair ths); |
245 in ((prems, stmt, facts), goal_ctxt) end); |
246 in ((prems, stmt, facts), goal_ctxt) end); |
246 |
247 |
|
248 structure TheoremHook = GenericDataFun |
|
249 ( |
|
250 type T = ((bool -> Proof.state -> Proof.state) * stamp) list; |
|
251 val empty = []; |
|
252 val extend = I; |
|
253 fun merge _ type_checks : T = Library.merge (eq_snd op =) type_checks; |
|
254 ); |
|
255 |
247 fun gen_theorem prep_att prep_stmt |
256 fun gen_theorem prep_att prep_stmt |
248 kind before_qed after_qed (name, raw_atts) raw_elems raw_concl lthy0 = |
257 kind before_qed after_qed (name, raw_atts) raw_elems raw_concl int lthy0 = |
249 let |
258 let |
250 val _ = LocalTheory.affirm lthy0; |
259 val _ = LocalTheory.affirm lthy0; |
251 val thy = ProofContext.theory_of lthy0; |
260 val thy = ProofContext.theory_of lthy0; |
252 |
261 |
253 val (loc, ctxt, lthy) = |
262 val (loc, ctxt, lthy) = |
278 in |
287 in |
279 goal_ctxt |
288 goal_ctxt |
280 |> ProofContext.note_thmss_i Thm.assumptionK [((AutoBind.assmsN, []), [(prems, [])])] |
289 |> ProofContext.note_thmss_i Thm.assumptionK [((AutoBind.assmsN, []), [(prems, [])])] |
281 |> snd |
290 |> snd |
282 |> Proof.theorem_i before_qed after_qed' (map snd stmt) |
291 |> Proof.theorem_i before_qed after_qed' (map snd stmt) |
|
292 |> Library.apply (map (fn (f, _) => f int) |
|
293 (TheoremHook.get (Context.Proof goal_ctxt))) |
283 |> Proof.refine_insert facts |
294 |> Proof.refine_insert facts |
284 end; |
295 end; |
285 |
296 |
286 in |
297 in |
287 |
298 |
288 val theorem = gen_theorem Attrib.intern_src Locale.read_context_statement_i; |
299 val theorem = gen_theorem Attrib.intern_src Locale.read_context_statement_i; |
289 val theorem_i = gen_theorem (K I) Locale.cert_context_statement; |
300 val theorem_i = gen_theorem (K I) Locale.cert_context_statement; |
290 |
301 |
|
302 fun add_theorem_hook f = TheoremHook.map (cons (f, stamp ())); |
|
303 |
291 end; |
304 end; |
292 |
305 |
293 end; |
306 end; |