45 val theorems_cmd: string -> |
45 val theorems_cmd: string -> |
46 (Attrib.binding * (Facts.ref * Attrib.src list) list) list -> |
46 (Attrib.binding * (Facts.ref * Attrib.src list) list) list -> |
47 local_theory -> (string * thm list) list * local_theory |
47 local_theory -> (string * thm list) list * local_theory |
48 val theorem: string -> Method.text option -> |
48 val theorem: string -> Method.text option -> |
49 (thm list list -> local_theory -> local_theory) -> Attrib.binding -> |
49 (thm list list -> local_theory -> local_theory) -> Attrib.binding -> |
50 Element.context_i Locale.element list -> Element.statement_i -> |
50 Element.context_i list -> Element.statement_i -> |
51 bool -> local_theory -> Proof.state |
51 bool -> local_theory -> Proof.state |
52 val theorem_cmd: string -> Method.text option -> |
52 val theorem_cmd: string -> Method.text option -> |
53 (thm list list -> local_theory -> local_theory) -> Attrib.binding -> |
53 (thm list list -> local_theory -> local_theory) -> Attrib.binding -> |
54 Element.context Locale.element list -> Element.statement -> |
54 Element.context list -> Element.statement -> |
55 bool -> local_theory -> Proof.state |
55 bool -> local_theory -> Proof.state |
56 val add_theorem_hook: (bool -> Proof.state -> Proof.state) -> Context.generic -> Context.generic |
56 val add_theorem_hook: (bool -> Proof.state -> Proof.state) -> Context.generic -> Context.generic |
57 end; |
57 end; |
58 |
58 |
59 structure Specification: SPECIFICATION = |
59 structure Specification: SPECIFICATION = |
271 let |
271 let |
272 val case_names = obtains |> map_index (fn (i, (binding, _)) => |
272 val case_names = obtains |> map_index (fn (i, (binding, _)) => |
273 let val name = Name.name_of binding |
273 let val name = Name.name_of binding |
274 in if name = "" then string_of_int (i + 1) else name end); |
274 in if name = "" then string_of_int (i + 1) else name end); |
275 val constraints = obtains |> map (fn (_, (vars, _)) => |
275 val constraints = obtains |> map (fn (_, (vars, _)) => |
276 Locale.Elem (Element.Constrains |
276 Element.Constrains |
277 (vars |> map_filter (fn (x, SOME T) => SOME (Name.name_of x, T) | _ => NONE)))); |
277 (vars |> map_filter (fn (x, SOME T) => SOME (Name.name_of x, T) | _ => NONE))); |
278 |
278 |
279 val raw_propp = obtains |> map (fn (_, (_, props)) => map (rpair []) props); |
279 val raw_propp = obtains |> map (fn (_, (_, props)) => map (rpair []) props); |
280 val (_, loc_ctxt, elems_ctxt, propp) = prep_stmt (elems @ constraints) raw_propp ctxt; |
280 val (_, loc_ctxt, elems_ctxt, propp) = prep_stmt (elems @ constraints) raw_propp ctxt; |
281 |
281 |
282 val thesis = ObjectLogic.fixed_judgment (ProofContext.theory_of ctxt) AutoBind.thesisN; |
282 val thesis = ObjectLogic.fixed_judgment (ProofContext.theory_of ctxt) AutoBind.thesisN; |
323 let |
323 let |
324 val _ = LocalTheory.affirm lthy0; |
324 val _ = LocalTheory.affirm lthy0; |
325 val thy = ProofContext.theory_of lthy0; |
325 val thy = ProofContext.theory_of lthy0; |
326 |
326 |
327 val (loc, ctxt, lthy) = |
327 val (loc, ctxt, lthy) = |
328 (case (TheoryTarget.peek lthy0, exists (fn Locale.Expr _ => true | _ => false) raw_elems) of |
328 (case (TheoryTarget.peek lthy0, false (* exists (fn Locale.Expr _ => true | _ => false) raw_elems *)) of |
329 ({target, is_locale = true, ...}, true) => |
329 ({target, is_locale = true, ...}, true) => |
330 (*temporary workaround for non-modularity of in/includes*) (* FIXME *) |
330 (*temporary workaround for non-modularity of in/includes*) (* FIXME *) |
331 (SOME target, ProofContext.init thy, LocalTheory.restore lthy0) |
331 (SOME target, ProofContext.init thy, LocalTheory.restore lthy0) |
332 | _ => (NONE, lthy0, lthy0)); |
332 | _ => (NONE, lthy0, lthy0)); |
333 |
333 |
334 val attrib = prep_att thy; |
334 val attrib = prep_att thy; |
335 val atts = map attrib raw_atts; |
335 val atts = map attrib raw_atts; |
336 |
336 |
337 val elems = raw_elems |> map (Locale.map_elem (Element.map_ctxt_attrib attrib)); |
337 val elems = raw_elems |> map (Element.map_ctxt_attrib attrib); |
338 val ((prems, stmt, facts), goal_ctxt) = |
338 val ((prems, stmt, facts), goal_ctxt) = |
339 prep_statement attrib (prep_stmt loc) elems raw_concl ctxt; |
339 prep_statement attrib (prep_stmt loc) elems raw_concl ctxt; |
340 |
340 |
341 fun after_qed' results goal_ctxt' = |
341 fun after_qed' results goal_ctxt' = |
342 let val results' = |
342 let val results' = |