3 * Stefano Zacchiroli <zack@cs.unibo.it>
4 * for the HELM Team http://helm.cs.unibo.it/
6 * This file is part of HELM, an Hypertextual, Electronic
7 * Library of Mathematics, developed at the Computer Science
8 * Department, University of Bologna, Italy.
10 * HELM is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * HELM is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with HELM; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 * For details, see the HELM World-Wide-Web page,
26 * http://helm.cs.unibo.it/
34 fun s -> prerr_endline (sprintf "HBUGS DEBUG: %s" s)
37 exception NoProofInProgress;;
39 let hbugs_client = ref None
40 let use_hint_callback = ref ignore
41 let describe_hint_callback = ref ignore
43 let set_describe_hint_callback c = describe_hint_callback := c
46 match !hbugs_client with
47 | Some c -> c#unregisterFromBroker ()
50 let hbugs_enabled = ref false
52 let get_hbugs_client () =
53 match !hbugs_client with
55 | None -> assert false
58 match !hbugs_client with None -> () | Some c -> c#hide ()
62 if !hbugs_enabled then begin
63 let client = get_hbugs_client () in
65 match !ProofEngine.goal with
67 | None -> raise NoProofInProgress
69 let (type_string, body_string) =
70 let (type_xml, body_xml) = ProofEngine.get_current_status_as_xml () in
71 (Xml.pp_to_string type_xml, Xml.pp_to_string body_xml)
74 (Misc.strip_xml_headings type_string,
75 Misc.strip_xml_headings body_string,
78 client#stateChange (Some new_state)
80 with NoProofInProgress -> ()
83 if !hbugs_enabled then
85 let client = get_hbugs_client () in
86 client#stateChange None
90 (match !hbugs_client with
91 | None -> (* create an hbugs client and show its window *)
94 Some (new Hbugs_client.hbugsClient
95 ~use_hint_callback:!use_hint_callback
96 ~describe_hint_callback:!describe_hint_callback
99 prerr_endline (sprintf "Can't start HBugs client: %s"
100 (Printexc.to_string e));
102 (match !hbugs_client with
105 client#subscribeAll ()
107 | Some c -> (* show hbugs client window *)
111 if state <> !hbugs_enabled then begin (* status has been changed *)
112 if state then enable () else disable ();
115 hbugs_enabled := state
117 module type Unit = sig end
119 module Initialize (Tactics: InvokeTactics.Tactics) : Unit =
121 let use_hint = function
122 | Use_ring -> Tactics.ring ()
123 | Use_fourier -> Tactics.fourier ()
124 | Use_reflexivity -> Tactics.reflexivity ()
125 | Use_symmetry -> Tactics.symmetry ()
126 | Use_assumption -> Tactics.assumption ()
127 | Use_contradiction -> Tactics.contradiction ()
128 | Use_exists -> Tactics.exists ()
129 | Use_split -> Tactics.split ()
130 | Use_left -> Tactics.left ()
131 | Use_right -> Tactics.right ()
133 (* we remove the "cic:" prefix *)
134 let term' = String.sub term 4 (String.length term - 4) in
135 Tactics.apply ~term:term' ()
136 | Hints _ -> assert false
138 let _ = use_hint_callback := use_hint
141 let start_web_services () = ignore (Unix.system "make -C ../hbugs/ start")
142 let stop_web_services () = ignore (Unix.system "make -C ../hbugs/ stop")