(* * Copyright (C) 2003: * Stefano Zacchiroli * for the HELM Team http://helm.cs.unibo.it/ * * This file is part of HELM, an Hypertextual, Electronic * Library of Mathematics, developed at the Computer Science * Department, University of Bologna, Italy. * * HELM is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * HELM is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HELM; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * For details, see the HELM World-Wide-Web page, * http://helm.cs.unibo.it/ *) open Hbugs_types;; open Printf;; let debug_print = let debug = true in fun s -> prerr_endline (sprintf "HBUGS DEBUG: %s" s) ;; exception NoProofInProgress;; let hbugs_client = ref None let use_hint_callback = ref ignore let describe_hint_callback = ref ignore let set_describe_hint_callback c = describe_hint_callback := c let quit () = match !hbugs_client with | Some c -> c#unregisterFromBroker () | None -> () let hbugs_enabled = ref false let get_hbugs_client () = match !hbugs_client with | Some c -> c | None -> assert false let disable () = match !hbugs_client with None -> () | Some c -> c#hide () let notify () = try if !hbugs_enabled then begin let client = get_hbugs_client () in let goal = match !ProofEngine.goal with | Some g -> g | None -> raise NoProofInProgress in let (type_string, body_string) = let (type_xml, body_xml) = ProofEngine.get_current_status_as_xml () in (Xml.pp_to_string type_xml, Xml.pp_to_string body_xml) in let new_state = (Misc.strip_xml_headings type_string, Misc.strip_xml_headings body_string, goal) in client#stateChange (Some new_state) end with NoProofInProgress -> () let clear () = if !hbugs_enabled then begin let client = get_hbugs_client () in client#stateChange None end let rec enable () = (match !hbugs_client with | None -> (* create an hbugs client and show its window *) hbugs_client := (try Some (new Hbugs_client.hbugsClient ~use_hint_callback:!use_hint_callback ~describe_hint_callback:!describe_hint_callback ()) with e -> prerr_endline (sprintf "Can't start HBugs client: %s" (Printexc.to_string e)); None); (match !hbugs_client with |Some client -> client#show (); client#subscribeAll () | None -> ()) | Some c -> (* show hbugs client window *) c#show ()) let toggle state = if state <> !hbugs_enabled then begin (* status has been changed *) if state then enable () else disable (); clear () end; hbugs_enabled := state module type Unit = sig end module Initialize (Tactics: InvokeTactics.Tactics) : Unit = struct let use_hint = function | Use_ring -> Tactics.ring () | Use_fourier -> Tactics.fourier () | Use_reflexivity -> Tactics.reflexivity () | Use_symmetry -> Tactics.symmetry () | Use_assumption -> Tactics.assumption () | Use_contradiction -> Tactics.contradiction () | Use_exists -> Tactics.exists () | Use_split -> Tactics.split () | Use_left -> Tactics.left () | Use_right -> Tactics.right () | Use_apply term -> (* we remove the "cic:" prefix *) let term' = String.sub term 4 (String.length term - 4) in Tactics.apply ~term:term' () | Hints _ -> assert false let _ = use_hint_callback := use_hint end let start_web_services () = ignore (Unix.system "make -C ../hbugs/ start") let stop_web_services () = ignore (Unix.system "make -C ../hbugs/ stop")