1 (* Copyright (C) 2000-2002, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 (******************************************************************************)
30 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
34 (******************************************************************************)
40 module MQI = MQueryInterpreter
42 module MQG = MQueryGenerator
44 (* GLOBAL CONSTANTS *)
46 let mqi_flags = [MQIC.Postgres ; MQIC.Stat ; MQIC.Warn ; MQIC.Log] (* default MathQL interpreter options *)
48 let mqi_flags = [] (* default MathQL interpreter options *)
50 let mqi_handle = MQIC.init mqi_flags prerr_string
52 let xlinkns = Gdome.domString "http://www.w3.org/1999/xlink";;
56 " <body bgColor=\"white\">"
66 Sys.getenv "GTOPLEVEL_PROOFFILE"
68 Not_found -> "/public/currentproof"
73 Sys.getenv "GTOPLEVEL_PROOFFILETYPE"
75 Not_found -> "/public/currentprooftype"
78 (* GLOBAL REFERENCES (USED BY CALLBACKS) *)
80 let htmlheader_and_content = ref htmlheader;;
82 let check_term = ref (fun _ _ _ -> assert false);;
84 exception RenderingWindowsNotInitialized;;
86 let set_rendering_window,rendering_window =
87 let rendering_window_ref = ref None in
88 (function rw -> rendering_window_ref := Some rw),
90 match !rendering_window_ref with
91 None -> raise RenderingWindowsNotInitialized
96 exception SettingsWindowsNotInitialized;;
98 let set_settings_window,settings_window =
99 let settings_window_ref = ref None in
100 (function rw -> settings_window_ref := Some rw),
102 match !settings_window_ref with
103 None -> raise SettingsWindowsNotInitialized
108 exception OutputHtmlNotInitialized;;
110 let set_outputhtml,outputhtml =
111 let outputhtml_ref = ref None in
112 (function rw -> outputhtml_ref := Some rw),
114 match !outputhtml_ref with
115 None -> raise OutputHtmlNotInitialized
116 | Some outputhtml -> outputhtml
120 exception QedSetSensitiveNotInitialized;;
121 let qed_set_sensitive =
122 ref (function _ -> raise QedSetSensitiveNotInitialized)
125 exception SaveSetSensitiveNotInitialized;;
126 let save_set_sensitive =
127 ref (function _ -> raise SaveSetSensitiveNotInitialized)
130 (* COMMAND LINE OPTIONS *)
136 "-nodb", Arg.Clear usedb, "disable use of MathQL DB"
139 Arg.parse argspec ignore ""
143 let term_of_cic_textual_parser_uri uri =
144 let module C = Cic in
145 let module CTP = CicTextualParser0 in
147 CTP.ConUri uri -> C.Const (uri,[])
148 | CTP.VarUri uri -> C.Var (uri,[])
149 | CTP.IndTyUri (uri,tyno) -> C.MutInd (uri,tyno,[])
150 | CTP.IndConUri (uri,tyno,consno) -> C.MutConstruct (uri,tyno,consno,[])
153 let string_of_cic_textual_parser_uri uri =
154 let module C = Cic in
155 let module CTP = CicTextualParser0 in
158 CTP.ConUri uri -> UriManager.string_of_uri uri
159 | CTP.VarUri uri -> UriManager.string_of_uri uri
160 | CTP.IndTyUri (uri,tyno) ->
161 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1)
162 | CTP.IndConUri (uri,tyno,consno) ->
163 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1) ^ "/" ^
166 (* 4 = String.length "cic:" *)
167 String.sub uri' 4 (String.length uri' - 4)
170 let output_html outputhtml msg =
171 htmlheader_and_content := !htmlheader_and_content ^ msg ;
172 outputhtml#source (!htmlheader_and_content ^ htmlfooter) ;
173 outputhtml#set_topline (-1)
176 (* UTILITY FUNCTIONS TO DISAMBIGUATE AN URI *)
180 let check_window outputhtml uris =
183 ~width:800 ~modal:true ~title:"Check" ~border_width:2 () in
185 GPack.notebook ~scrollable:true ~packing:window#add () in
190 let scrolled_window =
191 GBin.scrolled_window ~border_width:10
193 (notebook#append_page ~tab_label:((GMisc.label ~text:uri ())#coerce))
198 TermViewer.sequent_viewer
199 ~packing:scrolled_window#add ~width:400 ~height:280 () in
202 term_of_cic_textual_parser_uri
203 (MQueryMisc.cic_textual_parser_uri_of_string uri)
205 (Cic.Cast (term, CicTypeChecker.type_of_aux' [] [] term))
208 mmlwidget#load_sequent [] (111,[],expr)
211 output_html outputhtml
212 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
217 (notebook#connect#switch_page
218 (function i -> Lazy.force (List.nth render_terms i)))
224 interactive_user_uri_choice ~(selection_mode:[`SINGLE|`EXTENDED]) ?(ok="Ok")
225 ?(enable_button_for_non_vars=false) ~title ~msg uris
227 let choices = ref [] in
228 let chosen = ref false in
229 let use_only_constants = ref false in
231 GWindow.dialog ~modal:true ~title ~width:600 () in
233 GMisc.label ~text:msg
234 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
235 let scrolled_window =
236 GBin.scrolled_window ~border_width:10
237 ~packing:(window#vbox#pack ~expand:true ~fill:true ~padding:5) () in
239 let expected_height = 18 * List.length uris in
240 let height = if expected_height > 400 then 400 else expected_height in
241 GList.clist ~columns:1 ~packing:scrolled_window#add
242 ~height ~selection_mode:(selection_mode :> Gtk.Tags.selection_mode) () in
243 let _ = List.map (function x -> clist#append [x]) uris in
245 GPack.hbox ~border_width:0
246 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
248 GMisc.label ~text:"None of the above. Try this one:"
249 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
251 GEdit.entry ~editable:true
252 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
254 GPack.hbox ~border_width:0 ~packing:window#action_area#add () in
256 GButton.button ~label:ok
257 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
258 let _ = okb#misc#set_sensitive false in
263 if enable_button_for_non_vars then
264 hbox#pack ~expand:false ~fill:false ~padding:5 w)
265 ~label:"Try constants only" () in
267 GButton.button ~label:"Check"
268 ~packing:(hbox#pack ~padding:5) () in
269 let _ = checkb#misc#set_sensitive false in
271 GButton.button ~label:"Abort"
272 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
274 let check_callback () =
275 assert (List.length !choices > 0) ;
276 check_window (outputhtml ()) !choices
278 ignore (window#connect#destroy GMain.Main.quit) ;
279 ignore (cancelb#connect#clicked window#destroy) ;
281 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
283 (nonvarsb#connect#clicked
285 use_only_constants := true ;
289 ignore (checkb#connect#clicked check_callback) ;
291 (clist#connect#select_row
292 (fun ~row ~column ~event ->
293 checkb#misc#set_sensitive true ;
294 okb#misc#set_sensitive true ;
295 choices := (List.nth uris row)::!choices)) ;
297 (clist#connect#unselect_row
298 (fun ~row ~column ~event ->
300 List.filter (function uri -> uri != (List.nth uris row)) !choices)) ;
302 (manual_input#connect#changed
304 if manual_input#text = "" then
307 checkb#misc#set_sensitive false ;
308 okb#misc#set_sensitive false ;
309 clist#misc#set_sensitive true
313 choices := [manual_input#text] ;
314 clist#unselect_all () ;
315 checkb#misc#set_sensitive true ;
316 okb#misc#set_sensitive true ;
317 clist#misc#set_sensitive false
319 window#set_position `CENTER ;
323 if !use_only_constants then
325 (function uri -> not (String.sub uri (String.length uri - 4) 4 = ".var"))
328 if List.length !choices > 0 then !choices else raise NoChoice
333 let interactive_interpretation_choice interpretations =
334 let chosen = ref None in
337 ~modal:true ~title:"Ambiguous well-typed input." ~border_width:2 () in
338 let vbox = GPack.vbox ~packing:window#add () in
342 ("Ambiguous input since there are many well-typed interpretations." ^
343 " Please, choose one of them.")
344 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
346 GPack.notebook ~scrollable:true
347 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
350 (function interpretation ->
352 let expected_height = 18 * List.length interpretation in
353 let height = if expected_height > 400 then 400 else expected_height in
354 GList.clist ~columns:2 ~packing:notebook#append_page ~height
355 ~titles:["id" ; "URI"] ()
359 (function (id,uri) ->
360 let n = clist#append [id;uri] in
361 clist#set_row ~selectable:false n
364 clist#columns_autosize ()
367 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
369 GButton.button ~label:"Ok"
370 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
372 GButton.button ~label:"Abort"
373 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
375 ignore (window#connect#destroy GMain.Main.quit) ;
376 ignore (cancelb#connect#clicked window#destroy) ;
379 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
380 window#set_position `CENTER ;
384 None -> raise NoChoice
392 save_object_to_disk uri annobj ids_to_inner_sorts ids_to_inner_types pathname
395 let struri = UriManager.string_of_uri uri in
396 let idx = (String.rindex struri '/') + 1 in
397 String.sub struri idx (String.length struri - idx)
399 let path = pathname ^ "/" ^ name in
401 Cic2Xml.print_object uri ~ids_to_inner_sorts ~ask_dtd_to_the_getter:false
405 Cic2Xml.print_inner_types uri ~ids_to_inner_sorts ~ids_to_inner_types
406 ~ask_dtd_to_the_getter:false
409 let innertypesuri = UriManager.innertypesuri_of_uri uri in
410 Xml.pp ~quiet:true xmlinnertypes (Some (path ^ ".types.xml")) ;
411 Getter.register innertypesuri
412 (Configuration.annotations_url ^
413 Str.replace_first (Str.regexp "^cic:") ""
414 (UriManager.string_of_uri innertypesuri) ^ ".xml"
416 (* constant type / variable / mutual inductive types definition *)
417 Xml.pp ~quiet:true xml (Some (path ^ ".xml")) ;
419 (Configuration.annotations_url ^
420 Str.replace_first (Str.regexp "^cic:") ""
421 (UriManager.string_of_uri uri) ^ ".xml"
428 match UriManager.bodyuri_of_uri uri with
430 | Some bodyuri -> bodyuri
432 Xml.pp ~quiet:true bodyxml' (Some (path ^ ".body.xml")) ;
433 Getter.register bodyuri
434 (Configuration.annotations_url ^
435 Str.replace_first (Str.regexp "^cic:") ""
436 (UriManager.string_of_uri bodyuri) ^ ".xml"
443 exception OpenConjecturesStillThere;;
444 exception WrongProof;;
446 let pathname_of_annuri uristring =
447 Configuration.annotations_dir ^
448 Str.replace_first (Str.regexp "^cic:") "" uristring
451 let make_dirs dirpath =
452 ignore (Unix.system ("mkdir -p " ^ dirpath))
455 let save_obj uri obj =
457 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
458 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
460 Cic2acic.acic_object_of_cic_object obj
462 (* let's save the theorem and register it to the getter *)
463 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
465 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
470 match !ProofEngine.proof with
472 | Some (uri,[],bo,ty) ->
474 CicReduction.are_convertible []
475 (CicTypeChecker.type_of_aux' [] [] bo) ty
478 (*CSC: Wrong: [] is just plainly wrong *)
479 let proof = Cic.Constant (UriManager.name_of_uri uri,Some bo,ty,[]) in
480 let (acic,ids_to_inner_types,ids_to_inner_sorts) =
481 (rendering_window ())#output#load_proof uri proof
483 !qed_set_sensitive false ;
484 (* let's save the theorem and register it to the getter *)
485 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
487 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
492 | _ -> raise OpenConjecturesStillThere
495 (** save an unfinished proof on the filesystem *)
496 let save_unfinished_proof () =
497 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
498 let (xml, bodyxml) = ProofEngine.get_current_status_as_xml () in
499 Xml.pp ~quiet:true xml (Some prooffiletype) ;
500 output_html outputhtml
501 ("<h1 color=\"Green\">Current proof type saved to " ^
502 prooffiletype ^ "</h1>") ;
503 Xml.pp ~quiet:true bodyxml (Some prooffile) ;
504 output_html outputhtml
505 ("<h1 color=\"Green\">Current proof body saved to " ^
509 (* Used to typecheck the loaded proofs *)
510 let typecheck_loaded_proof metasenv bo ty =
511 let module T = CicTypeChecker in
514 (fun metasenv ((_,context,ty) as conj) ->
515 ignore (T.type_of_aux' metasenv context ty) ;
518 ignore (T.type_of_aux' metasenv [] ty) ;
519 ignore (T.type_of_aux' metasenv [] bo)
522 let decompose_uris_choice_callback uris =
523 (* N.B.: in questo passaggio perdo l'informazione su exp_named_subst !!!! *)
524 let module U = UriManager in
527 match MQueryMisc.cic_textual_parser_uri_of_string uri with
528 CicTextualParser0.IndTyUri (uri,typeno) -> (uri,typeno,[])
530 (interactive_user_uri_choice
531 ~selection_mode:`EXTENDED ~ok:"Ok" ~enable_button_for_non_vars:false
532 ~title:"Decompose" ~msg:"Please, select the Inductive Types to decompose"
534 (function (uri,typeno,_) ->
535 U.string_of_uri uri ^ "#1/" ^ string_of_int (typeno+1)
540 let mk_fresh_name_callback context name ~typ =
542 match ProofEngineHelpers.mk_fresh_name context name ~typ with
543 Cic.Name fresh_name -> fresh_name
544 | Cic.Anonymous -> assert false
547 GToolbox.input_string ~title:"Enter a fresh hypothesis name" ~text:fresh_name
548 ("Enter a fresh name for the hypothesis " ^
550 (List.map (function None -> None | Some (n,_) -> Some n) context))
552 Some fresh_name' -> Cic.Name fresh_name'
553 | None -> raise NoChoice
556 let refresh_proof (output : TermViewer.proof_viewer) =
558 let uri,currentproof =
559 match !ProofEngine.proof with
561 | Some (uri,metasenv,bo,ty) ->
562 if List.length metasenv = 0 then
564 !qed_set_sensitive true ;
565 prerr_endline "CSC: ###### REFRESH_PROOF, Hbugs.clear ()" ;
570 prerr_endline "CSC: ###### REFRESH_PROOF, Hbugs.notify ()" ;
573 (*CSC: Wrong: [] is just plainly wrong *)
575 (Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, []))
577 ignore (output#load_proof uri currentproof)
580 match !ProofEngine.proof with
582 | Some (uri,metasenv,bo,ty) ->
583 prerr_endline ("Offending proof: " ^ CicPp.ppobj (Cic.CurrentProof ("questa",metasenv,bo,ty,[]))) ; flush stderr ;
584 raise (InvokeTactics.RefreshProofException e)
586 let refresh_goals ?(empty_notebook=true) notebook =
588 match !ProofEngine.goal with
590 if empty_notebook then
592 notebook#remove_all_pages ~skip_switch_page_event:false ;
593 notebook#set_empty_page
596 notebook#proofw#unload
599 match !ProofEngine.proof with
601 | Some (_,metasenv,_,_) -> metasenv
604 List.find (function (m,_,_) -> m=metano) metasenv
606 let regenerate_notebook () =
607 let skip_switch_page_event =
609 (m,_,_)::_ when m = metano -> false
612 notebook#remove_all_pages ~skip_switch_page_event ;
613 List.iter (function (m,_,_) -> notebook#add_page m) metasenv ;
615 if empty_notebook then
617 regenerate_notebook () ;
618 notebook#set_current_page
619 ~may_skip_switch_page_event:false metano
623 notebook#set_current_page
624 ~may_skip_switch_page_event:true metano ;
625 notebook#proofw#load_sequent metasenv currentsequent
630 match !ProofEngine.goal with
635 match !ProofEngine.proof with
637 | Some (_,metasenv,_,_) -> metasenv
640 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
641 prerr_endline ("Offending sequent: " ^ SequentPp.TextualPp.print_sequent currentsequent) ; flush stderr ;
642 raise (InvokeTactics.RefreshSequentException e)
643 with Not_found -> prerr_endline ("Offending sequent " ^ string_of_int metano ^ " unknown."); raise (InvokeTactics.RefreshSequentException e)
645 module InvokeTacticsCallbacks =
647 let sequent_viewer () = (rendering_window ())#notebook#proofw
648 let term_editor () = (rendering_window ())#inputt
649 let scratch_window () = (rendering_window ())#scratch_window
651 let refresh_proof () =
652 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
655 let refresh_goals () =
656 let notebook = (rendering_window ())#notebook in
657 refresh_goals notebook
659 let decompose_uris_choice_callback = decompose_uris_choice_callback
660 let mk_fresh_name_callback = mk_fresh_name_callback
661 let output_html msg = output_html (outputhtml ()) msg
664 module InvokeTactics' = InvokeTactics.Make (InvokeTacticsCallbacks);;
665 (* Just to initialize the Hbugs module *)
666 module Ignore = Hbugs.Initialize (InvokeTactics');;
668 (** load an unfinished proof from filesystem *)
669 let load_unfinished_proof () =
670 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
671 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
672 let notebook = (rendering_window ())#notebook in
675 GToolbox.input_string ~title:"Load Unfinished Proof" ~text:"/dummy.con"
678 None -> raise NoChoice
680 let uri = UriManager.uri_of_string ("cic:" ^ uri0) in
681 match CicParser.obj_of_xml prooffiletype (Some prooffile) with
682 Cic.CurrentProof (_,metasenv,bo,ty,_) ->
683 typecheck_loaded_proof metasenv bo ty ;
685 Some (uri, metasenv, bo, ty) ;
689 | (metano,_,_)::_ -> Some metano
691 refresh_proof output ;
692 refresh_goals notebook ;
693 output_html outputhtml
694 ("<h1 color=\"Green\">Current proof type loaded from " ^
695 prooffiletype ^ "</h1>") ;
696 output_html outputhtml
697 ("<h1 color=\"Green\">Current proof body loaded from " ^
698 prooffile ^ "</h1>") ;
699 !save_set_sensitive true;
702 InvokeTactics.RefreshSequentException e ->
703 output_html outputhtml
704 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
705 "sequent: " ^ Printexc.to_string e ^ "</h1>")
706 | InvokeTactics.RefreshProofException e ->
707 output_html outputhtml
708 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
709 "proof: " ^ Printexc.to_string e ^ "</h1>")
711 output_html outputhtml
712 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
715 let edit_aliases () =
716 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
717 let id_to_uris = inputt#id_to_uris in
718 let chosen = ref false in
721 ~width:400 ~modal:true ~title:"Edit Aliases..." ~border_width:2 () in
723 GPack.vbox ~border_width:0 ~packing:window#add () in
724 let scrolled_window =
725 GBin.scrolled_window ~border_width:10
726 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
727 let input = GEdit.text ~editable:true ~width:400 ~height:100
728 ~packing:scrolled_window#add () in
730 GPack.hbox ~border_width:0
731 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
733 GButton.button ~label:"Ok"
734 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
736 GButton.button ~label:"Cancel"
737 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
738 ignore (window#connect#destroy GMain.Main.quit) ;
739 ignore (cancelb#connect#clicked window#destroy) ;
741 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
742 let dom,resolve_id = !id_to_uris in
744 (input#insert_text ~pos:0
749 match resolve_id v with
751 | Some (CicTextualParser0.Uri uri) -> uri
752 | Some (CicTextualParser0.Term _)
753 | Some CicTextualParser0.Implicit -> assert false
757 CicTextualParser0.Id id -> id
758 | CicTextualParser0.Symbol (descr,_) ->
759 (* CSC: To be implemented *)
761 )^ " " ^ (string_of_cic_textual_parser_uri uri)
767 let inputtext = input#get_chars 0 input#length in
769 let alfa = "[a-zA-Z_-]" in
770 let digit = "[0-9]" in
771 let ident = alfa ^ "\(" ^ alfa ^ "\|" ^ digit ^ "\)*" in
772 let blanks = "\( \|\t\|\n\)+" in
773 let nonblanks = "[^ \t\n]+" in
774 let uri = "/\(" ^ ident ^ "/\)*" ^ nonblanks in (* not very strict check *)
776 ("alias" ^ blanks ^ "\(" ^ ident ^ "\)" ^ blanks ^ "\(" ^ uri ^ "\)")
780 let n' = Str.search_forward regexpr inputtext n in
781 let id = CicTextualParser0.Id (Str.matched_group 2 inputtext) in
783 MQueryMisc.cic_textual_parser_uri_of_string
784 ("cic:" ^ (Str.matched_group 5 inputtext))
786 let dom,resolve_id = aux (n' + 1) in
787 if List.mem id dom then
793 Some (CicTextualParser0.Uri uri)
796 Not_found -> TermEditor.empty_id_to_uris
800 id_to_uris := (dom,resolve_id)
804 let module L = LogicalOperations in
805 let module G = Gdome in
806 let notebook = (rendering_window ())#notebook in
807 let output = (rendering_window ())#output in
808 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
810 output#make_sequent_of_selected_term ;
811 refresh_proof output ;
812 refresh_goals notebook
814 InvokeTactics.RefreshSequentException e ->
815 output_html outputhtml
816 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
817 "sequent: " ^ Printexc.to_string e ^ "</h1>")
818 | InvokeTactics.RefreshProofException e ->
819 output_html outputhtml
820 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
821 "proof: " ^ Printexc.to_string e ^ "</h1>")
823 output_html outputhtml
824 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
828 let module L = LogicalOperations in
829 let module G = Gdome in
830 let notebook = (rendering_window ())#notebook in
831 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
832 let output = (rendering_window ())#output in
834 output#focus_sequent_of_selected_term ;
835 refresh_goals notebook
837 InvokeTactics.RefreshSequentException e ->
838 output_html outputhtml
839 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
840 "sequent: " ^ Printexc.to_string e ^ "</h1>")
841 | InvokeTactics.RefreshProofException e ->
842 output_html outputhtml
843 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
844 "proof: " ^ Printexc.to_string e ^ "</h1>")
846 output_html outputhtml
847 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
850 exception NoPrevGoal;;
851 exception NoNextGoal;;
854 let module L = LogicalOperations in
855 let module G = Gdome in
856 let notebook = (rendering_window ())#notebook in
857 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
859 match !ProofEngine.proof with
861 | Some (_,metasenv,_,_) -> metasenv
864 refresh_goals ~empty_notebook:false notebook
866 InvokeTactics.RefreshSequentException e ->
867 output_html outputhtml
868 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
869 "sequent: " ^ Printexc.to_string e ^ "</h1>")
871 output_html outputhtml
872 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
876 show_in_show_window_obj, show_in_show_window_uri, show_in_show_window_callback
879 GWindow.window ~width:800 ~border_width:2 () in
880 let scrolled_window =
881 GBin.scrolled_window ~border_width:10 ~packing:window#add () in
883 GMathViewAux.single_selection_math_view
884 ~packing:scrolled_window#add ~width:600 ~height:400 ()
886 let _ = window#event#connect#delete (fun _ -> window#misc#hide () ; true ) in
887 let href = Gdome.domString "href" in
888 let show_in_show_window_obj uri obj =
889 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
892 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
893 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
895 Cic2acic.acic_object_of_cic_object obj
898 ApplyStylesheets.mml_of_cic_object
899 ~explode_all:false uri acic ids_to_inner_sorts ids_to_inner_types
901 window#set_title (UriManager.string_of_uri uri) ;
902 window#misc#hide () ; window#show () ;
903 mmlwidget#load_doc mml ;
906 output_html outputhtml
907 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
909 let show_in_show_window_uri uri =
910 let obj = CicEnvironment.get_obj uri in
911 show_in_show_window_obj uri obj
913 let show_in_show_window_callback mmlwidget (n : Gdome.element option) _ =
917 if n'#hasAttributeNS ~namespaceURI:xlinkns ~localName:href then
919 (n'#getAttributeNS ~namespaceURI:xlinkns ~localName:href)#to_string
921 show_in_show_window_uri (UriManager.uri_of_string uri)
923 ignore (mmlwidget#action_toggle n')
926 mmlwidget#connect#click (show_in_show_window_callback mmlwidget)
928 show_in_show_window_obj, show_in_show_window_uri,
929 show_in_show_window_callback
932 exception NoObjectsLocated;;
934 let user_uri_choice ~title ~msg uris =
937 [] -> raise NoObjectsLocated
941 interactive_user_uri_choice ~selection_mode:`SINGLE ~title ~msg uris
946 String.sub uri 4 (String.length uri - 4)
949 let locate_callback id =
950 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
951 let out = output_html outputhtml in
952 let query = MQG.locate id in
953 let result = MQI.execute mqi_handle query in
957 MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format' uri)
959 out "<h1>Locate Query: </h1><pre>";
960 MQueryUtil.text_of_query out query "";
961 out "<h1>Result:</h1>";
962 MQueryUtil.text_of_result out result "<br>";
963 user_uri_choice ~title:"Ambiguous input."
965 ("Ambiguous input \"" ^ id ^
966 "\". Please, choose one interpetation:")
971 let input_or_locate_uri ~title =
972 let uri = ref None in
975 ~width:400 ~modal:true ~title ~border_width:2 () in
976 let vbox = GPack.vbox ~packing:window#add () in
978 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
980 GMisc.label ~text:"Enter a valid URI:" ~packing:(hbox1#pack ~padding:5) () in
982 GEdit.entry ~editable:true
983 ~packing:(hbox1#pack ~expand:true ~fill:true ~padding:5) () in
985 GButton.button ~label:"Check"
986 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
987 let _ = checkb#misc#set_sensitive false in
989 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
991 GMisc.label ~text:"You can also enter an indentifier to locate:"
992 ~packing:(hbox2#pack ~padding:5) () in
994 GEdit.entry ~editable:true
995 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
997 GButton.button ~label:"Locate"
998 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
999 let _ = locateb#misc#set_sensitive false in
1001 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1003 GButton.button ~label:"Ok"
1004 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1005 let _ = okb#misc#set_sensitive false in
1007 GButton.button ~label:"Cancel"
1008 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) ()
1010 ignore (window#connect#destroy GMain.Main.quit) ;
1012 (cancelb#connect#clicked (function () -> uri := None ; window#destroy ())) ;
1013 let check_callback () =
1014 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1015 let uri = "cic:" ^ manual_input#text in
1017 ignore (Getter.resolve (UriManager.uri_of_string uri)) ;
1018 output_html outputhtml "<h1 color=\"Green\">OK</h1>" ;
1021 Getter.Unresolved ->
1022 output_html outputhtml
1023 ("<h1 color=\"Red\">URI " ^ uri ^
1024 " does not correspond to any object.</h1>") ;
1026 | UriManager.IllFormedUri _ ->
1027 output_html outputhtml
1028 ("<h1 color=\"Red\">URI " ^ uri ^ " is not well-formed.</h1>") ;
1031 output_html outputhtml
1032 ("<h1 color=\"Red\">" ^ Printexc.to_string e ^ "</h1>") ;
1036 (okb#connect#clicked
1038 if check_callback () then
1040 uri := Some manual_input#text ;
1044 ignore (checkb#connect#clicked (function () -> ignore (check_callback ()))) ;
1046 (manual_input#connect#changed
1048 if manual_input#text = "" then
1050 checkb#misc#set_sensitive false ;
1051 okb#misc#set_sensitive false
1055 checkb#misc#set_sensitive true ;
1056 okb#misc#set_sensitive true
1059 (locate_input#connect#changed
1060 (fun _ -> locateb#misc#set_sensitive (locate_input#text <> ""))) ;
1062 (locateb#connect#clicked
1064 let id = locate_input#text in
1065 manual_input#set_text (locate_callback id) ;
1066 locate_input#delete_text 0 (String.length id)
1071 None -> raise NoChoice
1072 | Some uri -> UriManager.uri_of_string ("cic:" ^ uri)
1075 exception AmbiguousInput;;
1077 (* A WIDGET TO ENTER CIC TERMS *)
1079 module ChosenTermEditor = TexTermEditor;;
1080 module ChosenTextualParser0 = TexCicTextualParser0;;
1082 module ChosenTermEditor = TermEditor;;
1083 module ChosenTextualParser0 = CicTextualParser0;;
1088 let get_metasenv () = !ChosenTextualParser0.metasenv
1089 let set_metasenv metasenv = ChosenTextualParser0.metasenv := metasenv
1091 let output_html msg = output_html (outputhtml ()) msg;;
1092 let interactive_user_uri_choice =
1093 fun ~selection_mode ?ok ?enable_button_for_non_vars ~title ~msg ~id ->
1094 interactive_user_uri_choice ~selection_mode ?ok
1095 ?enable_button_for_non_vars ~title ~msg;;
1096 let interactive_interpretation_choice = interactive_interpretation_choice;;
1097 let input_or_locate_uri = input_or_locate_uri;;
1101 module TexTermEditor' = ChosenTermEditor.Make(Callbacks);;
1103 (* OTHER FUNCTIONS *)
1106 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1107 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1110 GToolbox.input_string ~title:"Locate" "Enter an identifier to locate:"
1112 None -> raise NoChoice
1114 let uri = locate_callback input in
1118 output_html outputhtml
1119 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
1123 exception UriAlreadyInUse;;
1124 exception NotAUriToAConstant;;
1126 let new_inductive () =
1127 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1128 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1129 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1130 let notebook = (rendering_window ())#notebook in
1132 let chosen = ref false in
1133 let inductive = ref true in
1134 let paramsno = ref 0 in
1135 let get_uri = ref (function _ -> assert false) in
1136 let get_base_uri = ref (function _ -> assert false) in
1137 let get_names = ref (function _ -> assert false) in
1138 let get_types_and_cons = ref (function _ -> assert false) in
1139 let get_context_and_subst = ref (function _ -> assert false) in
1142 ~width:600 ~modal:true ~position:`CENTER
1143 ~title:"New Block of Mutual (Co)Inductive Definitions"
1144 ~border_width:2 () in
1145 let vbox = GPack.vbox ~packing:window#add () in
1147 GPack.hbox ~border_width:0
1148 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1150 GMisc.label ~text:"Enter the URI for the new block:"
1151 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1153 GEdit.entry ~editable:true
1154 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1156 GPack.hbox ~border_width:0
1157 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1161 "Enter the number of left parameters in every arity and constructor type:"
1162 ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1163 let paramsno_entry =
1164 GEdit.entry ~editable:true ~text:"0"
1165 ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
1167 GPack.hbox ~border_width:0
1168 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1170 GMisc.label ~text:"Are the definitions inductive or coinductive?"
1171 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1173 GButton.radio_button ~label:"Inductive"
1174 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1176 GButton.radio_button ~label:"Coinductive"
1177 ~group:inductiveb#group
1178 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1180 GPack.hbox ~border_width:0
1181 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1183 GMisc.label ~text:"Enter the list of the names of the types:"
1184 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1186 GEdit.entry ~editable:true
1187 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1189 GPack.hbox ~border_width:0
1190 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1192 GButton.button ~label:"> Next"
1193 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1194 let _ = okb#misc#set_sensitive true in
1196 GButton.button ~label:"Abort"
1197 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1198 ignore (window#connect#destroy GMain.Main.quit) ;
1199 ignore (cancelb#connect#clicked window#destroy) ;
1203 (okb#connect#clicked
1206 let uristr = "cic:" ^ uri_entry#text in
1207 let namesstr = names_entry#text in
1208 let paramsno' = int_of_string (paramsno_entry#text) in
1209 match Str.split (Str.regexp " +") namesstr with
1211 | (he::tl) as names ->
1212 let uri = UriManager.uri_of_string (uristr ^ "/" ^ he ^ ".ind") in
1215 ignore (Getter.resolve uri) ;
1216 raise UriAlreadyInUse
1218 Getter.Unresolved ->
1219 get_uri := (function () -> uri) ;
1220 get_names := (function () -> names) ;
1221 inductive := inductiveb#active ;
1222 paramsno := paramsno' ;
1227 output_html outputhtml
1228 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1236 GBin.frame ~label:name
1237 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1238 let vbox = GPack.vbox ~packing:frame#add () in
1239 let hbox = GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false) () in
1241 GMisc.label ~text:("Enter its type:")
1242 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1243 let scrolled_window =
1244 GBin.scrolled_window ~border_width:5
1245 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1247 TexTermEditor'.term_editor
1249 ~width:400 ~height:20 ~packing:scrolled_window#add
1250 ~share_id_to_uris_with:inputt ()
1251 ~isnotempty_callback:
1253 (*non_empty_type := b ;*)
1254 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*)
1257 GPack.hbox ~border_width:0
1258 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1260 GMisc.label ~text:("Enter the list of its constructors:")
1261 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1262 let cons_names_entry =
1263 GEdit.entry ~editable:true
1264 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1265 (newinputt,cons_names_entry)
1268 vbox#remove hboxn#coerce ;
1270 GPack.hbox ~border_width:0
1271 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1273 GButton.button ~label:"> Next"
1274 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1276 GButton.button ~label:"Abort"
1277 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1278 ignore (cancelb#connect#clicked window#destroy) ;
1280 (okb#connect#clicked
1283 let names = !get_names () in
1284 let types_and_cons =
1286 (fun name (newinputt,cons_names_entry) ->
1287 let consnamesstr = cons_names_entry#text in
1288 let cons_names = Str.split (Str.regexp " +") consnamesstr in
1290 newinputt#get_metasenv_and_term ~context:[] ~metasenv:[]
1293 [] -> expr,cons_names
1294 | _ -> raise AmbiguousInput
1295 ) names type_widgets
1297 let uri = !get_uri () in
1299 (* Let's see if so far the definition is well-typed *)
1302 (* To test if the arities of the inductive types are well *)
1303 (* typed, we check the inductive block definition where *)
1304 (* no constructor is given to each type. *)
1307 (fun name (ty,cons) -> (name, !inductive, ty, []))
1308 names types_and_cons
1310 CicTypeChecker.typecheck_mutual_inductive_defs uri
1311 (tys,params,paramsno)
1313 get_context_and_subst :=
1317 (fun (context,subst) name (ty,_) ->
1319 (Some (Cic.Name name, Cic.Decl ty))::context,
1320 (Cic.MutInd (uri,!i,[]))::subst
1323 ) ([],[]) names types_and_cons) ;
1324 let types_and_cons' =
1326 (fun name (ty,cons) -> (name, !inductive, ty, phase3 name cons))
1327 names types_and_cons
1329 get_types_and_cons := (function () -> types_and_cons') ;
1334 output_html outputhtml
1335 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1338 and phase3 name cons =
1339 let get_cons_types = ref (function () -> assert false) in
1342 ~width:600 ~modal:true ~position:`CENTER
1343 ~title:(name ^ " Constructors")
1344 ~border_width:2 () in
1345 let vbox = GPack.vbox ~packing:window2#add () in
1346 let cons_type_widgets =
1348 (function consname ->
1350 GPack.hbox ~border_width:0
1351 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1353 GMisc.label ~text:("Enter the type of " ^ consname ^ ":")
1354 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1355 let scrolled_window =
1356 GBin.scrolled_window ~border_width:5
1357 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1359 TexTermEditor'.term_editor
1361 ~width:400 ~height:20 ~packing:scrolled_window#add
1362 ~share_id_to_uris_with:inputt ()
1363 ~isnotempty_callback:
1365 (* (*non_empty_type := b ;*)
1366 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*) *)())
1371 GPack.hbox ~border_width:0
1372 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1374 GButton.button ~label:"> Next"
1375 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1376 let _ = okb#misc#set_sensitive true in
1378 GButton.button ~label:"Abort"
1379 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1380 ignore (window2#connect#destroy GMain.Main.quit) ;
1381 ignore (cancelb#connect#clicked window2#destroy) ;
1383 (okb#connect#clicked
1387 let context,subst= !get_context_and_subst () in
1392 inputt#get_metasenv_and_term ~context ~metasenv:[]
1396 let undebrujined_expr =
1398 (fun expr t -> CicSubstitution.subst t expr) expr subst
1400 name, undebrujined_expr
1401 | _ -> raise AmbiguousInput
1402 ) cons cons_type_widgets
1404 get_cons_types := (function () -> cons_types) ;
1408 output_html outputhtml
1409 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1413 let okb_pressed = !chosen in
1415 if (not okb_pressed) then
1418 assert false (* The control never reaches this point *)
1421 (!get_cons_types ())
1424 (* No more phases left or Abort pressed *)
1430 let uri = !get_uri () in
1433 let tys = !get_types_and_cons () in
1434 let obj = Cic.InductiveDefinition tys params !paramsno in
1437 prerr_endline (CicPp.ppobj obj) ;
1438 CicTypeChecker.typecheck_mutual_inductive_defs uri
1439 (tys,params,!paramsno) ;
1442 prerr_endline "Offending mutual (co)inductive type declaration:" ;
1443 prerr_endline (CicPp.ppobj obj) ;
1445 (* We already know that obj is well-typed. We need to add it to the *)
1446 (* environment in order to compute the inner-types without having to *)
1447 (* debrujin it or having to modify lots of other functions to avoid *)
1448 (* asking the environment for the MUTINDs we are defining now. *)
1449 CicEnvironment.put_inductive_definition uri obj ;
1451 show_in_show_window_obj uri obj
1454 output_html outputhtml
1455 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1459 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1460 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1461 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1462 let notebook = (rendering_window ())#notebook in
1464 let chosen = ref false in
1465 let get_metasenv_and_term = ref (function _ -> assert false) in
1466 let get_uri = ref (function _ -> assert false) in
1467 let non_empty_type = ref false in
1470 ~width:600 ~modal:true ~title:"New Proof or Definition"
1471 ~border_width:2 () in
1472 let vbox = GPack.vbox ~packing:window#add () in
1474 GPack.hbox ~border_width:0
1475 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1477 GMisc.label ~text:"Enter the URI for the new theorem or definition:"
1478 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1480 GEdit.entry ~editable:true
1481 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1483 GPack.hbox ~border_width:0
1484 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1486 GMisc.label ~text:"Enter the theorem or definition type:"
1487 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1488 let scrolled_window =
1489 GBin.scrolled_window ~border_width:5
1490 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1491 (* the content of the scrolled_window is moved below (see comment) *)
1493 GPack.hbox ~border_width:0
1494 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1496 GButton.button ~label:"Ok"
1497 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1498 let _ = okb#misc#set_sensitive false in
1500 GButton.button ~label:"Cancel"
1501 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1502 (* moved here to have visibility of the ok button *)
1504 TexTermEditor'.term_editor
1506 ~width:400 ~height:100 ~packing:scrolled_window#add
1507 ~share_id_to_uris_with:inputt ()
1508 ~isnotempty_callback:
1510 non_empty_type := b ;
1511 okb#misc#set_sensitive (b && uri_entry#text <> ""))
1514 let xxx = inputt#get_as_string in
1515 prerr_endline ("######################## " ^ xxx) ;
1516 newinputt#set_term xxx ;
1518 newinputt#set_term inputt#get_as_string ;
1522 uri_entry#connect#changed
1524 okb#misc#set_sensitive (!non_empty_type && uri_entry#text <> ""))
1526 ignore (window#connect#destroy GMain.Main.quit) ;
1527 ignore (cancelb#connect#clicked window#destroy) ;
1529 (okb#connect#clicked
1533 let metasenv,parsed = newinputt#get_metasenv_and_term [] [] in
1534 let uristr = "cic:" ^ uri_entry#text in
1535 let uri = UriManager.uri_of_string uristr in
1536 if String.sub uristr (String.length uristr - 4) 4 <> ".con" then
1537 raise NotAUriToAConstant
1541 ignore (Getter.resolve uri) ;
1542 raise UriAlreadyInUse
1544 Getter.Unresolved ->
1545 get_metasenv_and_term := (function () -> metasenv,parsed) ;
1546 get_uri := (function () -> uri) ;
1551 output_html outputhtml
1552 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1558 let metasenv,expr = !get_metasenv_and_term () in
1559 let _ = CicTypeChecker.type_of_aux' metasenv [] expr in
1560 ProofEngine.proof :=
1561 Some (!get_uri (), (1,[],expr)::metasenv, Cic.Meta (1,[]), expr) ;
1562 ProofEngine.goal := Some 1 ;
1563 refresh_goals notebook ;
1564 refresh_proof output ;
1565 !save_set_sensitive true ;
1567 ProofEngine.intros ~mk_fresh_name_callback () ;
1568 refresh_goals notebook ;
1569 refresh_proof output
1571 InvokeTactics.RefreshSequentException e ->
1572 output_html outputhtml
1573 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1574 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1575 | InvokeTactics.RefreshProofException e ->
1576 output_html outputhtml
1577 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1578 "proof: " ^ Printexc.to_string e ^ "</h1>")
1580 output_html outputhtml
1581 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1584 let check_term_in_scratch scratch_window metasenv context expr =
1586 let ty = CicTypeChecker.type_of_aux' metasenv context expr in
1587 let expr = Cic.Cast (expr,ty) in
1588 scratch_window#show () ;
1589 scratch_window#set_term expr ;
1590 scratch_window#set_context context ;
1591 scratch_window#set_metasenv metasenv ;
1592 scratch_window#sequent_viewer#load_sequent metasenv (111,context,expr)
1595 print_endline ("? " ^ CicPp.ppterm expr) ;
1599 let check scratch_window () =
1600 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1601 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1603 match !ProofEngine.proof with
1605 | Some (_,metasenv,_,_) -> metasenv
1608 match !ProofEngine.goal with
1611 let (_,canonical_context,_) =
1612 List.find (function (m,_,_) -> m=metano) metasenv
1617 let metasenv',expr = inputt#get_metasenv_and_term context metasenv in
1618 check_term_in_scratch scratch_window metasenv' context expr
1621 output_html outputhtml
1622 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1626 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1628 show_in_show_window_uri (input_or_locate_uri ~title:"Show")
1631 output_html outputhtml
1632 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1635 exception NotADefinition;;
1638 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1639 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1640 let notebook = (rendering_window ())#notebook in
1642 let uri = input_or_locate_uri ~title:"Open" in
1643 CicTypeChecker.typecheck uri ;
1644 let metasenv,bo,ty =
1645 match CicEnvironment.get_cooked_obj uri with
1646 Cic.Constant (_,Some bo,ty,_) -> [],bo,ty
1647 | Cic.CurrentProof (_,metasenv,bo,ty,_) -> metasenv,bo,ty
1650 | Cic.InductiveDefinition _ -> raise NotADefinition
1652 ProofEngine.proof :=
1653 Some (uri, metasenv, bo, ty) ;
1654 ProofEngine.goal := None ;
1655 refresh_goals notebook ;
1656 refresh_proof output
1658 InvokeTactics.RefreshSequentException e ->
1659 output_html outputhtml
1660 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1661 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1662 | InvokeTactics.RefreshProofException e ->
1663 output_html outputhtml
1664 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1665 "proof: " ^ Printexc.to_string e ^ "</h1>")
1667 output_html outputhtml
1668 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1671 let show_query_results results =
1674 ~modal:false ~title:"Query results." ~border_width:2 () in
1675 let vbox = GPack.vbox ~packing:window#add () in
1677 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1680 ~text:"Click on a URI to show that object"
1681 ~packing:hbox#add () in
1682 let scrolled_window =
1683 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1684 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1685 let clist = GList.clist ~columns:1 ~packing:scrolled_window#add () in
1688 (function (uri,_) ->
1692 clist#set_row ~selectable:false n
1695 clist#columns_autosize () ;
1697 (clist#connect#select_row
1698 (fun ~row ~column ~event ->
1699 let (uristr,_) = List.nth results row in
1701 MQueryMisc.cic_textual_parser_uri_of_string
1702 (MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format'
1705 CicTextualParser0.ConUri uri
1706 | CicTextualParser0.VarUri uri
1707 | CicTextualParser0.IndTyUri (uri,_)
1708 | CicTextualParser0.IndConUri (uri,_,_) ->
1709 show_in_show_window_uri uri
1715 let refine_constraints (must_obj,must_rel,must_sort) =
1716 let chosen = ref false in
1717 let use_only = ref false in
1720 ~modal:true ~title:"Constraints refinement."
1721 ~width:800 ~border_width:2 () in
1722 let vbox = GPack.vbox ~packing:window#add () in
1724 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1727 ~text: "\"Only\" constraints can be enforced or not."
1728 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1730 GButton.toggle_button ~label:"Enforce \"only\" constraints"
1731 ~active:false ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1734 (onlyb#connect#toggled (function () -> use_only := onlyb#active)) ;
1735 (* Notebook for the constraints choice *)
1737 GPack.notebook ~scrollable:true
1738 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1739 (* Rel constraints *)
1742 ~text: "Constraints on Rels" () in
1744 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1747 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1750 ~text: "You can now specify the constraints on Rels."
1751 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1752 let expected_height = 25 * (List.length must_rel + 2) in
1753 let height = if expected_height > 400 then 400 else expected_height in
1754 let scrolled_window =
1755 GBin.scrolled_window ~border_width:10 ~height ~width:600
1756 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1757 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1758 let rel_constraints =
1760 (function (position,depth) ->
1763 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1767 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1769 None -> position, ref None
1771 let mutable_ref = ref (Some depth') in
1773 GButton.toggle_button
1774 ~label:("depth = " ^ string_of_int depth') ~active:true
1775 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1778 (depthb#connect#toggled
1780 let sel_depth = if depthb#active then Some depth' else None in
1781 mutable_ref := sel_depth
1783 position, mutable_ref
1785 (* Sort constraints *)
1788 ~text: "Constraints on Sorts" () in
1790 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1793 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1796 ~text: "You can now specify the constraints on Sorts."
1797 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1798 let expected_height = 25 * (List.length must_sort + 2) in
1799 let height = if expected_height > 400 then 400 else expected_height in
1800 let scrolled_window =
1801 GBin.scrolled_window ~border_width:10 ~height ~width:600
1802 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1803 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1804 let sort_constraints =
1806 (function (position,depth,sort) ->
1809 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1812 ~text:(sort ^ " " ^ position)
1813 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1815 None -> position, ref None, sort
1817 let mutable_ref = ref (Some depth') in
1819 GButton.toggle_button ~label:("depth = " ^ string_of_int depth')
1821 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1824 (depthb#connect#toggled
1826 let sel_depth = if depthb#active then Some depth' else None in
1827 mutable_ref := sel_depth
1829 position, mutable_ref, sort
1831 (* Obj constraints *)
1834 ~text: "Constraints on constants" () in
1836 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1839 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1842 ~text: "You can now specify the constraints on constants."
1843 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1844 let expected_height = 25 * (List.length must_obj + 2) in
1845 let height = if expected_height > 400 then 400 else expected_height in
1846 let scrolled_window =
1847 GBin.scrolled_window ~border_width:10 ~height ~width:600
1848 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1849 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1850 let obj_constraints =
1852 (function (uri,position,depth) ->
1855 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1858 ~text:(uri ^ " " ^ position)
1859 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1861 None -> uri, position, ref None
1863 let mutable_ref = ref (Some depth') in
1865 GButton.toggle_button ~label:("depth = " ^ string_of_int depth')
1867 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1870 (depthb#connect#toggled
1872 let sel_depth = if depthb#active then Some depth' else None in
1873 mutable_ref := sel_depth
1875 uri, position, mutable_ref
1877 (* Confirm/abort buttons *)
1879 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1881 GButton.button ~label:"Ok"
1882 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1884 GButton.button ~label:"Abort"
1885 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1887 ignore (window#connect#destroy GMain.Main.quit) ;
1888 ignore (cancelb#connect#clicked window#destroy) ;
1890 (okb#connect#clicked (function () -> chosen := true ; window#destroy ()));
1891 window#set_position `CENTER ;
1895 let chosen_must_rel =
1897 (function (position,ref_depth) -> position,!ref_depth) rel_constraints in
1898 let chosen_must_sort =
1900 (function (position,ref_depth,sort) -> position,!ref_depth,sort)
1903 let chosen_must_obj =
1905 (function (uri,position,ref_depth) -> uri,position,!ref_depth)
1908 (chosen_must_obj,chosen_must_rel,chosen_must_sort),
1910 (*CSC: ???????????????????????? I assume that must and only are the same... *)
1911 Some chosen_must_obj,Some chosen_must_rel,Some chosen_must_sort
1919 let completeSearchPattern () =
1920 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1921 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1923 let metasenv,expr = inputt#get_metasenv_and_term ~context:[] ~metasenv:[] in
1924 let must = MQueryLevels2.get_constraints expr in
1925 let must',only = refine_constraints must in
1927 MQG.query_of_constraints
1929 ["http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion" ;
1930 "http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis" ;
1931 "http://www.cs.unibo.it/helm/schemas/schema-helm#InConclusion" ;
1932 "http://www.cs.unibo.it/helm/schemas/schema-helm#InHypothesis"
1936 let results = MQI.execute mqi_handle query in
1937 show_query_results results
1940 output_html outputhtml
1941 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1944 let insertQuery () =
1945 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1947 let chosen = ref None in
1950 ~modal:true ~title:"Insert Query (Experts Only)" ~border_width:2 () in
1951 let vbox = GPack.vbox ~packing:window#add () in
1953 GMisc.label ~text:"Insert Query. For Experts Only."
1954 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1955 let scrolled_window =
1956 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1957 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1958 let input = GEdit.text ~editable:true
1959 ~packing:scrolled_window#add () in
1961 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1963 GButton.button ~label:"Ok"
1964 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1966 GButton.button ~label:"Load from file..."
1967 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1969 GButton.button ~label:"Abort"
1970 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1971 ignore (window#connect#destroy GMain.Main.quit) ;
1972 ignore (cancelb#connect#clicked window#destroy) ;
1974 (okb#connect#clicked
1976 chosen := Some (input#get_chars 0 input#length) ; window#destroy ())) ;
1978 (loadb#connect#clicked
1981 GToolbox.select_file ~title:"Select Query File" ()
1985 let inch = open_in filename in
1986 let rec read_file () =
1988 let line = input_line inch in
1989 line ^ "\n" ^ read_file ()
1993 let text = read_file () in
1994 input#delete_text 0 input#length ;
1995 ignore (input#insert_text text ~pos:0))) ;
1996 window#set_position `CENTER ;
2003 MQI.execute mqi_handle (MQueryUtil.query_of_text (Lexing.from_string q))
2005 show_query_results results
2008 output_html outputhtml
2009 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
2012 let choose_must list_of_must only =
2013 let chosen = ref None in
2014 let user_constraints = ref [] in
2017 ~modal:true ~title:"Query refinement." ~border_width:2 () in
2018 let vbox = GPack.vbox ~packing:window#add () in
2020 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2024 ("You can now specify the genericity of the query. " ^
2025 "The more generic the slower.")
2026 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2028 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2032 "Suggestion: start with faster queries before moving to more generic ones."
2033 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2035 GPack.notebook ~scrollable:true
2036 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2039 let last = List.length list_of_must in
2045 (if !page = 1 then "More generic" else
2046 if !page = last then "More precise" else " ") () in
2047 let expected_height = 25 * (List.length must + 2) in
2048 let height = if expected_height > 400 then 400 else expected_height in
2049 let scrolled_window =
2050 GBin.scrolled_window ~border_width:10 ~height ~width:600
2051 ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2053 GList.clist ~columns:2 ~packing:scrolled_window#add
2054 ~titles:["URI" ; "Position"] ()
2058 (function (uri,position) ->
2061 [uri; if position then "MainConclusion" else "Conclusion"]
2063 clist#set_row ~selectable:false n
2066 clist#columns_autosize ()
2069 let label = GMisc.label ~text:"User provided" () in
2071 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2073 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2076 ~text:"Select the constraints that must be satisfied and press OK."
2077 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2078 let expected_height = 25 * (List.length only + 2) in
2079 let height = if expected_height > 400 then 400 else expected_height in
2080 let scrolled_window =
2081 GBin.scrolled_window ~border_width:10 ~height ~width:600
2082 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2084 GList.clist ~columns:2 ~packing:scrolled_window#add
2085 ~selection_mode:`EXTENDED
2086 ~titles:["URI" ; "Position"] ()
2090 (function (uri,position) ->
2093 [uri; if position then "MainConclusion" else "Conclusion"]
2095 clist#set_row ~selectable:true n
2098 clist#columns_autosize () ;
2100 (clist#connect#select_row
2101 (fun ~row ~column ~event ->
2102 user_constraints := (List.nth only row)::!user_constraints)) ;
2104 (clist#connect#unselect_row
2105 (fun ~row ~column ~event ->
2108 (function uri -> uri != (List.nth only row)) !user_constraints)) ;
2111 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2113 GButton.button ~label:"Ok"
2114 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2116 GButton.button ~label:"Abort"
2117 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2119 ignore (window#connect#destroy GMain.Main.quit) ;
2120 ignore (cancelb#connect#clicked window#destroy) ;
2122 (okb#connect#clicked
2123 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
2124 window#set_position `CENTER ;
2128 None -> raise NoChoice
2130 if n = List.length list_of_must then
2131 (* user provided constraints *)
2134 List.nth list_of_must n
2137 let searchPattern () =
2138 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
2139 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
2142 match !ProofEngine.proof with
2143 None -> assert false
2144 | Some proof -> proof
2146 match !ProofEngine.goal with
2150 TacticChaser.searchPattern
2152 ~output_html:(output_html outputhtml) ~choose_must ()
2153 ~status:(proof, metano)
2156 user_uri_choice ~title:"Ambiguous input."
2157 ~msg: "Many lemmas can be successfully applied. Please, choose one:"
2160 inputt#set_term uri' ;
2161 InvokeTactics'.apply ()
2164 output_html outputhtml
2165 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
2168 let choose_selection mmlwidget (element : Gdome.element option) =
2169 let module G = Gdome in
2170 let rec aux element =
2171 if element#hasAttributeNS
2172 ~namespaceURI:Misc.helmns
2173 ~localName:(G.domString "xref")
2175 mmlwidget#set_selection (Some element)
2178 match element#get_parentNode with
2179 None -> assert false
2180 (*CSC: OCAML DIVERGES!
2181 | Some p -> aux (new G.element_of_node p)
2183 | Some p -> aux (new Gdome.element_of_node p)
2185 GdomeInit.DOMCastException _ ->
2187 "******* trying to select above the document root ********"
2191 | None -> mmlwidget#set_selection None
2194 (* STUFF TO BUILD THE GTK INTERFACE *)
2196 (* Stuff for the widget settings *)
2198 let export_to_postscript output =
2199 let lastdir = ref (Unix.getcwd ()) in
2202 GToolbox.select_file ~title:"Export to PostScript"
2203 ~dir:lastdir ~filename:"screenshot.ps" ()
2207 (output :> GMathView.math_view)#export_to_postscript
2208 ~filename:filename ();
2211 let activate_t1 output button_set_anti_aliasing
2212 button_set_transparency export_to_postscript_menu_item
2215 let is_set = button_t1#active in
2216 output#set_font_manager_type
2217 ~fm_type:(if is_set then `font_manager_t1 else `font_manager_gtk) ;
2220 button_set_anti_aliasing#misc#set_sensitive true ;
2221 button_set_transparency#misc#set_sensitive true ;
2222 export_to_postscript_menu_item#misc#set_sensitive true ;
2226 button_set_anti_aliasing#misc#set_sensitive false ;
2227 button_set_transparency#misc#set_sensitive false ;
2228 export_to_postscript_menu_item#misc#set_sensitive false ;
2232 let set_anti_aliasing output button_set_anti_aliasing () =
2233 output#set_anti_aliasing button_set_anti_aliasing#active
2236 let set_transparency output button_set_transparency () =
2237 output#set_transparency button_set_transparency#active
2240 let changefont output font_size_spinb () =
2241 output#set_font_size font_size_spinb#value_as_int
2244 let set_log_verbosity output log_verbosity_spinb () =
2245 output#set_log_verbosity log_verbosity_spinb#value_as_int
2248 class settings_window output sw
2249 export_to_postscript_menu_item selection_changed_callback
2251 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
2253 GPack.vbox ~packing:settings_window#add () in
2256 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2257 ~border_width:5 ~packing:vbox#add () in
2259 GButton.toggle_button ~label:"activate t1 fonts"
2260 ~packing:(table#attach ~left:0 ~top:0) () in
2261 let button_set_anti_aliasing =
2262 GButton.toggle_button ~label:"set_anti_aliasing"
2263 ~packing:(table#attach ~left:0 ~top:1) () in
2264 let button_set_transparency =
2265 GButton.toggle_button ~label:"set_transparency"
2266 ~packing:(table#attach ~left:2 ~top:1) () in
2269 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2270 ~border_width:5 ~packing:vbox#add () in
2271 let font_size_label =
2272 GMisc.label ~text:"font size:"
2273 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
2274 let font_size_spinb =
2276 GData.adjustment ~value:14.0 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
2279 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
2280 let log_verbosity_label =
2281 GMisc.label ~text:"log verbosity:"
2282 ~packing:(table#attach ~left:0 ~top:1) () in
2283 let log_verbosity_spinb =
2285 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
2288 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
2290 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2292 GButton.button ~label:"Close"
2293 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2295 method show = settings_window#show
2297 button_set_anti_aliasing#misc#set_sensitive false ;
2298 button_set_transparency#misc#set_sensitive false ;
2299 (* Signals connection *)
2300 ignore(button_t1#connect#clicked
2301 (activate_t1 output button_set_anti_aliasing
2302 button_set_transparency export_to_postscript_menu_item button_t1)) ;
2303 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
2304 ignore(button_set_anti_aliasing#connect#toggled
2305 (set_anti_aliasing output button_set_anti_aliasing));
2306 ignore(button_set_transparency#connect#toggled
2307 (set_transparency output button_set_transparency)) ;
2308 ignore(log_verbosity_spinb#connect#changed
2309 (set_log_verbosity output log_verbosity_spinb)) ;
2310 ignore(closeb#connect#clicked settings_window#misc#hide)
2313 (* Scratch window *)
2315 class scratch_window =
2318 ~title:"MathML viewer"
2319 ~border_width:2 () in
2321 GPack.vbox ~packing:window#add () in
2323 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2325 GButton.button ~label:"Whd"
2326 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2328 GButton.button ~label:"Reduce"
2329 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2331 GButton.button ~label:"Simpl"
2332 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2333 let scrolled_window =
2334 GBin.scrolled_window ~border_width:10
2335 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2336 let sequent_viewer =
2337 TermViewer.sequent_viewer
2338 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
2340 val mutable term = Cic.Rel 1 (* dummy value *)
2341 val mutable context = ([] : Cic.context) (* dummy value *)
2342 val mutable metasenv = ([] : Cic.metasenv) (* dummy value *)
2343 method sequent_viewer = sequent_viewer
2344 method show () = window#misc#hide () ; window#show ()
2346 method set_term t = term <- t
2347 method context = context
2348 method set_context t = context <- t
2349 method metasenv = metasenv
2350 method set_metasenv t = metasenv <- t
2353 (sequent_viewer#connect#selection_changed (choose_selection sequent_viewer));
2354 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
2355 ignore(whdb#connect#clicked InvokeTactics'.whd_in_scratch) ;
2356 ignore(reduceb#connect#clicked InvokeTactics'.reduce_in_scratch) ;
2357 ignore(simplb#connect#clicked InvokeTactics'.simpl_in_scratch)
2360 let open_contextual_menu_for_selected_terms mmlwidget infos =
2361 let button = GdkEvent.Button.button infos in
2362 let terms_selected = List.length mmlwidget#get_selections > 0 in
2365 let time = GdkEvent.Button.time infos in
2366 let menu = GMenu.menu () in
2367 let f = new GMenu.factory menu in
2369 f#add_item "Whd" ~key:GdkKeysyms._W ~callback:InvokeTactics'.whd in
2370 let reduce_menu_item =
2371 f#add_item "Reduce" ~key:GdkKeysyms._R ~callback:InvokeTactics'.reduce in
2372 let simpl_menu_item =
2373 f#add_item "Simpl" ~key:GdkKeysyms._S ~callback:InvokeTactics'.simpl in
2374 let _ = f#add_separator () in
2375 let generalize_menu_item =
2376 f#add_item "Generalize"
2377 ~key:GdkKeysyms._G ~callback:InvokeTactics'.generalize in
2378 let _ = f#add_separator () in
2379 let clear_menu_item =
2380 f#add_item "Clear" ~key:GdkKeysyms._C ~callback:InvokeTactics'.clear in
2381 let clearbody_menu_item =
2382 f#add_item "ClearBody"
2383 ~key:GdkKeysyms._B ~callback:InvokeTactics'.clearbody
2385 whd_menu_item#misc#set_sensitive terms_selected ;
2386 reduce_menu_item#misc#set_sensitive terms_selected ;
2387 simpl_menu_item#misc#set_sensitive terms_selected ;
2388 generalize_menu_item#misc#set_sensitive terms_selected ;
2389 clear_menu_item#misc#set_sensitive terms_selected ;
2390 clearbody_menu_item#misc#set_sensitive terms_selected ;
2391 menu#popup ~button ~time
2397 let vbox1 = GPack.vbox () in
2399 val mutable proofw_ref = None
2400 val mutable compute_ref = None
2402 Lazy.force self#compute ;
2403 match proofw_ref with
2404 None -> assert false
2405 | Some proofw -> proofw
2406 method content = vbox1
2408 match compute_ref with
2409 None -> assert false
2410 | Some compute -> compute
2414 let scrolled_window1 =
2415 GBin.scrolled_window ~border_width:10
2416 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2418 TermViewer.sequent_viewer ~width:400 ~height:275
2419 ~packing:(scrolled_window1#add) () in
2420 let _ = proofw_ref <- Some proofw in
2422 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2424 GButton.button ~label:"Ring"
2425 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2427 GButton.button ~label:"Fourier"
2428 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2430 GButton.button ~label:"Reflexivity"
2431 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2433 GButton.button ~label:"Symmetry"
2434 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2436 GButton.button ~label:"Assumption"
2437 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2438 let contradictionb =
2439 GButton.button ~label:"Contradiction"
2440 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2442 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2444 GButton.button ~label:"Exists"
2445 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2447 GButton.button ~label:"Split"
2448 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2450 GButton.button ~label:"Left"
2451 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2453 GButton.button ~label:"Right"
2454 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2455 let searchpatternb =
2456 GButton.button ~label:"SearchPattern_Apply"
2457 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2459 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2461 GButton.button ~label:"Exact"
2462 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2464 GButton.button ~label:"Intros"
2465 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2467 GButton.button ~label:"Apply"
2468 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2469 let elimintrossimplb =
2470 GButton.button ~label:"ElimIntrosSimpl"
2471 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2473 GButton.button ~label:"ElimType"
2474 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2476 GButton.button ~label:"Fold_whd"
2477 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2479 GButton.button ~label:"Fold_reduce"
2480 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2482 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2484 GButton.button ~label:"Fold_simpl"
2485 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2487 GButton.button ~label:"Cut"
2488 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2490 GButton.button ~label:"Change"
2491 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2493 GButton.button ~label:"Let ... In"
2494 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2496 GButton.button ~label:"RewriteSimpl ->"
2497 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2498 let rewritebacksimplb =
2499 GButton.button ~label:"RewriteSimpl <-"
2500 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2502 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2504 GButton.button ~label:"Absurd"
2505 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2507 GButton.button ~label:"Decompose"
2508 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2510 GButton.button ~label:"Transitivity"
2511 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2513 GButton.button ~label:"Replace"
2514 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2516 GButton.button ~label:"Injection"
2517 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2519 GButton.button ~label:"Discriminate"
2520 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2521 (* Zack: spostare in una toolbar
2523 GButton.button ~label:"Generalize"
2524 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2526 GButton.button ~label:"ClearBody"
2527 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2529 GButton.button ~label:"Clear"
2530 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2532 GButton.button ~label:"Whd"
2533 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2535 GButton.button ~label:"Reduce"
2536 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2538 GButton.button ~label:"Simpl"
2539 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2542 ignore(exactb#connect#clicked InvokeTactics'.exact) ;
2543 ignore(applyb#connect#clicked InvokeTactics'.apply) ;
2544 ignore(elimintrossimplb#connect#clicked InvokeTactics'.elimintrossimpl) ;
2545 ignore(elimtypeb#connect#clicked InvokeTactics'.elimtype) ;
2546 ignore(foldwhdb#connect#clicked InvokeTactics'.fold_whd) ;
2547 ignore(foldreduceb#connect#clicked InvokeTactics'.fold_reduce) ;
2548 ignore(foldsimplb#connect#clicked InvokeTactics'.fold_simpl) ;
2549 ignore(cutb#connect#clicked InvokeTactics'.cut) ;
2550 ignore(changeb#connect#clicked InvokeTactics'.change) ;
2551 ignore(letinb#connect#clicked InvokeTactics'.letin) ;
2552 ignore(ringb#connect#clicked InvokeTactics'.ring) ;
2553 ignore(fourierb#connect#clicked InvokeTactics'.fourier) ;
2554 ignore(rewritesimplb#connect#clicked InvokeTactics'.rewritesimpl) ;
2555 ignore(rewritebacksimplb#connect#clicked InvokeTactics'.rewritebacksimpl) ;
2556 ignore(replaceb#connect#clicked InvokeTactics'.replace) ;
2557 ignore(reflexivityb#connect#clicked InvokeTactics'.reflexivity) ;
2558 ignore(symmetryb#connect#clicked InvokeTactics'.symmetry) ;
2559 ignore(transitivityb#connect#clicked InvokeTactics'.transitivity) ;
2560 ignore(existsb#connect#clicked InvokeTactics'.exists) ;
2561 ignore(splitb#connect#clicked InvokeTactics'.split) ;
2562 ignore(leftb#connect#clicked InvokeTactics'.left) ;
2563 ignore(rightb#connect#clicked InvokeTactics'.right) ;
2564 ignore(assumptionb#connect#clicked InvokeTactics'.assumption) ;
2565 ignore(absurdb#connect#clicked InvokeTactics'.absurd) ;
2566 ignore(contradictionb#connect#clicked InvokeTactics'.contradiction) ;
2567 ignore(introsb#connect#clicked InvokeTactics'.intros) ;
2568 ignore(decomposeb#connect#clicked InvokeTactics'.decompose) ;
2569 ignore(searchpatternb#connect#clicked searchPattern) ;
2570 ignore(injectionb#connect#clicked InvokeTactics'.injection) ;
2571 ignore(discriminateb#connect#clicked InvokeTactics'.discriminate) ;
2572 (* Zack: spostare in una toolbar
2573 ignore(whdb#connect#clicked whd) ;
2574 ignore(reduceb#connect#clicked reduce) ;
2575 ignore(simplb#connect#clicked simpl) ;
2576 ignore(clearbodyb#connect#clicked clearbody) ;
2577 ignore(clearb#connect#clicked clear) ;
2578 ignore(generalizeb#connect#clicked generalize) ;
2580 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
2582 ((new GObj.event_ops proofw#as_widget)#connect#button_press
2583 (open_contextual_menu_for_selected_terms proofw)) ;
2589 let vbox1 = GPack.vbox () in
2590 let scrolled_window1 =
2591 GBin.scrolled_window ~border_width:10
2592 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2594 TermViewer.sequent_viewer ~width:400 ~height:275
2595 ~packing:(scrolled_window1#add) () in
2597 method proofw = (assert false : TermViewer.sequent_viewer)
2598 method content = vbox1
2599 method compute = (assert false : unit)
2603 let empty_page = new empty_page;;
2607 val notebook = GPack.notebook ()
2609 val mutable skip_switch_page_event = false
2610 val mutable empty = true
2611 method notebook = notebook
2613 let new_page = new page () in
2615 pages := !pages @ [n,lazy (setgoal n),new_page] ;
2616 notebook#append_page
2617 ~tab_label:((GMisc.label ~text:("?" ^ string_of_int n) ())#coerce)
2618 new_page#content#coerce
2619 method remove_all_pages ~skip_switch_page_event:skip =
2621 notebook#remove_page 0 (* let's remove the empty page *)
2623 List.iter (function _ -> notebook#remove_page 0) !pages ;
2625 skip_switch_page_event <- skip
2626 method set_current_page ~may_skip_switch_page_event n =
2627 let (_,_,page) = List.find (function (m,_,_) -> m=n) !pages in
2628 let new_page = notebook#page_num page#content#coerce in
2629 if may_skip_switch_page_event && new_page <> notebook#current_page then
2630 skip_switch_page_event <- true ;
2631 notebook#goto_page new_page
2632 method set_empty_page =
2635 notebook#append_page
2636 ~tab_label:((GMisc.label ~text:"No proof in progress" ())#coerce)
2637 empty_page#content#coerce
2639 let (_,_,page) = List.nth !pages notebook#current_page in
2643 (notebook#connect#switch_page
2645 let skip = skip_switch_page_event in
2646 skip_switch_page_event <- false ;
2649 let (metano,setgoal,page) = List.nth !pages i in
2650 ProofEngine.goal := Some metano ;
2651 Lazy.force (page#compute) ;
2660 class rendering_window output (notebook : notebook) =
2661 let scratch_window = new scratch_window in
2664 ~title:"gTopLevel - Helm's Proof Assistant"
2665 ~border_width:0 ~allow_shrink:false () in
2666 let vbox_for_menu = GPack.vbox ~packing:window#add () in
2668 let handle_box = GBin.handle_box ~border_width:2
2669 ~packing:(vbox_for_menu#pack ~padding:0) () in
2670 let menubar = GMenu.menu_bar ~packing:handle_box#add () in
2671 let factory0 = new GMenu.factory menubar in
2672 let accel_group = factory0#accel_group in
2674 let file_menu = factory0#add_submenu "File" in
2675 let factory1 = new GMenu.factory file_menu ~accel_group in
2676 let export_to_postscript_menu_item =
2679 factory1#add_item "New Block of (Co)Inductive Definitions..."
2680 ~key:GdkKeysyms._B ~callback:new_inductive
2683 factory1#add_item "New Proof or Definition..." ~key:GdkKeysyms._N
2686 let reopen_menu_item =
2687 factory1#add_item "Reopen a Finished Proof..." ~key:GdkKeysyms._R
2691 factory1#add_item "Qed" ~key:GdkKeysyms._E ~callback:qed in
2692 ignore (factory1#add_separator ()) ;
2694 (factory1#add_item "Load Unfinished Proof..." ~key:GdkKeysyms._L
2695 ~callback:load_unfinished_proof) ;
2696 let save_menu_item =
2697 factory1#add_item "Save Unfinished Proof" ~key:GdkKeysyms._S
2698 ~callback:save_unfinished_proof
2701 (save_set_sensitive := function b -> save_menu_item#misc#set_sensitive b);
2702 ignore (!save_set_sensitive false);
2703 ignore (qed_set_sensitive:=function b -> qed_menu_item#misc#set_sensitive b);
2704 ignore (!qed_set_sensitive false);
2705 ignore (factory1#add_separator ()) ;
2706 let export_to_postscript_menu_item =
2707 factory1#add_item "Export to PostScript..."
2708 ~callback:(export_to_postscript output) in
2709 ignore (factory1#add_separator ()) ;
2711 (factory1#add_item "Exit" ~key:GdkKeysyms._Q ~callback:GMain.Main.quit) ;
2712 export_to_postscript_menu_item
2715 let edit_menu = factory0#add_submenu "Edit Current Proof" in
2716 let factory2 = new GMenu.factory edit_menu ~accel_group in
2717 let focus_and_proveit_set_sensitive = ref (function _ -> assert false) in
2718 let proveit_menu_item =
2719 factory2#add_item "Prove It" ~key:GdkKeysyms._I
2720 ~callback:(function () -> proveit ();!focus_and_proveit_set_sensitive false)
2722 let focus_menu_item =
2723 factory2#add_item "Focus" ~key:GdkKeysyms._F
2724 ~callback:(function () -> focus () ; !focus_and_proveit_set_sensitive false)
2727 focus_and_proveit_set_sensitive :=
2729 proveit_menu_item#misc#set_sensitive b ;
2730 focus_menu_item#misc#set_sensitive b
2732 let _ = !focus_and_proveit_set_sensitive false in
2733 (* edit term menu *)
2734 let edit_term_menu = factory0#add_submenu "Edit Term" in
2735 let factory5 = new GMenu.factory edit_term_menu ~accel_group in
2736 let check_menu_item =
2737 factory5#add_item "Check Term" ~key:GdkKeysyms._C
2738 ~callback:(check scratch_window) in
2739 let _ = check_menu_item#misc#set_sensitive false in
2741 let search_menu = factory0#add_submenu "Search" in
2742 let factory4 = new GMenu.factory search_menu ~accel_group in
2744 factory4#add_item "Locate..." ~key:GdkKeysyms._T
2746 let searchPattern_menu_item =
2747 factory4#add_item "SearchPattern..." ~key:GdkKeysyms._D
2748 ~callback:completeSearchPattern in
2749 let _ = searchPattern_menu_item#misc#set_sensitive false in
2750 let show_menu_item =
2751 factory4#add_item "Show..." ~key:GdkKeysyms._H ~callback:show
2753 let insert_query_item =
2754 factory4#add_item "Insert Query (Experts Only)..." ~key:GdkKeysyms._Y
2755 ~callback:insertQuery in
2757 let hbugs_menu = factory0#add_submenu "HBugs" in
2758 let factory6 = new GMenu.factory hbugs_menu ~accel_group in
2759 let toggle_hbugs_menu_item =
2760 factory6#add_check_item
2761 ~active:false ~key:GdkKeysyms._F5 ~callback:Hbugs.toggle "HBugs enabled"
2764 let settings_menu = factory0#add_submenu "Settings" in
2765 let factory3 = new GMenu.factory settings_menu ~accel_group in
2767 factory3#add_item "Edit Aliases..." ~key:GdkKeysyms._A
2768 ~callback:edit_aliases in
2769 let _ = factory3#add_separator () in
2771 factory3#add_item "MathML Widget Preferences..." ~key:GdkKeysyms._P
2772 ~callback:(function _ -> (settings_window ())#show ()) in
2773 let _ = factory3#add_separator () in
2775 factory3#add_item "Reload Stylesheets"
2778 ApplyStylesheets.reload_stylesheets () ;
2779 refresh_proof output ;
2780 refresh_goals notebook
2783 let _ = window#add_accel_group accel_group in
2787 ~packing:(vbox_for_menu#pack ~expand:true ~fill:true ~padding:5) () in
2789 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2790 let scrolled_window0 =
2791 GBin.scrolled_window ~border_width:10
2792 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2793 let _ = scrolled_window0#add output#coerce in
2795 GBin.frame ~label:"Insert Term"
2796 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2797 let scrolled_window1 =
2798 GBin.scrolled_window ~border_width:5
2799 ~packing:frame#add () in
2801 TexTermEditor'.term_editor
2803 ~width:400 ~height:100 ~packing:scrolled_window1#add ()
2804 ~isnotempty_callback:
2806 check_menu_item#misc#set_sensitive b ;
2807 searchPattern_menu_item#misc#set_sensitive b) in
2809 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2811 vboxl#pack ~expand:true ~fill:true ~padding:5 notebook#notebook#coerce in
2813 GBin.frame ~shadow_type:`IN ~packing:(vboxl#pack ~expand:true ~padding:5) ()
2817 ~source:"<html><body bgColor=\"white\"></body></html>"
2818 ~width:400 ~height: 100
2823 method outputhtml = outputhtml
2824 method inputt = inputt
2825 method output = (output : TermViewer.proof_viewer)
2826 method scratch_window = scratch_window
2827 method notebook = notebook
2828 method show = window#show
2830 notebook#set_empty_page ;
2831 export_to_postscript_menu_item#misc#set_sensitive false ;
2832 check_term := (check_term_in_scratch scratch_window) ;
2834 (* signal handlers here *)
2835 ignore(output#connect#selection_changed
2837 choose_selection output elem ;
2838 !focus_and_proveit_set_sensitive true
2840 ignore (output#connect#click (show_in_show_window_callback output)) ;
2841 let settings_window = new settings_window output scrolled_window0
2842 export_to_postscript_menu_item (choose_selection output) in
2843 set_settings_window settings_window ;
2844 set_outputhtml outputhtml ;
2845 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
2846 Logger.log_callback :=
2847 (Logger.log_to_html ~print_and_flush:(output_html outputhtml))
2852 let initialize_everything () =
2853 let module U = Unix in
2854 let output = TermViewer.proof_viewer ~width:350 ~height:280 () in
2855 let notebook = new notebook in
2856 let rendering_window' = new rendering_window output notebook in
2857 set_rendering_window rendering_window' ;
2858 let print_error_as_html prefix msg =
2859 output_html (outputhtml ())
2860 ("<h1 color=\"red\">" ^ prefix ^ msg ^ "</h1>")
2862 Gdome_xslt.setErrorCallback (Some (print_error_as_html "XSLT Error: "));
2863 Gdome_xslt.setDebugCallback
2864 (Some (print_error_as_html "XSLT Debug Message: "));
2865 rendering_window'#show () ;
2866 (* Hbugs.toggle true; *)
2871 ignore (GtkMain.Main.init ()) ;
2872 initialize_everything () ;
2873 MQIC.close mqi_handle;
2878 Sys.catch_break true;
2880 with Sys.Break -> () (* exit nicely, invoking at_exit functions *)