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 MQGT = MQGTypes
44 module MQG = MQueryGenerator
46 (* GLOBAL CONSTANTS *)
48 let mqi_flags = [MQIC.Postgres ; MQIC.Stat ; MQIC.Warn ; MQIC.Log] (* default MathQL interpreter options *)
50 let mqi_flags = [] (* default MathQL interpreter options *)
52 let mqi_handle = MQIC.init mqi_flags prerr_string
54 let xlinkns = Gdome.domString "http://www.w3.org/1999/xlink";;
58 " <body bgColor=\"white\">"
68 Sys.getenv "GTOPLEVEL_PROOFFILE"
70 Not_found -> "/public/currentproof"
75 Sys.getenv "GTOPLEVEL_PROOFFILETYPE"
77 Not_found -> "/public/currentprooftype"
80 (* GLOBAL REFERENCES (USED BY CALLBACKS) *)
82 let htmlheader_and_content = ref htmlheader;;
84 let check_term = ref (fun _ _ _ -> assert false);;
86 exception RenderingWindowsNotInitialized;;
88 let set_rendering_window,rendering_window =
89 let rendering_window_ref = ref None in
90 (function rw -> rendering_window_ref := Some rw),
92 match !rendering_window_ref with
93 None -> raise RenderingWindowsNotInitialized
98 exception SettingsWindowsNotInitialized;;
100 let set_settings_window,settings_window =
101 let settings_window_ref = ref None in
102 (function rw -> settings_window_ref := Some rw),
104 match !settings_window_ref with
105 None -> raise SettingsWindowsNotInitialized
110 exception OutputHtmlNotInitialized;;
112 let set_outputhtml,outputhtml =
113 let outputhtml_ref = ref None in
114 (function rw -> outputhtml_ref := Some rw),
116 match !outputhtml_ref with
117 None -> raise OutputHtmlNotInitialized
118 | Some outputhtml -> outputhtml
122 exception QedSetSensitiveNotInitialized;;
123 let qed_set_sensitive =
124 ref (function _ -> raise QedSetSensitiveNotInitialized)
127 exception SaveSetSensitiveNotInitialized;;
128 let save_set_sensitive =
129 ref (function _ -> raise SaveSetSensitiveNotInitialized)
132 (* COMMAND LINE OPTIONS *)
138 "-nodb", Arg.Clear usedb, "disable use of MathQL DB"
141 Arg.parse argspec ignore ""
145 let term_of_cic_textual_parser_uri uri =
146 let module C = Cic in
147 let module CTP = CicTextualParser0 in
149 CTP.ConUri uri -> C.Const (uri,[])
150 | CTP.VarUri uri -> C.Var (uri,[])
151 | CTP.IndTyUri (uri,tyno) -> C.MutInd (uri,tyno,[])
152 | CTP.IndConUri (uri,tyno,consno) -> C.MutConstruct (uri,tyno,consno,[])
155 let string_of_cic_textual_parser_uri uri =
156 let module C = Cic in
157 let module CTP = CicTextualParser0 in
160 CTP.ConUri uri -> UriManager.string_of_uri uri
161 | CTP.VarUri uri -> UriManager.string_of_uri uri
162 | CTP.IndTyUri (uri,tyno) ->
163 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1)
164 | CTP.IndConUri (uri,tyno,consno) ->
165 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1) ^ "/" ^
168 (* 4 = String.length "cic:" *)
169 String.sub uri' 4 (String.length uri' - 4)
172 let output_html outputhtml msg =
173 htmlheader_and_content := !htmlheader_and_content ^ msg ;
174 outputhtml#source (!htmlheader_and_content ^ htmlfooter) ;
175 outputhtml#set_topline (-1)
178 (* UTILITY FUNCTIONS TO DISAMBIGUATE AN URI *)
182 let check_window outputhtml uris =
185 ~width:800 ~modal:true ~title:"Check" ~border_width:2 () in
187 GPack.notebook ~scrollable:true ~packing:window#add () in
192 let scrolled_window =
193 GBin.scrolled_window ~border_width:10
195 (notebook#append_page ~tab_label:((GMisc.label ~text:uri ())#coerce))
200 TermViewer.sequent_viewer
201 ~packing:scrolled_window#add ~width:400 ~height:280 () in
204 term_of_cic_textual_parser_uri
205 (MQueryMisc.cic_textual_parser_uri_of_string uri)
207 (Cic.Cast (term, CicTypeChecker.type_of_aux' [] [] term))
210 mmlwidget#load_sequent [] (111,[],expr)
213 output_html outputhtml
214 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
219 (notebook#connect#switch_page
221 Lazy.force (List.nth render_terms i)))
227 interactive_user_uri_choice ~(selection_mode:[`SINGLE|`EXTENDED]) ?(ok="Ok")
228 ?(enable_button_for_non_vars=false) ~title ~msg uris
230 let choices = ref [] in
231 let chosen = ref false in
232 let use_only_constants = ref false in
234 GWindow.dialog ~modal:true ~title ~width:600 () in
236 GMisc.label ~text:msg
237 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
238 let scrolled_window =
239 GBin.scrolled_window ~border_width:10
240 ~packing:(window#vbox#pack ~expand:true ~fill:true ~padding:5) () in
242 let expected_height = 18 * List.length uris in
243 let height = if expected_height > 400 then 400 else expected_height in
244 GList.clist ~columns:1 ~packing:scrolled_window#add
245 ~height ~selection_mode:(selection_mode :> Gtk.Tags.selection_mode) () in
246 let _ = List.map (function x -> clist#append [x]) uris in
248 GPack.hbox ~border_width:0
249 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
251 GMisc.label ~text:"None of the above. Try this one:"
252 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
254 GEdit.entry ~editable:true
255 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
257 GPack.hbox ~border_width:0 ~packing:window#action_area#add () in
259 GButton.button ~label:ok
260 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
261 let _ = okb#misc#set_sensitive false in
266 if enable_button_for_non_vars then
267 hbox#pack ~expand:false ~fill:false ~padding:5 w)
268 ~label:"Try constants only" () in
270 GButton.button ~label:"Check"
271 ~packing:(hbox#pack ~padding:5) () in
272 let _ = checkb#misc#set_sensitive false in
274 GButton.button ~label:"Abort"
275 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
277 let check_callback () =
278 assert (List.length !choices > 0) ;
279 check_window (outputhtml ()) !choices
281 ignore (window#connect#destroy GMain.Main.quit) ;
282 ignore (cancelb#connect#clicked window#destroy) ;
284 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
286 (nonvarsb#connect#clicked
288 use_only_constants := true ;
292 ignore (checkb#connect#clicked check_callback) ;
294 (clist#connect#select_row
295 (fun ~row ~column ~event ->
296 checkb#misc#set_sensitive true ;
297 okb#misc#set_sensitive true ;
298 choices := (List.nth uris row)::!choices)) ;
300 (clist#connect#unselect_row
301 (fun ~row ~column ~event ->
303 List.filter (function uri -> uri != (List.nth uris row)) !choices)) ;
305 (manual_input#connect#changed
307 if manual_input#text = "" then
310 checkb#misc#set_sensitive false ;
311 okb#misc#set_sensitive false ;
312 clist#misc#set_sensitive true
316 choices := [manual_input#text] ;
317 clist#unselect_all () ;
318 checkb#misc#set_sensitive true ;
319 okb#misc#set_sensitive true ;
320 clist#misc#set_sensitive false
322 window#set_position `CENTER ;
326 if !use_only_constants then
328 (function uri -> not (String.sub uri (String.length uri - 4) 4 = ".var"))
331 if List.length !choices > 0 then !choices else raise NoChoice
336 let interactive_interpretation_choice interpretations =
337 let chosen = ref None in
340 ~modal:true ~title:"Ambiguous well-typed input." ~border_width:2 () in
341 let vbox = GPack.vbox ~packing:window#add () in
345 ("Ambiguous input since there are many well-typed interpretations." ^
346 " Please, choose one of them.")
347 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
349 GPack.notebook ~scrollable:true
350 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
353 (function interpretation ->
355 let expected_height = 18 * List.length interpretation in
356 let height = if expected_height > 400 then 400 else expected_height in
357 GList.clist ~columns:2 ~packing:notebook#append_page ~height
358 ~titles:["id" ; "URI"] ()
362 (function (id,uri) ->
363 let n = clist#append [id;uri] in
364 clist#set_row ~selectable:false n
367 clist#columns_autosize ()
370 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
372 GButton.button ~label:"Ok"
373 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
375 GButton.button ~label:"Abort"
376 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
378 ignore (window#connect#destroy GMain.Main.quit) ;
379 ignore (cancelb#connect#clicked window#destroy) ;
382 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
383 window#set_position `CENTER ;
387 None -> raise NoChoice
395 save_object_to_disk uri annobj ids_to_inner_sorts ids_to_inner_types pathname
398 let struri = UriManager.string_of_uri uri in
399 let idx = (String.rindex struri '/') + 1 in
400 String.sub struri idx (String.length struri - idx)
402 let path = pathname ^ "/" ^ name in
404 Cic2Xml.print_object uri ~ids_to_inner_sorts ~ask_dtd_to_the_getter:false
408 Cic2Xml.print_inner_types uri ~ids_to_inner_sorts ~ids_to_inner_types
409 ~ask_dtd_to_the_getter:false
412 let innertypesuri = UriManager.innertypesuri_of_uri uri in
413 Xml.pp ~quiet:true xmlinnertypes (Some (path ^ ".types.xml")) ;
414 Getter.register innertypesuri
415 (Configuration.annotations_url ^
416 Str.replace_first (Str.regexp "^cic:") ""
417 (UriManager.string_of_uri innertypesuri) ^ ".xml"
419 (* constant type / variable / mutual inductive types definition *)
420 Xml.pp ~quiet:true xml (Some (path ^ ".xml")) ;
422 (Configuration.annotations_url ^
423 Str.replace_first (Str.regexp "^cic:") ""
424 (UriManager.string_of_uri uri) ^ ".xml"
431 match UriManager.bodyuri_of_uri uri with
433 | Some bodyuri -> bodyuri
435 Xml.pp ~quiet:true bodyxml' (Some (path ^ ".body.xml")) ;
436 Getter.register bodyuri
437 (Configuration.annotations_url ^
438 Str.replace_first (Str.regexp "^cic:") ""
439 (UriManager.string_of_uri bodyuri) ^ ".xml"
446 exception OpenConjecturesStillThere;;
447 exception WrongProof;;
449 let pathname_of_annuri uristring =
450 Configuration.annotations_dir ^
451 Str.replace_first (Str.regexp "^cic:") "" uristring
454 let make_dirs dirpath =
455 ignore (Unix.system ("mkdir -p " ^ dirpath))
458 let save_obj uri obj =
460 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
461 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
463 Cic2acic.acic_object_of_cic_object obj
465 (* let's save the theorem and register it to the getter *)
466 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
468 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
473 match !ProofEngine.proof with
475 | Some (uri,[],bo,ty) ->
477 CicReduction.are_convertible []
478 (CicTypeChecker.type_of_aux' [] [] bo) ty
481 (*CSC: Wrong: [] is just plainly wrong *)
482 let proof = Cic.Constant (UriManager.name_of_uri uri,Some bo,ty,[]) in
483 let (acic,ids_to_inner_types,ids_to_inner_sorts) =
484 (rendering_window ())#output#load_proof uri proof
486 !qed_set_sensitive false ;
487 (* let's save the theorem and register it to the getter *)
488 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
490 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
495 | _ -> raise OpenConjecturesStillThere
498 (** save an unfinished proof on the filesystem *)
499 let save_unfinished_proof () =
500 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
501 let (xml, bodyxml) = ProofEngine.get_current_status_as_xml () in
502 Xml.pp ~quiet:true xml (Some prooffiletype) ;
503 output_html outputhtml
504 ("<h1 color=\"Green\">Current proof type saved to " ^
505 prooffiletype ^ "</h1>") ;
506 Xml.pp ~quiet:true bodyxml (Some prooffile) ;
507 output_html outputhtml
508 ("<h1 color=\"Green\">Current proof body saved to " ^
512 (* Used to typecheck the loaded proofs *)
513 let typecheck_loaded_proof metasenv bo ty =
514 let module T = CicTypeChecker in
517 (fun metasenv ((_,context,ty) as conj) ->
518 ignore (T.type_of_aux' metasenv context ty) ;
521 ignore (T.type_of_aux' metasenv [] ty) ;
522 ignore (T.type_of_aux' metasenv [] bo)
525 let decompose_uris_choice_callback uris =
526 (* N.B.: in questo passaggio perdo l'informazione su exp_named_subst !!!! *)
527 let module U = UriManager in
530 match MQueryMisc.cic_textual_parser_uri_of_string uri with
531 CicTextualParser0.IndTyUri (uri,typeno) -> (uri,typeno,[])
533 (interactive_user_uri_choice
534 ~selection_mode:`EXTENDED ~ok:"Ok" ~enable_button_for_non_vars:false
535 ~title:"Decompose" ~msg:"Please, select the Inductive Types to decompose"
537 (function (uri,typeno,_) ->
538 U.string_of_uri uri ^ "#1/" ^ string_of_int (typeno+1)
543 let mk_fresh_name_callback context name ~typ =
545 match ProofEngineHelpers.mk_fresh_name context name ~typ with
546 Cic.Name fresh_name -> fresh_name
547 | Cic.Anonymous -> assert false
550 GToolbox.input_string ~title:"Enter a fresh hypothesis name" ~text:fresh_name
551 ("Enter a fresh name for the hypothesis " ^
553 (List.map (function None -> None | Some (n,_) -> Some n) context))
555 Some fresh_name' -> Cic.Name fresh_name'
556 | None -> raise NoChoice
559 let refresh_proof (output : TermViewer.proof_viewer) =
561 let uri,currentproof =
562 match !ProofEngine.proof with
564 | Some (uri,metasenv,bo,ty) ->
565 ProofEngine.proof := Some(uri,metasenv,bo,ty);
566 if List.length metasenv = 0 then
568 !qed_set_sensitive true ;
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);;
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 ;
695 Some (uri, metasenv, bo, ty) ;
699 | (metano,_,_)::_ -> Some metano
701 refresh_proof output ;
702 refresh_goals notebook ;
703 output_html outputhtml
704 ("<h1 color=\"Green\">Current proof type loaded from " ^
705 prooffiletype ^ "</h1>") ;
706 output_html outputhtml
707 ("<h1 color=\"Green\">Current proof body loaded from " ^
708 prooffile ^ "</h1>") ;
709 !save_set_sensitive true;
712 InvokeTactics.RefreshSequentException e ->
713 output_html outputhtml
714 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
715 "sequent: " ^ Printexc.to_string e ^ "</h1>")
716 | InvokeTactics.RefreshProofException e ->
717 output_html outputhtml
718 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
719 "proof: " ^ Printexc.to_string e ^ "</h1>")
721 output_html outputhtml
722 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
725 let edit_aliases () =
726 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
727 let id_to_uris = inputt#id_to_uris in
728 let chosen = ref false in
731 ~width:400 ~modal:true ~title:"Edit Aliases..." ~border_width:2 () in
733 GPack.vbox ~border_width:0 ~packing:window#add () in
734 let scrolled_window =
735 GBin.scrolled_window ~border_width:10
736 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
737 let input = GEdit.text ~editable:true ~width:400 ~height:100
738 ~packing:scrolled_window#add () in
740 GPack.hbox ~border_width:0
741 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
743 GButton.button ~label:"Ok"
744 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
746 GButton.button ~label:"Cancel"
747 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
748 ignore (window#connect#destroy GMain.Main.quit) ;
749 ignore (cancelb#connect#clicked window#destroy) ;
751 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
752 let dom,resolve_id = !id_to_uris in
754 (input#insert_text ~pos:0
759 match resolve_id v with
761 | Some (CicTextualParser0.Uri uri) -> uri
762 | Some (CicTextualParser0.Term _)
763 | Some CicTextualParser0.Implicit -> assert false
767 CicTextualParser0.Id id -> id
768 | CicTextualParser0.Symbol (descr,_) ->
769 (* CSC: To be implemented *)
771 )^ " " ^ (string_of_cic_textual_parser_uri uri)
777 let inputtext = input#get_chars 0 input#length in
779 let alfa = "[a-zA-Z_-]" in
780 let digit = "[0-9]" in
781 let ident = alfa ^ "\(" ^ alfa ^ "\|" ^ digit ^ "\)*" in
782 let blanks = "\( \|\t\|\n\)+" in
783 let nonblanks = "[^ \t\n]+" in
784 let uri = "/\(" ^ ident ^ "/\)*" ^ nonblanks in (* not very strict check *)
786 ("alias" ^ blanks ^ "\(" ^ ident ^ "\)" ^ blanks ^ "\(" ^ uri ^ "\)")
790 let n' = Str.search_forward regexpr inputtext n in
791 let id = CicTextualParser0.Id (Str.matched_group 2 inputtext) in
793 MQueryMisc.cic_textual_parser_uri_of_string
794 ("cic:" ^ (Str.matched_group 5 inputtext))
796 let dom,resolve_id = aux (n' + 1) in
797 if List.mem id dom then
803 Some (CicTextualParser0.Uri uri)
806 Not_found -> TermEditor.empty_id_to_uris
810 id_to_uris := (dom,resolve_id)
814 let module L = LogicalOperations in
815 let module G = Gdome in
816 let notebook = (rendering_window ())#notebook in
817 let output = (rendering_window ())#output in
818 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
820 output#make_sequent_of_selected_term ;
821 refresh_proof output ;
822 refresh_goals notebook
824 InvokeTactics.RefreshSequentException e ->
825 output_html outputhtml
826 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
827 "sequent: " ^ Printexc.to_string e ^ "</h1>")
828 | InvokeTactics.RefreshProofException e ->
829 output_html outputhtml
830 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
831 "proof: " ^ Printexc.to_string e ^ "</h1>")
833 output_html outputhtml
834 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
838 let module L = LogicalOperations in
839 let module G = Gdome in
840 let notebook = (rendering_window ())#notebook in
841 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
842 let output = (rendering_window ())#output in
844 output#focus_sequent_of_selected_term ;
845 refresh_goals notebook
847 InvokeTactics.RefreshSequentException e ->
848 output_html outputhtml
849 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
850 "sequent: " ^ Printexc.to_string e ^ "</h1>")
851 | InvokeTactics.RefreshProofException e ->
852 output_html outputhtml
853 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
854 "proof: " ^ Printexc.to_string e ^ "</h1>")
856 output_html outputhtml
857 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
860 exception NoPrevGoal;;
861 exception NoNextGoal;;
864 let module L = LogicalOperations in
865 let module G = Gdome in
866 let notebook = (rendering_window ())#notebook in
867 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
869 match !ProofEngine.proof with
871 | Some (_,metasenv,_,_) -> metasenv
874 refresh_goals ~empty_notebook:false notebook
876 InvokeTactics.RefreshSequentException e ->
877 output_html outputhtml
878 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
879 "sequent: " ^ Printexc.to_string e ^ "</h1>")
881 output_html outputhtml
882 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
886 show_in_show_window_obj, show_in_show_window_uri, show_in_show_window_callback
889 GWindow.window ~width:800 ~border_width:2 () in
890 let scrolled_window =
891 GBin.scrolled_window ~border_width:10 ~packing:window#add () in
893 GMathViewAux.single_selection_math_view
894 ~packing:scrolled_window#add ~width:600 ~height:400 ()
896 let _ = window#event#connect#delete (fun _ -> window#misc#hide () ; true ) in
897 let href = Gdome.domString "href" in
898 let show_in_show_window_obj uri obj =
899 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
902 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
903 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
905 Cic2acic.acic_object_of_cic_object obj
908 ApplyStylesheets.mml_of_cic_object
909 ~explode_all:false uri acic ids_to_inner_sorts ids_to_inner_types
911 window#set_title (UriManager.string_of_uri uri) ;
912 window#misc#hide () ; window#show () ;
913 mmlwidget#load_doc mml ;
916 output_html outputhtml
917 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
919 let show_in_show_window_uri uri =
920 let obj = CicEnvironment.get_obj uri in
921 show_in_show_window_obj uri obj
923 let show_in_show_window_callback mmlwidget (n : Gdome.element option) _ =
927 if n'#hasAttributeNS ~namespaceURI:xlinkns ~localName:href then
929 (n'#getAttributeNS ~namespaceURI:xlinkns ~localName:href)#to_string
931 show_in_show_window_uri (UriManager.uri_of_string uri)
933 ignore (mmlwidget#action_toggle n')
936 mmlwidget#connect#click (show_in_show_window_callback mmlwidget)
938 show_in_show_window_obj, show_in_show_window_uri,
939 show_in_show_window_callback
942 exception NoObjectsLocated;;
944 let user_uri_choice ~title ~msg uris =
947 [] -> raise NoObjectsLocated
951 interactive_user_uri_choice ~selection_mode:`SINGLE ~title ~msg uris
956 String.sub uri 4 (String.length uri - 4)
959 let locate_callback id =
960 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
961 let out = output_html outputhtml in
962 let query = MQG.locate id in
963 let result = MQI.execute mqi_handle query in
967 MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format' uri)
969 out "<h1>Locate Query: </h1><pre>";
970 MQueryUtil.text_of_query out query "";
971 out "<h1>Result:</h1>";
972 MQueryUtil.text_of_result out result "<br>";
973 user_uri_choice ~title:"Ambiguous input."
975 ("Ambiguous input \"" ^ id ^
976 "\". Please, choose one interpetation:")
981 let input_or_locate_uri ~title =
982 let uri = ref None in
985 ~width:400 ~modal:true ~title ~border_width:2 () in
986 let vbox = GPack.vbox ~packing:window#add () in
988 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
990 GMisc.label ~text:"Enter a valid URI:" ~packing:(hbox1#pack ~padding:5) () in
992 GEdit.entry ~editable:true
993 ~packing:(hbox1#pack ~expand:true ~fill:true ~padding:5) () in
995 GButton.button ~label:"Check"
996 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
997 let _ = checkb#misc#set_sensitive false in
999 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1001 GMisc.label ~text:"You can also enter an indentifier to locate:"
1002 ~packing:(hbox2#pack ~padding:5) () in
1004 GEdit.entry ~editable:true
1005 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1007 GButton.button ~label:"Locate"
1008 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1009 let _ = locateb#misc#set_sensitive false in
1011 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1013 GButton.button ~label:"Ok"
1014 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1015 let _ = okb#misc#set_sensitive false in
1017 GButton.button ~label:"Cancel"
1018 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) ()
1020 ignore (window#connect#destroy GMain.Main.quit) ;
1022 (cancelb#connect#clicked (function () -> uri := None ; window#destroy ())) ;
1023 let check_callback () =
1024 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1025 let uri = "cic:" ^ manual_input#text in
1027 ignore (Getter.resolve (UriManager.uri_of_string uri)) ;
1028 output_html outputhtml "<h1 color=\"Green\">OK</h1>" ;
1031 Getter.Unresolved ->
1032 output_html outputhtml
1033 ("<h1 color=\"Red\">URI " ^ uri ^
1034 " does not correspond to any object.</h1>") ;
1036 | UriManager.IllFormedUri _ ->
1037 output_html outputhtml
1038 ("<h1 color=\"Red\">URI " ^ uri ^ " is not well-formed.</h1>") ;
1041 output_html outputhtml
1042 ("<h1 color=\"Red\">" ^ Printexc.to_string e ^ "</h1>") ;
1046 (okb#connect#clicked
1048 if check_callback () then
1050 uri := Some manual_input#text ;
1054 ignore (checkb#connect#clicked (function () -> ignore (check_callback ()))) ;
1056 (manual_input#connect#changed
1058 if manual_input#text = "" then
1060 checkb#misc#set_sensitive false ;
1061 okb#misc#set_sensitive false
1065 checkb#misc#set_sensitive true ;
1066 okb#misc#set_sensitive true
1069 (locate_input#connect#changed
1070 (fun _ -> locateb#misc#set_sensitive (locate_input#text <> ""))) ;
1072 (locateb#connect#clicked
1074 let id = locate_input#text in
1075 manual_input#set_text (locate_callback id) ;
1076 locate_input#delete_text 0 (String.length id)
1081 None -> raise NoChoice
1082 | Some uri -> UriManager.uri_of_string ("cic:" ^ uri)
1085 exception AmbiguousInput;;
1087 (* A WIDGET TO ENTER CIC TERMS *)
1089 module ChosenTermEditor = TexTermEditor;;
1090 module ChosenTextualParser0 = TexCicTextualParser0;;
1092 module ChosenTermEditor = TermEditor;;
1093 module ChosenTextualParser0 = CicTextualParser0;;
1098 let get_metasenv () = !ChosenTextualParser0.metasenv
1099 let set_metasenv metasenv = ChosenTextualParser0.metasenv := metasenv
1101 let output_html msg = output_html (outputhtml ()) msg;;
1102 let interactive_user_uri_choice =
1103 fun ~selection_mode ?ok ?enable_button_for_non_vars ~title ~msg ~id ->
1104 interactive_user_uri_choice ~selection_mode ?ok
1105 ?enable_button_for_non_vars ~title ~msg;;
1106 let interactive_interpretation_choice = interactive_interpretation_choice;;
1107 let input_or_locate_uri = input_or_locate_uri;;
1111 module TexTermEditor' = ChosenTermEditor.Make(Callbacks);;
1113 (* OTHER FUNCTIONS *)
1116 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1117 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1120 GToolbox.input_string ~title:"Locate" "Enter an identifier to locate:"
1122 None -> raise NoChoice
1124 let uri = locate_callback input in
1128 output_html outputhtml
1129 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
1133 exception UriAlreadyInUse;;
1134 exception NotAUriToAConstant;;
1136 let new_inductive () =
1137 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1138 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1139 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1140 let notebook = (rendering_window ())#notebook in
1142 let chosen = ref false in
1143 let inductive = ref true in
1144 let paramsno = ref 0 in
1145 let get_uri = ref (function _ -> assert false) in
1146 let get_base_uri = ref (function _ -> assert false) in
1147 let get_names = ref (function _ -> assert false) in
1148 let get_types_and_cons = ref (function _ -> assert false) in
1149 let get_context_and_subst = ref (function _ -> assert false) in
1152 ~width:600 ~modal:true ~position:`CENTER
1153 ~title:"New Block of Mutual (Co)Inductive Definitions"
1154 ~border_width:2 () in
1155 let vbox = GPack.vbox ~packing:window#add () in
1157 GPack.hbox ~border_width:0
1158 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1160 GMisc.label ~text:"Enter the URI for the new block:"
1161 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1163 GEdit.entry ~editable:true
1164 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1166 GPack.hbox ~border_width:0
1167 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1171 "Enter the number of left parameters in every arity and constructor type:"
1172 ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1173 let paramsno_entry =
1174 GEdit.entry ~editable:true ~text:"0"
1175 ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
1177 GPack.hbox ~border_width:0
1178 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1180 GMisc.label ~text:"Are the definitions inductive or coinductive?"
1181 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1183 GButton.radio_button ~label:"Inductive"
1184 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1186 GButton.radio_button ~label:"Coinductive"
1187 ~group:inductiveb#group
1188 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1190 GPack.hbox ~border_width:0
1191 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1193 GMisc.label ~text:"Enter the list of the names of the types:"
1194 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1196 GEdit.entry ~editable:true
1197 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1199 GPack.hbox ~border_width:0
1200 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1202 GButton.button ~label:"> Next"
1203 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1204 let _ = okb#misc#set_sensitive true in
1206 GButton.button ~label:"Abort"
1207 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1208 ignore (window#connect#destroy GMain.Main.quit) ;
1209 ignore (cancelb#connect#clicked window#destroy) ;
1213 (okb#connect#clicked
1216 let uristr = "cic:" ^ uri_entry#text in
1217 let namesstr = names_entry#text in
1218 let paramsno' = int_of_string (paramsno_entry#text) in
1219 match Str.split (Str.regexp " +") namesstr with
1221 | (he::tl) as names ->
1222 let uri = UriManager.uri_of_string (uristr ^ "/" ^ he ^ ".ind") in
1225 ignore (Getter.resolve uri) ;
1226 raise UriAlreadyInUse
1228 Getter.Unresolved ->
1229 get_uri := (function () -> uri) ;
1230 get_names := (function () -> names) ;
1231 inductive := inductiveb#active ;
1232 paramsno := paramsno' ;
1237 output_html outputhtml
1238 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1246 GBin.frame ~label:name
1247 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1248 let vbox = GPack.vbox ~packing:frame#add () in
1249 let hbox = GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false) () in
1251 GMisc.label ~text:("Enter its type:")
1252 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1253 let scrolled_window =
1254 GBin.scrolled_window ~border_width:5
1255 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1257 TexTermEditor'.term_editor
1259 ~width:400 ~height:20 ~packing:scrolled_window#add
1260 ~share_id_to_uris_with:inputt ()
1261 ~isnotempty_callback:
1263 (*non_empty_type := b ;*)
1264 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*)
1267 GPack.hbox ~border_width:0
1268 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1270 GMisc.label ~text:("Enter the list of its constructors:")
1271 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1272 let cons_names_entry =
1273 GEdit.entry ~editable:true
1274 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1275 (newinputt,cons_names_entry)
1278 vbox#remove hboxn#coerce ;
1280 GPack.hbox ~border_width:0
1281 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1283 GButton.button ~label:"> Next"
1284 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1286 GButton.button ~label:"Abort"
1287 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1288 ignore (cancelb#connect#clicked window#destroy) ;
1290 (okb#connect#clicked
1293 let names = !get_names () in
1294 let types_and_cons =
1296 (fun name (newinputt,cons_names_entry) ->
1297 let consnamesstr = cons_names_entry#text in
1298 let cons_names = Str.split (Str.regexp " +") consnamesstr in
1300 newinputt#get_metasenv_and_term ~context:[] ~metasenv:[]
1303 [] -> expr,cons_names
1304 | _ -> raise AmbiguousInput
1305 ) names type_widgets
1307 let uri = !get_uri () in
1309 (* Let's see if so far the definition is well-typed *)
1312 (* To test if the arities of the inductive types are well *)
1313 (* typed, we check the inductive block definition where *)
1314 (* no constructor is given to each type. *)
1317 (fun name (ty,cons) -> (name, !inductive, ty, []))
1318 names types_and_cons
1320 CicTypeChecker.typecheck_mutual_inductive_defs uri
1321 (tys,params,paramsno)
1323 get_context_and_subst :=
1327 (fun (context,subst) name (ty,_) ->
1329 (Some (Cic.Name name, Cic.Decl ty))::context,
1330 (Cic.MutInd (uri,!i,[]))::subst
1333 ) ([],[]) names types_and_cons) ;
1334 let types_and_cons' =
1336 (fun name (ty,cons) -> (name, !inductive, ty, phase3 name cons))
1337 names types_and_cons
1339 get_types_and_cons := (function () -> types_and_cons') ;
1344 output_html outputhtml
1345 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1348 and phase3 name cons =
1349 let get_cons_types = ref (function () -> assert false) in
1352 ~width:600 ~modal:true ~position:`CENTER
1353 ~title:(name ^ " Constructors")
1354 ~border_width:2 () in
1355 let vbox = GPack.vbox ~packing:window2#add () in
1356 let cons_type_widgets =
1358 (function consname ->
1360 GPack.hbox ~border_width:0
1361 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1363 GMisc.label ~text:("Enter the type of " ^ consname ^ ":")
1364 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1365 let scrolled_window =
1366 GBin.scrolled_window ~border_width:5
1367 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1369 TexTermEditor'.term_editor
1371 ~width:400 ~height:20 ~packing:scrolled_window#add
1372 ~share_id_to_uris_with:inputt ()
1373 ~isnotempty_callback:
1375 (* (*non_empty_type := b ;*)
1376 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*) *)())
1381 GPack.hbox ~border_width:0
1382 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1384 GButton.button ~label:"> Next"
1385 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1386 let _ = okb#misc#set_sensitive true in
1388 GButton.button ~label:"Abort"
1389 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1390 ignore (window2#connect#destroy GMain.Main.quit) ;
1391 ignore (cancelb#connect#clicked window2#destroy) ;
1393 (okb#connect#clicked
1397 let context,subst= !get_context_and_subst () in
1402 inputt#get_metasenv_and_term ~context ~metasenv:[]
1406 let undebrujined_expr =
1408 (fun expr t -> CicSubstitution.subst t expr) expr subst
1410 name, undebrujined_expr
1411 | _ -> raise AmbiguousInput
1412 ) cons cons_type_widgets
1414 get_cons_types := (function () -> cons_types) ;
1418 output_html outputhtml
1419 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1423 let okb_pressed = !chosen in
1425 if (not okb_pressed) then
1428 assert false (* The control never reaches this point *)
1431 (!get_cons_types ())
1434 (* No more phases left or Abort pressed *)
1440 let uri = !get_uri () in
1443 let tys = !get_types_and_cons () in
1444 let obj = Cic.InductiveDefinition tys params !paramsno in
1447 prerr_endline (CicPp.ppobj obj) ;
1448 CicTypeChecker.typecheck_mutual_inductive_defs uri
1449 (tys,params,!paramsno) ;
1452 prerr_endline "Offending mutual (co)inductive type declaration:" ;
1453 prerr_endline (CicPp.ppobj obj) ;
1455 (* We already know that obj is well-typed. We need to add it to the *)
1456 (* environment in order to compute the inner-types without having to *)
1457 (* debrujin it or having to modify lots of other functions to avoid *)
1458 (* asking the environment for the MUTINDs we are defining now. *)
1459 CicEnvironment.put_inductive_definition uri obj ;
1461 show_in_show_window_obj uri obj
1464 output_html outputhtml
1465 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1469 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1470 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1471 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1472 let notebook = (rendering_window ())#notebook in
1474 let chosen = ref false in
1475 let get_metasenv_and_term = ref (function _ -> assert false) in
1476 let get_uri = ref (function _ -> assert false) in
1477 let non_empty_type = ref false in
1480 ~width:600 ~modal:true ~title:"New Proof or Definition"
1481 ~border_width:2 () in
1482 let vbox = GPack.vbox ~packing:window#add () in
1484 GPack.hbox ~border_width:0
1485 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1487 GMisc.label ~text:"Enter the URI for the new theorem or definition:"
1488 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1490 GEdit.entry ~editable:true
1491 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1492 uri_entry#set_text dummy_uri;
1493 uri_entry#select_region ~start:1 ~stop:(String.length dummy_uri);
1495 GPack.hbox ~border_width:0
1496 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1498 GMisc.label ~text:"Enter the theorem or definition type:"
1499 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1500 let scrolled_window =
1501 GBin.scrolled_window ~border_width:5
1502 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1503 (* the content of the scrolled_window is moved below (see comment) *)
1505 GPack.hbox ~border_width:0
1506 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1508 GButton.button ~label:"Ok"
1509 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1510 let _ = okb#misc#set_sensitive false in
1512 GButton.button ~label:"Cancel"
1513 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1514 (* moved here to have visibility of the ok button *)
1516 TexTermEditor'.term_editor
1518 ~width:400 ~height:100 ~packing:scrolled_window#add
1519 ~share_id_to_uris_with:inputt ()
1520 ~isnotempty_callback:
1522 non_empty_type := b ;
1523 okb#misc#set_sensitive (b && uri_entry#text <> ""))
1526 let xxx = inputt#get_as_string in
1527 prerr_endline ("######################## " ^ xxx) ;
1528 newinputt#set_term xxx ;
1530 newinputt#set_term inputt#get_as_string ;
1534 uri_entry#connect#changed
1536 okb#misc#set_sensitive (!non_empty_type && uri_entry#text <> ""))
1538 ignore (window#connect#destroy GMain.Main.quit) ;
1539 ignore (cancelb#connect#clicked window#destroy) ;
1541 (okb#connect#clicked
1545 let metasenv,parsed = newinputt#get_metasenv_and_term [] [] in
1546 let uristr = "cic:" ^ uri_entry#text in
1547 let uri = UriManager.uri_of_string uristr in
1548 if String.sub uristr (String.length uristr - 4) 4 <> ".con" then
1549 raise NotAUriToAConstant
1553 ignore (Getter.resolve uri) ;
1554 raise UriAlreadyInUse
1556 Getter.Unresolved ->
1557 get_metasenv_and_term := (function () -> metasenv,parsed) ;
1558 get_uri := (function () -> uri) ;
1563 output_html outputhtml
1564 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1570 let metasenv,expr = !get_metasenv_and_term () in
1571 let _ = CicTypeChecker.type_of_aux' metasenv [] expr in
1572 ProofEngine.proof :=
1573 Some (!get_uri (), (1,[],expr)::metasenv, Cic.Meta (1,[]), expr) ;
1574 ProofEngine.goal := Some 1 ;
1575 refresh_goals notebook ;
1576 refresh_proof output ;
1577 !save_set_sensitive true ;
1579 ProofEngine.intros ~mk_fresh_name_callback () ;
1580 refresh_goals notebook ;
1581 refresh_proof output
1583 InvokeTactics.RefreshSequentException e ->
1584 output_html outputhtml
1585 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1586 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1587 | InvokeTactics.RefreshProofException e ->
1588 output_html outputhtml
1589 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1590 "proof: " ^ Printexc.to_string e ^ "</h1>")
1592 output_html outputhtml
1593 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1596 let check_term_in_scratch scratch_window metasenv context expr =
1598 let ty = CicTypeChecker.type_of_aux' metasenv context expr in
1599 let expr = Cic.Cast (expr,ty) in
1600 scratch_window#show () ;
1601 scratch_window#set_term expr ;
1602 scratch_window#set_context context ;
1603 scratch_window#set_metasenv metasenv ;
1604 scratch_window#sequent_viewer#load_sequent metasenv (111,context,expr)
1607 print_endline ("? " ^ CicPp.ppterm expr) ;
1611 let check scratch_window () =
1612 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1613 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1615 match !ProofEngine.proof with
1617 | Some (_,metasenv,_,_) -> metasenv
1620 match !ProofEngine.goal with
1623 let (_,canonical_context,_) =
1624 List.find (function (m,_,_) -> m=metano) metasenv
1629 let metasenv',expr = inputt#get_metasenv_and_term context metasenv in
1630 check_term_in_scratch scratch_window metasenv' context expr
1633 output_html outputhtml
1634 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1638 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1640 show_in_show_window_uri (input_or_locate_uri ~title:"Show")
1643 output_html outputhtml
1644 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1647 exception NotADefinition;;
1650 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1651 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1652 let notebook = (rendering_window ())#notebook in
1654 let uri = input_or_locate_uri ~title:"Open" in
1655 CicTypeChecker.typecheck uri ;
1656 let metasenv,bo,ty =
1657 match CicEnvironment.get_cooked_obj uri with
1658 Cic.Constant (_,Some bo,ty,_) -> [],bo,ty
1659 | Cic.CurrentProof (_,metasenv,bo,ty,_) -> metasenv,bo,ty
1662 | Cic.InductiveDefinition _ -> raise NotADefinition
1664 ProofEngine.proof :=
1665 Some (uri, metasenv, bo, ty) ;
1666 ProofEngine.goal := None ;
1667 refresh_goals notebook ;
1668 refresh_proof output ;
1669 !save_set_sensitive true
1671 InvokeTactics.RefreshSequentException e ->
1672 output_html outputhtml
1673 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1674 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1675 | InvokeTactics.RefreshProofException e ->
1676 output_html outputhtml
1677 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1678 "proof: " ^ Printexc.to_string e ^ "</h1>")
1680 output_html outputhtml
1681 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1684 let show_query_results results =
1687 ~modal:false ~title:"Query results." ~border_width:2 () in
1688 let vbox = GPack.vbox ~packing:window#add () in
1690 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1693 ~text:"Click on a URI to show that object"
1694 ~packing:hbox#add () in
1695 let scrolled_window =
1696 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1697 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1698 let clist = GList.clist ~columns:1 ~packing:scrolled_window#add () in
1701 (function (uri,_) ->
1705 clist#set_row ~selectable:false n
1708 clist#columns_autosize () ;
1710 (clist#connect#select_row
1711 (fun ~row ~column ~event ->
1712 let (uristr,_) = List.nth results row in
1714 MQueryMisc.cic_textual_parser_uri_of_string
1715 (MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format'
1718 CicTextualParser0.ConUri uri
1719 | CicTextualParser0.VarUri uri
1720 | CicTextualParser0.IndTyUri (uri,_)
1721 | CicTextualParser0.IndConUri (uri,_,_) ->
1722 show_in_show_window_uri uri
1728 let refine_constraints (must_obj,must_rel,must_sort) =
1729 let chosen = ref false in
1730 let use_only = ref false in
1733 ~modal:true ~title:"Constraints refinement."
1734 ~width:800 ~border_width:2 () in
1735 let vbox = GPack.vbox ~packing:window#add () in
1737 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1740 ~text: "\"Only\" constraints can be enforced or not."
1741 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1743 GButton.toggle_button ~label:"Enforce \"only\" constraints"
1744 ~active:false ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1747 (onlyb#connect#toggled (function () -> use_only := onlyb#active)) ;
1748 (* Notebook for the constraints choice *)
1750 GPack.notebook ~scrollable:true
1751 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1752 (* Rel constraints *)
1755 ~text: "Constraints on Rels" () in
1757 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1760 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1763 ~text: "You can now specify the constraints on Rels."
1764 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1765 let expected_height = 25 * (List.length must_rel + 2) in
1766 let height = if expected_height > 400 then 400 else expected_height in
1767 let scrolled_window =
1768 GBin.scrolled_window ~border_width:10 ~height ~width:600
1769 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1770 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1771 let mk_depth_button (hbox:GPack.box) d =
1772 let mutable_ref = ref (Some d) in
1774 GButton.toggle_button
1775 ~label:("depth = " ^ string_of_int d)
1777 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1780 (depthb#connect#toggled
1782 let sel_depth = if depthb#active then Some d else None in
1783 mutable_ref := sel_depth
1786 let rel_constraints =
1791 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1794 ~text:(MQGU.text_of_position (p:>MQGT.full_position))
1795 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1797 | `MainHypothesis None
1798 | `MainConclusion None -> p, ref None
1799 | `MainHypothesis (Some depth')
1800 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth'
1802 (* Sort constraints *)
1805 ~text: "Constraints on Sorts" () in
1807 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1810 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1813 ~text: "You can now specify the constraints on Sorts."
1814 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1815 let expected_height = 25 * (List.length must_sort + 2) in
1816 let height = if expected_height > 400 then 400 else expected_height in
1817 let scrolled_window =
1818 GBin.scrolled_window ~border_width:10 ~height ~width:600
1819 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1820 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1821 let sort_constraints =
1823 (function (p, sort) ->
1826 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1829 ~text:(MQGU.text_of_sort sort ^ " " ^ MQGU.text_of_position (p:>MQGT.full_position))
1830 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1832 | `MainHypothesis None
1833 | `MainConclusion None -> p, ref None, sort
1834 | `MainHypothesis (Some depth')
1835 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', sort
1837 (* Obj constraints *)
1840 ~text: "Constraints on constants" () in
1842 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1845 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1848 ~text: "You can now specify the constraints on constants."
1849 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1850 let expected_height = 25 * (List.length must_obj + 2) in
1851 let height = if expected_height > 400 then 400 else expected_height in
1852 let scrolled_window =
1853 GBin.scrolled_window ~border_width:10 ~height ~width:600
1854 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1855 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1856 let obj_constraints =
1858 (function (p, uri) ->
1861 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1864 ~text:(uri ^ " " ^ (MQGU.text_of_position p))
1865 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1870 | `MainHypothesis None
1871 | `MainConclusion None -> p, ref None, uri
1872 | `MainHypothesis (Some depth')
1873 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', uri
1875 (* Confirm/abort buttons *)
1877 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1879 GButton.button ~label:"Ok"
1880 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1882 GButton.button ~label:"Abort"
1883 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1885 ignore (window#connect#destroy GMain.Main.quit) ;
1886 ignore (cancelb#connect#clicked window#destroy) ;
1888 (okb#connect#clicked (function () -> chosen := true ; window#destroy ()));
1889 window#set_position `CENTER ;
1893 let chosen_must_rel =
1895 (function (position, ref_depth) -> MQGU.set_main_position position !ref_depth)
1898 let chosen_must_sort =
1900 (function (position, ref_depth, sort) ->
1901 MQGU.set_main_position position !ref_depth,sort)
1904 let chosen_must_obj =
1906 (function (position, ref_depth, uri) -> MQGU.set_full_position position !ref_depth, uri)
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 = CGSearchPattern.get_constraints expr in
1926 let must',only = refine_constraints must in
1928 MQG.query_of_constraints (Some CGSearchPattern.universe) must' only
1930 let results = MQI.execute mqi_handle query in
1931 show_query_results results
1934 output_html outputhtml
1935 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1938 let insertQuery () =
1939 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1941 let chosen = ref None in
1944 ~modal:true ~title:"Insert Query (Experts Only)" ~border_width:2 () in
1945 let vbox = GPack.vbox ~packing:window#add () in
1947 GMisc.label ~text:"Insert Query. For Experts Only."
1948 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1949 let scrolled_window =
1950 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1951 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1952 let input = GEdit.text ~editable:true
1953 ~packing:scrolled_window#add () in
1955 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1957 GButton.button ~label:"Ok"
1958 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1960 GButton.button ~label:"Load from file..."
1961 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1963 GButton.button ~label:"Abort"
1964 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1965 ignore (window#connect#destroy GMain.Main.quit) ;
1966 ignore (cancelb#connect#clicked window#destroy) ;
1968 (okb#connect#clicked
1970 chosen := Some (input#get_chars 0 input#length) ; window#destroy ())) ;
1972 (loadb#connect#clicked
1975 GToolbox.select_file ~title:"Select Query File" ()
1979 let inch = open_in filename in
1980 let rec read_file () =
1982 let line = input_line inch in
1983 line ^ "\n" ^ read_file ()
1987 let text = read_file () in
1988 input#delete_text 0 input#length ;
1989 ignore (input#insert_text text ~pos:0))) ;
1990 window#set_position `CENTER ;
1997 MQI.execute mqi_handle (MQueryUtil.query_of_text (Lexing.from_string q))
1999 show_query_results results
2002 output_html outputhtml
2003 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
2006 let choose_must list_of_must only =
2007 let chosen = ref None in
2008 let user_constraints = ref [] in
2011 ~modal:true ~title:"Query refinement." ~border_width:2 () in
2012 let vbox = GPack.vbox ~packing:window#add () in
2014 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2018 ("You can now specify the genericity of the query. " ^
2019 "The more generic the slower.")
2020 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2022 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2026 "Suggestion: start with faster queries before moving to more generic ones."
2027 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2029 GPack.notebook ~scrollable:true
2030 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2033 let last = List.length list_of_must in
2039 (if !page = 1 then "More generic" else
2040 if !page = last then "More precise" else " ") () in
2041 let expected_height = 25 * (List.length must + 2) in
2042 let height = if expected_height > 400 then 400 else expected_height in
2043 let scrolled_window =
2044 GBin.scrolled_window ~border_width:10 ~height ~width:600
2045 ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2047 GList.clist ~columns:2 ~packing:scrolled_window#add
2048 ~titles:["URI" ; "Position"] ()
2052 (function (position, uri) ->
2055 [uri; MQGUtil.text_of_position position]
2057 clist#set_row ~selectable:false n
2060 clist#columns_autosize ()
2063 let label = GMisc.label ~text:"User provided" () in
2065 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2067 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2070 ~text:"Select the constraints that must be satisfied and press OK."
2071 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2072 let expected_height = 25 * (List.length only + 2) in
2073 let height = if expected_height > 400 then 400 else expected_height in
2074 let scrolled_window =
2075 GBin.scrolled_window ~border_width:10 ~height ~width:600
2076 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2078 GList.clist ~columns:2 ~packing:scrolled_window#add
2079 ~selection_mode:`EXTENDED
2080 ~titles:["URI" ; "Position"] ()
2084 (function (position, uri) ->
2087 [uri; MQGUtil.text_of_position position]
2089 clist#set_row ~selectable:true n
2092 clist#columns_autosize () ;
2094 (clist#connect#select_row
2095 (fun ~row ~column ~event ->
2096 user_constraints := (List.nth only row)::!user_constraints)) ;
2098 (clist#connect#unselect_row
2099 (fun ~row ~column ~event ->
2102 (function uri -> uri != (List.nth only row)) !user_constraints)) ;
2105 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2107 GButton.button ~label:"Ok"
2108 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2110 GButton.button ~label:"Abort"
2111 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2113 ignore (window#connect#destroy GMain.Main.quit) ;
2114 ignore (cancelb#connect#clicked window#destroy) ;
2116 (okb#connect#clicked
2117 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
2118 window#set_position `CENTER ;
2122 None -> raise NoChoice
2124 if n = List.length list_of_must then
2125 (* user provided constraints *)
2128 List.nth list_of_must n
2131 let searchPattern () =
2132 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
2133 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
2136 match !ProofEngine.proof with
2137 None -> assert false
2138 | Some proof -> proof
2140 match !ProofEngine.goal with
2144 TacticChaser.matchConclusion
2146 ~output_html:(output_html outputhtml) ~choose_must ()
2147 ~status:(proof, metano)
2150 user_uri_choice ~title:"Ambiguous input."
2151 ~msg: "Many lemmas can be successfully applied. Please, choose one:"
2154 inputt#set_term uri' ;
2155 InvokeTactics'.apply ()
2158 output_html outputhtml
2159 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
2162 let choose_selection mmlwidget (element : Gdome.element option) =
2163 let module G = Gdome in
2164 let rec aux element =
2165 if element#hasAttributeNS
2166 ~namespaceURI:Misc.helmns
2167 ~localName:(G.domString "xref")
2169 mmlwidget#set_selection (Some element)
2172 match element#get_parentNode with
2173 None -> assert false
2174 (*CSC: OCAML DIVERGES!
2175 | Some p -> aux (new G.element_of_node p)
2177 | Some p -> aux (new Gdome.element_of_node p)
2179 GdomeInit.DOMCastException _ ->
2181 "******* trying to select above the document root ********"
2185 | None -> mmlwidget#set_selection None
2188 (* STUFF TO BUILD THE GTK INTERFACE *)
2190 (* Stuff for the widget settings *)
2192 let export_to_postscript output =
2193 let lastdir = ref (Unix.getcwd ()) in
2196 GToolbox.select_file ~title:"Export to PostScript"
2197 ~dir:lastdir ~filename:"screenshot.ps" ()
2201 (output :> GMathView.math_view)#export_to_postscript
2202 ~filename:filename ();
2205 let activate_t1 output button_set_anti_aliasing
2206 button_set_transparency export_to_postscript_menu_item
2209 let is_set = button_t1#active in
2210 output#set_font_manager_type
2211 ~fm_type:(if is_set then `font_manager_t1 else `font_manager_gtk) ;
2214 button_set_anti_aliasing#misc#set_sensitive true ;
2215 button_set_transparency#misc#set_sensitive true ;
2216 export_to_postscript_menu_item#misc#set_sensitive true ;
2220 button_set_anti_aliasing#misc#set_sensitive false ;
2221 button_set_transparency#misc#set_sensitive false ;
2222 export_to_postscript_menu_item#misc#set_sensitive false ;
2226 let set_anti_aliasing output button_set_anti_aliasing () =
2227 output#set_anti_aliasing button_set_anti_aliasing#active
2230 let set_transparency output button_set_transparency () =
2231 output#set_transparency button_set_transparency#active
2234 let changefont output font_size_spinb () =
2235 output#set_font_size font_size_spinb#value_as_int
2238 let set_log_verbosity output log_verbosity_spinb () =
2239 output#set_log_verbosity log_verbosity_spinb#value_as_int
2242 class settings_window output sw
2243 export_to_postscript_menu_item selection_changed_callback
2245 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
2247 GPack.vbox ~packing:settings_window#add () in
2250 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2251 ~border_width:5 ~packing:vbox#add () in
2253 GButton.toggle_button ~label:"activate t1 fonts"
2254 ~packing:(table#attach ~left:0 ~top:0) () in
2255 let button_set_anti_aliasing =
2256 GButton.toggle_button ~label:"set_anti_aliasing"
2257 ~packing:(table#attach ~left:0 ~top:1) () in
2258 let button_set_transparency =
2259 GButton.toggle_button ~label:"set_transparency"
2260 ~packing:(table#attach ~left:2 ~top:1) () in
2263 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2264 ~border_width:5 ~packing:vbox#add () in
2265 let font_size_label =
2266 GMisc.label ~text:"font size:"
2267 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
2268 let font_size_spinb =
2270 GData.adjustment ~value:(float_of_int output#get_font_size)
2271 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
2274 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
2275 let log_verbosity_label =
2276 GMisc.label ~text:"log verbosity:"
2277 ~packing:(table#attach ~left:0 ~top:1) () in
2278 let log_verbosity_spinb =
2280 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
2283 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
2285 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2287 GButton.button ~label:"Close"
2288 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2290 method show = settings_window#show
2292 button_set_anti_aliasing#misc#set_sensitive false ;
2293 button_set_transparency#misc#set_sensitive false ;
2294 (* Signals connection *)
2295 ignore(button_t1#connect#clicked
2296 (activate_t1 output button_set_anti_aliasing
2297 button_set_transparency export_to_postscript_menu_item button_t1)) ;
2298 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
2299 ignore(button_set_anti_aliasing#connect#toggled
2300 (set_anti_aliasing output button_set_anti_aliasing));
2301 ignore(button_set_transparency#connect#toggled
2302 (set_transparency output button_set_transparency)) ;
2303 ignore(log_verbosity_spinb#connect#changed
2304 (set_log_verbosity output log_verbosity_spinb)) ;
2305 ignore(closeb#connect#clicked settings_window#misc#hide)
2308 (* Scratch window *)
2310 class scratch_window =
2313 ~title:"MathML viewer"
2314 ~border_width:2 () in
2316 GPack.vbox ~packing:window#add () in
2318 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2320 GButton.button ~label:"Whd"
2321 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2323 GButton.button ~label:"Reduce"
2324 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2326 GButton.button ~label:"Simpl"
2327 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2328 let scrolled_window =
2329 GBin.scrolled_window ~border_width:10
2330 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2331 let sequent_viewer =
2332 TermViewer.sequent_viewer
2333 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
2335 val mutable term = Cic.Rel 1 (* dummy value *)
2336 val mutable context = ([] : Cic.context) (* dummy value *)
2337 val mutable metasenv = ([] : Cic.metasenv) (* dummy value *)
2338 method sequent_viewer = sequent_viewer
2339 method show () = window#misc#hide () ; window#show ()
2341 method set_term t = term <- t
2342 method context = context
2343 method set_context t = context <- t
2344 method metasenv = metasenv
2345 method set_metasenv t = metasenv <- t
2348 (sequent_viewer#connect#selection_changed (choose_selection sequent_viewer));
2349 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
2350 ignore(whdb#connect#clicked InvokeTactics'.whd_in_scratch) ;
2351 ignore(reduceb#connect#clicked InvokeTactics'.reduce_in_scratch) ;
2352 ignore(simplb#connect#clicked InvokeTactics'.simpl_in_scratch)
2355 let open_contextual_menu_for_selected_terms mmlwidget infos =
2356 let button = GdkEvent.Button.button infos in
2357 let terms_selected = List.length mmlwidget#get_selections > 0 in
2360 let time = GdkEvent.Button.time infos in
2361 let menu = GMenu.menu () in
2362 let f = new GMenu.factory menu in
2364 f#add_item "Whd" ~key:GdkKeysyms._W ~callback:InvokeTactics'.whd in
2365 let reduce_menu_item =
2366 f#add_item "Reduce" ~key:GdkKeysyms._R ~callback:InvokeTactics'.reduce in
2367 let simpl_menu_item =
2368 f#add_item "Simpl" ~key:GdkKeysyms._S ~callback:InvokeTactics'.simpl in
2369 let _ = f#add_separator () in
2370 let generalize_menu_item =
2371 f#add_item "Generalize"
2372 ~key:GdkKeysyms._G ~callback:InvokeTactics'.generalize in
2373 let _ = f#add_separator () in
2374 let clear_menu_item =
2375 f#add_item "Clear" ~key:GdkKeysyms._C ~callback:InvokeTactics'.clear in
2376 let clearbody_menu_item =
2377 f#add_item "ClearBody"
2378 ~key:GdkKeysyms._B ~callback:InvokeTactics'.clearbody
2380 whd_menu_item#misc#set_sensitive terms_selected ;
2381 reduce_menu_item#misc#set_sensitive terms_selected ;
2382 simpl_menu_item#misc#set_sensitive terms_selected ;
2383 generalize_menu_item#misc#set_sensitive terms_selected ;
2384 clear_menu_item#misc#set_sensitive terms_selected ;
2385 clearbody_menu_item#misc#set_sensitive terms_selected ;
2386 menu#popup ~button ~time
2392 let vbox1 = GPack.vbox () in
2394 val mutable proofw_ref = None
2395 val mutable compute_ref = None
2397 Lazy.force self#compute ;
2398 match proofw_ref with
2399 None -> assert false
2400 | Some proofw -> proofw
2401 method content = vbox1
2403 match compute_ref with
2404 None -> assert false
2405 | Some compute -> compute
2409 let scrolled_window1 =
2410 GBin.scrolled_window ~border_width:10
2411 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2413 TermViewer.sequent_viewer ~width:400 ~height:275
2414 ~packing:(scrolled_window1#add) () in
2415 let _ = proofw_ref <- Some proofw in
2417 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2419 GButton.button ~label:"Ring"
2420 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2422 GButton.button ~label:"Fourier"
2423 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2425 GButton.button ~label:"Reflexivity"
2426 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2428 GButton.button ~label:"Symmetry"
2429 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2431 GButton.button ~label:"Assumption"
2432 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2433 let contradictionb =
2434 GButton.button ~label:"Contradiction"
2435 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2437 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2439 GButton.button ~label:"Exists"
2440 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2442 GButton.button ~label:"Split"
2443 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2445 GButton.button ~label:"Left"
2446 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2448 GButton.button ~label:"Right"
2449 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2450 let searchpatternb =
2451 GButton.button ~label:"SearchPattern_Apply"
2452 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2454 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2456 GButton.button ~label:"Exact"
2457 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2459 GButton.button ~label:"Intros"
2460 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2462 GButton.button ~label:"Apply"
2463 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2464 let elimintrossimplb =
2465 GButton.button ~label:"ElimIntrosSimpl"
2466 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2468 GButton.button ~label:"ElimType"
2469 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2471 GButton.button ~label:"Fold_whd"
2472 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2474 GButton.button ~label:"Fold_reduce"
2475 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2477 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2479 GButton.button ~label:"Fold_simpl"
2480 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2482 GButton.button ~label:"Cut"
2483 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2485 GButton.button ~label:"Change"
2486 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2488 GButton.button ~label:"Let ... In"
2489 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2491 GButton.button ~label:"RewriteSimpl ->"
2492 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2493 let rewritebacksimplb =
2494 GButton.button ~label:"RewriteSimpl <-"
2495 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2497 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2499 GButton.button ~label:"Absurd"
2500 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2502 GButton.button ~label:"Decompose"
2503 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2505 GButton.button ~label:"Transitivity"
2506 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2508 GButton.button ~label:"Replace"
2509 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2511 GButton.button ~label:"Injection"
2512 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2514 GButton.button ~label:"Discriminate"
2515 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2516 (* Zack: spostare in una toolbar
2518 GButton.button ~label:"Generalize"
2519 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2521 GButton.button ~label:"ClearBody"
2522 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2524 GButton.button ~label:"Clear"
2525 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2527 GButton.button ~label:"Whd"
2528 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2530 GButton.button ~label:"Reduce"
2531 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2533 GButton.button ~label:"Simpl"
2534 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2537 ignore(exactb#connect#clicked InvokeTactics'.exact) ;
2538 ignore(applyb#connect#clicked InvokeTactics'.apply) ;
2539 ignore(elimintrossimplb#connect#clicked InvokeTactics'.elimintrossimpl) ;
2540 ignore(elimtypeb#connect#clicked InvokeTactics'.elimtype) ;
2541 ignore(foldwhdb#connect#clicked InvokeTactics'.fold_whd) ;
2542 ignore(foldreduceb#connect#clicked InvokeTactics'.fold_reduce) ;
2543 ignore(foldsimplb#connect#clicked InvokeTactics'.fold_simpl) ;
2544 ignore(cutb#connect#clicked InvokeTactics'.cut) ;
2545 ignore(changeb#connect#clicked InvokeTactics'.change) ;
2546 ignore(letinb#connect#clicked InvokeTactics'.letin) ;
2547 ignore(ringb#connect#clicked InvokeTactics'.ring) ;
2548 ignore(fourierb#connect#clicked InvokeTactics'.fourier) ;
2549 ignore(rewritesimplb#connect#clicked InvokeTactics'.rewritesimpl) ;
2550 ignore(rewritebacksimplb#connect#clicked InvokeTactics'.rewritebacksimpl) ;
2551 ignore(replaceb#connect#clicked InvokeTactics'.replace) ;
2552 ignore(reflexivityb#connect#clicked InvokeTactics'.reflexivity) ;
2553 ignore(symmetryb#connect#clicked InvokeTactics'.symmetry) ;
2554 ignore(transitivityb#connect#clicked InvokeTactics'.transitivity) ;
2555 ignore(existsb#connect#clicked InvokeTactics'.exists) ;
2556 ignore(splitb#connect#clicked InvokeTactics'.split) ;
2557 ignore(leftb#connect#clicked InvokeTactics'.left) ;
2558 ignore(rightb#connect#clicked InvokeTactics'.right) ;
2559 ignore(assumptionb#connect#clicked InvokeTactics'.assumption) ;
2560 ignore(absurdb#connect#clicked InvokeTactics'.absurd) ;
2561 ignore(contradictionb#connect#clicked InvokeTactics'.contradiction) ;
2562 ignore(introsb#connect#clicked InvokeTactics'.intros) ;
2563 ignore(decomposeb#connect#clicked InvokeTactics'.decompose) ;
2564 ignore(searchpatternb#connect#clicked searchPattern) ;
2565 ignore(injectionb#connect#clicked InvokeTactics'.injection) ;
2566 ignore(discriminateb#connect#clicked InvokeTactics'.discriminate) ;
2567 (* Zack: spostare in una toolbar
2568 ignore(whdb#connect#clicked whd) ;
2569 ignore(reduceb#connect#clicked reduce) ;
2570 ignore(simplb#connect#clicked simpl) ;
2571 ignore(clearbodyb#connect#clicked clearbody) ;
2572 ignore(clearb#connect#clicked clear) ;
2573 ignore(generalizeb#connect#clicked generalize) ;
2575 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
2577 ((new GObj.event_ops proofw#as_widget)#connect#button_press
2578 (open_contextual_menu_for_selected_terms proofw)) ;
2584 let vbox1 = GPack.vbox () in
2585 let scrolled_window1 =
2586 GBin.scrolled_window ~border_width:10
2587 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2589 TermViewer.sequent_viewer ~width:400 ~height:275
2590 ~packing:(scrolled_window1#add) () in
2592 method proofw = (assert false : TermViewer.sequent_viewer)
2593 method content = vbox1
2594 method compute = (assert false : unit)
2598 let empty_page = new empty_page;;
2602 val notebook = GPack.notebook ()
2604 val mutable skip_switch_page_event = false
2605 val mutable empty = true
2606 method notebook = notebook
2608 let new_page = new page () in
2610 pages := !pages @ [n,lazy (setgoal n),new_page] ;
2611 notebook#append_page
2612 ~tab_label:((GMisc.label ~text:("?" ^ string_of_int n) ())#coerce)
2613 new_page#content#coerce
2614 method remove_all_pages ~skip_switch_page_event:skip =
2616 notebook#remove_page 0 (* let's remove the empty page *)
2618 List.iter (function _ -> notebook#remove_page 0) !pages ;
2620 skip_switch_page_event <- skip
2621 method set_current_page ~may_skip_switch_page_event n =
2622 let (_,_,page) = List.find (function (m,_,_) -> m=n) !pages in
2623 let new_page = notebook#page_num page#content#coerce in
2624 if may_skip_switch_page_event && new_page <> notebook#current_page then
2625 skip_switch_page_event <- true ;
2626 notebook#goto_page new_page
2627 method set_empty_page =
2630 notebook#append_page
2631 ~tab_label:((GMisc.label ~text:"No proof in progress" ())#coerce)
2632 empty_page#content#coerce
2634 let (_,_,page) = List.nth !pages notebook#current_page in
2638 (notebook#connect#switch_page
2640 let skip = skip_switch_page_event in
2641 skip_switch_page_event <- false ;
2644 let (metano,setgoal,page) = List.nth !pages i in
2645 ProofEngine.goal := Some metano ;
2646 Lazy.force (page#compute) ;
2656 class rendering_window output (notebook : notebook) =
2657 let scratch_window = new scratch_window in
2660 ~title:"gTopLevel - Helm's Proof Assistant"
2661 ~border_width:0 ~allow_shrink:false () in
2662 let vbox_for_menu = GPack.vbox ~packing:window#add () in
2664 let handle_box = GBin.handle_box ~border_width:2
2665 ~packing:(vbox_for_menu#pack ~padding:0) () in
2666 let menubar = GMenu.menu_bar ~packing:handle_box#add () in
2667 let factory0 = new GMenu.factory menubar in
2668 let accel_group = factory0#accel_group in
2670 let file_menu = factory0#add_submenu "File" in
2671 let factory1 = new GMenu.factory file_menu ~accel_group in
2672 let export_to_postscript_menu_item =
2675 factory1#add_item "New Block of (Co)Inductive Definitions..."
2676 ~key:GdkKeysyms._B ~callback:new_inductive
2679 factory1#add_item "New Proof or Definition..." ~key:GdkKeysyms._N
2682 let reopen_menu_item =
2683 factory1#add_item "Reopen a Finished Proof..." ~key:GdkKeysyms._R
2687 factory1#add_item "Qed" ~key:GdkKeysyms._E ~callback:qed in
2688 ignore (factory1#add_separator ()) ;
2690 (factory1#add_item "Load Unfinished Proof..." ~key:GdkKeysyms._L
2691 ~callback:load_unfinished_proof) ;
2692 let save_menu_item =
2693 factory1#add_item "Save Unfinished Proof" ~key:GdkKeysyms._S
2694 ~callback:save_unfinished_proof
2697 (save_set_sensitive := function b -> save_menu_item#misc#set_sensitive b);
2698 ignore (!save_set_sensitive false);
2699 ignore (qed_set_sensitive:=function b -> qed_menu_item#misc#set_sensitive b);
2700 ignore (!qed_set_sensitive false);
2701 ignore (factory1#add_separator ()) ;
2702 let export_to_postscript_menu_item =
2703 factory1#add_item "Export to PostScript..."
2704 ~callback:(export_to_postscript output) in
2705 ignore (factory1#add_separator ()) ;
2707 (factory1#add_item "Exit" ~key:GdkKeysyms._Q ~callback:GMain.Main.quit) ;
2708 export_to_postscript_menu_item
2711 let edit_menu = factory0#add_submenu "Edit Current Proof" in
2712 let factory2 = new GMenu.factory edit_menu ~accel_group in
2713 let focus_and_proveit_set_sensitive = ref (function _ -> assert false) in
2714 let proveit_menu_item =
2715 factory2#add_item "Prove It" ~key:GdkKeysyms._I
2716 ~callback:(function () -> proveit ();!focus_and_proveit_set_sensitive false)
2718 let focus_menu_item =
2719 factory2#add_item "Focus" ~key:GdkKeysyms._F
2720 ~callback:(function () -> focus () ; !focus_and_proveit_set_sensitive false)
2723 focus_and_proveit_set_sensitive :=
2725 proveit_menu_item#misc#set_sensitive b ;
2726 focus_menu_item#misc#set_sensitive b
2728 let _ = !focus_and_proveit_set_sensitive false in
2729 (* edit term menu *)
2730 let edit_term_menu = factory0#add_submenu "Edit Term" in
2731 let factory5 = new GMenu.factory edit_term_menu ~accel_group in
2732 let check_menu_item =
2733 factory5#add_item "Check Term" ~key:GdkKeysyms._C
2734 ~callback:(check scratch_window) in
2735 let _ = check_menu_item#misc#set_sensitive false in
2737 let search_menu = factory0#add_submenu "Search" in
2738 let factory4 = new GMenu.factory search_menu ~accel_group in
2740 factory4#add_item "Locate..." ~key:GdkKeysyms._T
2742 let searchPattern_menu_item =
2743 factory4#add_item "SearchPattern..." ~key:GdkKeysyms._D
2744 ~callback:completeSearchPattern in
2745 let _ = searchPattern_menu_item#misc#set_sensitive false in
2746 let show_menu_item =
2747 factory4#add_item "Show..." ~key:GdkKeysyms._H ~callback:show
2749 let insert_query_item =
2750 factory4#add_item "Insert Query (Experts Only)..." ~key:GdkKeysyms._Y
2751 ~callback:insertQuery in
2753 let hbugs_menu = factory0#add_submenu "HBugs" in
2754 let factory6 = new GMenu.factory hbugs_menu ~accel_group in
2756 factory6#add_check_item
2757 ~active:false ~key:GdkKeysyms._F5 ~callback:Hbugs.toggle "HBugs enabled"
2759 let _ = factory6#add_item ~callback:Hbugs.notify "(Re)Submit status!" in
2760 let _ = factory6#add_separator () in
2762 factory6#add_item ~callback:Hbugs.start_web_services "Start Web Services"
2765 factory6#add_item ~callback:Hbugs.stop_web_services "Stop Web Services"
2768 let settings_menu = factory0#add_submenu "Settings" in
2769 let factory3 = new GMenu.factory settings_menu ~accel_group in
2771 factory3#add_item "Edit Aliases..." ~key:GdkKeysyms._A
2772 ~callback:edit_aliases in
2773 let _ = factory3#add_separator () in
2775 factory3#add_item "MathML Widget Preferences..." ~key:GdkKeysyms._P
2776 ~callback:(function _ -> (settings_window ())#show ()) in
2777 let _ = factory3#add_separator () in
2779 factory3#add_item "Reload Stylesheets"
2782 ApplyStylesheets.reload_stylesheets () ;
2783 if !ProofEngine.proof <> None then
2785 refresh_goals notebook ;
2786 refresh_proof output
2788 InvokeTactics.RefreshSequentException e ->
2789 output_html (outputhtml ())
2790 ("<h1 color=\"red\">An error occurred while refreshing the " ^
2791 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
2792 (*notebook#remove_all_pages ~skip_switch_page_event:false ;*)
2793 notebook#set_empty_page
2794 | InvokeTactics.RefreshProofException e ->
2795 output_html (outputhtml ())
2796 ("<h1 color=\"red\">An error occurred while refreshing the proof: " ^ Printexc.to_string e ^ "</h1>") ;
2800 let _ = window#add_accel_group accel_group in
2804 ~packing:(vbox_for_menu#pack ~expand:true ~fill:true ~padding:5) () in
2806 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2807 let scrolled_window0 =
2808 GBin.scrolled_window ~border_width:10
2809 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2810 let _ = scrolled_window0#add output#coerce in
2812 GBin.frame ~label:"Insert Term"
2813 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2814 let scrolled_window1 =
2815 GBin.scrolled_window ~border_width:5
2816 ~packing:frame#add () in
2818 TexTermEditor'.term_editor
2820 ~width:400 ~height:100 ~packing:scrolled_window1#add ()
2821 ~isnotempty_callback:
2823 check_menu_item#misc#set_sensitive b ;
2824 searchPattern_menu_item#misc#set_sensitive b) in
2826 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2828 vboxl#pack ~expand:true ~fill:true ~padding:5 notebook#notebook#coerce in
2830 GBin.frame ~shadow_type:`IN ~packing:(vboxl#pack ~expand:true ~padding:5) ()
2834 ~source:"<html><body bgColor=\"white\"></body></html>"
2835 ~width:400 ~height: 100
2840 method outputhtml = outputhtml
2841 method inputt = inputt
2842 method output = (output : TermViewer.proof_viewer)
2843 method scratch_window = scratch_window
2844 method notebook = notebook
2845 method show = window#show
2847 notebook#set_empty_page ;
2848 export_to_postscript_menu_item#misc#set_sensitive false ;
2849 check_term := (check_term_in_scratch scratch_window) ;
2851 (* signal handlers here *)
2852 ignore(output#connect#selection_changed
2854 choose_selection output elem ;
2855 !focus_and_proveit_set_sensitive true
2857 ignore (output#connect#click (show_in_show_window_callback output)) ;
2858 let settings_window = new settings_window output scrolled_window0
2859 export_to_postscript_menu_item (choose_selection output) in
2860 set_settings_window settings_window ;
2861 set_outputhtml outputhtml ;
2862 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
2863 Logger.log_callback :=
2864 (Logger.log_to_html ~print_and_flush:(output_html outputhtml))
2869 let initialize_everything () =
2870 let module U = Unix in
2871 let output = TermViewer.proof_viewer ~width:350 ~height:280 () in
2872 let notebook = new notebook in
2873 let rendering_window' = new rendering_window output notebook in
2874 set_rendering_window rendering_window' ;
2875 let print_error_as_html prefix msg =
2876 output_html (outputhtml ())
2877 ("<h1 color=\"red\">" ^ prefix ^ msg ^ "</h1>")
2879 Gdome_xslt.setErrorCallback (Some (print_error_as_html "XSLT Error: "));
2880 Gdome_xslt.setDebugCallback
2881 (Some (print_error_as_html "XSLT Debug Message: "));
2882 rendering_window'#show () ;
2883 (* Hbugs.toggle true; *)
2888 ignore (GtkMain.Main.init ()) ;
2889 initialize_everything () ;
2890 MQIC.close mqi_handle;
2895 Sys.catch_break true;
2897 with Sys.Break -> () (* exit nicely, invoking at_exit functions *)