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 ()
57 (** send current proof assistant state to hbugs broker *)
60 if !hbugs_enabled then begin
61 let client = get_hbugs_client () in
63 match !ProofEngine.goal with
65 | None -> raise NoProofInProgress
67 let (type_string, body_string) =
68 let (type_xml, body_xml) = ProofEngine.get_current_status_as_xml () in
69 (Xml.pp_to_string type_xml, Xml.pp_to_string body_xml)
72 (Misc.strip_xml_headings type_string,
73 Misc.strip_xml_headings body_string,
76 client#stateChange (Some new_state)
78 with NoProofInProgress -> ()
81 if !hbugs_enabled then
83 let client = get_hbugs_client () in
84 client#stateChange None
88 (match !hbugs_client with
89 | None -> (* create an hbugs client and show its window *)
92 Some (new Hbugs_client.hbugsClient
93 ~use_hint_callback:!use_hint_callback ())
95 prerr_endline (sprintf "Can't start HBugs client: %s"
96 (Printexc.to_string e));
98 (match !hbugs_client with
101 client#subscribeAll ()
103 | Some c -> (* show hbugs client window *)
107 if state <> !hbugs_enabled then (* status has been changed *)
108 (if state then enable () else disable ());
109 hbugs_enabled := state
111 module type Unit = sig end
113 module Initialize (Tactics: InvokeTactics.Tactics) : Unit =
115 let use_hint = function
116 | Use_ring_Luke -> Tactics.ring ()
117 | Use_fourier_Luke -> Tactics.fourier ()
118 | Use_reflexivity_Luke -> Tactics.reflexivity ()
119 | Use_symmetry_Luke -> Tactics.symmetry ()
120 | Use_assumption_Luke -> Tactics.assumption ()
121 | Use_contradiction_Luke -> Tactics.contradiction ()
122 | Use_exists_Luke -> Tactics.exists ()
123 | Use_split_Luke -> Tactics.split ()
124 | Use_left_Luke -> Tactics.left ()
125 | Use_right_Luke -> Tactics.right ()
126 | Use_apply_Luke term ->
127 (* we remove the "cic:" prefix *)
128 let term' = String.sub term 4 (String.length term - 4) in
129 Tactics.apply ~term:term' ()
130 | Hints _ -> assert false
132 let _ = use_hint_callback := use_hint