78 #> tap (present_theorems kind); |
78 #> tap (present_theorems kind); |
79 |
79 |
80 fun apply_theorems args = apfst (maps snd) o theorems "" [(("", []), args)]; |
80 fun apply_theorems args = apfst (maps snd) o theorems "" [(("", []), args)]; |
81 fun apply_theorems_i args = apfst (maps snd) o theorems_i "" [(("", []), args)]; |
81 fun apply_theorems_i args = apfst (maps snd) o theorems_i "" [(("", []), args)]; |
82 |
82 |
|
83 (* FIXME local_theory *) |
83 fun smart_theorems kind NONE args thy = thy |
84 fun smart_theorems kind NONE args thy = thy |
84 |> theorems kind args |
85 |> theorems kind args |
85 |> tap (present_theorems kind) |
86 |> tap (present_theorems kind) |
86 |> (fn (_, thy) => `ProofContext.init thy) |
87 |> (fn (_, thy) => `ProofContext.init thy) |
87 | smart_theorems kind (SOME loc) args thy = thy |
88 | smart_theorems kind (SOME loc) args thy = thy |
88 |> Locale.note_thmss kind loc args |
89 |> Locale.note_thmss kind loc args |
|
90 ||> (fn ctxt' => (ctxt', ProofContext.theory_of ctxt')) |
89 |> tap (fn ((_, res), (_, thy')) => present_theorems kind (res, thy')) |
91 |> tap (fn ((_, res), (_, thy')) => present_theorems kind (res, thy')) |
90 |> #2; |
92 |> #2; |
91 |
93 |
92 fun declare_theorems opt_loc args = |
94 fun declare_theorems opt_loc args = |
93 smart_theorems "" opt_loc [(("", []), args)]; |
95 smart_theorems "" opt_loc [(("", []), args)]; |
129 |
131 |
130 |
132 |
131 (* global endings *) |
133 (* global endings *) |
132 |
134 |
133 fun global_ending ending = Toplevel.proof_to_theory_context (fn int => fn state => |
135 fun global_ending ending = Toplevel.proof_to_theory_context (fn int => fn state => |
134 if can (Proof.assert_bottom true) state then ending int state |
136 if can (Proof.assert_bottom true) state then |
|
137 ending int state |> (fn ctxt' => (ctxt', ProofContext.theory_of ctxt')) |
135 else raise Toplevel.UNDEF); |
138 else raise Toplevel.UNDEF); |
136 |
139 |
137 fun global_qed m = global_ending (K (Proof.global_qed (m, true))); |
140 fun global_qed m = global_ending (K (Proof.global_qed (m, true))); |
138 val global_terminal_proof = global_ending o K o Proof.global_terminal_proof; |
141 val global_terminal_proof = global_ending o K o Proof.global_terminal_proof; |
139 val global_default_proof = global_ending (K Proof.global_default_proof); |
142 val global_default_proof = global_ending (K Proof.global_default_proof); |