3 Author: David Aspinall and Markus Wenzel |
3 Author: David Aspinall and Markus Wenzel |
4 |
4 |
5 Isabelle configuration for Proof General using PGIP protocol. |
5 Isabelle configuration for Proof General using PGIP protocol. |
6 See http://proofgeneral.inf.ed.ac.uk/kit |
6 See http://proofgeneral.inf.ed.ac.uk/kit |
7 *) |
7 *) |
8 |
|
9 |
8 |
10 signature PROOF_GENERAL_PGIP = |
9 signature PROOF_GENERAL_PGIP = |
11 sig |
10 sig |
12 val init_pgip: bool -> unit (* main PGIP loop with true; fail with false *) |
11 val init_pgip: bool -> unit (* main PGIP loop with true; fail with false *) |
13 |
12 |
82 val skolem_tag = "skolem" |
82 val skolem_tag = "skolem" |
83 |
83 |
84 fun xml_atom kind x = XML.element "atom" [("kind", kind)] [XML.text x]; |
84 fun xml_atom kind x = XML.element "atom" [("kind", kind)] [XML.text x]; |
85 |
85 |
86 fun tagit kind x = |
86 fun tagit kind x = |
87 (xml_atom kind x, real (Symbol.length (Symbol.explode x))); |
87 (xml_atom kind x, real (Symbol.length (Symbol.explode x))); |
88 |
88 |
89 fun free_or_skolem x = |
89 fun free_or_skolem x = |
90 (case try Name.dest_skolem x of |
90 (case try Name.dest_skolem x of |
91 NONE => tagit free_tag x |
91 NONE => tagit free_tag x |
92 | SOME x' => tagit skolem_tag x'); |
92 | SOME x' => tagit skolem_tag x'); |
264 fun setup_thy_loader () = ThyInfo.add_hook trace_action; |
264 fun setup_thy_loader () = ThyInfo.add_hook trace_action; |
265 fun sync_thy_loader () = List.app (trace_action ThyInfo.Update) (ThyInfo.names ()); |
265 fun sync_thy_loader () = List.app (trace_action ThyInfo.Update) (ThyInfo.names ()); |
266 end; |
266 end; |
267 |
267 |
268 |
268 |
269 (* prepare theory context *) |
269 (* get informed about files *) |
270 |
270 |
271 val thy_name = Path.implode o #1 o Path.split_ext o Path.base o Path.explode; |
271 val thy_name = Path.implode o #1 o Path.split_ext o Path.base o Path.explode; |
272 |
|
273 (* FIXME general treatment of tracing*) |
|
274 val update_thy_only = setmp MetaSimplifier.trace_simp false ThyInfo.update_thy_only; |
|
275 |
|
276 fun dynamic_context () = |
|
277 (case Context.get_context () of |
|
278 SOME thy => " Using current (dynamic!) one: " ^ quote (Context.theory_name thy) |
|
279 | NONE => ""); |
|
280 |
|
281 fun try_update_thy_only file = |
|
282 ThyLoad.cond_add_path (Path.dir (Path.explode file)) (fn () => |
|
283 let val name = thy_name file in |
|
284 if is_some (ThyLoad.check_file NONE (ThyLoad.thy_path name)) |
|
285 then update_thy_only name |
|
286 else warning ("Unkown theory context of ML file." ^ dynamic_context ()) |
|
287 end) (); |
|
288 |
|
289 |
|
290 (* get informed about files *) |
|
291 |
272 |
292 val inform_file_retracted = ThyInfo.if_known_thy ThyInfo.remove_thy o thy_name; |
273 val inform_file_retracted = ThyInfo.if_known_thy ThyInfo.remove_thy o thy_name; |
293 val inform_file_processed = ThyInfo.if_known_thy ThyInfo.touch_child_thys o thy_name; |
274 val inform_file_processed = ThyInfo.if_known_thy ThyInfo.touch_child_thys o thy_name; |
294 |
275 |
295 fun proper_inform_file_processed file state = |
276 fun proper_inform_file_processed file state = |
952 |
933 |
953 val redoP = (*redo without output*) |
934 val redoP = (*redo without output*) |
954 OuterSyntax.improper_command "ProofGeneral.redo" "(internal)" K.control |
935 OuterSyntax.improper_command "ProofGeneral.redo" "(internal)" K.control |
955 (Scan.succeed (Toplevel.no_timing o IsarCmd.redo)); |
936 (Scan.succeed (Toplevel.no_timing o IsarCmd.redo)); |
956 |
937 |
957 (* da: what were these context commands ones for? *) |
|
958 val context_thy_onlyP = |
|
959 OuterSyntax.improper_command "ProofGeneral.context_thy_only" "(internal)" K.control |
|
960 (P.name >> (Toplevel.no_timing oo IsarCmd.init_context update_thy_only)); |
|
961 |
|
962 val try_context_thy_onlyP = |
|
963 OuterSyntax.improper_command "ProofGeneral.try_context_thy_only" "(internal)" K.control |
|
964 (P.name >> (Toplevel.no_timing oo |
|
965 (Toplevel.imperative (K ()) oo IsarCmd.init_context try_update_thy_only))); |
|
966 |
|
967 (* ProofGeneral.kill_proof still used above *) |
938 (* ProofGeneral.kill_proof still used above *) |
968 val kill_proofP = |
939 val kill_proofP = |
969 OuterSyntax.improper_command "ProofGeneral.kill_proof" "(internal)" K.control |
940 OuterSyntax.improper_command "ProofGeneral.kill_proof" "(internal)" K.control |
970 (Scan.succeed (Toplevel.no_timing o IsarCmd.kill_proof_notify tell_clear_goals)); |
941 (Scan.succeed (Toplevel.no_timing o IsarCmd.kill_proof_notify tell_clear_goals)); |
971 |
942 |
987 OuterSyntax.improper_command "ProofGeneral.process_pgip" "(internal)" K.control |
958 OuterSyntax.improper_command "ProofGeneral.process_pgip" "(internal)" K.control |
988 (P.text >> (Toplevel.no_timing oo |
959 (P.text >> (Toplevel.no_timing oo |
989 (fn txt => Toplevel.imperative (fn () => process_pgip_plain txt)))); |
960 (fn txt => Toplevel.imperative (fn () => process_pgip_plain txt)))); |
990 |
961 |
991 fun init_outer_syntax () = OuterSyntax.add_parsers |
962 fun init_outer_syntax () = OuterSyntax.add_parsers |
992 [undoP, redoP, kill_proofP, context_thy_onlyP, try_context_thy_onlyP, |
963 [undoP, redoP, kill_proofP, inform_file_processedP, inform_file_retractedP, process_pgipP]; |
993 inform_file_processedP, inform_file_retractedP, process_pgipP]; |
|
994 |
964 |
995 end; |
965 end; |
996 |
966 |
997 |
967 |
998 (* init *) |
968 (* init *) |