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 ;
1657 !save_set_sensitive true
1659 InvokeTactics.RefreshSequentException e ->
1660 output_html outputhtml
1661 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1662 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1663 | InvokeTactics.RefreshProofException e ->
1664 output_html outputhtml
1665 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1666 "proof: " ^ Printexc.to_string e ^ "</h1>")
1668 output_html outputhtml
1669 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1672 let show_query_results results =
1675 ~modal:false ~title:"Query results." ~border_width:2 () in
1676 let vbox = GPack.vbox ~packing:window#add () in
1678 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1681 ~text:"Click on a URI to show that object"
1682 ~packing:hbox#add () in
1683 let scrolled_window =
1684 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1685 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1686 let clist = GList.clist ~columns:1 ~packing:scrolled_window#add () in
1689 (function (uri,_) ->
1693 clist#set_row ~selectable:false n
1696 clist#columns_autosize () ;
1698 (clist#connect#select_row
1699 (fun ~row ~column ~event ->
1700 let (uristr,_) = List.nth results row in
1702 MQueryMisc.cic_textual_parser_uri_of_string
1703 (MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format'
1706 CicTextualParser0.ConUri uri
1707 | CicTextualParser0.VarUri uri
1708 | CicTextualParser0.IndTyUri (uri,_)
1709 | CicTextualParser0.IndConUri (uri,_,_) ->
1710 show_in_show_window_uri uri
1716 let refine_constraints (must_obj,must_rel,must_sort) =
1717 let chosen = ref false in
1718 let use_only = ref false in
1721 ~modal:true ~title:"Constraints refinement."
1722 ~width:800 ~border_width:2 () in
1723 let vbox = GPack.vbox ~packing:window#add () in
1725 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1728 ~text: "\"Only\" constraints can be enforced or not."
1729 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1731 GButton.toggle_button ~label:"Enforce \"only\" constraints"
1732 ~active:false ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1735 (onlyb#connect#toggled (function () -> use_only := onlyb#active)) ;
1736 (* Notebook for the constraints choice *)
1738 GPack.notebook ~scrollable:true
1739 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1740 (* Rel constraints *)
1743 ~text: "Constraints on Rels" () in
1745 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1748 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1751 ~text: "You can now specify the constraints on Rels."
1752 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1753 let expected_height = 25 * (List.length must_rel + 2) in
1754 let height = if expected_height > 400 then 400 else expected_height in
1755 let scrolled_window =
1756 GBin.scrolled_window ~border_width:10 ~height ~width:600
1757 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1758 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1759 let rel_constraints =
1761 (function (position,depth) ->
1764 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1768 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1770 None -> position, ref None
1772 let mutable_ref = ref (Some depth') in
1774 GButton.toggle_button
1775 ~label:("depth = " ^ string_of_int depth') ~active:true
1776 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1779 (depthb#connect#toggled
1781 let sel_depth = if depthb#active then Some depth' else None in
1782 mutable_ref := sel_depth
1784 position, mutable_ref
1786 (* Sort constraints *)
1789 ~text: "Constraints on Sorts" () in
1791 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1794 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1797 ~text: "You can now specify the constraints on Sorts."
1798 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1799 let expected_height = 25 * (List.length must_sort + 2) in
1800 let height = if expected_height > 400 then 400 else expected_height in
1801 let scrolled_window =
1802 GBin.scrolled_window ~border_width:10 ~height ~width:600
1803 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1804 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1805 let sort_constraints =
1807 (function (position,depth,sort) ->
1810 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1813 ~text:(sort ^ " " ^ position)
1814 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1816 None -> position, ref None, sort
1818 let mutable_ref = ref (Some depth') in
1820 GButton.toggle_button ~label:("depth = " ^ string_of_int depth')
1822 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1825 (depthb#connect#toggled
1827 let sel_depth = if depthb#active then Some depth' else None in
1828 mutable_ref := sel_depth
1830 position, mutable_ref, sort
1832 (* Obj constraints *)
1835 ~text: "Constraints on constants" () in
1837 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1840 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1843 ~text: "You can now specify the constraints on constants."
1844 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1845 let expected_height = 25 * (List.length must_obj + 2) in
1846 let height = if expected_height > 400 then 400 else expected_height in
1847 let scrolled_window =
1848 GBin.scrolled_window ~border_width:10 ~height ~width:600
1849 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1850 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1851 let obj_constraints =
1853 (function (uri,position,depth) ->
1856 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1859 ~text:(uri ^ " " ^ position)
1860 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1862 None -> uri, position, ref None
1864 let mutable_ref = ref (Some depth') in
1866 GButton.toggle_button ~label:("depth = " ^ string_of_int depth')
1868 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1871 (depthb#connect#toggled
1873 let sel_depth = if depthb#active then Some depth' else None in
1874 mutable_ref := sel_depth
1876 uri, position, mutable_ref
1878 (* Confirm/abort buttons *)
1880 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1882 GButton.button ~label:"Ok"
1883 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1885 GButton.button ~label:"Abort"
1886 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1888 ignore (window#connect#destroy GMain.Main.quit) ;
1889 ignore (cancelb#connect#clicked window#destroy) ;
1891 (okb#connect#clicked (function () -> chosen := true ; window#destroy ()));
1892 window#set_position `CENTER ;
1896 let chosen_must_rel =
1898 (function (position,ref_depth) -> position,!ref_depth) rel_constraints in
1899 let chosen_must_sort =
1901 (function (position,ref_depth,sort) -> position,!ref_depth,sort)
1904 let chosen_must_obj =
1906 (function (uri,position,ref_depth) -> uri,position,!ref_depth)
1909 (chosen_must_obj,chosen_must_rel,chosen_must_sort),
1911 (*CSC: ???????????????????????? I assume that must and only are the same... *)
1912 Some chosen_must_obj,Some chosen_must_rel,Some chosen_must_sort
1920 let completeSearchPattern () =
1921 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1922 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1924 let metasenv,expr = inputt#get_metasenv_and_term ~context:[] ~metasenv:[] in
1925 let must = MQueryLevels2.get_constraints expr in
1926 let must',only = refine_constraints must in
1928 MQG.query_of_constraints
1930 ["http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion" ;
1931 "http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis" ;
1932 "http://www.cs.unibo.it/helm/schemas/schema-helm#InConclusion" ;
1933 "http://www.cs.unibo.it/helm/schemas/schema-helm#InHypothesis"
1937 let results = MQI.execute mqi_handle query in
1938 show_query_results results
1941 output_html outputhtml
1942 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1945 let insertQuery () =
1946 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1948 let chosen = ref None in
1951 ~modal:true ~title:"Insert Query (Experts Only)" ~border_width:2 () in
1952 let vbox = GPack.vbox ~packing:window#add () in
1954 GMisc.label ~text:"Insert Query. For Experts Only."
1955 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1956 let scrolled_window =
1957 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1958 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1959 let input = GEdit.text ~editable:true
1960 ~packing:scrolled_window#add () in
1962 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1964 GButton.button ~label:"Ok"
1965 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1967 GButton.button ~label:"Load from file..."
1968 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1970 GButton.button ~label:"Abort"
1971 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1972 ignore (window#connect#destroy GMain.Main.quit) ;
1973 ignore (cancelb#connect#clicked window#destroy) ;
1975 (okb#connect#clicked
1977 chosen := Some (input#get_chars 0 input#length) ; window#destroy ())) ;
1979 (loadb#connect#clicked
1982 GToolbox.select_file ~title:"Select Query File" ()
1986 let inch = open_in filename in
1987 let rec read_file () =
1989 let line = input_line inch in
1990 line ^ "\n" ^ read_file ()
1994 let text = read_file () in
1995 input#delete_text 0 input#length ;
1996 ignore (input#insert_text text ~pos:0))) ;
1997 window#set_position `CENTER ;
2004 MQI.execute mqi_handle (MQueryUtil.query_of_text (Lexing.from_string q))
2006 show_query_results results
2009 output_html outputhtml
2010 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
2013 let choose_must list_of_must only =
2014 let chosen = ref None in
2015 let user_constraints = ref [] in
2018 ~modal:true ~title:"Query refinement." ~border_width:2 () in
2019 let vbox = GPack.vbox ~packing:window#add () in
2021 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2025 ("You can now specify the genericity of the query. " ^
2026 "The more generic the slower.")
2027 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2029 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2033 "Suggestion: start with faster queries before moving to more generic ones."
2034 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2036 GPack.notebook ~scrollable:true
2037 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2040 let last = List.length list_of_must in
2046 (if !page = 1 then "More generic" else
2047 if !page = last then "More precise" else " ") () in
2048 let expected_height = 25 * (List.length must + 2) in
2049 let height = if expected_height > 400 then 400 else expected_height in
2050 let scrolled_window =
2051 GBin.scrolled_window ~border_width:10 ~height ~width:600
2052 ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2054 GList.clist ~columns:2 ~packing:scrolled_window#add
2055 ~titles:["URI" ; "Position"] ()
2059 (function (uri,position) ->
2062 [uri; if position then "MainConclusion" else "Conclusion"]
2064 clist#set_row ~selectable:false n
2067 clist#columns_autosize ()
2070 let label = GMisc.label ~text:"User provided" () in
2072 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2074 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2077 ~text:"Select the constraints that must be satisfied and press OK."
2078 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2079 let expected_height = 25 * (List.length only + 2) in
2080 let height = if expected_height > 400 then 400 else expected_height in
2081 let scrolled_window =
2082 GBin.scrolled_window ~border_width:10 ~height ~width:600
2083 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2085 GList.clist ~columns:2 ~packing:scrolled_window#add
2086 ~selection_mode:`EXTENDED
2087 ~titles:["URI" ; "Position"] ()
2091 (function (uri,position) ->
2094 [uri; if position then "MainConclusion" else "Conclusion"]
2096 clist#set_row ~selectable:true n
2099 clist#columns_autosize () ;
2101 (clist#connect#select_row
2102 (fun ~row ~column ~event ->
2103 user_constraints := (List.nth only row)::!user_constraints)) ;
2105 (clist#connect#unselect_row
2106 (fun ~row ~column ~event ->
2109 (function uri -> uri != (List.nth only row)) !user_constraints)) ;
2112 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2114 GButton.button ~label:"Ok"
2115 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2117 GButton.button ~label:"Abort"
2118 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2120 ignore (window#connect#destroy GMain.Main.quit) ;
2121 ignore (cancelb#connect#clicked window#destroy) ;
2123 (okb#connect#clicked
2124 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
2125 window#set_position `CENTER ;
2129 None -> raise NoChoice
2131 if n = List.length list_of_must then
2132 (* user provided constraints *)
2135 List.nth list_of_must n
2138 let searchPattern () =
2139 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
2140 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
2143 match !ProofEngine.proof with
2144 None -> assert false
2145 | Some proof -> proof
2147 match !ProofEngine.goal with
2151 TacticChaser.searchPattern
2153 ~output_html:(output_html outputhtml) ~choose_must ()
2154 ~status:(proof, metano)
2157 user_uri_choice ~title:"Ambiguous input."
2158 ~msg: "Many lemmas can be successfully applied. Please, choose one:"
2161 inputt#set_term uri' ;
2162 InvokeTactics'.apply ()
2165 output_html outputhtml
2166 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
2169 let choose_selection mmlwidget (element : Gdome.element option) =
2170 let module G = Gdome in
2171 let rec aux element =
2172 if element#hasAttributeNS
2173 ~namespaceURI:Misc.helmns
2174 ~localName:(G.domString "xref")
2176 mmlwidget#set_selection (Some element)
2179 match element#get_parentNode with
2180 None -> assert false
2181 (*CSC: OCAML DIVERGES!
2182 | Some p -> aux (new G.element_of_node p)
2184 | Some p -> aux (new Gdome.element_of_node p)
2186 GdomeInit.DOMCastException _ ->
2188 "******* trying to select above the document root ********"
2192 | None -> mmlwidget#set_selection None
2195 (* STUFF TO BUILD THE GTK INTERFACE *)
2197 (* Stuff for the widget settings *)
2199 let export_to_postscript output =
2200 let lastdir = ref (Unix.getcwd ()) in
2203 GToolbox.select_file ~title:"Export to PostScript"
2204 ~dir:lastdir ~filename:"screenshot.ps" ()
2208 (output :> GMathView.math_view)#export_to_postscript
2209 ~filename:filename ();
2212 let activate_t1 output button_set_anti_aliasing
2213 button_set_transparency export_to_postscript_menu_item
2216 let is_set = button_t1#active in
2217 output#set_font_manager_type
2218 ~fm_type:(if is_set then `font_manager_t1 else `font_manager_gtk) ;
2221 button_set_anti_aliasing#misc#set_sensitive true ;
2222 button_set_transparency#misc#set_sensitive true ;
2223 export_to_postscript_menu_item#misc#set_sensitive true ;
2227 button_set_anti_aliasing#misc#set_sensitive false ;
2228 button_set_transparency#misc#set_sensitive false ;
2229 export_to_postscript_menu_item#misc#set_sensitive false ;
2233 let set_anti_aliasing output button_set_anti_aliasing () =
2234 output#set_anti_aliasing button_set_anti_aliasing#active
2237 let set_transparency output button_set_transparency () =
2238 output#set_transparency button_set_transparency#active
2241 let changefont output font_size_spinb () =
2242 output#set_font_size font_size_spinb#value_as_int
2245 let set_log_verbosity output log_verbosity_spinb () =
2246 output#set_log_verbosity log_verbosity_spinb#value_as_int
2249 class settings_window output sw
2250 export_to_postscript_menu_item selection_changed_callback
2252 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
2254 GPack.vbox ~packing:settings_window#add () in
2257 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2258 ~border_width:5 ~packing:vbox#add () in
2260 GButton.toggle_button ~label:"activate t1 fonts"
2261 ~packing:(table#attach ~left:0 ~top:0) () in
2262 let button_set_anti_aliasing =
2263 GButton.toggle_button ~label:"set_anti_aliasing"
2264 ~packing:(table#attach ~left:0 ~top:1) () in
2265 let button_set_transparency =
2266 GButton.toggle_button ~label:"set_transparency"
2267 ~packing:(table#attach ~left:2 ~top:1) () in
2270 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2271 ~border_width:5 ~packing:vbox#add () in
2272 let font_size_label =
2273 GMisc.label ~text:"font size:"
2274 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
2275 let font_size_spinb =
2277 GData.adjustment ~value:(float_of_int output#get_font_size)
2278 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
2281 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
2282 let log_verbosity_label =
2283 GMisc.label ~text:"log verbosity:"
2284 ~packing:(table#attach ~left:0 ~top:1) () in
2285 let log_verbosity_spinb =
2287 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
2290 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
2292 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2294 GButton.button ~label:"Close"
2295 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2297 method show = settings_window#show
2299 button_set_anti_aliasing#misc#set_sensitive false ;
2300 button_set_transparency#misc#set_sensitive false ;
2301 (* Signals connection *)
2302 ignore(button_t1#connect#clicked
2303 (activate_t1 output button_set_anti_aliasing
2304 button_set_transparency export_to_postscript_menu_item button_t1)) ;
2305 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
2306 ignore(button_set_anti_aliasing#connect#toggled
2307 (set_anti_aliasing output button_set_anti_aliasing));
2308 ignore(button_set_transparency#connect#toggled
2309 (set_transparency output button_set_transparency)) ;
2310 ignore(log_verbosity_spinb#connect#changed
2311 (set_log_verbosity output log_verbosity_spinb)) ;
2312 ignore(closeb#connect#clicked settings_window#misc#hide)
2315 (* Scratch window *)
2317 class scratch_window =
2320 ~title:"MathML viewer"
2321 ~border_width:2 () in
2323 GPack.vbox ~packing:window#add () in
2325 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2327 GButton.button ~label:"Whd"
2328 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2330 GButton.button ~label:"Reduce"
2331 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2333 GButton.button ~label:"Simpl"
2334 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2335 let scrolled_window =
2336 GBin.scrolled_window ~border_width:10
2337 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2338 let sequent_viewer =
2339 TermViewer.sequent_viewer
2340 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
2342 val mutable term = Cic.Rel 1 (* dummy value *)
2343 val mutable context = ([] : Cic.context) (* dummy value *)
2344 val mutable metasenv = ([] : Cic.metasenv) (* dummy value *)
2345 method sequent_viewer = sequent_viewer
2346 method show () = window#misc#hide () ; window#show ()
2348 method set_term t = term <- t
2349 method context = context
2350 method set_context t = context <- t
2351 method metasenv = metasenv
2352 method set_metasenv t = metasenv <- t
2355 (sequent_viewer#connect#selection_changed (choose_selection sequent_viewer));
2356 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
2357 ignore(whdb#connect#clicked InvokeTactics'.whd_in_scratch) ;
2358 ignore(reduceb#connect#clicked InvokeTactics'.reduce_in_scratch) ;
2359 ignore(simplb#connect#clicked InvokeTactics'.simpl_in_scratch)
2362 let open_contextual_menu_for_selected_terms mmlwidget infos =
2363 let button = GdkEvent.Button.button infos in
2364 let terms_selected = List.length mmlwidget#get_selections > 0 in
2367 let time = GdkEvent.Button.time infos in
2368 let menu = GMenu.menu () in
2369 let f = new GMenu.factory menu in
2371 f#add_item "Whd" ~key:GdkKeysyms._W ~callback:InvokeTactics'.whd in
2372 let reduce_menu_item =
2373 f#add_item "Reduce" ~key:GdkKeysyms._R ~callback:InvokeTactics'.reduce in
2374 let simpl_menu_item =
2375 f#add_item "Simpl" ~key:GdkKeysyms._S ~callback:InvokeTactics'.simpl in
2376 let _ = f#add_separator () in
2377 let generalize_menu_item =
2378 f#add_item "Generalize"
2379 ~key:GdkKeysyms._G ~callback:InvokeTactics'.generalize in
2380 let _ = f#add_separator () in
2381 let clear_menu_item =
2382 f#add_item "Clear" ~key:GdkKeysyms._C ~callback:InvokeTactics'.clear in
2383 let clearbody_menu_item =
2384 f#add_item "ClearBody"
2385 ~key:GdkKeysyms._B ~callback:InvokeTactics'.clearbody
2387 whd_menu_item#misc#set_sensitive terms_selected ;
2388 reduce_menu_item#misc#set_sensitive terms_selected ;
2389 simpl_menu_item#misc#set_sensitive terms_selected ;
2390 generalize_menu_item#misc#set_sensitive terms_selected ;
2391 clear_menu_item#misc#set_sensitive terms_selected ;
2392 clearbody_menu_item#misc#set_sensitive terms_selected ;
2393 menu#popup ~button ~time
2399 let vbox1 = GPack.vbox () in
2401 val mutable proofw_ref = None
2402 val mutable compute_ref = None
2404 Lazy.force self#compute ;
2405 match proofw_ref with
2406 None -> assert false
2407 | Some proofw -> proofw
2408 method content = vbox1
2410 match compute_ref with
2411 None -> assert false
2412 | Some compute -> compute
2416 let scrolled_window1 =
2417 GBin.scrolled_window ~border_width:10
2418 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2420 TermViewer.sequent_viewer ~width:400 ~height:275
2421 ~packing:(scrolled_window1#add) () in
2422 let _ = proofw_ref <- Some proofw in
2424 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2426 GButton.button ~label:"Ring"
2427 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2429 GButton.button ~label:"Fourier"
2430 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2432 GButton.button ~label:"Reflexivity"
2433 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2435 GButton.button ~label:"Symmetry"
2436 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2438 GButton.button ~label:"Assumption"
2439 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2440 let contradictionb =
2441 GButton.button ~label:"Contradiction"
2442 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2444 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2446 GButton.button ~label:"Exists"
2447 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2449 GButton.button ~label:"Split"
2450 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2452 GButton.button ~label:"Left"
2453 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2455 GButton.button ~label:"Right"
2456 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2457 let searchpatternb =
2458 GButton.button ~label:"SearchPattern_Apply"
2459 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2461 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2463 GButton.button ~label:"Exact"
2464 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2466 GButton.button ~label:"Intros"
2467 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2469 GButton.button ~label:"Apply"
2470 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2471 let elimintrossimplb =
2472 GButton.button ~label:"ElimIntrosSimpl"
2473 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2475 GButton.button ~label:"ElimType"
2476 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2478 GButton.button ~label:"Fold_whd"
2479 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2481 GButton.button ~label:"Fold_reduce"
2482 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2484 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2486 GButton.button ~label:"Fold_simpl"
2487 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2489 GButton.button ~label:"Cut"
2490 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2492 GButton.button ~label:"Change"
2493 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2495 GButton.button ~label:"Let ... In"
2496 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2498 GButton.button ~label:"RewriteSimpl ->"
2499 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2500 let rewritebacksimplb =
2501 GButton.button ~label:"RewriteSimpl <-"
2502 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2504 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2506 GButton.button ~label:"Absurd"
2507 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2509 GButton.button ~label:"Decompose"
2510 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2512 GButton.button ~label:"Transitivity"
2513 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2515 GButton.button ~label:"Replace"
2516 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2518 GButton.button ~label:"Injection"
2519 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2521 GButton.button ~label:"Discriminate"
2522 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2523 (* Zack: spostare in una toolbar
2525 GButton.button ~label:"Generalize"
2526 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2528 GButton.button ~label:"ClearBody"
2529 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2531 GButton.button ~label:"Clear"
2532 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2534 GButton.button ~label:"Whd"
2535 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2537 GButton.button ~label:"Reduce"
2538 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2540 GButton.button ~label:"Simpl"
2541 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2544 ignore(exactb#connect#clicked InvokeTactics'.exact) ;
2545 ignore(applyb#connect#clicked InvokeTactics'.apply) ;
2546 ignore(elimintrossimplb#connect#clicked InvokeTactics'.elimintrossimpl) ;
2547 ignore(elimtypeb#connect#clicked InvokeTactics'.elimtype) ;
2548 ignore(foldwhdb#connect#clicked InvokeTactics'.fold_whd) ;
2549 ignore(foldreduceb#connect#clicked InvokeTactics'.fold_reduce) ;
2550 ignore(foldsimplb#connect#clicked InvokeTactics'.fold_simpl) ;
2551 ignore(cutb#connect#clicked InvokeTactics'.cut) ;
2552 ignore(changeb#connect#clicked InvokeTactics'.change) ;
2553 ignore(letinb#connect#clicked InvokeTactics'.letin) ;
2554 ignore(ringb#connect#clicked InvokeTactics'.ring) ;
2555 ignore(fourierb#connect#clicked InvokeTactics'.fourier) ;
2556 ignore(rewritesimplb#connect#clicked InvokeTactics'.rewritesimpl) ;
2557 ignore(rewritebacksimplb#connect#clicked InvokeTactics'.rewritebacksimpl) ;
2558 ignore(replaceb#connect#clicked InvokeTactics'.replace) ;
2559 ignore(reflexivityb#connect#clicked InvokeTactics'.reflexivity) ;
2560 ignore(symmetryb#connect#clicked InvokeTactics'.symmetry) ;
2561 ignore(transitivityb#connect#clicked InvokeTactics'.transitivity) ;
2562 ignore(existsb#connect#clicked InvokeTactics'.exists) ;
2563 ignore(splitb#connect#clicked InvokeTactics'.split) ;
2564 ignore(leftb#connect#clicked InvokeTactics'.left) ;
2565 ignore(rightb#connect#clicked InvokeTactics'.right) ;
2566 ignore(assumptionb#connect#clicked InvokeTactics'.assumption) ;
2567 ignore(absurdb#connect#clicked InvokeTactics'.absurd) ;
2568 ignore(contradictionb#connect#clicked InvokeTactics'.contradiction) ;
2569 ignore(introsb#connect#clicked InvokeTactics'.intros) ;
2570 ignore(decomposeb#connect#clicked InvokeTactics'.decompose) ;
2571 ignore(searchpatternb#connect#clicked searchPattern) ;
2572 ignore(injectionb#connect#clicked InvokeTactics'.injection) ;
2573 ignore(discriminateb#connect#clicked InvokeTactics'.discriminate) ;
2574 (* Zack: spostare in una toolbar
2575 ignore(whdb#connect#clicked whd) ;
2576 ignore(reduceb#connect#clicked reduce) ;
2577 ignore(simplb#connect#clicked simpl) ;
2578 ignore(clearbodyb#connect#clicked clearbody) ;
2579 ignore(clearb#connect#clicked clear) ;
2580 ignore(generalizeb#connect#clicked generalize) ;
2582 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
2584 ((new GObj.event_ops proofw#as_widget)#connect#button_press
2585 (open_contextual_menu_for_selected_terms proofw)) ;
2591 let vbox1 = GPack.vbox () in
2592 let scrolled_window1 =
2593 GBin.scrolled_window ~border_width:10
2594 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2596 TermViewer.sequent_viewer ~width:400 ~height:275
2597 ~packing:(scrolled_window1#add) () in
2599 method proofw = (assert false : TermViewer.sequent_viewer)
2600 method content = vbox1
2601 method compute = (assert false : unit)
2605 let empty_page = new empty_page;;
2609 val notebook = GPack.notebook ()
2611 val mutable skip_switch_page_event = false
2612 val mutable empty = true
2613 method notebook = notebook
2615 let new_page = new page () in
2617 pages := !pages @ [n,lazy (setgoal n),new_page] ;
2618 notebook#append_page
2619 ~tab_label:((GMisc.label ~text:("?" ^ string_of_int n) ())#coerce)
2620 new_page#content#coerce
2621 method remove_all_pages ~skip_switch_page_event:skip =
2623 notebook#remove_page 0 (* let's remove the empty page *)
2625 List.iter (function _ -> notebook#remove_page 0) !pages ;
2627 skip_switch_page_event <- skip
2628 method set_current_page ~may_skip_switch_page_event n =
2629 let (_,_,page) = List.find (function (m,_,_) -> m=n) !pages in
2630 let new_page = notebook#page_num page#content#coerce in
2631 if may_skip_switch_page_event && new_page <> notebook#current_page then
2632 skip_switch_page_event <- true ;
2633 notebook#goto_page new_page
2634 method set_empty_page =
2637 notebook#append_page
2638 ~tab_label:((GMisc.label ~text:"No proof in progress" ())#coerce)
2639 empty_page#content#coerce
2641 let (_,_,page) = List.nth !pages notebook#current_page in
2645 (notebook#connect#switch_page
2647 let skip = skip_switch_page_event in
2648 skip_switch_page_event <- false ;
2651 let (metano,setgoal,page) = List.nth !pages i in
2652 ProofEngine.goal := Some metano ;
2653 Lazy.force (page#compute) ;
2662 class rendering_window output (notebook : notebook) =
2663 let scratch_window = new scratch_window in
2666 ~title:"gTopLevel - Helm's Proof Assistant"
2667 ~border_width:0 ~allow_shrink:false () in
2668 let vbox_for_menu = GPack.vbox ~packing:window#add () in
2670 let handle_box = GBin.handle_box ~border_width:2
2671 ~packing:(vbox_for_menu#pack ~padding:0) () in
2672 let menubar = GMenu.menu_bar ~packing:handle_box#add () in
2673 let factory0 = new GMenu.factory menubar in
2674 let accel_group = factory0#accel_group in
2676 let file_menu = factory0#add_submenu "File" in
2677 let factory1 = new GMenu.factory file_menu ~accel_group in
2678 let export_to_postscript_menu_item =
2681 factory1#add_item "New Block of (Co)Inductive Definitions..."
2682 ~key:GdkKeysyms._B ~callback:new_inductive
2685 factory1#add_item "New Proof or Definition..." ~key:GdkKeysyms._N
2688 let reopen_menu_item =
2689 factory1#add_item "Reopen a Finished Proof..." ~key:GdkKeysyms._R
2693 factory1#add_item "Qed" ~key:GdkKeysyms._E ~callback:qed in
2694 ignore (factory1#add_separator ()) ;
2696 (factory1#add_item "Load Unfinished Proof..." ~key:GdkKeysyms._L
2697 ~callback:load_unfinished_proof) ;
2698 let save_menu_item =
2699 factory1#add_item "Save Unfinished Proof" ~key:GdkKeysyms._S
2700 ~callback:save_unfinished_proof
2703 (save_set_sensitive := function b -> save_menu_item#misc#set_sensitive b);
2704 ignore (!save_set_sensitive false);
2705 ignore (qed_set_sensitive:=function b -> qed_menu_item#misc#set_sensitive b);
2706 ignore (!qed_set_sensitive false);
2707 ignore (factory1#add_separator ()) ;
2708 let export_to_postscript_menu_item =
2709 factory1#add_item "Export to PostScript..."
2710 ~callback:(export_to_postscript output) in
2711 ignore (factory1#add_separator ()) ;
2713 (factory1#add_item "Exit" ~key:GdkKeysyms._Q ~callback:GMain.Main.quit) ;
2714 export_to_postscript_menu_item
2717 let edit_menu = factory0#add_submenu "Edit Current Proof" in
2718 let factory2 = new GMenu.factory edit_menu ~accel_group in
2719 let focus_and_proveit_set_sensitive = ref (function _ -> assert false) in
2720 let proveit_menu_item =
2721 factory2#add_item "Prove It" ~key:GdkKeysyms._I
2722 ~callback:(function () -> proveit ();!focus_and_proveit_set_sensitive false)
2724 let focus_menu_item =
2725 factory2#add_item "Focus" ~key:GdkKeysyms._F
2726 ~callback:(function () -> focus () ; !focus_and_proveit_set_sensitive false)
2729 focus_and_proveit_set_sensitive :=
2731 proveit_menu_item#misc#set_sensitive b ;
2732 focus_menu_item#misc#set_sensitive b
2734 let _ = !focus_and_proveit_set_sensitive false in
2735 (* edit term menu *)
2736 let edit_term_menu = factory0#add_submenu "Edit Term" in
2737 let factory5 = new GMenu.factory edit_term_menu ~accel_group in
2738 let check_menu_item =
2739 factory5#add_item "Check Term" ~key:GdkKeysyms._C
2740 ~callback:(check scratch_window) in
2741 let _ = check_menu_item#misc#set_sensitive false in
2743 let search_menu = factory0#add_submenu "Search" in
2744 let factory4 = new GMenu.factory search_menu ~accel_group in
2746 factory4#add_item "Locate..." ~key:GdkKeysyms._T
2748 let searchPattern_menu_item =
2749 factory4#add_item "SearchPattern..." ~key:GdkKeysyms._D
2750 ~callback:completeSearchPattern in
2751 let _ = searchPattern_menu_item#misc#set_sensitive false in
2752 let show_menu_item =
2753 factory4#add_item "Show..." ~key:GdkKeysyms._H ~callback:show
2755 let insert_query_item =
2756 factory4#add_item "Insert Query (Experts Only)..." ~key:GdkKeysyms._Y
2757 ~callback:insertQuery in
2759 let hbugs_menu = factory0#add_submenu "HBugs" in
2760 let factory6 = new GMenu.factory hbugs_menu ~accel_group in
2761 let toggle_hbugs_menu_item =
2762 factory6#add_check_item
2763 ~active:false ~key:GdkKeysyms._F5 ~callback:Hbugs.toggle "HBugs enabled"
2766 let settings_menu = factory0#add_submenu "Settings" in
2767 let factory3 = new GMenu.factory settings_menu ~accel_group in
2769 factory3#add_item "Edit Aliases..." ~key:GdkKeysyms._A
2770 ~callback:edit_aliases in
2771 let _ = factory3#add_separator () in
2773 factory3#add_item "MathML Widget Preferences..." ~key:GdkKeysyms._P
2774 ~callback:(function _ -> (settings_window ())#show ()) in
2775 let _ = factory3#add_separator () in
2777 factory3#add_item "Reload Stylesheets"
2780 ApplyStylesheets.reload_stylesheets () ;
2781 if !ProofEngine.proof <> None then
2783 refresh_goals notebook ;
2784 refresh_proof output
2786 InvokeTactics.RefreshSequentException e ->
2787 output_html (outputhtml ())
2788 ("<h1 color=\"red\">An error occurred while refreshing the " ^
2789 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
2790 (*notebook#remove_all_pages ~skip_switch_page_event:false ;*)
2791 notebook#set_empty_page
2792 | InvokeTactics.RefreshProofException e ->
2793 output_html (outputhtml ())
2794 ("<h1 color=\"red\">An error occurred while refreshing the proof: " ^ Printexc.to_string e ^ "</h1>") ;
2798 let _ = window#add_accel_group accel_group in
2802 ~packing:(vbox_for_menu#pack ~expand:true ~fill:true ~padding:5) () in
2804 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2805 let scrolled_window0 =
2806 GBin.scrolled_window ~border_width:10
2807 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2808 let _ = scrolled_window0#add output#coerce in
2810 GBin.frame ~label:"Insert Term"
2811 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2812 let scrolled_window1 =
2813 GBin.scrolled_window ~border_width:5
2814 ~packing:frame#add () in
2816 TexTermEditor'.term_editor
2818 ~width:400 ~height:100 ~packing:scrolled_window1#add ()
2819 ~isnotempty_callback:
2821 check_menu_item#misc#set_sensitive b ;
2822 searchPattern_menu_item#misc#set_sensitive b) in
2824 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2826 vboxl#pack ~expand:true ~fill:true ~padding:5 notebook#notebook#coerce in
2828 GBin.frame ~shadow_type:`IN ~packing:(vboxl#pack ~expand:true ~padding:5) ()
2832 ~source:"<html><body bgColor=\"white\"></body></html>"
2833 ~width:400 ~height: 100
2838 method outputhtml = outputhtml
2839 method inputt = inputt
2840 method output = (output : TermViewer.proof_viewer)
2841 method scratch_window = scratch_window
2842 method notebook = notebook
2843 method show = window#show
2845 notebook#set_empty_page ;
2846 export_to_postscript_menu_item#misc#set_sensitive false ;
2847 check_term := (check_term_in_scratch scratch_window) ;
2849 (* signal handlers here *)
2850 ignore(output#connect#selection_changed
2852 choose_selection output elem ;
2853 !focus_and_proveit_set_sensitive true
2855 ignore (output#connect#click (show_in_show_window_callback output)) ;
2856 let settings_window = new settings_window output scrolled_window0
2857 export_to_postscript_menu_item (choose_selection output) in
2858 set_settings_window settings_window ;
2859 set_outputhtml outputhtml ;
2860 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
2861 Logger.log_callback :=
2862 (Logger.log_to_html ~print_and_flush:(output_html outputhtml))
2867 let initialize_everything () =
2868 let module U = Unix in
2869 let output = TermViewer.proof_viewer ~width:350 ~height:280 () in
2870 let notebook = new notebook in
2871 let rendering_window' = new rendering_window output notebook in
2872 set_rendering_window rendering_window' ;
2873 let print_error_as_html prefix msg =
2874 output_html (outputhtml ())
2875 ("<h1 color=\"red\">" ^ prefix ^ msg ^ "</h1>")
2877 Gdome_xslt.setErrorCallback (Some (print_error_as_html "XSLT Error: "));
2878 Gdome_xslt.setDebugCallback
2879 (Some (print_error_as_html "XSLT Debug Message: "));
2880 rendering_window'#show () ;
2881 (* Hbugs.toggle true; *)
2886 ignore (GtkMain.Main.init ()) ;
2887 initialize_everything () ;
2888 MQIC.close mqi_handle;
2893 Sys.catch_break true;
2895 with Sys.Break -> () (* exit nicely, invoking at_exit functions *)