1 (* Copyright (C) 2000-2004, 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 (******************************************************************************)
36 let debug_level = ref 1
37 let debug_print ?(level = 1) s = if !debug_level >= level then prerr_endline s
43 module MQI = MQueryInterpreter
45 module MQGT = MQGTypes
47 module MQG = MQueryGenerator
49 (* GLOBAL CONSTANTS *)
51 let mqi_debug_fun s = debug_print ~level:2 s
52 let mqi_flags = [MQIC.Postgres ; MQIC.Stat ; MQIC.Warn ; MQIC.Log]
53 let mqi_handle = MQIC.init mqi_flags mqi_debug_fun
55 let xlinkns = Gdome.domString "http://www.w3.org/1999/xlink";;
59 Sys.getenv "GTOPLEVEL_PROOFFILE"
61 Not_found -> "/public/currentproof"
66 Sys.getenv "GTOPLEVEL_PROOFFILETYPE"
68 Not_found -> "/public/currentprooftype"
73 Sys.getenv "GTOPLEVEL_ENVIRONMENTFILE"
75 Not_found -> "/public/environment"
78 let restore_environment_on_boot = true ;;
79 let notify_hbugs_on_goal_change = false ;;
81 (* GLOBAL REFERENCES (USED BY CALLBACKS) *)
83 let check_term = ref (fun _ _ _ -> assert false);;
85 exception RenderingWindowsNotInitialized;;
87 let set_rendering_window,rendering_window =
88 let rendering_window_ref = ref None in
89 (function rw -> rendering_window_ref := Some rw),
91 match !rendering_window_ref with
92 None -> raise RenderingWindowsNotInitialized
97 exception SettingsWindowsNotInitialized;;
99 let set_settings_window,settings_window =
100 let settings_window_ref = ref None in
101 (function rw -> settings_window_ref := Some rw),
103 match !settings_window_ref with
104 None -> raise SettingsWindowsNotInitialized
109 exception OutputHtmlNotInitialized;;
111 let set_outputhtml,outputhtml =
112 let outputhtml_ref = ref None in
113 (function (rw: Ui_logger.html_logger) -> outputhtml_ref := Some rw),
115 match !outputhtml_ref with
116 | None -> raise OutputHtmlNotInitialized
117 | Some outputhtml -> (outputhtml: Ui_logger.html_logger)
121 exception QedSetSensitiveNotInitialized;;
122 let qed_set_sensitive =
123 ref (function _ -> raise QedSetSensitiveNotInitialized)
126 exception SaveSetSensitiveNotInitialized;;
127 let save_set_sensitive =
128 ref (function _ -> raise SaveSetSensitiveNotInitialized)
131 (* COMMAND LINE OPTIONS *)
137 "-nodb", Arg.Clear usedb, "disable use of MathQL DB"
140 Arg.parse argspec ignore ""
144 let term_of_cic_textual_parser_uri uri =
145 let module C = Cic in
146 let module CTP = CicTextualParser0 in
148 CTP.ConUri uri -> C.Const (uri,[])
149 | CTP.VarUri uri -> C.Var (uri,[])
150 | CTP.IndTyUri (uri,tyno) -> C.MutInd (uri,tyno,[])
151 | CTP.IndConUri (uri,tyno,consno) -> C.MutConstruct (uri,tyno,consno,[])
154 let string_of_cic_textual_parser_uri uri =
155 let module C = Cic in
156 let module CTP = CicTextualParser0 in
159 CTP.ConUri uri -> UriManager.string_of_uri uri
160 | CTP.VarUri uri -> UriManager.string_of_uri uri
161 | CTP.IndTyUri (uri,tyno) ->
162 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1)
163 | CTP.IndConUri (uri,tyno,consno) ->
164 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1) ^ "/" ^
167 (* 4 = String.length "cic:" *)
168 String.sub uri' 4 (String.length uri' - 4)
171 let output_html ?(append_NL = true) (outputhtml: Ui_logger.html_logger) =
172 outputhtml#log ~append_NL
174 (* UTILITY FUNCTIONS TO DISAMBIGUATE AN URI *)
178 let check_window (outputhtml: Ui_logger.html_logger) uris =
181 ~width:800 ~modal:true ~title:"Check" ~border_width:2 () in
183 GPack.notebook ~scrollable:true ~packing:window#add () in
188 let scrolled_window =
189 GBin.scrolled_window ~border_width:10
191 (notebook#append_page ~tab_label:((GMisc.label ~text:uri ())#coerce))
196 TermViewer.sequent_viewer
197 ~packing:scrolled_window#add ~width:400 ~height:280 () in
200 term_of_cic_textual_parser_uri
201 (MQueryMisc.cic_textual_parser_uri_of_string uri)
203 (Cic.Cast (term, CicTypeChecker.type_of_aux' [] [] term))
206 mmlwidget#load_sequent [] (111,[],expr)
209 output_html outputhtml (`Error (`T (Printexc.to_string e)))
214 (notebook#connect#switch_page
216 Lazy.force (List.nth render_terms i)))
222 interactive_user_uri_choice ~(selection_mode:[`MULTIPLE|`SINGLE]) ?(ok="Ok")
223 ?(enable_button_for_non_vars=false) ~title ~msg uris
225 let choices = ref [] in
226 let chosen = ref false in
227 let use_only_constants = ref false in
229 GWindow.dialog ~modal:true ~title ~width:600 () in
231 GMisc.label ~text:msg
232 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
233 let scrolled_window =
234 GBin.scrolled_window ~border_width:10
235 ~packing:(window#vbox#pack ~expand:true ~fill:true ~padding:5) () in
237 let expected_height = 18 * List.length uris in
238 let height = if expected_height > 400 then 400 else expected_height in
239 GList.clist ~columns:1 ~packing:scrolled_window#add
240 ~height ~selection_mode:(selection_mode :> Gtk.Tags.selection_mode) () in
241 let _ = List.map (function x -> clist#append [x]) uris in
243 GPack.hbox ~border_width:0
244 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
246 GMisc.label ~text:"None of the above. Try this one:"
247 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
249 GEdit.entry ~editable:true
250 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
252 GPack.hbox ~border_width:0 ~packing:window#action_area#add () in
254 GButton.button ~label:ok
255 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
256 let _ = okb#misc#set_sensitive false in
261 if enable_button_for_non_vars then
262 hbox#pack ~expand:false ~fill:false ~padding:5 w)
263 ~label:"Try constants only" () in
265 GButton.button ~label:"Check"
266 ~packing:(hbox#pack ~padding:5) () in
267 let _ = checkb#misc#set_sensitive false in
269 GButton.button ~label:"Abort"
270 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
272 let check_callback () =
273 assert (List.length !choices > 0) ;
274 check_window (outputhtml ()) !choices
276 ignore (window#connect#destroy GMain.Main.quit) ;
277 ignore (cancelb#connect#clicked window#destroy) ;
279 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
281 (nonvarsb#connect#clicked
283 use_only_constants := true ;
287 ignore (checkb#connect#clicked check_callback) ;
289 (clist#connect#select_row
290 (fun ~row ~column ~event ->
291 checkb#misc#set_sensitive true ;
292 okb#misc#set_sensitive true ;
293 choices := (List.nth uris row)::!choices)) ;
295 (clist#connect#unselect_row
296 (fun ~row ~column ~event ->
298 List.filter (function uri -> uri != (List.nth uris row)) !choices)) ;
300 (manual_input#connect#changed
302 if manual_input#text = "" then
305 checkb#misc#set_sensitive false ;
306 okb#misc#set_sensitive false ;
307 clist#misc#set_sensitive true
311 choices := [manual_input#text] ;
312 clist#unselect_all () ;
313 checkb#misc#set_sensitive true ;
314 okb#misc#set_sensitive true ;
315 clist#misc#set_sensitive false
317 window#set_position `CENTER ;
321 if !use_only_constants then
323 (function uri -> not (String.sub uri (String.length uri - 4) 4 = ".var"))
326 if List.length !choices > 0 then !choices else raise NoChoice
331 let interactive_interpretation_choice interpretations =
332 let chosen = ref None in
335 ~modal:true ~title:"Ambiguous well-typed input." ~border_width:2 () in
336 let vbox = GPack.vbox ~packing:window#add () in
340 ("Ambiguous input since there are many well-typed interpretations." ^
341 " Please, choose one of them.")
342 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
344 GPack.notebook ~scrollable:true
345 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
348 (function interpretation ->
350 let expected_height = 18 * List.length interpretation in
351 let height = if expected_height > 400 then 400 else expected_height in
352 GList.clist ~columns:2 ~packing:notebook#append_page ~height
353 ~titles:["id" ; "URI"] ()
357 (function (id,uri) ->
358 let n = clist#append [id;uri] in
359 clist#set_row ~selectable:false n
362 clist#columns_autosize ()
365 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
367 GButton.button ~label:"Ok"
368 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
370 GButton.button ~label:"Abort"
371 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
373 ignore (window#connect#destroy GMain.Main.quit) ;
374 ignore (cancelb#connect#clicked window#destroy) ;
377 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
378 window#set_position `CENTER ;
382 None -> raise NoChoice
390 save_object_to_disk uri annobj ids_to_inner_sorts ids_to_inner_types pathname
393 let struri = UriManager.string_of_uri uri in
394 let idx = (String.rindex struri '/') + 1 in
395 String.sub struri idx (String.length struri - idx)
397 let path = pathname ^ "/" ^ name in
399 Cic2Xml.print_object uri ~ids_to_inner_sorts ~ask_dtd_to_the_getter:false
403 Cic2Xml.print_inner_types uri ~ids_to_inner_sorts ~ids_to_inner_types
404 ~ask_dtd_to_the_getter:false
407 let innertypesuri = UriManager.innertypesuri_of_uri uri in
408 Xml.pp ~quiet:true xmlinnertypes (Some (path ^ ".types.xml")) ;
409 Getter.register innertypesuri
410 (Configuration.annotations_url ^
411 Str.replace_first (Str.regexp "^cic:") ""
412 (UriManager.string_of_uri innertypesuri) ^ ".xml"
414 (* constant type / variable / mutual inductive types definition *)
415 Xml.pp ~quiet:true xml (Some (path ^ ".xml")) ;
417 (Configuration.annotations_url ^
418 Str.replace_first (Str.regexp "^cic:") ""
419 (UriManager.string_of_uri uri) ^ ".xml"
426 match UriManager.bodyuri_of_uri uri with
428 | Some bodyuri -> bodyuri
430 Xml.pp ~quiet:true bodyxml' (Some (path ^ ".body.xml")) ;
431 Getter.register bodyuri
432 (Configuration.annotations_url ^
433 Str.replace_first (Str.regexp "^cic:") ""
434 (UriManager.string_of_uri bodyuri) ^ ".xml"
441 exception OpenConjecturesStillThere;;
442 exception WrongProof;;
444 let pathname_of_annuri uristring =
445 Configuration.annotations_dir ^
446 Str.replace_first (Str.regexp "^cic:") "" uristring
449 let make_dirs dirpath =
450 ignore (Unix.system ("mkdir -p " ^ dirpath))
453 let save_obj uri obj =
455 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
456 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
458 Cic2acic.acic_object_of_cic_object obj
460 (* let's save the theorem and register it to the getter *)
461 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
463 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
468 match ProofEngine.get_proof () with
470 | Some (uri,[],bo,ty) ->
472 CicReduction.are_convertible []
473 (CicTypeChecker.type_of_aux' [] [] bo) ty
476 (*CSC: Wrong: [] is just plainly wrong *)
477 let proof = Cic.Constant (UriManager.name_of_uri uri,Some bo,ty,[]) in
478 let (acic,ids_to_inner_types,ids_to_inner_sorts) =
479 (rendering_window ())#output#load_proof uri proof
481 !qed_set_sensitive false ;
482 (* let's save the theorem and register it to the getter *)
483 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
485 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
490 | _ -> raise OpenConjecturesStillThere
493 (** save an unfinished proof on the filesystem *)
494 let save_unfinished_proof () =
495 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
496 let (xml, bodyxml) = ProofEngine.get_current_status_as_xml () in
497 Xml.pp ~quiet:true xml (Some prooffiletype) ;
498 output_html outputhtml
499 (`Msg (`T ("Current proof type saved to " ^ prooffiletype))) ;
500 Xml.pp ~quiet:true bodyxml (Some prooffile) ;
501 output_html outputhtml
502 (`Msg (`T ("Current proof body saved to " ^ prooffile)))
505 (* Used to typecheck the loaded proofs *)
506 let typecheck_loaded_proof metasenv bo ty =
507 let module T = CicTypeChecker in
510 (fun metasenv ((_,context,ty) as conj) ->
511 ignore (T.type_of_aux' metasenv context ty) ;
514 ignore (T.type_of_aux' metasenv [] ty) ;
515 ignore (T.type_of_aux' metasenv [] bo)
518 let decompose_uris_choice_callback uris =
519 (* N.B.: in questo passaggio perdo l'informazione su exp_named_subst !!!! *)
520 let module U = UriManager in
523 match MQueryMisc.cic_textual_parser_uri_of_string uri with
524 CicTextualParser0.IndTyUri (uri,typeno) -> (uri,typeno,[])
526 (interactive_user_uri_choice
527 ~selection_mode:`MULTIPLE ~ok:"Ok" ~enable_button_for_non_vars:false
528 ~title:"Decompose" ~msg:"Please, select the Inductive Types to decompose"
530 (function (uri,typeno,_) ->
531 U.string_of_uri uri ^ "#1/" ^ string_of_int (typeno+1)
536 let mk_fresh_name_callback context name ~typ =
538 match ProofEngineHelpers.mk_fresh_name context name ~typ with
539 Cic.Name fresh_name -> fresh_name
540 | Cic.Anonymous -> assert false
543 GToolbox.input_string ~title:"Enter a fresh hypothesis name" ~text:fresh_name
544 ("Enter a fresh name for the hypothesis " ^
546 (List.map (function None -> None | Some (n,_) -> Some n) context))
548 Some fresh_name' -> Cic.Name fresh_name'
549 | None -> raise NoChoice
552 let refresh_proof (output : TermViewer.proof_viewer) =
554 let uri,currentproof =
555 match ProofEngine.get_proof () with
557 | Some (uri,metasenv,bo,ty) ->
558 ProofEngine.set_proof (Some (uri,metasenv,bo,ty)) ;
559 if List.length metasenv = 0 then
561 !qed_set_sensitive true ;
566 (*CSC: Wrong: [] is just plainly wrong *)
568 (Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, []))
570 ignore (output#load_proof uri currentproof)
573 match ProofEngine.get_proof () with
575 | Some (uri,metasenv,bo,ty) ->
576 debug_print ("Offending proof: " ^ CicPp.ppobj (Cic.CurrentProof ("questa",metasenv,bo,ty,[])));
577 raise (InvokeTactics.RefreshProofException e)
579 let set_proof_engine_goal g =
580 ProofEngine.goal := g
583 let refresh_goals ?(empty_notebook=true) notebook =
585 match !ProofEngine.goal with
587 if empty_notebook then
589 notebook#remove_all_pages ~skip_switch_page_event:false ;
590 notebook#set_empty_page
593 notebook#proofw#unload
596 match ProofEngine.get_proof () with
598 | Some (_,metasenv,_,_) -> metasenv
601 List.find (function (m,_,_) -> m=metano) metasenv
603 let regenerate_notebook () =
604 let skip_switch_page_event =
606 (m,_,_)::_ when m = metano -> false
609 notebook#remove_all_pages ~skip_switch_page_event ;
610 List.iter (function (m,_,_) -> notebook#add_page m) metasenv ;
612 if empty_notebook then
614 regenerate_notebook () ;
615 notebook#set_current_page
616 ~may_skip_switch_page_event:false metano
620 notebook#set_current_page
621 ~may_skip_switch_page_event:true metano ;
622 notebook#proofw#load_sequent metasenv currentsequent
627 match !ProofEngine.goal with
632 match ProofEngine.get_proof () with
634 | Some (_,metasenv,_,_) -> metasenv
637 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
639 ("Offending sequent: " ^ SequentPp.TextualPp.print_sequent currentsequent);
640 raise (InvokeTactics.RefreshSequentException e)
642 debug_print ("Offending sequent " ^ string_of_int metano ^ " unknown.");
643 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);;
666 (* Just to initialize the Hbugs module *)
667 module Ignore = Hbugs.Initialize (InvokeTactics');;
668 Hbugs.set_describe_hint_callback (fun hint ->
670 | Hbugs_types.Use_apply_Luke term ->
671 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
672 check_window outputhtml [term]
676 let dummy_uri = "/dummy.con"
678 (** load an unfinished proof from filesystem *)
679 let load_unfinished_proof () =
680 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
681 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
682 let notebook = (rendering_window ())#notebook in
685 GToolbox.input_string ~title:"Load Unfinished Proof" ~text:dummy_uri
688 None -> raise NoChoice
690 let uri = UriManager.uri_of_string ("cic:" ^ uri0) in
691 match CicParser.obj_of_xml prooffiletype (Some prooffile) with
692 Cic.CurrentProof (_,metasenv,bo,ty,_) ->
693 typecheck_loaded_proof metasenv bo ty ;
694 ProofEngine.set_proof (Some (uri, metasenv, bo, ty)) ;
695 refresh_proof output ;
696 set_proof_engine_goal
699 | (metano,_,_)::_ -> Some metano
701 refresh_goals notebook ;
702 output_html outputhtml
703 (`Msg (`T ("Current proof type loaded from " ^
705 output_html outputhtml
706 (`Msg (`T ("Current proof body loaded from " ^
708 !save_set_sensitive true;
711 InvokeTactics.RefreshSequentException e ->
712 output_html outputhtml
713 (`Error (`T ("Exception raised during the refresh of the " ^
714 "sequent: " ^ Printexc.to_string e)))
715 | InvokeTactics.RefreshProofException e ->
716 output_html outputhtml
717 (`Error (`T ("Exception raised during the refresh of the " ^
718 "proof: " ^ Printexc.to_string e)))
720 output_html outputhtml
721 (`Error (`T (Printexc.to_string e)))
724 let edit_aliases () =
725 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
726 let disambiguation_env = inputt#environment in
727 let chosen_aliases = ref None in
730 ~width:400 ~modal:true ~title:"Edit Aliases..." ~border_width:2 () in
732 GPack.vbox ~border_width:0 ~packing:window#add () in
733 let scrolled_window =
734 GBin.scrolled_window ~border_width:10
735 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
736 let input = GText.view ~editable:true ~width:400 ~height:100
737 ~packing:scrolled_window#add () in
739 GPack.hbox ~border_width:0
740 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
742 GButton.button ~label:"Ok"
743 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
745 GButton.button ~label:"Cancel"
746 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
747 ignore (window#connect#destroy GMain.Main.quit) ;
748 ignore (cancelb#connect#clicked window#destroy) ;
749 ignore (okb#connect#clicked (fun () ->
750 chosen_aliases := Some (input#buffer#get_text
751 ~start:input#buffer#start_iter ~stop:input#buffer#end_iter ());
754 (input#buffer#insert ~iter:(input#buffer#get_iter_at_char 0)
755 (DisambiguatingParser.EnvironmentP3.to_string !disambiguation_env ^ "\n"));
758 match !chosen_aliases with
760 | Some raw_aliases ->
761 let new_disambiguation_env =
763 DisambiguatingParser.EnvironmentP3.of_string raw_aliases
765 output_html (outputhtml ())
767 ("Error while parsing aliases: " ^ Printexc.to_string e)));
770 disambiguation_env := new_disambiguation_env
774 let module L = LogicalOperations in
775 let module G = Gdome in
776 let notebook = (rendering_window ())#notebook in
777 let output = (rendering_window ())#output in
778 let outputhtml = (rendering_window ())#outputhtml in
780 output#make_sequent_of_selected_term ;
781 refresh_proof output ;
782 refresh_goals notebook
784 InvokeTactics.RefreshSequentException e ->
785 output_html outputhtml
786 (`Error (`T ("Exception raised during the refresh of the " ^
787 "sequent: " ^ Printexc.to_string e)))
788 | InvokeTactics.RefreshProofException e ->
789 output_html outputhtml
790 (`Error (`T ("Exception raised during the refresh of the " ^
791 "proof: " ^ Printexc.to_string e)))
793 output_html outputhtml
794 (`Error (`T (Printexc.to_string e)))
798 let module L = LogicalOperations in
799 let module G = Gdome in
800 let notebook = (rendering_window ())#notebook in
801 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
802 let output = (rendering_window ())#output in
804 output#focus_sequent_of_selected_term ;
805 refresh_goals notebook
807 InvokeTactics.RefreshSequentException e ->
808 output_html outputhtml
809 (`Error (`T ("Exception raised during the refresh of the " ^
810 "sequent: " ^ Printexc.to_string e)))
811 | InvokeTactics.RefreshProofException e ->
812 output_html outputhtml
813 (`Error (`T ("Exception raised during the refresh of the " ^
814 "proof: " ^ Printexc.to_string e)))
816 output_html outputhtml
817 (`Error (`T (Printexc.to_string e)))
820 exception NoPrevGoal;;
821 exception NoNextGoal;;
824 let module L = LogicalOperations in
825 let module G = Gdome in
826 let notebook = (rendering_window ())#notebook in
827 let output = (rendering_window ())#output in
828 let outputhtml = (rendering_window ())#outputhtml in
830 match ProofEngine.get_proof () with
832 | Some (_,metasenv,_,_) -> metasenv
835 refresh_goals ~empty_notebook:false notebook
837 InvokeTactics.RefreshSequentException e ->
838 output_html outputhtml
839 (`Error (`T ("Exception raised during the refresh of the " ^
840 "sequent: " ^ Printexc.to_string e)))
842 output_html outputhtml
843 (`Error (`T (Printexc.to_string e)))
847 show_in_show_window_obj, show_in_show_window_uri, show_in_show_window_callback
850 GWindow.window ~width:800 ~border_width:2 () in
851 let scrolled_window =
852 GBin.scrolled_window ~border_width:10 ~packing:window#add () in
854 GMathViewAux.single_selection_math_view
855 ~packing:scrolled_window#add ~width:600 ~height:400 ()
857 let _ = window#event#connect#delete (fun _ -> window#misc#hide () ; true ) in
858 let href = Gdome.domString "href" in
859 let show_in_show_window_obj uri obj =
860 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
863 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
864 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
866 Cic2acic.acic_object_of_cic_object obj
869 ChosenTransformer.mml_of_cic_object
870 ~explode_all:false uri acic ids_to_inner_sorts ids_to_inner_types
872 window#set_title (UriManager.string_of_uri uri) ;
873 window#misc#hide () ; window#show () ;
874 mmlwidget#load_doc mml ;
877 output_html outputhtml
878 (`Error (`T (Printexc.to_string e)))
880 let show_in_show_window_uri uri =
881 let obj = CicEnvironment.get_obj uri in
882 show_in_show_window_obj uri obj
884 let show_in_show_window_callback mmlwidget (n : Gdome.element option) _ =
888 if n'#hasAttributeNS ~namespaceURI:xlinkns ~localName:href then
890 (n'#getAttributeNS ~namespaceURI:xlinkns ~localName:href)#to_string
892 show_in_show_window_uri (UriManager.uri_of_string uri)
894 ignore (mmlwidget#action_toggle n')
897 mmlwidget#connect#click (show_in_show_window_callback mmlwidget)
899 show_in_show_window_obj, show_in_show_window_uri,
900 show_in_show_window_callback
903 exception NoObjectsLocated;;
905 let user_uri_choice ~title ~msg uris =
908 [] -> raise NoObjectsLocated
912 interactive_user_uri_choice ~selection_mode:`SINGLE ~title ~msg uris
917 String.sub uri 4 (String.length uri - 4)
920 let locate_callback id =
921 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
922 let out = output_html outputhtml in
923 let query = MQG.locate id in
924 let result = MQI.execute mqi_handle query in
928 MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format' uri)
930 out (`Msg (`T "Locate Query:")) ;
931 MQueryUtil.text_of_query (fun m -> out (`Msg (`T m))) "" query;
932 out (`Msg (`T "Result:")) ;
933 MQueryUtil.text_of_result (fun m -> out (`Msg (`T m))) "" result;
934 user_uri_choice ~title:"Ambiguous input."
936 ("Ambiguous input \"" ^ id ^
937 "\". Please, choose one interpetation:")
942 let input_or_locate_uri ~title =
943 let uri = ref None in
946 ~width:400 ~modal:true ~title ~border_width:2 () in
947 let vbox = GPack.vbox ~packing:window#add () in
949 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
951 GMisc.label ~text:"Enter a valid URI:" ~packing:(hbox1#pack ~padding:5) () in
953 GEdit.entry ~editable:true
954 ~packing:(hbox1#pack ~expand:true ~fill:true ~padding:5) () in
956 GButton.button ~label:"Check"
957 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
958 let _ = checkb#misc#set_sensitive false in
960 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
962 GMisc.label ~text:"You can also enter an indentifier to locate:"
963 ~packing:(hbox2#pack ~padding:5) () in
965 GEdit.entry ~editable:true
966 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
968 GButton.button ~label:"Locate"
969 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
970 let _ = locateb#misc#set_sensitive false in
972 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
974 GButton.button ~label:"Ok"
975 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
976 let _ = okb#misc#set_sensitive false in
978 GButton.button ~label:"Cancel"
979 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) ()
981 ignore (window#connect#destroy GMain.Main.quit) ;
983 (cancelb#connect#clicked (function () -> uri := None ; window#destroy ())) ;
984 let check_callback () =
985 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
986 let uri = "cic:" ^ manual_input#text in
988 ignore (Getter.resolve (UriManager.uri_of_string uri)) ;
989 output_html outputhtml (`Msg (`T "OK")) ;
993 output_html outputhtml
994 (`Error (`T ("URI " ^ uri ^
995 " does not correspond to any object."))) ;
997 | UriManager.IllFormedUri _ ->
998 output_html outputhtml
999 (`Error (`T ("URI " ^ uri ^ " is not well-formed."))) ;
1002 output_html outputhtml
1003 (`Error (`T (Printexc.to_string e))) ;
1007 (okb#connect#clicked
1009 if check_callback () then
1011 uri := Some manual_input#text ;
1015 ignore (checkb#connect#clicked (function () -> ignore (check_callback ()))) ;
1017 (manual_input#connect#changed
1019 if manual_input#text = "" then
1021 checkb#misc#set_sensitive false ;
1022 okb#misc#set_sensitive false
1026 checkb#misc#set_sensitive true ;
1027 okb#misc#set_sensitive true
1030 (locate_input#connect#changed
1031 (fun _ -> locateb#misc#set_sensitive (locate_input#text <> ""))) ;
1033 (locateb#connect#clicked
1035 let id = locate_input#text in
1036 manual_input#set_text (locate_callback id) ;
1037 locate_input#delete_text 0 (String.length id)
1042 None -> raise NoChoice
1043 | Some uri -> UriManager.uri_of_string ("cic:" ^ uri)
1046 exception AmbiguousInput;;
1048 (* A WIDGET TO ENTER CIC TERMS *)
1052 let output_html ?append_NL = output_html ?append_NL (outputhtml ())
1053 let interactive_user_uri_choice =
1054 fun ~selection_mode ?ok ?enable_button_for_non_vars ~title ~msg ~id ->
1055 interactive_user_uri_choice ~selection_mode ?ok
1056 ?enable_button_for_non_vars ~title ~msg
1057 let interactive_interpretation_choice = interactive_interpretation_choice
1058 let input_or_locate_uri = input_or_locate_uri
1062 module TexTermEditor' = ChosenTermEditor.Make(Callbacks);;
1064 (* OTHER FUNCTIONS *)
1067 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1068 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1071 GToolbox.input_string ~title:"Locate" "Enter an identifier to locate:"
1073 None -> raise NoChoice
1075 let uri = locate_callback input in
1079 output_html outputhtml
1080 (`Error (`T (Printexc.to_string e)))
1084 exception UriAlreadyInUse;;
1085 exception NotAUriToAConstant;;
1087 let new_inductive () =
1088 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1089 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1090 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1091 let notebook = (rendering_window ())#notebook in
1093 let chosen = ref false in
1094 let inductive = ref true in
1095 let paramsno = ref 0 in
1096 let get_uri = ref (function _ -> assert false) in
1097 let get_base_uri = ref (function _ -> assert false) in
1098 let get_names = ref (function _ -> assert false) in
1099 let get_types_and_cons = ref (function _ -> assert false) in
1100 let get_context_and_subst = ref (function _ -> assert false) in
1103 ~width:600 ~modal:true ~position:`CENTER
1104 ~title:"New Block of Mutual (Co)Inductive Definitions"
1105 ~border_width:2 () in
1106 let vbox = GPack.vbox ~packing:window#add () in
1108 GPack.hbox ~border_width:0
1109 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1111 GMisc.label ~text:"Enter the URI for the new block:"
1112 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1114 GEdit.entry ~editable:true
1115 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1117 GPack.hbox ~border_width:0
1118 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1122 "Enter the number of left parameters in every arity and constructor type:"
1123 ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1124 let paramsno_entry =
1125 GEdit.entry ~editable:true ~text:"0"
1126 ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
1128 GPack.hbox ~border_width:0
1129 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1131 GMisc.label ~text:"Are the definitions inductive or coinductive?"
1132 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1134 GButton.radio_button ~label:"Inductive"
1135 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1137 GButton.radio_button ~label:"Coinductive"
1138 ~group:inductiveb#group
1139 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1141 GPack.hbox ~border_width:0
1142 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1144 GMisc.label ~text:"Enter the list of the names of the types:"
1145 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1147 GEdit.entry ~editable:true
1148 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1150 GPack.hbox ~border_width:0
1151 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1153 GButton.button ~label:"> Next"
1154 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1155 let _ = okb#misc#set_sensitive true in
1157 GButton.button ~label:"Abort"
1158 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1159 ignore (window#connect#destroy GMain.Main.quit) ;
1160 ignore (cancelb#connect#clicked window#destroy) ;
1164 (okb#connect#clicked
1167 let uristr = "cic:" ^ uri_entry#text in
1168 let namesstr = names_entry#text in
1169 let paramsno' = int_of_string (paramsno_entry#text) in
1170 match Str.split (Str.regexp " +") namesstr with
1172 | (he::tl) as names ->
1173 let uri = UriManager.uri_of_string (uristr ^ "/" ^ he ^ ".ind") in
1176 ignore (Getter.resolve uri) ;
1177 raise UriAlreadyInUse
1179 Getter.Unresolved ->
1180 get_uri := (function () -> uri) ;
1181 get_names := (function () -> names) ;
1182 inductive := inductiveb#active ;
1183 paramsno := paramsno' ;
1188 output_html outputhtml
1189 (`Error (`T (Printexc.to_string e)))
1197 GBin.frame ~label:name
1198 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1199 let vbox = GPack.vbox ~packing:frame#add () in
1200 let hbox = GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false) () in
1202 GMisc.label ~text:("Enter its type:")
1203 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1204 let scrolled_window =
1205 GBin.scrolled_window ~border_width:5
1206 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1208 TexTermEditor'.term_editor
1210 ~width:400 ~height:20 ~packing:scrolled_window#add
1211 ~share_environment_with:inputt ()
1212 ~isnotempty_callback:
1214 (*non_empty_type := b ;*)
1215 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*)
1218 GPack.hbox ~border_width:0
1219 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1221 GMisc.label ~text:("Enter the list of its constructors:")
1222 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1223 let cons_names_entry =
1224 GEdit.entry ~editable:true
1225 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1226 (newinputt,cons_names_entry)
1229 vbox#remove hboxn#coerce ;
1231 GPack.hbox ~border_width:0
1232 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1234 GButton.button ~label:"> Next"
1235 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1237 GButton.button ~label:"Abort"
1238 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1239 ignore (cancelb#connect#clicked window#destroy) ;
1241 (okb#connect#clicked
1244 let names = !get_names () in
1245 let types_and_cons =
1247 (fun name (newinputt,cons_names_entry) ->
1248 let consnamesstr = cons_names_entry#text in
1249 let cons_names = Str.split (Str.regexp " +") consnamesstr in
1251 newinputt#get_metasenv_and_term ~context:[] ~metasenv:[]
1254 [] -> expr,cons_names
1255 | _ -> raise AmbiguousInput
1256 ) names type_widgets
1258 let uri = !get_uri () in
1260 (* Let's see if so far the definition is well-typed *)
1263 (* To test if the arities of the inductive types are well *)
1264 (* typed, we check the inductive block definition where *)
1265 (* no constructor is given to each type. *)
1268 (fun name (ty,cons) -> (name, !inductive, ty, []))
1269 names types_and_cons
1271 CicTypeChecker.typecheck_mutual_inductive_defs uri
1272 (tys,params,paramsno)
1274 get_context_and_subst :=
1278 (fun (context,subst) name (ty,_) ->
1280 (Some (Cic.Name name, Cic.Decl ty))::context,
1281 (Cic.MutInd (uri,!i,[]))::subst
1284 ) ([],[]) names types_and_cons) ;
1285 let types_and_cons' =
1287 (fun name (ty,cons) -> (name, !inductive, ty, phase3 name cons))
1288 names types_and_cons
1290 get_types_and_cons := (function () -> types_and_cons') ;
1295 output_html outputhtml
1296 (`Error (`T (Printexc.to_string e)))
1299 and phase3 name cons =
1300 let get_cons_types = ref (function () -> assert false) in
1303 ~width:600 ~modal:true ~position:`CENTER
1304 ~title:(name ^ " Constructors")
1305 ~border_width:2 () in
1306 let vbox = GPack.vbox ~packing:window2#add () in
1307 let cons_type_widgets =
1309 (function consname ->
1311 GPack.hbox ~border_width:0
1312 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1314 GMisc.label ~text:("Enter the type of " ^ consname ^ ":")
1315 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1316 let scrolled_window =
1317 GBin.scrolled_window ~border_width:5
1318 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1320 TexTermEditor'.term_editor
1322 ~width:400 ~height:20 ~packing:scrolled_window#add
1323 ~share_environment_with:inputt ()
1324 ~isnotempty_callback:
1326 (* (*non_empty_type := b ;*)
1327 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*) *)())
1332 GPack.hbox ~border_width:0
1333 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1335 GButton.button ~label:"> Next"
1336 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1337 let _ = okb#misc#set_sensitive true in
1339 GButton.button ~label:"Abort"
1340 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1341 ignore (window2#connect#destroy GMain.Main.quit) ;
1342 ignore (cancelb#connect#clicked window2#destroy) ;
1344 (okb#connect#clicked
1348 let context,subst= !get_context_and_subst () in
1353 inputt#get_metasenv_and_term ~context ~metasenv:[]
1357 let undebrujined_expr =
1359 (fun expr t -> CicSubstitution.subst t expr) expr subst
1361 name, undebrujined_expr
1362 | _ -> raise AmbiguousInput
1363 ) cons cons_type_widgets
1365 get_cons_types := (function () -> cons_types) ;
1369 output_html outputhtml
1370 (`Error (`T (Printexc.to_string e)))
1374 let okb_pressed = !chosen in
1376 if (not okb_pressed) then
1379 assert false (* The control never reaches this point *)
1382 (!get_cons_types ())
1385 (* No more phases left or Abort pressed *)
1391 let uri = !get_uri () in
1394 let tys = !get_types_and_cons () in
1395 let obj = Cic.InductiveDefinition(tys,params,!paramsno) in
1398 debug_print (CicPp.ppobj obj);
1399 CicTypeChecker.typecheck_mutual_inductive_defs uri
1400 (tys,params,!paramsno) ;
1403 debug_print "Offending mutual (co)inductive type declaration:" ;
1404 debug_print (CicPp.ppobj obj) ;
1406 (* We already know that obj is well-typed. We need to add it to the *)
1407 (* environment in order to compute the inner-types without having to *)
1408 (* debrujin it or having to modify lots of other functions to avoid *)
1409 (* asking the environment for the MUTINDs we are defining now. *)
1410 CicEnvironment.put_inductive_definition uri obj ;
1412 show_in_show_window_obj uri obj
1415 output_html outputhtml
1416 (`Error (`T (Printexc.to_string e)))
1420 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1421 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1422 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1423 let notebook = (rendering_window ())#notebook in
1425 let chosen = ref false in
1426 let get_metasenv_and_term = ref (function _ -> assert false) in
1427 let get_uri = ref (function _ -> assert false) in
1428 let non_empty_type = ref false in
1431 ~width:600 ~modal:true ~title:"New Proof or Definition"
1432 ~border_width:2 () in
1433 let vbox = GPack.vbox ~packing:window#add () in
1435 GPack.hbox ~border_width:0
1436 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1438 GMisc.label ~text:"Enter the URI for the new theorem or definition:"
1439 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1441 GEdit.entry ~editable:true
1442 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1443 uri_entry#set_text dummy_uri;
1444 uri_entry#select_region ~start:1 ~stop:(String.length dummy_uri);
1446 GPack.hbox ~border_width:0
1447 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1449 GMisc.label ~text:"Enter the theorem or definition type:"
1450 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1451 let scrolled_window =
1452 GBin.scrolled_window ~border_width:5
1453 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1454 (* the content of the scrolled_window is moved below (see comment) *)
1456 GPack.hbox ~border_width:0
1457 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1459 GButton.button ~label:"Ok"
1460 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1461 let _ = okb#misc#set_sensitive false in
1463 GButton.button ~label:"Cancel"
1464 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1465 (* moved here to have visibility of the ok button *)
1467 TexTermEditor'.term_editor
1469 ~width:400 ~height:100 ~packing:scrolled_window#add
1470 ~share_environment_with:inputt ()
1471 ~isnotempty_callback:
1473 non_empty_type := b ;
1474 okb#misc#set_sensitive (b && uri_entry#text <> ""))
1477 newinputt#set_term inputt#get_as_string ;
1480 uri_entry#connect#changed
1482 okb#misc#set_sensitive (!non_empty_type && uri_entry#text <> ""))
1484 ignore (window#connect#destroy GMain.Main.quit) ;
1485 ignore (cancelb#connect#clicked window#destroy) ;
1487 (okb#connect#clicked
1491 let metasenv,parsed = newinputt#get_metasenv_and_term [] [] in
1492 let uristr = "cic:" ^ uri_entry#text in
1493 let uri = UriManager.uri_of_string uristr in
1494 if String.sub uristr (String.length uristr - 4) 4 <> ".con" then
1495 raise NotAUriToAConstant
1499 ignore (Getter.resolve uri) ;
1500 raise UriAlreadyInUse
1502 Getter.Unresolved ->
1503 get_metasenv_and_term := (function () -> metasenv,parsed) ;
1504 get_uri := (function () -> uri) ;
1509 output_html outputhtml
1510 (`Error (`T (Printexc.to_string e)))
1516 let metasenv,expr = !get_metasenv_and_term () in
1517 let _ = CicTypeChecker.type_of_aux' metasenv [] expr in
1518 ProofEngine.set_proof
1519 (Some (!get_uri (), (1,[],expr)::metasenv, Cic.Meta (1,[]), expr)) ;
1520 set_proof_engine_goal (Some 1) ;
1521 refresh_goals notebook ;
1522 refresh_proof output ;
1523 !save_set_sensitive true ;
1525 ProofEngine.intros ~mk_fresh_name_callback () ;
1526 refresh_goals notebook ;
1527 refresh_proof output
1529 InvokeTactics.RefreshSequentException e ->
1530 output_html outputhtml
1531 (`Error (`T ("Exception raised during the refresh of the " ^
1532 "sequent: " ^ Printexc.to_string e)))
1533 | InvokeTactics.RefreshProofException e ->
1534 output_html outputhtml
1535 (`Error (`T ("Exception raised during the refresh of the " ^
1536 "proof: " ^ Printexc.to_string e)))
1538 output_html outputhtml
1539 (`Error (`T (Printexc.to_string e)))
1542 let check_term_in_scratch scratch_window metasenv context expr =
1544 let ty = CicTypeChecker.type_of_aux' metasenv context expr in
1545 let expr = Cic.Cast (expr,ty) in
1546 scratch_window#show () ;
1547 scratch_window#set_term expr ;
1548 scratch_window#set_context context ;
1549 scratch_window#set_metasenv metasenv ;
1550 scratch_window#sequent_viewer#load_sequent metasenv (111,context,expr)
1553 print_endline ("? " ^ CicPp.ppterm expr) ;
1557 let check scratch_window () =
1558 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1559 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1561 match ProofEngine.get_proof () with
1563 | Some (_,metasenv,_,_) -> metasenv
1566 match !ProofEngine.goal with
1569 let (_,canonical_context,_) =
1570 List.find (function (m,_,_) -> m=metano) metasenv
1575 let metasenv',expr = inputt#get_metasenv_and_term context metasenv in
1576 check_term_in_scratch scratch_window metasenv' context expr
1579 output_html outputhtml
1580 (`Error (`T (Printexc.to_string e)))
1584 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1586 show_in_show_window_uri (input_or_locate_uri ~title:"Show")
1589 output_html outputhtml
1590 (`Error (`T (Printexc.to_string e)))
1593 exception NotADefinition;;
1596 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1597 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1598 let notebook = (rendering_window ())#notebook in
1600 let uri = input_or_locate_uri ~title:"Open" in
1601 CicTypeChecker.typecheck uri ;
1602 let metasenv,bo,ty =
1603 match CicEnvironment.get_cooked_obj uri with
1604 Cic.Constant (_,Some bo,ty,_) -> [],bo,ty
1605 | Cic.CurrentProof (_,metasenv,bo,ty,_) -> metasenv,bo,ty
1608 | Cic.InductiveDefinition _ -> raise NotADefinition
1610 ProofEngine.set_proof (Some (uri, metasenv, bo, ty)) ;
1611 set_proof_engine_goal None ;
1612 refresh_goals notebook ;
1613 refresh_proof output ;
1614 !save_set_sensitive true
1616 InvokeTactics.RefreshSequentException e ->
1617 output_html outputhtml
1618 (`Error (`T ("Exception raised during the refresh of the " ^
1619 "sequent: " ^ Printexc.to_string e)))
1620 | InvokeTactics.RefreshProofException e ->
1621 output_html outputhtml
1622 (`Error (`T ("Exception raised during the refresh of the " ^
1623 "proof: " ^ Printexc.to_string e)))
1625 output_html outputhtml
1626 (`Error (`T (Printexc.to_string e)))
1629 let show_query_results results =
1632 ~modal:false ~title:"Query results." ~border_width:2 () in
1633 let vbox = GPack.vbox ~packing:window#add () in
1635 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1638 ~text:"Click on a URI to show that object"
1639 ~packing:hbox#add () in
1640 let scrolled_window =
1641 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1642 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1643 let clist = GList.clist ~columns:1 ~packing:scrolled_window#add () in
1646 (function (uri,_) ->
1650 clist#set_row ~selectable:false n
1653 clist#columns_autosize () ;
1655 (clist#connect#select_row
1656 (fun ~row ~column ~event ->
1657 let (uristr,_) = List.nth results row in
1659 MQueryMisc.cic_textual_parser_uri_of_string
1660 (MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format'
1663 CicTextualParser0.ConUri uri
1664 | CicTextualParser0.VarUri uri
1665 | CicTextualParser0.IndTyUri (uri,_)
1666 | CicTextualParser0.IndConUri (uri,_,_) ->
1667 show_in_show_window_uri uri
1673 let refine_constraints (must_obj,must_rel,must_sort) =
1674 let chosen = ref false in
1675 let use_only = ref false in
1678 ~modal:true ~title:"Constraints refinement."
1679 ~width:800 ~border_width:2 () in
1680 let vbox = GPack.vbox ~packing:window#add () in
1682 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1685 ~text: "\"Only\" constraints can be enforced or not."
1686 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1688 GButton.toggle_button ~label:"Enforce \"only\" constraints"
1689 ~active:false ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1692 (onlyb#connect#toggled (function () -> use_only := onlyb#active)) ;
1693 (* Notebook for the constraints choice *)
1695 GPack.notebook ~scrollable:true
1696 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1697 (* Rel constraints *)
1700 ~text: "Constraints on Rels" () in
1702 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1705 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1708 ~text: "You can now specify the constraints on Rels."
1709 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1710 let expected_height = 25 * (List.length must_rel + 2) in
1711 let height = if expected_height > 400 then 400 else expected_height in
1712 let scrolled_window =
1713 GBin.scrolled_window ~border_width:10 ~height ~width:600
1714 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1715 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1716 let mk_depth_button (hbox:GPack.box) d =
1717 let mutable_ref = ref (Some d) in
1719 GButton.toggle_button
1720 ~label:("depth = " ^ string_of_int d)
1722 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1725 (depthb#connect#toggled
1727 let sel_depth = if depthb#active then Some d else None in
1728 mutable_ref := sel_depth
1731 let rel_constraints =
1736 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1739 ~text:(MQGU.text_of_position (p:>MQGT.full_position))
1740 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1742 | `MainHypothesis None
1743 | `MainConclusion None -> p, ref None
1744 | `MainHypothesis (Some depth')
1745 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth'
1747 (* Sort constraints *)
1750 ~text: "Constraints on Sorts" () in
1752 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1755 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1758 ~text: "You can now specify the constraints on Sorts."
1759 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1760 let expected_height = 25 * (List.length must_sort + 2) in
1761 let height = if expected_height > 400 then 400 else expected_height in
1762 let scrolled_window =
1763 GBin.scrolled_window ~border_width:10 ~height ~width:600
1764 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1765 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1766 let sort_constraints =
1768 (function (p, sort) ->
1771 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1774 ~text:(MQGU.text_of_sort sort ^ " " ^ MQGU.text_of_position (p:>MQGT.full_position))
1775 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1777 | `MainHypothesis None
1778 | `MainConclusion None -> p, ref None, sort
1779 | `MainHypothesis (Some depth')
1780 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', sort
1782 (* Obj constraints *)
1785 ~text: "Constraints on constants" () in
1787 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1790 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1793 ~text: "You can now specify the constraints on constants."
1794 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1795 let expected_height = 25 * (List.length must_obj + 2) in
1796 let height = if expected_height > 400 then 400 else expected_height in
1797 let scrolled_window =
1798 GBin.scrolled_window ~border_width:10 ~height ~width:600
1799 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1800 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1801 let obj_constraints =
1803 (function (p, uri) ->
1806 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1809 ~text:(uri ^ " " ^ (MQGU.text_of_position p))
1810 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1815 | `MainHypothesis None
1816 | `MainConclusion None -> p, ref None, uri
1817 | `MainHypothesis (Some depth')
1818 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', uri
1820 (* Confirm/abort buttons *)
1822 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1824 GButton.button ~label:"Ok"
1825 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1827 GButton.button ~label:"Abort"
1828 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1830 ignore (window#connect#destroy GMain.Main.quit) ;
1831 ignore (cancelb#connect#clicked window#destroy) ;
1833 (okb#connect#clicked (function () -> chosen := true ; window#destroy ()));
1834 window#set_position `CENTER ;
1838 let chosen_must_rel =
1840 (function (position, ref_depth) -> MQGU.set_main_position position !ref_depth)
1843 let chosen_must_sort =
1845 (function (position, ref_depth, sort) ->
1846 MQGU.set_main_position position !ref_depth,sort)
1849 let chosen_must_obj =
1851 (function (position, ref_depth, uri) -> MQGU.set_full_position position !ref_depth, uri)
1854 (chosen_must_obj,chosen_must_rel,chosen_must_sort),
1856 (*CSC: ???????????????????????? I assume that must and only are the same... *)
1857 Some chosen_must_obj,Some chosen_must_rel,Some chosen_must_sort
1865 let completeSearchPattern () =
1866 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1867 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1869 let metasenv,expr = inputt#get_metasenv_and_term ~context:[] ~metasenv:[] in
1870 let must = CGSearchPattern.get_constraints expr in
1871 let must',only = refine_constraints must in
1873 MQG.query_of_constraints (Some CGSearchPattern.universe) must' only
1875 let results = MQI.execute mqi_handle query in
1876 show_query_results results
1879 output_html outputhtml
1880 (`Error (`T (Printexc.to_string e)))
1883 let insertQuery () =
1884 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1886 let chosen = ref None in
1889 ~modal:true ~title:"Insert Query (Experts Only)" ~border_width:2 () in
1890 let vbox = GPack.vbox ~packing:window#add () in
1892 GMisc.label ~text:"Insert Query. For Experts Only."
1893 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1894 let scrolled_window =
1895 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1896 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1897 let input = GText.view ~editable:true
1898 ~packing:scrolled_window#add () in
1900 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1902 GButton.button ~label:"Ok"
1903 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1905 GButton.button ~label:"Load from file..."
1906 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1908 GButton.button ~label:"Abort"
1909 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1910 ignore (window#connect#destroy GMain.Main.quit) ;
1911 ignore (cancelb#connect#clicked window#destroy) ;
1913 (okb#connect#clicked
1915 chosen := Some (input#buffer#get_text ()) ; window#destroy ())) ;
1917 (loadb#connect#clicked
1920 GToolbox.select_file ~title:"Select Query File" ()
1924 let inch = open_in filename in
1925 let rec read_file () =
1927 let line = input_line inch in
1928 line ^ "\n" ^ read_file ()
1932 let text = read_file () in
1933 input#buffer#delete input#buffer#start_iter input#buffer#end_iter ;
1934 ignore (input#buffer#insert text))) ;
1935 window#set_position `CENTER ;
1942 MQI.execute mqi_handle (MQueryUtil.query_of_text (Lexing.from_string q))
1944 show_query_results results
1947 output_html outputhtml
1948 (`Error (`T (Printexc.to_string e)))
1951 let choose_must list_of_must only =
1952 let chosen = ref None in
1953 let user_constraints = ref [] in
1956 ~modal:true ~title:"Query refinement." ~border_width:2 () in
1957 let vbox = GPack.vbox ~packing:window#add () in
1959 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1963 ("You can now specify the genericity of the query. " ^
1964 "The more generic the slower.")
1965 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1967 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1971 "Suggestion: start with faster queries before moving to more generic ones."
1972 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1974 GPack.notebook ~scrollable:true
1975 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1978 let last = List.length list_of_must in
1984 (if !page = 1 then "More generic" else
1985 if !page = last then "More precise" else " ") () in
1986 let expected_height = 25 * (List.length must + 2) in
1987 let height = if expected_height > 400 then 400 else expected_height in
1988 let scrolled_window =
1989 GBin.scrolled_window ~border_width:10 ~height ~width:600
1990 ~packing:(notebook#append_page ~tab_label:label#coerce) () in
1992 GList.clist ~columns:2 ~packing:scrolled_window#add
1993 ~titles:["URI" ; "Position"] ()
1997 (function (position, uri) ->
2000 [uri; MQGUtil.text_of_position position]
2002 clist#set_row ~selectable:false n
2005 clist#columns_autosize ()
2008 let label = GMisc.label ~text:"User provided" () in
2010 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2012 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2015 ~text:"Select the constraints that must be satisfied and press OK."
2016 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2017 let expected_height = 25 * (List.length only + 2) in
2018 let height = if expected_height > 400 then 400 else expected_height in
2019 let scrolled_window =
2020 GBin.scrolled_window ~border_width:10 ~height ~width:600
2021 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2023 GList.clist ~columns:2 ~packing:scrolled_window#add
2024 ~selection_mode:`MULTIPLE
2025 ~titles:["URI" ; "Position"] ()
2029 (function (position, uri) ->
2032 [uri; MQGUtil.text_of_position position]
2034 clist#set_row ~selectable:true n
2037 clist#columns_autosize () ;
2039 (clist#connect#select_row
2040 (fun ~row ~column ~event ->
2041 user_constraints := (List.nth only row)::!user_constraints)) ;
2043 (clist#connect#unselect_row
2044 (fun ~row ~column ~event ->
2047 (function uri -> uri != (List.nth only row)) !user_constraints)) ;
2050 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2052 GButton.button ~label:"Ok"
2053 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2055 GButton.button ~label:"Abort"
2056 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2058 ignore (window#connect#destroy GMain.Main.quit) ;
2059 ignore (cancelb#connect#clicked window#destroy) ;
2061 (okb#connect#clicked
2062 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
2063 window#set_position `CENTER ;
2067 None -> raise NoChoice
2069 if n = List.length list_of_must then
2070 (* user provided constraints *)
2073 List.nth list_of_must n
2076 let searchPattern () =
2077 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
2078 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
2081 match ProofEngine.get_proof () with
2082 None -> assert false
2083 | Some proof -> proof
2085 match !ProofEngine.goal with
2089 TacticChaser.matchConclusion
2091 ~output_html:(fun m -> output_html outputhtml (`Msg (`T m)))
2092 ~choose_must () ~status:(proof, metano)
2095 user_uri_choice ~title:"Ambiguous input."
2096 ~msg: "Many lemmas can be successfully applied. Please, choose one:"
2099 inputt#set_term uri' ;
2100 InvokeTactics'.apply ()
2103 output_html outputhtml
2104 (`Error (`T (Printexc.to_string e)))
2107 let choose_selection mmlwidget (element : Gdome.element option) =
2108 let module G = Gdome in
2109 let rec aux element =
2110 if element#hasAttributeNS
2111 ~namespaceURI:Misc.helmns
2112 ~localName:(G.domString "xref")
2114 mmlwidget#set_selection (Some element)
2117 match element#get_parentNode with
2118 None -> assert false
2119 (*CSC: OCAML DIVERGES!
2120 | Some p -> aux (new G.element_of_node p)
2122 | Some p -> aux (new Gdome.element_of_node p)
2124 GdomeInit.DOMCastException _ ->
2126 "******* trying to select above the document root ********"
2130 | None -> mmlwidget#set_selection None
2133 (* STUFF TO BUILD THE GTK INTERFACE *)
2135 (* Stuff for the widget settings *)
2138 let export_to_postscript output =
2139 let lastdir = ref (Unix.getcwd ()) in
2142 GToolbox.select_file ~title:"Export to PostScript"
2143 ~dir:lastdir ~filename:"screenshot.ps" ()
2147 (output :> GMathView.math_view)#export_to_postscript
2148 ~filename:filename ();
2153 let activate_t1 output button_set_anti_aliasing
2154 button_set_transparency export_to_postscript_menu_item
2157 let is_set = button_t1#active in
2158 output#set_font_manager_type
2159 ~fm_type:(if is_set then `font_manager_t1 else `font_manager_gtk) ;
2162 button_set_anti_aliasing#misc#set_sensitive true ;
2163 button_set_transparency#misc#set_sensitive true ;
2164 export_to_postscript_menu_item#misc#set_sensitive true ;
2168 button_set_anti_aliasing#misc#set_sensitive false ;
2169 button_set_transparency#misc#set_sensitive false ;
2170 export_to_postscript_menu_item#misc#set_sensitive false ;
2174 let set_anti_aliasing output button_set_anti_aliasing () =
2175 output#set_anti_aliasing button_set_anti_aliasing#active
2178 let set_transparency output button_set_transparency () =
2179 output#set_transparency button_set_transparency#active
2183 let changefont output font_size_spinb () =
2184 output#set_font_size font_size_spinb#value_as_int
2187 let set_log_verbosity output log_verbosity_spinb () =
2188 output#set_log_verbosity log_verbosity_spinb#value_as_int
2191 class settings_window output sw
2192 export_to_postscript_menu_item selection_changed_callback
2194 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
2196 GPack.vbox ~packing:settings_window#add () in
2199 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2200 ~border_width:5 ~packing:vbox#add () in
2202 GButton.toggle_button ~label:"activate t1 fonts"
2203 ~packing:(table#attach ~left:0 ~top:0) () in
2204 let button_set_anti_aliasing =
2205 GButton.toggle_button ~label:"set_anti_aliasing"
2206 ~packing:(table#attach ~left:0 ~top:1) () in
2207 let button_set_transparency =
2208 GButton.toggle_button ~label:"set_transparency"
2209 ~packing:(table#attach ~left:2 ~top:1) () in
2212 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2213 ~border_width:5 ~packing:vbox#add () in
2214 let font_size_label =
2215 GMisc.label ~text:"font size:"
2216 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
2217 let font_size_spinb =
2219 GData.adjustment ~value:(float_of_int output#get_font_size)
2220 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
2223 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
2224 let log_verbosity_label =
2225 GMisc.label ~text:"log verbosity:"
2226 ~packing:(table#attach ~left:0 ~top:1) () in
2227 let log_verbosity_spinb =
2229 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
2232 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
2234 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2236 GButton.button ~label:"Close"
2237 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2239 method show = settings_window#show
2241 button_set_anti_aliasing#misc#set_sensitive false ;
2242 button_set_transparency#misc#set_sensitive false ;
2243 (* Signals connection *)
2245 ignore(button_t1#connect#clicked
2246 (activate_t1 output button_set_anti_aliasing
2247 button_set_transparency export_to_postscript_menu_item button_t1)) ;
2249 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
2251 ignore(button_set_anti_aliasing#connect#toggled
2252 (set_anti_aliasing output button_set_anti_aliasing));
2253 ignore(button_set_transparency#connect#toggled
2254 (set_transparency output button_set_transparency)) ;
2256 ignore(log_verbosity_spinb#connect#changed
2257 (set_log_verbosity output log_verbosity_spinb)) ;
2258 ignore(closeb#connect#clicked settings_window#misc#hide)
2261 (* Scratch window *)
2263 class scratch_window =
2266 ~title:"MathML viewer"
2267 ~border_width:2 () in
2269 GPack.vbox ~packing:window#add () in
2271 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2273 GButton.button ~label:"Whd"
2274 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2276 GButton.button ~label:"Reduce"
2277 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2279 GButton.button ~label:"Simpl"
2280 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2281 let scrolled_window =
2282 GBin.scrolled_window ~border_width:10
2283 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2284 let sequent_viewer =
2285 TermViewer.sequent_viewer
2286 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
2288 val mutable term = Cic.Rel 1 (* dummy value *)
2289 val mutable context = ([] : Cic.context) (* dummy value *)
2290 val mutable metasenv = ([] : Cic.metasenv) (* dummy value *)
2291 method sequent_viewer = sequent_viewer
2292 method show () = window#misc#hide () ; window#show ()
2294 method set_term t = term <- t
2295 method context = context
2296 method set_context t = context <- t
2297 method metasenv = metasenv
2298 method set_metasenv t = metasenv <- t
2301 (sequent_viewer#connect#selection_changed (choose_selection sequent_viewer));
2302 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
2303 ignore(whdb#connect#clicked InvokeTactics'.whd_in_scratch) ;
2304 ignore(reduceb#connect#clicked InvokeTactics'.reduce_in_scratch) ;
2305 ignore(simplb#connect#clicked InvokeTactics'.simpl_in_scratch)
2308 let open_contextual_menu_for_selected_terms mmlwidget infos =
2309 let button = GdkEvent.Button.button infos in
2310 let terms_selected = List.length mmlwidget#get_selections > 0 in
2313 let time = GdkEvent.Button.time infos in
2314 let menu = GMenu.menu () in
2315 let f = new GMenu.factory menu in
2317 f#add_item "Whd" ~key:GdkKeysyms._W ~callback:InvokeTactics'.whd in
2318 let reduce_menu_item =
2319 f#add_item "Reduce" ~key:GdkKeysyms._R ~callback:InvokeTactics'.reduce in
2320 let simpl_menu_item =
2321 f#add_item "Simpl" ~key:GdkKeysyms._S ~callback:InvokeTactics'.simpl in
2322 let _ = f#add_separator () in
2323 let generalize_menu_item =
2324 f#add_item "Generalize"
2325 ~key:GdkKeysyms._G ~callback:InvokeTactics'.generalize in
2326 let _ = f#add_separator () in
2327 let clear_menu_item =
2328 f#add_item "Clear" ~key:GdkKeysyms._C ~callback:InvokeTactics'.clear in
2329 let clearbody_menu_item =
2330 f#add_item "ClearBody"
2331 ~key:GdkKeysyms._B ~callback:InvokeTactics'.clearbody
2333 whd_menu_item#misc#set_sensitive terms_selected ;
2334 reduce_menu_item#misc#set_sensitive terms_selected ;
2335 simpl_menu_item#misc#set_sensitive terms_selected ;
2336 generalize_menu_item#misc#set_sensitive terms_selected ;
2337 clear_menu_item#misc#set_sensitive terms_selected ;
2338 clearbody_menu_item#misc#set_sensitive terms_selected ;
2339 menu#popup ~button ~time
2345 let vbox1 = GPack.vbox () in
2347 val mutable proofw_ref = None
2348 val mutable compute_ref = None
2350 Lazy.force self#compute ;
2351 match proofw_ref with
2352 None -> assert false
2353 | Some proofw -> proofw
2354 method content = vbox1
2356 match compute_ref with
2357 None -> assert false
2358 | Some compute -> compute
2362 let scrolled_window1 =
2363 GBin.scrolled_window ~border_width:10
2364 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2366 TermViewer.sequent_viewer ~width:400 ~height:275
2367 ~packing:(scrolled_window1#add) () in
2368 let _ = proofw_ref <- Some proofw in
2370 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2372 GButton.button ~label:"Ring"
2373 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2375 GButton.button ~label:"Fourier"
2376 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2378 GButton.button ~label:"Reflexivity"
2379 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2381 GButton.button ~label:"Symmetry"
2382 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2384 GButton.button ~label:"Assumption"
2385 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2386 let contradictionb =
2387 GButton.button ~label:"Contradiction"
2388 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2390 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2392 GButton.button ~label:"Exists"
2393 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2395 GButton.button ~label:"Split"
2396 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2398 GButton.button ~label:"Left"
2399 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2401 GButton.button ~label:"Right"
2402 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2403 let searchpatternb =
2404 GButton.button ~label:"SearchPattern_Apply"
2405 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2407 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2409 GButton.button ~label:"Exact"
2410 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2412 GButton.button ~label:"Intros"
2413 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2415 GButton.button ~label:"Apply"
2416 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2417 let elimintrossimplb =
2418 GButton.button ~label:"ElimIntrosSimpl"
2419 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2421 GButton.button ~label:"ElimType"
2422 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2424 GButton.button ~label:"Fold_whd"
2425 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2427 GButton.button ~label:"Fold_reduce"
2428 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2430 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2432 GButton.button ~label:"Fold_simpl"
2433 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2435 GButton.button ~label:"Cut"
2436 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2438 GButton.button ~label:"Change"
2439 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2441 GButton.button ~label:"Let ... In"
2442 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2444 GButton.button ~label:"RewriteSimpl ->"
2445 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2446 let rewritebacksimplb =
2447 GButton.button ~label:"RewriteSimpl <-"
2448 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2450 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2452 GButton.button ~label:"Absurd"
2453 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2455 GButton.button ~label:"Decompose"
2456 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2458 GButton.button ~label:"Transitivity"
2459 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2461 GButton.button ~label:"Replace"
2462 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2464 GButton.button ~label:"Injection"
2465 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2467 GButton.button ~label:"Discriminate"
2468 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2469 (* Zack: spostare in una toolbar
2471 GButton.button ~label:"Generalize"
2472 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2474 GButton.button ~label:"ClearBody"
2475 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2477 GButton.button ~label:"Clear"
2478 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2480 GButton.button ~label:"Whd"
2481 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2483 GButton.button ~label:"Reduce"
2484 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2486 GButton.button ~label:"Simpl"
2487 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2490 ignore(exactb#connect#clicked InvokeTactics'.exact) ;
2491 ignore(applyb#connect#clicked InvokeTactics'.apply) ;
2492 ignore(elimintrossimplb#connect#clicked InvokeTactics'.elimintrossimpl) ;
2493 ignore(elimtypeb#connect#clicked InvokeTactics'.elimtype) ;
2494 ignore(foldwhdb#connect#clicked InvokeTactics'.fold_whd) ;
2495 ignore(foldreduceb#connect#clicked InvokeTactics'.fold_reduce) ;
2496 ignore(foldsimplb#connect#clicked InvokeTactics'.fold_simpl) ;
2497 ignore(cutb#connect#clicked InvokeTactics'.cut) ;
2498 ignore(changeb#connect#clicked InvokeTactics'.change) ;
2499 ignore(letinb#connect#clicked InvokeTactics'.letin) ;
2500 ignore(ringb#connect#clicked InvokeTactics'.ring) ;
2501 ignore(fourierb#connect#clicked InvokeTactics'.fourier) ;
2502 ignore(rewritesimplb#connect#clicked InvokeTactics'.rewritesimpl) ;
2503 ignore(rewritebacksimplb#connect#clicked InvokeTactics'.rewritebacksimpl) ;
2504 ignore(replaceb#connect#clicked InvokeTactics'.replace) ;
2505 ignore(reflexivityb#connect#clicked InvokeTactics'.reflexivity) ;
2506 ignore(symmetryb#connect#clicked InvokeTactics'.symmetry) ;
2507 ignore(transitivityb#connect#clicked InvokeTactics'.transitivity) ;
2508 ignore(existsb#connect#clicked InvokeTactics'.exists) ;
2509 ignore(splitb#connect#clicked InvokeTactics'.split) ;
2510 ignore(leftb#connect#clicked InvokeTactics'.left) ;
2511 ignore(rightb#connect#clicked InvokeTactics'.right) ;
2512 ignore(assumptionb#connect#clicked InvokeTactics'.assumption) ;
2513 ignore(absurdb#connect#clicked InvokeTactics'.absurd) ;
2514 ignore(contradictionb#connect#clicked InvokeTactics'.contradiction) ;
2515 ignore(introsb#connect#clicked InvokeTactics'.intros) ;
2516 ignore(decomposeb#connect#clicked InvokeTactics'.decompose) ;
2517 ignore(searchpatternb#connect#clicked searchPattern) ;
2518 ignore(injectionb#connect#clicked InvokeTactics'.injection) ;
2519 ignore(discriminateb#connect#clicked InvokeTactics'.discriminate) ;
2520 (* Zack: spostare in una toolbar
2521 ignore(whdb#connect#clicked whd) ;
2522 ignore(reduceb#connect#clicked reduce) ;
2523 ignore(simplb#connect#clicked simpl) ;
2524 ignore(clearbodyb#connect#clicked clearbody) ;
2525 ignore(clearb#connect#clicked clear) ;
2526 ignore(generalizeb#connect#clicked generalize) ;
2528 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
2530 ((new GObj.event_ops proofw#as_widget)#connect#button_press
2531 (open_contextual_menu_for_selected_terms proofw)) ;
2537 let vbox1 = GPack.vbox () in
2538 let scrolled_window1 =
2539 GBin.scrolled_window ~border_width:10
2540 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2542 TermViewer.sequent_viewer ~width:400 ~height:275
2543 ~packing:(scrolled_window1#add) () in
2545 method proofw = (assert false : TermViewer.sequent_viewer)
2546 method content = vbox1
2547 method compute = (assert false : unit)
2551 let empty_page = new empty_page;;
2555 val notebook = GPack.notebook ()
2557 val mutable skip_switch_page_event = false
2558 val mutable empty = true
2559 method notebook = notebook
2561 let new_page = new page () in
2563 pages := !pages @ [n,lazy (setgoal n),new_page] ;
2564 notebook#append_page
2565 ~tab_label:((GMisc.label ~text:("?" ^ string_of_int n) ())#coerce)
2566 new_page#content#coerce
2567 method remove_all_pages ~skip_switch_page_event:skip =
2569 notebook#remove_page 0 (* let's remove the empty page *)
2571 List.iter (function _ -> notebook#remove_page 0) !pages ;
2573 skip_switch_page_event <- skip
2574 method set_current_page ~may_skip_switch_page_event n =
2575 let (_,_,page) = List.find (function (m,_,_) -> m=n) !pages in
2576 let new_page = notebook#page_num page#content#coerce in
2577 if may_skip_switch_page_event && new_page <> notebook#current_page then
2578 skip_switch_page_event <- true ;
2579 notebook#goto_page new_page
2580 method set_empty_page =
2583 notebook#append_page
2584 ~tab_label:((GMisc.label ~text:"No proof in progress" ())#coerce)
2585 empty_page#content#coerce
2587 let (_,_,page) = List.nth !pages notebook#current_page in
2591 (notebook#connect#switch_page
2593 let skip = skip_switch_page_event in
2594 skip_switch_page_event <- false ;
2597 let (metano,setgoal,page) = List.nth !pages i in
2598 set_proof_engine_goal (Some metano) ;
2599 Lazy.force (page#compute) ;
2601 if notify_hbugs_on_goal_change then
2608 let dump_environment () =
2610 let oc = open_out environmentfile in
2611 output_html (outputhtml ()) (`Msg (`T "Dumping environment ..."));
2612 CicEnvironment.dump_to_channel
2613 ~callback:(fun uri -> output_html (outputhtml ()) (`Msg (`T uri)))
2615 output_html (outputhtml ()) (`Msg (`T "... done!")) ;
2618 output_html (outputhtml ())
2619 (`Error (`T (Printf.sprintf "Dump failure, uncaught exception:%s"
2620 (Printexc.to_string exc))))
2622 let restore_environment () =
2624 let ic = open_in environmentfile in
2625 output_html (outputhtml ()) (`Msg (`T "Restoring environment ... "));
2626 CicEnvironment.restore_from_channel
2627 ~callback:(fun uri -> output_html (outputhtml ()) (`Msg (`T uri)))
2629 output_html (outputhtml ()) (`Msg (`T "... done!"));
2632 output_html (outputhtml ())
2633 (`Error (`T (Printf.sprintf "Restore failure, uncaught exception:%s"
2634 (Printexc.to_string exc))))
2639 class rendering_window output (notebook : notebook) =
2640 let scratch_window = new scratch_window in
2643 ~title:"gTopLevel - Helm's Proof Assistant"
2644 ~border_width:0 ~allow_shrink:false () in
2645 let vbox_for_menu = GPack.vbox ~packing:window#add () in
2647 let handle_box = GBin.handle_box ~border_width:2
2648 ~packing:(vbox_for_menu#pack ~padding:0) () in
2649 let menubar = GMenu.menu_bar ~packing:handle_box#add () in
2650 let factory0 = new GMenu.factory menubar in
2651 let accel_group = factory0#accel_group in
2653 let file_menu = factory0#add_submenu "File" in
2654 let factory1 = new GMenu.factory file_menu ~accel_group in
2655 (* let export_to_postscript_menu_item = *)
2659 factory1#add_item "New Block of (Co)Inductive Definitions..."
2660 ~key:GdkKeysyms._B ~callback:new_inductive
2663 factory1#add_item "New Proof or Definition..." ~key:GdkKeysyms._N
2666 let reopen_menu_item =
2667 factory1#add_item "Reopen a Finished Proof..." ~key:GdkKeysyms._R
2671 factory1#add_item "Qed" ~key:GdkKeysyms._E ~callback:qed in
2672 ignore (factory1#add_separator ()) ;
2674 (factory1#add_item "Load Unfinished Proof..." ~key:GdkKeysyms._L
2675 ~callback:load_unfinished_proof) ;
2676 let save_menu_item =
2677 factory1#add_item "Save Unfinished Proof" ~key:GdkKeysyms._S
2678 ~callback:save_unfinished_proof
2680 ignore (factory1#add_separator ()) ;
2681 ignore (factory1#add_item "Clear Environment" ~callback:CicEnvironment.empty);
2682 ignore (factory1#add_item "Dump Environment" ~callback:dump_environment);
2684 (factory1#add_item "Restore Environment" ~callback:restore_environment);
2686 (save_set_sensitive := function b -> save_menu_item#misc#set_sensitive b);
2687 ignore (!save_set_sensitive false);
2688 ignore (qed_set_sensitive:=function b -> qed_menu_item#misc#set_sensitive b);
2689 ignore (!qed_set_sensitive false);
2690 ignore (factory1#add_separator ()) ;
2692 let export_to_postscript_menu_item =
2693 factory1#add_item "Export to PostScript..."
2694 ~callback:(export_to_postscript output) in
2696 ignore (factory1#add_separator ()) ;
2698 (factory1#add_item "Exit" ~key:GdkKeysyms._Q ~callback:GMain.Main.quit) (*;
2699 export_to_postscript_menu_item *)
2702 let edit_menu = factory0#add_submenu "Edit Current Proof" in
2703 let factory2 = new GMenu.factory edit_menu ~accel_group in
2704 let focus_and_proveit_set_sensitive = ref (function _ -> assert false) in
2705 let proveit_menu_item =
2706 factory2#add_item "Prove It" ~key:GdkKeysyms._I
2707 ~callback:(function () -> proveit ();!focus_and_proveit_set_sensitive false)
2709 let focus_menu_item =
2710 factory2#add_item "Focus" ~key:GdkKeysyms._F
2711 ~callback:(function () -> focus () ; !focus_and_proveit_set_sensitive false)
2714 focus_and_proveit_set_sensitive :=
2716 proveit_menu_item#misc#set_sensitive b ;
2717 focus_menu_item#misc#set_sensitive b
2719 let _ = !focus_and_proveit_set_sensitive false in
2720 (* edit term menu *)
2721 let edit_term_menu = factory0#add_submenu "Edit Term" in
2722 let factory5 = new GMenu.factory edit_term_menu ~accel_group in
2723 let check_menu_item =
2724 factory5#add_item "Check Term" ~key:GdkKeysyms._C
2725 ~callback:(check scratch_window) in
2726 let _ = check_menu_item#misc#set_sensitive false in
2728 let search_menu = factory0#add_submenu "Search" in
2729 let factory4 = new GMenu.factory search_menu ~accel_group in
2731 factory4#add_item "Locate..." ~key:GdkKeysyms._T
2733 let searchPattern_menu_item =
2734 factory4#add_item "SearchPattern..." ~key:GdkKeysyms._D
2735 ~callback:completeSearchPattern in
2736 let _ = searchPattern_menu_item#misc#set_sensitive false in
2737 let show_menu_item =
2738 factory4#add_item "Show..." ~key:GdkKeysyms._H ~callback:show
2740 let insert_query_item =
2741 factory4#add_item "Insert Query (Experts Only)..." ~key:GdkKeysyms._Y
2742 ~callback:insertQuery in
2744 let hbugs_menu = factory0#add_submenu "HBugs" in
2745 let factory6 = new GMenu.factory hbugs_menu ~accel_group in
2747 factory6#add_check_item
2748 ~active:false ~key:GdkKeysyms._F5 ~callback:Hbugs.toggle "HBugs enabled"
2751 factory6#add_item ~key:GdkKeysyms._Return ~callback:Hbugs.notify
2752 "(Re)Submit status!"
2754 let _ = factory6#add_separator () in
2756 factory6#add_item ~callback:Hbugs.start_web_services "Start Web Services"
2759 factory6#add_item ~callback:Hbugs.stop_web_services "Stop Web Services"
2762 let settings_menu = factory0#add_submenu "Settings" in
2763 let factory3 = new GMenu.factory settings_menu ~accel_group in
2765 factory3#add_item "Edit Aliases..." ~key:GdkKeysyms._A
2766 ~callback:edit_aliases in
2767 let _ = factory3#add_separator () in
2769 factory3#add_item "MathML Widget Preferences..." ~key:GdkKeysyms._P
2770 ~callback:(function _ -> (settings_window ())#show ()) in
2771 let _ = factory3#add_separator () in
2773 factory3#add_item "Reload Stylesheets"
2776 ChosenTransformer.reload_stylesheets () ;
2777 if ProofEngine.get_proof () <> None then
2779 refresh_goals notebook ;
2780 refresh_proof output
2782 InvokeTactics.RefreshSequentException e ->
2783 output_html (outputhtml ())
2784 (`Error (`T ("An error occurred while refreshing the " ^
2785 "sequent: " ^ Printexc.to_string e))) ;
2786 (*notebook#remove_all_pages ~skip_switch_page_event:false ;*)
2787 notebook#set_empty_page
2788 | InvokeTactics.RefreshProofException e ->
2789 output_html (outputhtml ())
2790 (`Error (`T ("An error occurred while refreshing the proof: " ^ Printexc.to_string e))) ;
2794 let _ = window#add_accel_group accel_group in
2798 ~packing:(vbox_for_menu#pack ~expand:true ~fill:true ~padding:5) () in
2800 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2801 let scrolled_window0 =
2802 GBin.scrolled_window ~border_width:10
2803 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2804 let _ = scrolled_window0#add output#coerce in
2806 GBin.frame ~label:"Insert Term"
2807 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2808 let scrolled_window1 =
2809 GBin.scrolled_window ~border_width:5
2810 ~packing:frame#add () in
2812 TexTermEditor'.term_editor
2814 ~width:400 ~height:100 ~packing:scrolled_window1#add ()
2815 ~isnotempty_callback:
2817 check_menu_item#misc#set_sensitive b ;
2818 searchPattern_menu_item#misc#set_sensitive b) in
2820 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2822 vboxl#pack ~expand:true ~fill:true ~padding:5 notebook#notebook#coerce in
2824 GBin.frame ~shadow_type:`IN ~packing:(vboxl#pack ~expand:true ~padding:5) ()
2827 new Ui_logger.html_logger
2828 ~width:400 ~height: 100 ~show:true ~packing:frame#add ()
2831 method outputhtml = outputhtml
2832 method inputt = inputt
2833 method output = (output : TermViewer.proof_viewer)
2834 method scratch_window = scratch_window
2835 method notebook = notebook
2836 method show = window#show
2838 notebook#set_empty_page ;
2839 (*export_to_postscript_menu_item#misc#set_sensitive false ;*)
2840 check_term := (check_term_in_scratch scratch_window) ;
2842 (* signal handlers here *)
2843 ignore(output#connect#selection_changed
2845 choose_selection output elem ;
2846 !focus_and_proveit_set_sensitive true
2848 ignore (output#connect#click (show_in_show_window_callback output)) ;
2849 let settings_window = new settings_window output scrolled_window0
2850 (*export_to_postscript_menu_item*)() (choose_selection output) in
2851 set_settings_window settings_window ;
2852 set_outputhtml outputhtml ;
2853 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
2854 CicLogger.log_callback := (outputhtml#log_cic_msg ~append_NL:true)
2859 let initialize_everything () =
2860 let module U = Unix in
2861 let output = TermViewer.proof_viewer ~width:350 ~height:280 () in
2862 let notebook = new notebook in
2863 let rendering_window' = new rendering_window output notebook in
2864 set_rendering_window rendering_window' ;
2865 let print_error_as_html prefix msg =
2866 output_html (outputhtml ()) (`Error (`T (prefix ^ msg)))
2868 Gdome_xslt.setErrorCallback (Some (print_error_as_html "XSLT Error: "));
2869 Gdome_xslt.setDebugCallback
2870 (Some (print_error_as_html "XSLT Debug Message: "));
2871 rendering_window'#show () ;
2872 if restore_environment_on_boot && Sys.file_exists environmentfile then
2873 restore_environment ();
2878 ignore (GtkMain.Main.init ()) ;
2879 initialize_everything () ;
2880 MQIC.close mqi_handle;
2885 Sys.catch_break true;
2887 with Sys.Break -> () (* exit nicely, invoking at_exit functions *)