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 "DEBUG: %s" s)
37 exception NoProofInProgress;;
39 let hbugs_client = ref None
40 let use_hint_callback = ref ignore
43 match !hbugs_client with
44 | Some c -> c#unregisterFromBroker ()
47 let hbugs_enabled = ref false
49 let get_hbugs_client () =
50 match !hbugs_client with
52 | None -> assert false
55 match !hbugs_client with None -> () | Some c -> c#hide ()
59 if !hbugs_enabled then begin
60 let client = get_hbugs_client () in
62 match !ProofEngine.goal with
64 | None -> raise NoProofInProgress
66 let (type_string, body_string) =
67 let (type_xml, body_xml) = ProofEngine.get_current_status_as_xml () in
68 (Xml.pp_to_string type_xml, Xml.pp_to_string body_xml)
71 (Misc.strip_xml_headings type_string,
72 Misc.strip_xml_headings body_string,
75 client#stateChange (Some new_state)
77 with NoProofInProgress -> ()
80 if !hbugs_enabled then
82 let client = get_hbugs_client () in
83 client#stateChange None
87 (match !hbugs_client with
88 | None -> (* create an hbugs client and show its window *)
91 Some (new Hbugs_client.hbugsClient
92 ~use_hint_callback:!use_hint_callback ())
94 prerr_endline (sprintf "Can't start HBugs client: %s"
95 (Printexc.to_string e));
97 (match !hbugs_client with
100 client#subscribeAll ()
102 | Some c -> (* show hbugs client window *)
106 if state <> !hbugs_enabled then (* status has been changed *)
107 (if state then enable () else disable ());
108 hbugs_enabled := state
110 module type Unit = sig end
112 module Initialize (Tactics: InvokeTactics.Tactics) : Unit =
114 let use_hint = function
115 | Use_ring_Luke -> Tactics.ring ()
116 | Use_fourier_Luke -> Tactics.fourier ()
117 | Use_reflexivity_Luke -> Tactics.reflexivity ()
118 | Use_symmetry_Luke -> Tactics.symmetry ()
119 | Use_assumption_Luke -> Tactics.assumption ()
120 | Use_contradiction_Luke -> Tactics.contradiction ()
121 | Use_exists_Luke -> Tactics.exists ()
122 | Use_split_Luke -> Tactics.split ()
123 | Use_left_Luke -> Tactics.left ()
124 | Use_right_Luke -> Tactics.right ()
125 | Use_apply_Luke term ->
126 (* we remove the "cic:" prefix *)
127 let term' = String.sub term 4 (String.length term - 4) in
128 Tactics.apply ~term:term' ()
129 | Hints _ -> assert false
131 let _ = use_hint_callback := use_hint
134 let start_web_services () = ignore (Unix.system "make -C ../hbugs/ start")
135 let stop_web_services () = ignore (Unix.system "make -C ../hbugs/ stop")