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
220 (function i -> Lazy.force (List.nth render_terms i)))
226 interactive_user_uri_choice ~(selection_mode:[`SINGLE|`EXTENDED]) ?(ok="Ok")
227 ?(enable_button_for_non_vars=false) ~title ~msg uris
229 let choices = ref [] in
230 let chosen = ref false in
231 let use_only_constants = ref false in
233 GWindow.dialog ~modal:true ~title ~width:600 () in
235 GMisc.label ~text:msg
236 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
237 let scrolled_window =
238 GBin.scrolled_window ~border_width:10
239 ~packing:(window#vbox#pack ~expand:true ~fill:true ~padding:5) () in
241 let expected_height = 18 * List.length uris in
242 let height = if expected_height > 400 then 400 else expected_height in
243 GList.clist ~columns:1 ~packing:scrolled_window#add
244 ~height ~selection_mode:(selection_mode :> Gtk.Tags.selection_mode) () in
245 let _ = List.map (function x -> clist#append [x]) uris in
247 GPack.hbox ~border_width:0
248 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
250 GMisc.label ~text:"None of the above. Try this one:"
251 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
253 GEdit.entry ~editable:true
254 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
256 GPack.hbox ~border_width:0 ~packing:window#action_area#add () in
258 GButton.button ~label:ok
259 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
260 let _ = okb#misc#set_sensitive false in
265 if enable_button_for_non_vars then
266 hbox#pack ~expand:false ~fill:false ~padding:5 w)
267 ~label:"Try constants only" () in
269 GButton.button ~label:"Check"
270 ~packing:(hbox#pack ~padding:5) () in
271 let _ = checkb#misc#set_sensitive false in
273 GButton.button ~label:"Abort"
274 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
276 let check_callback () =
277 assert (List.length !choices > 0) ;
278 check_window (outputhtml ()) !choices
280 ignore (window#connect#destroy GMain.Main.quit) ;
281 ignore (cancelb#connect#clicked window#destroy) ;
283 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
285 (nonvarsb#connect#clicked
287 use_only_constants := true ;
291 ignore (checkb#connect#clicked check_callback) ;
293 (clist#connect#select_row
294 (fun ~row ~column ~event ->
295 checkb#misc#set_sensitive true ;
296 okb#misc#set_sensitive true ;
297 choices := (List.nth uris row)::!choices)) ;
299 (clist#connect#unselect_row
300 (fun ~row ~column ~event ->
302 List.filter (function uri -> uri != (List.nth uris row)) !choices)) ;
304 (manual_input#connect#changed
306 if manual_input#text = "" then
309 checkb#misc#set_sensitive false ;
310 okb#misc#set_sensitive false ;
311 clist#misc#set_sensitive true
315 choices := [manual_input#text] ;
316 clist#unselect_all () ;
317 checkb#misc#set_sensitive true ;
318 okb#misc#set_sensitive true ;
319 clist#misc#set_sensitive false
321 window#set_position `CENTER ;
325 if !use_only_constants then
327 (function uri -> not (String.sub uri (String.length uri - 4) 4 = ".var"))
330 if List.length !choices > 0 then !choices else raise NoChoice
335 let interactive_interpretation_choice interpretations =
336 let chosen = ref None in
339 ~modal:true ~title:"Ambiguous well-typed input." ~border_width:2 () in
340 let vbox = GPack.vbox ~packing:window#add () in
344 ("Ambiguous input since there are many well-typed interpretations." ^
345 " Please, choose one of them.")
346 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
348 GPack.notebook ~scrollable:true
349 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
352 (function interpretation ->
354 let expected_height = 18 * List.length interpretation in
355 let height = if expected_height > 400 then 400 else expected_height in
356 GList.clist ~columns:2 ~packing:notebook#append_page ~height
357 ~titles:["id" ; "URI"] ()
361 (function (id,uri) ->
362 let n = clist#append [id;uri] in
363 clist#set_row ~selectable:false n
366 clist#columns_autosize ()
369 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
371 GButton.button ~label:"Ok"
372 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
374 GButton.button ~label:"Abort"
375 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
377 ignore (window#connect#destroy GMain.Main.quit) ;
378 ignore (cancelb#connect#clicked window#destroy) ;
381 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
382 window#set_position `CENTER ;
386 None -> raise NoChoice
394 save_object_to_disk uri annobj ids_to_inner_sorts ids_to_inner_types pathname
397 let struri = UriManager.string_of_uri uri in
398 let idx = (String.rindex struri '/') + 1 in
399 String.sub struri idx (String.length struri - idx)
401 let path = pathname ^ "/" ^ name in
403 Cic2Xml.print_object uri ~ids_to_inner_sorts ~ask_dtd_to_the_getter:false
407 Cic2Xml.print_inner_types uri ~ids_to_inner_sorts ~ids_to_inner_types
408 ~ask_dtd_to_the_getter:false
411 let innertypesuri = UriManager.innertypesuri_of_uri uri in
412 Xml.pp ~quiet:true xmlinnertypes (Some (path ^ ".types.xml")) ;
413 Getter.register innertypesuri
414 (Configuration.annotations_url ^
415 Str.replace_first (Str.regexp "^cic:") ""
416 (UriManager.string_of_uri innertypesuri) ^ ".xml"
418 (* constant type / variable / mutual inductive types definition *)
419 Xml.pp ~quiet:true xml (Some (path ^ ".xml")) ;
421 (Configuration.annotations_url ^
422 Str.replace_first (Str.regexp "^cic:") ""
423 (UriManager.string_of_uri uri) ^ ".xml"
430 match UriManager.bodyuri_of_uri uri with
432 | Some bodyuri -> bodyuri
434 Xml.pp ~quiet:true bodyxml' (Some (path ^ ".body.xml")) ;
435 Getter.register bodyuri
436 (Configuration.annotations_url ^
437 Str.replace_first (Str.regexp "^cic:") ""
438 (UriManager.string_of_uri bodyuri) ^ ".xml"
445 exception OpenConjecturesStillThere;;
446 exception WrongProof;;
448 let pathname_of_annuri uristring =
449 Configuration.annotations_dir ^
450 Str.replace_first (Str.regexp "^cic:") "" uristring
453 let make_dirs dirpath =
454 ignore (Unix.system ("mkdir -p " ^ dirpath))
457 let save_obj uri obj =
459 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
460 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
462 Cic2acic.acic_object_of_cic_object obj
464 (* let's save the theorem and register it to the getter *)
465 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
467 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
472 match !ProofEngine.proof with
474 | Some (uri,[],bo,ty) ->
476 CicReduction.are_convertible []
477 (CicTypeChecker.type_of_aux' [] [] bo) ty
480 (*CSC: Wrong: [] is just plainly wrong *)
481 let proof = Cic.Constant (UriManager.name_of_uri uri,Some bo,ty,[]) in
482 let (acic,ids_to_inner_types,ids_to_inner_sorts) =
483 (rendering_window ())#output#load_proof uri proof
485 !qed_set_sensitive false ;
486 (* let's save the theorem and register it to the getter *)
487 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
489 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
494 | _ -> raise OpenConjecturesStillThere
497 (** save an unfinished proof on the filesystem *)
498 let save_unfinished_proof () =
499 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
500 let (xml, bodyxml) = ProofEngine.get_current_status_as_xml () in
501 Xml.pp ~quiet:true xml (Some prooffiletype) ;
502 output_html outputhtml
503 ("<h1 color=\"Green\">Current proof type saved to " ^
504 prooffiletype ^ "</h1>") ;
505 Xml.pp ~quiet:true bodyxml (Some prooffile) ;
506 output_html outputhtml
507 ("<h1 color=\"Green\">Current proof body saved to " ^
511 (* Used to typecheck the loaded proofs *)
512 let typecheck_loaded_proof metasenv bo ty =
513 let module T = CicTypeChecker in
516 (fun metasenv ((_,context,ty) as conj) ->
517 ignore (T.type_of_aux' metasenv context ty) ;
520 ignore (T.type_of_aux' metasenv [] ty) ;
521 ignore (T.type_of_aux' metasenv [] bo)
524 let decompose_uris_choice_callback uris =
525 (* N.B.: in questo passaggio perdo l'informazione su exp_named_subst !!!! *)
526 let module U = UriManager in
529 match MQueryMisc.cic_textual_parser_uri_of_string uri with
530 CicTextualParser0.IndTyUri (uri,typeno) -> (uri,typeno,[])
532 (interactive_user_uri_choice
533 ~selection_mode:`EXTENDED ~ok:"Ok" ~enable_button_for_non_vars:false
534 ~title:"Decompose" ~msg:"Please, select the Inductive Types to decompose"
536 (function (uri,typeno,_) ->
537 U.string_of_uri uri ^ "#1/" ^ string_of_int (typeno+1)
542 let mk_fresh_name_callback context name ~typ =
544 match ProofEngineHelpers.mk_fresh_name context name ~typ with
545 Cic.Name fresh_name -> fresh_name
546 | Cic.Anonymous -> assert false
549 GToolbox.input_string ~title:"Enter a fresh hypothesis name" ~text:fresh_name
550 ("Enter a fresh name for the hypothesis " ^
552 (List.map (function None -> None | Some (n,_) -> Some n) context))
554 Some fresh_name' -> Cic.Name fresh_name'
555 | None -> raise NoChoice
558 let refresh_proof (output : TermViewer.proof_viewer) =
560 let uri,currentproof =
561 match !ProofEngine.proof with
563 | Some (uri,metasenv,bo,ty) ->
564 ProofEngine.proof := Some(uri,metasenv,bo,ty);
565 if List.length metasenv = 0 then
567 !qed_set_sensitive true ;
568 prerr_endline "CSC: ###### REFRESH_PROOF, Hbugs.clear ()" ;
573 prerr_endline "CSC: ###### REFRESH_PROOF, Hbugs.notify ()" ;
576 (*CSC: Wrong: [] is just plainly wrong *)
578 (Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, []))
580 ignore (output#load_proof uri currentproof)
583 match !ProofEngine.proof with
585 | Some (uri,metasenv,bo,ty) ->
586 prerr_endline ("Offending proof: " ^ CicPp.ppobj (Cic.CurrentProof ("questa",metasenv,bo,ty,[]))) ; flush stderr ;
587 raise (InvokeTactics.RefreshProofException e)
589 let refresh_goals ?(empty_notebook=true) notebook =
591 match !ProofEngine.goal with
593 if empty_notebook then
595 notebook#remove_all_pages ~skip_switch_page_event:false ;
596 notebook#set_empty_page
599 notebook#proofw#unload
602 match !ProofEngine.proof with
604 | Some (_,metasenv,_,_) -> metasenv
607 List.find (function (m,_,_) -> m=metano) metasenv
609 let regenerate_notebook () =
610 let skip_switch_page_event =
612 (m,_,_)::_ when m = metano -> false
615 notebook#remove_all_pages ~skip_switch_page_event ;
616 List.iter (function (m,_,_) -> notebook#add_page m) metasenv ;
618 if empty_notebook then
620 regenerate_notebook () ;
621 notebook#set_current_page
622 ~may_skip_switch_page_event:false metano
626 notebook#set_current_page
627 ~may_skip_switch_page_event:true metano ;
628 notebook#proofw#load_sequent metasenv currentsequent
633 match !ProofEngine.goal with
638 match !ProofEngine.proof with
640 | Some (_,metasenv,_,_) -> metasenv
643 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
644 prerr_endline ("Offending sequent: " ^ SequentPp.TextualPp.print_sequent currentsequent) ; flush stderr ;
645 raise (InvokeTactics.RefreshSequentException e)
646 with Not_found -> prerr_endline ("Offending sequent " ^ string_of_int metano ^ " unknown."); raise (InvokeTactics.RefreshSequentException e)
648 module InvokeTacticsCallbacks =
650 let sequent_viewer () = (rendering_window ())#notebook#proofw
651 let term_editor () = (rendering_window ())#inputt
652 let scratch_window () = (rendering_window ())#scratch_window
654 let refresh_proof () =
655 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
658 let refresh_goals () =
659 let notebook = (rendering_window ())#notebook in
660 refresh_goals notebook
662 let decompose_uris_choice_callback = decompose_uris_choice_callback
663 let mk_fresh_name_callback = mk_fresh_name_callback
664 let output_html msg = output_html (outputhtml ()) msg
667 module InvokeTactics' = InvokeTactics.Make (InvokeTacticsCallbacks);;
668 (* Just to initialize the Hbugs module *)
669 module Ignore = Hbugs.Initialize (InvokeTactics');;
671 (** load an unfinished proof from filesystem *)
672 let load_unfinished_proof () =
673 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
674 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
675 let notebook = (rendering_window ())#notebook in
678 GToolbox.input_string ~title:"Load Unfinished Proof" ~text:"/dummy.con"
681 None -> raise NoChoice
683 let uri = UriManager.uri_of_string ("cic:" ^ uri0) in
684 match CicParser.obj_of_xml prooffiletype (Some prooffile) with
685 Cic.CurrentProof (_,metasenv,bo,ty,_) ->
686 typecheck_loaded_proof metasenv bo ty ;
688 Some (uri, metasenv, bo, ty) ;
692 | (metano,_,_)::_ -> Some metano
694 refresh_proof output ;
695 refresh_goals notebook ;
696 output_html outputhtml
697 ("<h1 color=\"Green\">Current proof type loaded from " ^
698 prooffiletype ^ "</h1>") ;
699 output_html outputhtml
700 ("<h1 color=\"Green\">Current proof body loaded from " ^
701 prooffile ^ "</h1>") ;
702 !save_set_sensitive true;
705 InvokeTactics.RefreshSequentException e ->
706 output_html outputhtml
707 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
708 "sequent: " ^ Printexc.to_string e ^ "</h1>")
709 | InvokeTactics.RefreshProofException e ->
710 output_html outputhtml
711 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
712 "proof: " ^ Printexc.to_string e ^ "</h1>")
714 output_html outputhtml
715 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
718 let edit_aliases () =
719 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
720 let id_to_uris = inputt#id_to_uris in
721 let chosen = ref false in
724 ~width:400 ~modal:true ~title:"Edit Aliases..." ~border_width:2 () in
726 GPack.vbox ~border_width:0 ~packing:window#add () in
727 let scrolled_window =
728 GBin.scrolled_window ~border_width:10
729 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
730 let input = GEdit.text ~editable:true ~width:400 ~height:100
731 ~packing:scrolled_window#add () in
733 GPack.hbox ~border_width:0
734 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
736 GButton.button ~label:"Ok"
737 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
739 GButton.button ~label:"Cancel"
740 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
741 ignore (window#connect#destroy GMain.Main.quit) ;
742 ignore (cancelb#connect#clicked window#destroy) ;
744 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
745 let dom,resolve_id = !id_to_uris in
747 (input#insert_text ~pos:0
752 match resolve_id v with
754 | Some (CicTextualParser0.Uri uri) -> uri
755 | Some (CicTextualParser0.Term _)
756 | Some CicTextualParser0.Implicit -> assert false
760 CicTextualParser0.Id id -> id
761 | CicTextualParser0.Symbol (descr,_) ->
762 (* CSC: To be implemented *)
764 )^ " " ^ (string_of_cic_textual_parser_uri uri)
770 let inputtext = input#get_chars 0 input#length in
772 let alfa = "[a-zA-Z_-]" in
773 let digit = "[0-9]" in
774 let ident = alfa ^ "\(" ^ alfa ^ "\|" ^ digit ^ "\)*" in
775 let blanks = "\( \|\t\|\n\)+" in
776 let nonblanks = "[^ \t\n]+" in
777 let uri = "/\(" ^ ident ^ "/\)*" ^ nonblanks in (* not very strict check *)
779 ("alias" ^ blanks ^ "\(" ^ ident ^ "\)" ^ blanks ^ "\(" ^ uri ^ "\)")
783 let n' = Str.search_forward regexpr inputtext n in
784 let id = CicTextualParser0.Id (Str.matched_group 2 inputtext) in
786 MQueryMisc.cic_textual_parser_uri_of_string
787 ("cic:" ^ (Str.matched_group 5 inputtext))
789 let dom,resolve_id = aux (n' + 1) in
790 if List.mem id dom then
796 Some (CicTextualParser0.Uri uri)
799 Not_found -> TermEditor.empty_id_to_uris
803 id_to_uris := (dom,resolve_id)
807 let module L = LogicalOperations in
808 let module G = Gdome in
809 let notebook = (rendering_window ())#notebook in
810 let output = (rendering_window ())#output in
811 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
813 output#make_sequent_of_selected_term ;
814 refresh_proof output ;
815 refresh_goals notebook
817 InvokeTactics.RefreshSequentException e ->
818 output_html outputhtml
819 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
820 "sequent: " ^ Printexc.to_string e ^ "</h1>")
821 | InvokeTactics.RefreshProofException e ->
822 output_html outputhtml
823 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
824 "proof: " ^ Printexc.to_string e ^ "</h1>")
826 output_html outputhtml
827 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
831 let module L = LogicalOperations in
832 let module G = Gdome in
833 let notebook = (rendering_window ())#notebook in
834 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
835 let output = (rendering_window ())#output in
837 output#focus_sequent_of_selected_term ;
838 refresh_goals notebook
840 InvokeTactics.RefreshSequentException e ->
841 output_html outputhtml
842 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
843 "sequent: " ^ Printexc.to_string e ^ "</h1>")
844 | InvokeTactics.RefreshProofException e ->
845 output_html outputhtml
846 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
847 "proof: " ^ Printexc.to_string e ^ "</h1>")
849 output_html outputhtml
850 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
853 exception NoPrevGoal;;
854 exception NoNextGoal;;
857 let module L = LogicalOperations in
858 let module G = Gdome in
859 let notebook = (rendering_window ())#notebook in
860 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
862 match !ProofEngine.proof with
864 | Some (_,metasenv,_,_) -> metasenv
867 refresh_goals ~empty_notebook:false notebook
869 InvokeTactics.RefreshSequentException e ->
870 output_html outputhtml
871 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
872 "sequent: " ^ Printexc.to_string e ^ "</h1>")
874 output_html outputhtml
875 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
879 show_in_show_window_obj, show_in_show_window_uri, show_in_show_window_callback
882 GWindow.window ~width:800 ~border_width:2 () in
883 let scrolled_window =
884 GBin.scrolled_window ~border_width:10 ~packing:window#add () in
886 GMathViewAux.single_selection_math_view
887 ~packing:scrolled_window#add ~width:600 ~height:400 ()
889 let _ = window#event#connect#delete (fun _ -> window#misc#hide () ; true ) in
890 let href = Gdome.domString "href" in
891 let show_in_show_window_obj uri obj =
892 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
895 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
896 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
898 Cic2acic.acic_object_of_cic_object obj
901 ApplyStylesheets.mml_of_cic_object
902 ~explode_all:false uri acic ids_to_inner_sorts ids_to_inner_types
904 window#set_title (UriManager.string_of_uri uri) ;
905 window#misc#hide () ; window#show () ;
906 mmlwidget#load_doc mml ;
909 output_html outputhtml
910 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
912 let show_in_show_window_uri uri =
913 let obj = CicEnvironment.get_obj uri in
914 show_in_show_window_obj uri obj
916 let show_in_show_window_callback mmlwidget (n : Gdome.element option) _ =
920 if n'#hasAttributeNS ~namespaceURI:xlinkns ~localName:href then
922 (n'#getAttributeNS ~namespaceURI:xlinkns ~localName:href)#to_string
924 show_in_show_window_uri (UriManager.uri_of_string uri)
926 ignore (mmlwidget#action_toggle n')
929 mmlwidget#connect#click (show_in_show_window_callback mmlwidget)
931 show_in_show_window_obj, show_in_show_window_uri,
932 show_in_show_window_callback
935 exception NoObjectsLocated;;
937 let user_uri_choice ~title ~msg uris =
940 [] -> raise NoObjectsLocated
944 interactive_user_uri_choice ~selection_mode:`SINGLE ~title ~msg uris
949 String.sub uri 4 (String.length uri - 4)
952 let locate_callback id =
953 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
954 let out = output_html outputhtml in
955 let query = MQG.locate id in
956 let result = MQI.execute mqi_handle query in
960 MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format' uri)
962 out "<h1>Locate Query: </h1><pre>";
963 MQueryUtil.text_of_query out query "";
964 out "<h1>Result:</h1>";
965 MQueryUtil.text_of_result out result "<br>";
966 user_uri_choice ~title:"Ambiguous input."
968 ("Ambiguous input \"" ^ id ^
969 "\". Please, choose one interpetation:")
974 let input_or_locate_uri ~title =
975 let uri = ref None in
978 ~width:400 ~modal:true ~title ~border_width:2 () in
979 let vbox = GPack.vbox ~packing:window#add () in
981 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
983 GMisc.label ~text:"Enter a valid URI:" ~packing:(hbox1#pack ~padding:5) () in
985 GEdit.entry ~editable:true
986 ~packing:(hbox1#pack ~expand:true ~fill:true ~padding:5) () in
988 GButton.button ~label:"Check"
989 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
990 let _ = checkb#misc#set_sensitive false in
992 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
994 GMisc.label ~text:"You can also enter an indentifier to locate:"
995 ~packing:(hbox2#pack ~padding:5) () in
997 GEdit.entry ~editable:true
998 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1000 GButton.button ~label:"Locate"
1001 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1002 let _ = locateb#misc#set_sensitive false in
1004 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1006 GButton.button ~label:"Ok"
1007 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1008 let _ = okb#misc#set_sensitive false in
1010 GButton.button ~label:"Cancel"
1011 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) ()
1013 ignore (window#connect#destroy GMain.Main.quit) ;
1015 (cancelb#connect#clicked (function () -> uri := None ; window#destroy ())) ;
1016 let check_callback () =
1017 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1018 let uri = "cic:" ^ manual_input#text in
1020 ignore (Getter.resolve (UriManager.uri_of_string uri)) ;
1021 output_html outputhtml "<h1 color=\"Green\">OK</h1>" ;
1024 Getter.Unresolved ->
1025 output_html outputhtml
1026 ("<h1 color=\"Red\">URI " ^ uri ^
1027 " does not correspond to any object.</h1>") ;
1029 | UriManager.IllFormedUri _ ->
1030 output_html outputhtml
1031 ("<h1 color=\"Red\">URI " ^ uri ^ " is not well-formed.</h1>") ;
1034 output_html outputhtml
1035 ("<h1 color=\"Red\">" ^ Printexc.to_string e ^ "</h1>") ;
1039 (okb#connect#clicked
1041 if check_callback () then
1043 uri := Some manual_input#text ;
1047 ignore (checkb#connect#clicked (function () -> ignore (check_callback ()))) ;
1049 (manual_input#connect#changed
1051 if manual_input#text = "" then
1053 checkb#misc#set_sensitive false ;
1054 okb#misc#set_sensitive false
1058 checkb#misc#set_sensitive true ;
1059 okb#misc#set_sensitive true
1062 (locate_input#connect#changed
1063 (fun _ -> locateb#misc#set_sensitive (locate_input#text <> ""))) ;
1065 (locateb#connect#clicked
1067 let id = locate_input#text in
1068 manual_input#set_text (locate_callback id) ;
1069 locate_input#delete_text 0 (String.length id)
1074 None -> raise NoChoice
1075 | Some uri -> UriManager.uri_of_string ("cic:" ^ uri)
1078 exception AmbiguousInput;;
1080 (* A WIDGET TO ENTER CIC TERMS *)
1082 module ChosenTermEditor = TexTermEditor;;
1083 module ChosenTextualParser0 = TexCicTextualParser0;;
1085 module ChosenTermEditor = TermEditor;;
1086 module ChosenTextualParser0 = CicTextualParser0;;
1091 let get_metasenv () = !ChosenTextualParser0.metasenv
1092 let set_metasenv metasenv = ChosenTextualParser0.metasenv := metasenv
1094 let output_html msg = output_html (outputhtml ()) msg;;
1095 let interactive_user_uri_choice =
1096 fun ~selection_mode ?ok ?enable_button_for_non_vars ~title ~msg ~id ->
1097 interactive_user_uri_choice ~selection_mode ?ok
1098 ?enable_button_for_non_vars ~title ~msg;;
1099 let interactive_interpretation_choice = interactive_interpretation_choice;;
1100 let input_or_locate_uri = input_or_locate_uri;;
1104 module TexTermEditor' = ChosenTermEditor.Make(Callbacks);;
1106 (* OTHER FUNCTIONS *)
1109 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1110 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1113 GToolbox.input_string ~title:"Locate" "Enter an identifier to locate:"
1115 None -> raise NoChoice
1117 let uri = locate_callback input in
1121 output_html outputhtml
1122 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
1126 exception UriAlreadyInUse;;
1127 exception NotAUriToAConstant;;
1129 let new_inductive () =
1130 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1131 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1132 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1133 let notebook = (rendering_window ())#notebook in
1135 let chosen = ref false in
1136 let inductive = ref true in
1137 let paramsno = ref 0 in
1138 let get_uri = ref (function _ -> assert false) in
1139 let get_base_uri = ref (function _ -> assert false) in
1140 let get_names = ref (function _ -> assert false) in
1141 let get_types_and_cons = ref (function _ -> assert false) in
1142 let get_context_and_subst = ref (function _ -> assert false) in
1145 ~width:600 ~modal:true ~position:`CENTER
1146 ~title:"New Block of Mutual (Co)Inductive Definitions"
1147 ~border_width:2 () in
1148 let vbox = GPack.vbox ~packing:window#add () in
1150 GPack.hbox ~border_width:0
1151 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1153 GMisc.label ~text:"Enter the URI for the new block:"
1154 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1156 GEdit.entry ~editable:true
1157 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1159 GPack.hbox ~border_width:0
1160 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1164 "Enter the number of left parameters in every arity and constructor type:"
1165 ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1166 let paramsno_entry =
1167 GEdit.entry ~editable:true ~text:"0"
1168 ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
1170 GPack.hbox ~border_width:0
1171 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1173 GMisc.label ~text:"Are the definitions inductive or coinductive?"
1174 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1176 GButton.radio_button ~label:"Inductive"
1177 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1179 GButton.radio_button ~label:"Coinductive"
1180 ~group:inductiveb#group
1181 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1183 GPack.hbox ~border_width:0
1184 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1186 GMisc.label ~text:"Enter the list of the names of the types:"
1187 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1189 GEdit.entry ~editable:true
1190 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1192 GPack.hbox ~border_width:0
1193 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1195 GButton.button ~label:"> Next"
1196 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1197 let _ = okb#misc#set_sensitive true in
1199 GButton.button ~label:"Abort"
1200 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1201 ignore (window#connect#destroy GMain.Main.quit) ;
1202 ignore (cancelb#connect#clicked window#destroy) ;
1206 (okb#connect#clicked
1209 let uristr = "cic:" ^ uri_entry#text in
1210 let namesstr = names_entry#text in
1211 let paramsno' = int_of_string (paramsno_entry#text) in
1212 match Str.split (Str.regexp " +") namesstr with
1214 | (he::tl) as names ->
1215 let uri = UriManager.uri_of_string (uristr ^ "/" ^ he ^ ".ind") in
1218 ignore (Getter.resolve uri) ;
1219 raise UriAlreadyInUse
1221 Getter.Unresolved ->
1222 get_uri := (function () -> uri) ;
1223 get_names := (function () -> names) ;
1224 inductive := inductiveb#active ;
1225 paramsno := paramsno' ;
1230 output_html outputhtml
1231 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1239 GBin.frame ~label:name
1240 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1241 let vbox = GPack.vbox ~packing:frame#add () in
1242 let hbox = GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false) () in
1244 GMisc.label ~text:("Enter its type:")
1245 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1246 let scrolled_window =
1247 GBin.scrolled_window ~border_width:5
1248 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1250 TexTermEditor'.term_editor
1252 ~width:400 ~height:20 ~packing:scrolled_window#add
1253 ~share_id_to_uris_with:inputt ()
1254 ~isnotempty_callback:
1256 (*non_empty_type := b ;*)
1257 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*)
1260 GPack.hbox ~border_width:0
1261 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1263 GMisc.label ~text:("Enter the list of its constructors:")
1264 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1265 let cons_names_entry =
1266 GEdit.entry ~editable:true
1267 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1268 (newinputt,cons_names_entry)
1271 vbox#remove hboxn#coerce ;
1273 GPack.hbox ~border_width:0
1274 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1276 GButton.button ~label:"> Next"
1277 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1279 GButton.button ~label:"Abort"
1280 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1281 ignore (cancelb#connect#clicked window#destroy) ;
1283 (okb#connect#clicked
1286 let names = !get_names () in
1287 let types_and_cons =
1289 (fun name (newinputt,cons_names_entry) ->
1290 let consnamesstr = cons_names_entry#text in
1291 let cons_names = Str.split (Str.regexp " +") consnamesstr in
1293 newinputt#get_metasenv_and_term ~context:[] ~metasenv:[]
1296 [] -> expr,cons_names
1297 | _ -> raise AmbiguousInput
1298 ) names type_widgets
1300 let uri = !get_uri () in
1302 (* Let's see if so far the definition is well-typed *)
1305 (* To test if the arities of the inductive types are well *)
1306 (* typed, we check the inductive block definition where *)
1307 (* no constructor is given to each type. *)
1310 (fun name (ty,cons) -> (name, !inductive, ty, []))
1311 names types_and_cons
1313 CicTypeChecker.typecheck_mutual_inductive_defs uri
1314 (tys,params,paramsno)
1316 get_context_and_subst :=
1320 (fun (context,subst) name (ty,_) ->
1322 (Some (Cic.Name name, Cic.Decl ty))::context,
1323 (Cic.MutInd (uri,!i,[]))::subst
1326 ) ([],[]) names types_and_cons) ;
1327 let types_and_cons' =
1329 (fun name (ty,cons) -> (name, !inductive, ty, phase3 name cons))
1330 names types_and_cons
1332 get_types_and_cons := (function () -> types_and_cons') ;
1337 output_html outputhtml
1338 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1341 and phase3 name cons =
1342 let get_cons_types = ref (function () -> assert false) in
1345 ~width:600 ~modal:true ~position:`CENTER
1346 ~title:(name ^ " Constructors")
1347 ~border_width:2 () in
1348 let vbox = GPack.vbox ~packing:window2#add () in
1349 let cons_type_widgets =
1351 (function consname ->
1353 GPack.hbox ~border_width:0
1354 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1356 GMisc.label ~text:("Enter the type of " ^ consname ^ ":")
1357 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1358 let scrolled_window =
1359 GBin.scrolled_window ~border_width:5
1360 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1362 TexTermEditor'.term_editor
1364 ~width:400 ~height:20 ~packing:scrolled_window#add
1365 ~share_id_to_uris_with:inputt ()
1366 ~isnotempty_callback:
1368 (* (*non_empty_type := b ;*)
1369 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*) *)())
1374 GPack.hbox ~border_width:0
1375 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1377 GButton.button ~label:"> Next"
1378 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1379 let _ = okb#misc#set_sensitive true in
1381 GButton.button ~label:"Abort"
1382 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1383 ignore (window2#connect#destroy GMain.Main.quit) ;
1384 ignore (cancelb#connect#clicked window2#destroy) ;
1386 (okb#connect#clicked
1390 let context,subst= !get_context_and_subst () in
1395 inputt#get_metasenv_and_term ~context ~metasenv:[]
1399 let undebrujined_expr =
1401 (fun expr t -> CicSubstitution.subst t expr) expr subst
1403 name, undebrujined_expr
1404 | _ -> raise AmbiguousInput
1405 ) cons cons_type_widgets
1407 get_cons_types := (function () -> cons_types) ;
1411 output_html outputhtml
1412 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1416 let okb_pressed = !chosen in
1418 if (not okb_pressed) then
1421 assert false (* The control never reaches this point *)
1424 (!get_cons_types ())
1427 (* No more phases left or Abort pressed *)
1433 let uri = !get_uri () in
1436 let tys = !get_types_and_cons () in
1437 let obj = Cic.InductiveDefinition tys params !paramsno in
1440 prerr_endline (CicPp.ppobj obj) ;
1441 CicTypeChecker.typecheck_mutual_inductive_defs uri
1442 (tys,params,!paramsno) ;
1445 prerr_endline "Offending mutual (co)inductive type declaration:" ;
1446 prerr_endline (CicPp.ppobj obj) ;
1448 (* We already know that obj is well-typed. We need to add it to the *)
1449 (* environment in order to compute the inner-types without having to *)
1450 (* debrujin it or having to modify lots of other functions to avoid *)
1451 (* asking the environment for the MUTINDs we are defining now. *)
1452 CicEnvironment.put_inductive_definition uri obj ;
1454 show_in_show_window_obj uri obj
1457 output_html outputhtml
1458 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1462 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1463 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1464 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1465 let notebook = (rendering_window ())#notebook in
1467 let chosen = ref false in
1468 let get_metasenv_and_term = ref (function _ -> assert false) in
1469 let get_uri = ref (function _ -> assert false) in
1470 let non_empty_type = ref false in
1473 ~width:600 ~modal:true ~title:"New Proof or Definition"
1474 ~border_width:2 () in
1475 let vbox = GPack.vbox ~packing:window#add () in
1477 GPack.hbox ~border_width:0
1478 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1480 GMisc.label ~text:"Enter the URI for the new theorem or definition:"
1481 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1483 GEdit.entry ~editable:true
1484 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1485 let hint_uri = "/foo.con" in
1486 uri_entry#set_text hint_uri;
1487 uri_entry#select_region ~start:1 ~stop:(String.length hint_uri);
1489 GPack.hbox ~border_width:0
1490 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1492 GMisc.label ~text:"Enter the theorem or definition type:"
1493 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1494 let scrolled_window =
1495 GBin.scrolled_window ~border_width:5
1496 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1497 (* the content of the scrolled_window is moved below (see comment) *)
1499 GPack.hbox ~border_width:0
1500 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1502 GButton.button ~label:"Ok"
1503 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1504 let _ = okb#misc#set_sensitive false in
1506 GButton.button ~label:"Cancel"
1507 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1508 (* moved here to have visibility of the ok button *)
1510 TexTermEditor'.term_editor
1512 ~width:400 ~height:100 ~packing:scrolled_window#add
1513 ~share_id_to_uris_with:inputt ()
1514 ~isnotempty_callback:
1516 non_empty_type := b ;
1517 okb#misc#set_sensitive (b && uri_entry#text <> ""))
1520 let xxx = inputt#get_as_string in
1521 prerr_endline ("######################## " ^ xxx) ;
1522 newinputt#set_term xxx ;
1524 newinputt#set_term inputt#get_as_string ;
1528 uri_entry#connect#changed
1530 okb#misc#set_sensitive (!non_empty_type && uri_entry#text <> ""))
1532 ignore (window#connect#destroy GMain.Main.quit) ;
1533 ignore (cancelb#connect#clicked window#destroy) ;
1535 (okb#connect#clicked
1539 let metasenv,parsed = newinputt#get_metasenv_and_term [] [] in
1540 let uristr = "cic:" ^ uri_entry#text in
1541 let uri = UriManager.uri_of_string uristr in
1542 if String.sub uristr (String.length uristr - 4) 4 <> ".con" then
1543 raise NotAUriToAConstant
1547 ignore (Getter.resolve uri) ;
1548 raise UriAlreadyInUse
1550 Getter.Unresolved ->
1551 get_metasenv_and_term := (function () -> metasenv,parsed) ;
1552 get_uri := (function () -> uri) ;
1557 output_html outputhtml
1558 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1564 let metasenv,expr = !get_metasenv_and_term () in
1565 let _ = CicTypeChecker.type_of_aux' metasenv [] expr in
1566 ProofEngine.proof :=
1567 Some (!get_uri (), (1,[],expr)::metasenv, Cic.Meta (1,[]), expr) ;
1568 ProofEngine.goal := Some 1 ;
1569 refresh_goals notebook ;
1570 refresh_proof output ;
1571 !save_set_sensitive true ;
1573 ProofEngine.intros ~mk_fresh_name_callback () ;
1574 refresh_goals notebook ;
1575 refresh_proof output
1577 InvokeTactics.RefreshSequentException e ->
1578 output_html outputhtml
1579 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1580 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1581 | InvokeTactics.RefreshProofException e ->
1582 output_html outputhtml
1583 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1584 "proof: " ^ Printexc.to_string e ^ "</h1>")
1586 output_html outputhtml
1587 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1590 let check_term_in_scratch scratch_window metasenv context expr =
1592 let ty = CicTypeChecker.type_of_aux' metasenv context expr in
1593 let expr = Cic.Cast (expr,ty) in
1594 scratch_window#show () ;
1595 scratch_window#set_term expr ;
1596 scratch_window#set_context context ;
1597 scratch_window#set_metasenv metasenv ;
1598 scratch_window#sequent_viewer#load_sequent metasenv (111,context,expr)
1601 print_endline ("? " ^ CicPp.ppterm expr) ;
1605 let check scratch_window () =
1606 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1607 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1609 match !ProofEngine.proof with
1611 | Some (_,metasenv,_,_) -> metasenv
1614 match !ProofEngine.goal with
1617 let (_,canonical_context,_) =
1618 List.find (function (m,_,_) -> m=metano) metasenv
1623 let metasenv',expr = inputt#get_metasenv_and_term context metasenv in
1624 check_term_in_scratch scratch_window metasenv' context expr
1627 output_html outputhtml
1628 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1632 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1634 show_in_show_window_uri (input_or_locate_uri ~title:"Show")
1637 output_html outputhtml
1638 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1641 exception NotADefinition;;
1644 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1645 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1646 let notebook = (rendering_window ())#notebook in
1648 let uri = input_or_locate_uri ~title:"Open" in
1649 CicTypeChecker.typecheck uri ;
1650 let metasenv,bo,ty =
1651 match CicEnvironment.get_cooked_obj uri with
1652 Cic.Constant (_,Some bo,ty,_) -> [],bo,ty
1653 | Cic.CurrentProof (_,metasenv,bo,ty,_) -> metasenv,bo,ty
1656 | Cic.InductiveDefinition _ -> raise NotADefinition
1658 ProofEngine.proof :=
1659 Some (uri, metasenv, bo, ty) ;
1660 ProofEngine.goal := None ;
1661 refresh_goals notebook ;
1662 refresh_proof output ;
1663 !save_set_sensitive true
1665 InvokeTactics.RefreshSequentException e ->
1666 output_html outputhtml
1667 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1668 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1669 | InvokeTactics.RefreshProofException e ->
1670 output_html outputhtml
1671 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1672 "proof: " ^ Printexc.to_string e ^ "</h1>")
1674 output_html outputhtml
1675 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1678 let show_query_results results =
1681 ~modal:false ~title:"Query results." ~border_width:2 () in
1682 let vbox = GPack.vbox ~packing:window#add () in
1684 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1687 ~text:"Click on a URI to show that object"
1688 ~packing:hbox#add () in
1689 let scrolled_window =
1690 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1691 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1692 let clist = GList.clist ~columns:1 ~packing:scrolled_window#add () in
1695 (function (uri,_) ->
1699 clist#set_row ~selectable:false n
1702 clist#columns_autosize () ;
1704 (clist#connect#select_row
1705 (fun ~row ~column ~event ->
1706 let (uristr,_) = List.nth results row in
1708 MQueryMisc.cic_textual_parser_uri_of_string
1709 (MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format'
1712 CicTextualParser0.ConUri uri
1713 | CicTextualParser0.VarUri uri
1714 | CicTextualParser0.IndTyUri (uri,_)
1715 | CicTextualParser0.IndConUri (uri,_,_) ->
1716 show_in_show_window_uri uri
1722 let refine_constraints (must_obj,must_rel,must_sort) =
1723 let chosen = ref false in
1724 let use_only = ref false in
1727 ~modal:true ~title:"Constraints refinement."
1728 ~width:800 ~border_width:2 () in
1729 let vbox = GPack.vbox ~packing:window#add () in
1731 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1734 ~text: "\"Only\" constraints can be enforced or not."
1735 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1737 GButton.toggle_button ~label:"Enforce \"only\" constraints"
1738 ~active:false ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1741 (onlyb#connect#toggled (function () -> use_only := onlyb#active)) ;
1742 (* Notebook for the constraints choice *)
1744 GPack.notebook ~scrollable:true
1745 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1746 (* Rel constraints *)
1749 ~text: "Constraints on Rels" () in
1751 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1754 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1757 ~text: "You can now specify the constraints on Rels."
1758 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1759 let expected_height = 25 * (List.length must_rel + 2) in
1760 let height = if expected_height > 400 then 400 else expected_height in
1761 let scrolled_window =
1762 GBin.scrolled_window ~border_width:10 ~height ~width:600
1763 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1764 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1765 let mk_depth_button (hbox:GPack.box) d =
1766 let mutable_ref = ref (Some d) in
1768 GButton.toggle_button
1769 ~label:("depth = " ^ string_of_int d)
1771 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1774 (depthb#connect#toggled
1776 let sel_depth = if depthb#active then Some d else None in
1777 mutable_ref := sel_depth
1780 let rel_constraints =
1785 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1788 ~text:(MQGU.text_of_position (p:>MQGT.full_position))
1789 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1791 | `MainHypothesis None
1792 | `MainConclusion None -> p, ref None
1793 | `MainHypothesis (Some depth')
1794 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth'
1796 (* Sort constraints *)
1799 ~text: "Constraints on Sorts" () in
1801 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1804 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1807 ~text: "You can now specify the constraints on Sorts."
1808 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1809 let expected_height = 25 * (List.length must_sort + 2) in
1810 let height = if expected_height > 400 then 400 else expected_height in
1811 let scrolled_window =
1812 GBin.scrolled_window ~border_width:10 ~height ~width:600
1813 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1814 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1815 let sort_constraints =
1817 (function (p, sort) ->
1820 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1823 ~text:(MQGU.text_of_sort sort ^ " " ^ MQGU.text_of_position (p:>MQGT.full_position))
1824 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1826 | `MainHypothesis None
1827 | `MainConclusion None -> p, ref None, sort
1828 | `MainHypothesis (Some depth')
1829 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', sort
1831 (* Obj constraints *)
1834 ~text: "Constraints on constants" () in
1836 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1839 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1842 ~text: "You can now specify the constraints on constants."
1843 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1844 let expected_height = 25 * (List.length must_obj + 2) in
1845 let height = if expected_height > 400 then 400 else expected_height in
1846 let scrolled_window =
1847 GBin.scrolled_window ~border_width:10 ~height ~width:600
1848 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1849 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1850 let obj_constraints =
1852 (function (p, uri) ->
1855 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1858 ~text:(uri ^ " " ^ (MQGU.text_of_position p))
1859 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1864 | `MainHypothesis None
1865 | `MainConclusion None -> p, ref None, uri
1866 | `MainHypothesis (Some depth')
1867 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', uri
1869 (* Confirm/abort buttons *)
1871 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1873 GButton.button ~label:"Ok"
1874 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1876 GButton.button ~label:"Abort"
1877 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1879 ignore (window#connect#destroy GMain.Main.quit) ;
1880 ignore (cancelb#connect#clicked window#destroy) ;
1882 (okb#connect#clicked (function () -> chosen := true ; window#destroy ()));
1883 window#set_position `CENTER ;
1887 let chosen_must_rel =
1889 (function (position, ref_depth) -> MQGU.set_main_position position !ref_depth)
1892 let chosen_must_sort =
1894 (function (position, ref_depth, sort) ->
1895 MQGU.set_main_position position !ref_depth,sort)
1898 let chosen_must_obj =
1900 (function (position, ref_depth, uri) -> MQGU.set_full_position position !ref_depth, uri)
1903 (chosen_must_obj,chosen_must_rel,chosen_must_sort),
1905 (*CSC: ???????????????????????? I assume that must and only are the same... *)
1906 Some chosen_must_obj,Some chosen_must_rel,Some chosen_must_sort
1914 let completeSearchPattern () =
1915 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1916 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1918 let metasenv,expr = inputt#get_metasenv_and_term ~context:[] ~metasenv:[] in
1919 let must = CGSearchPattern.get_constraints expr in
1920 let must',only = refine_constraints must in
1922 MQG.query_of_constraints (Some CGSearchPattern.universe) must' only
1924 let results = MQI.execute mqi_handle query in
1925 show_query_results results
1928 output_html outputhtml
1929 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1932 let insertQuery () =
1933 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1935 let chosen = ref None in
1938 ~modal:true ~title:"Insert Query (Experts Only)" ~border_width:2 () in
1939 let vbox = GPack.vbox ~packing:window#add () in
1941 GMisc.label ~text:"Insert Query. For Experts Only."
1942 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1943 let scrolled_window =
1944 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1945 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1946 let input = GEdit.text ~editable:true
1947 ~packing:scrolled_window#add () in
1949 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1951 GButton.button ~label:"Ok"
1952 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1954 GButton.button ~label:"Load from file..."
1955 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1957 GButton.button ~label:"Abort"
1958 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1959 ignore (window#connect#destroy GMain.Main.quit) ;
1960 ignore (cancelb#connect#clicked window#destroy) ;
1962 (okb#connect#clicked
1964 chosen := Some (input#get_chars 0 input#length) ; window#destroy ())) ;
1966 (loadb#connect#clicked
1969 GToolbox.select_file ~title:"Select Query File" ()
1973 let inch = open_in filename in
1974 let rec read_file () =
1976 let line = input_line inch in
1977 line ^ "\n" ^ read_file ()
1981 let text = read_file () in
1982 input#delete_text 0 input#length ;
1983 ignore (input#insert_text text ~pos:0))) ;
1984 window#set_position `CENTER ;
1991 MQI.execute mqi_handle (MQueryUtil.query_of_text (Lexing.from_string q))
1993 show_query_results results
1996 output_html outputhtml
1997 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
2000 let choose_must list_of_must only =
2001 let chosen = ref None in
2002 let user_constraints = ref [] in
2005 ~modal:true ~title:"Query refinement." ~border_width:2 () in
2006 let vbox = GPack.vbox ~packing:window#add () in
2008 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2012 ("You can now specify the genericity of the query. " ^
2013 "The more generic the slower.")
2014 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2016 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2020 "Suggestion: start with faster queries before moving to more generic ones."
2021 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2023 GPack.notebook ~scrollable:true
2024 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2027 let last = List.length list_of_must in
2033 (if !page = 1 then "More generic" else
2034 if !page = last then "More precise" else " ") () in
2035 let expected_height = 25 * (List.length must + 2) in
2036 let height = if expected_height > 400 then 400 else expected_height in
2037 let scrolled_window =
2038 GBin.scrolled_window ~border_width:10 ~height ~width:600
2039 ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2041 GList.clist ~columns:2 ~packing:scrolled_window#add
2042 ~titles:["URI" ; "Position"] ()
2046 (function (position, uri) ->
2049 [uri; MQGUtil.text_of_position position]
2051 clist#set_row ~selectable:false n
2054 clist#columns_autosize ()
2057 let label = GMisc.label ~text:"User provided" () in
2059 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2061 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2064 ~text:"Select the constraints that must be satisfied and press OK."
2065 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2066 let expected_height = 25 * (List.length only + 2) in
2067 let height = if expected_height > 400 then 400 else expected_height in
2068 let scrolled_window =
2069 GBin.scrolled_window ~border_width:10 ~height ~width:600
2070 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2072 GList.clist ~columns:2 ~packing:scrolled_window#add
2073 ~selection_mode:`EXTENDED
2074 ~titles:["URI" ; "Position"] ()
2078 (function (position, uri) ->
2081 [uri; MQGUtil.text_of_position position]
2083 clist#set_row ~selectable:true n
2086 clist#columns_autosize () ;
2088 (clist#connect#select_row
2089 (fun ~row ~column ~event ->
2090 user_constraints := (List.nth only row)::!user_constraints)) ;
2092 (clist#connect#unselect_row
2093 (fun ~row ~column ~event ->
2096 (function uri -> uri != (List.nth only row)) !user_constraints)) ;
2099 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2101 GButton.button ~label:"Ok"
2102 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2104 GButton.button ~label:"Abort"
2105 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2107 ignore (window#connect#destroy GMain.Main.quit) ;
2108 ignore (cancelb#connect#clicked window#destroy) ;
2110 (okb#connect#clicked
2111 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
2112 window#set_position `CENTER ;
2116 None -> raise NoChoice
2118 if n = List.length list_of_must then
2119 (* user provided constraints *)
2122 List.nth list_of_must n
2125 let searchPattern () =
2126 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
2127 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
2130 match !ProofEngine.proof with
2131 None -> assert false
2132 | Some proof -> proof
2134 match !ProofEngine.goal with
2138 TacticChaser.matchConclusion
2140 ~output_html:(output_html outputhtml) ~choose_must ()
2141 ~status:(proof, metano)
2144 user_uri_choice ~title:"Ambiguous input."
2145 ~msg: "Many lemmas can be successfully applied. Please, choose one:"
2148 inputt#set_term uri' ;
2149 InvokeTactics'.apply ()
2152 output_html outputhtml
2153 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
2156 let choose_selection mmlwidget (element : Gdome.element option) =
2157 let module G = Gdome in
2158 let rec aux element =
2159 if element#hasAttributeNS
2160 ~namespaceURI:Misc.helmns
2161 ~localName:(G.domString "xref")
2163 mmlwidget#set_selection (Some element)
2166 match element#get_parentNode with
2167 None -> assert false
2168 (*CSC: OCAML DIVERGES!
2169 | Some p -> aux (new G.element_of_node p)
2171 | Some p -> aux (new Gdome.element_of_node p)
2173 GdomeInit.DOMCastException _ ->
2175 "******* trying to select above the document root ********"
2179 | None -> mmlwidget#set_selection None
2182 (* STUFF TO BUILD THE GTK INTERFACE *)
2184 (* Stuff for the widget settings *)
2186 let export_to_postscript output =
2187 let lastdir = ref (Unix.getcwd ()) in
2190 GToolbox.select_file ~title:"Export to PostScript"
2191 ~dir:lastdir ~filename:"screenshot.ps" ()
2195 (output :> GMathView.math_view)#export_to_postscript
2196 ~filename:filename ();
2199 let activate_t1 output button_set_anti_aliasing
2200 button_set_transparency export_to_postscript_menu_item
2203 let is_set = button_t1#active in
2204 output#set_font_manager_type
2205 ~fm_type:(if is_set then `font_manager_t1 else `font_manager_gtk) ;
2208 button_set_anti_aliasing#misc#set_sensitive true ;
2209 button_set_transparency#misc#set_sensitive true ;
2210 export_to_postscript_menu_item#misc#set_sensitive true ;
2214 button_set_anti_aliasing#misc#set_sensitive false ;
2215 button_set_transparency#misc#set_sensitive false ;
2216 export_to_postscript_menu_item#misc#set_sensitive false ;
2220 let set_anti_aliasing output button_set_anti_aliasing () =
2221 output#set_anti_aliasing button_set_anti_aliasing#active
2224 let set_transparency output button_set_transparency () =
2225 output#set_transparency button_set_transparency#active
2228 let changefont output font_size_spinb () =
2229 output#set_font_size font_size_spinb#value_as_int
2232 let set_log_verbosity output log_verbosity_spinb () =
2233 output#set_log_verbosity log_verbosity_spinb#value_as_int
2236 class settings_window output sw
2237 export_to_postscript_menu_item selection_changed_callback
2239 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
2241 GPack.vbox ~packing:settings_window#add () in
2244 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2245 ~border_width:5 ~packing:vbox#add () in
2247 GButton.toggle_button ~label:"activate t1 fonts"
2248 ~packing:(table#attach ~left:0 ~top:0) () in
2249 let button_set_anti_aliasing =
2250 GButton.toggle_button ~label:"set_anti_aliasing"
2251 ~packing:(table#attach ~left:0 ~top:1) () in
2252 let button_set_transparency =
2253 GButton.toggle_button ~label:"set_transparency"
2254 ~packing:(table#attach ~left:2 ~top:1) () in
2257 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2258 ~border_width:5 ~packing:vbox#add () in
2259 let font_size_label =
2260 GMisc.label ~text:"font size:"
2261 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
2262 let font_size_spinb =
2264 GData.adjustment ~value:(float_of_int output#get_font_size)
2265 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
2268 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
2269 let log_verbosity_label =
2270 GMisc.label ~text:"log verbosity:"
2271 ~packing:(table#attach ~left:0 ~top:1) () in
2272 let log_verbosity_spinb =
2274 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
2277 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
2279 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2281 GButton.button ~label:"Close"
2282 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2284 method show = settings_window#show
2286 button_set_anti_aliasing#misc#set_sensitive false ;
2287 button_set_transparency#misc#set_sensitive false ;
2288 (* Signals connection *)
2289 ignore(button_t1#connect#clicked
2290 (activate_t1 output button_set_anti_aliasing
2291 button_set_transparency export_to_postscript_menu_item button_t1)) ;
2292 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
2293 ignore(button_set_anti_aliasing#connect#toggled
2294 (set_anti_aliasing output button_set_anti_aliasing));
2295 ignore(button_set_transparency#connect#toggled
2296 (set_transparency output button_set_transparency)) ;
2297 ignore(log_verbosity_spinb#connect#changed
2298 (set_log_verbosity output log_verbosity_spinb)) ;
2299 ignore(closeb#connect#clicked settings_window#misc#hide)
2302 (* Scratch window *)
2304 class scratch_window =
2307 ~title:"MathML viewer"
2308 ~border_width:2 () in
2310 GPack.vbox ~packing:window#add () in
2312 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2314 GButton.button ~label:"Whd"
2315 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2317 GButton.button ~label:"Reduce"
2318 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2320 GButton.button ~label:"Simpl"
2321 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2322 let scrolled_window =
2323 GBin.scrolled_window ~border_width:10
2324 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2325 let sequent_viewer =
2326 TermViewer.sequent_viewer
2327 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
2329 val mutable term = Cic.Rel 1 (* dummy value *)
2330 val mutable context = ([] : Cic.context) (* dummy value *)
2331 val mutable metasenv = ([] : Cic.metasenv) (* dummy value *)
2332 method sequent_viewer = sequent_viewer
2333 method show () = window#misc#hide () ; window#show ()
2335 method set_term t = term <- t
2336 method context = context
2337 method set_context t = context <- t
2338 method metasenv = metasenv
2339 method set_metasenv t = metasenv <- t
2342 (sequent_viewer#connect#selection_changed (choose_selection sequent_viewer));
2343 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
2344 ignore(whdb#connect#clicked InvokeTactics'.whd_in_scratch) ;
2345 ignore(reduceb#connect#clicked InvokeTactics'.reduce_in_scratch) ;
2346 ignore(simplb#connect#clicked InvokeTactics'.simpl_in_scratch)
2349 let open_contextual_menu_for_selected_terms mmlwidget infos =
2350 let button = GdkEvent.Button.button infos in
2351 let terms_selected = List.length mmlwidget#get_selections > 0 in
2354 let time = GdkEvent.Button.time infos in
2355 let menu = GMenu.menu () in
2356 let f = new GMenu.factory menu in
2358 f#add_item "Whd" ~key:GdkKeysyms._W ~callback:InvokeTactics'.whd in
2359 let reduce_menu_item =
2360 f#add_item "Reduce" ~key:GdkKeysyms._R ~callback:InvokeTactics'.reduce in
2361 let simpl_menu_item =
2362 f#add_item "Simpl" ~key:GdkKeysyms._S ~callback:InvokeTactics'.simpl in
2363 let _ = f#add_separator () in
2364 let generalize_menu_item =
2365 f#add_item "Generalize"
2366 ~key:GdkKeysyms._G ~callback:InvokeTactics'.generalize in
2367 let _ = f#add_separator () in
2368 let clear_menu_item =
2369 f#add_item "Clear" ~key:GdkKeysyms._C ~callback:InvokeTactics'.clear in
2370 let clearbody_menu_item =
2371 f#add_item "ClearBody"
2372 ~key:GdkKeysyms._B ~callback:InvokeTactics'.clearbody
2374 whd_menu_item#misc#set_sensitive terms_selected ;
2375 reduce_menu_item#misc#set_sensitive terms_selected ;
2376 simpl_menu_item#misc#set_sensitive terms_selected ;
2377 generalize_menu_item#misc#set_sensitive terms_selected ;
2378 clear_menu_item#misc#set_sensitive terms_selected ;
2379 clearbody_menu_item#misc#set_sensitive terms_selected ;
2380 menu#popup ~button ~time
2386 let vbox1 = GPack.vbox () in
2388 val mutable proofw_ref = None
2389 val mutable compute_ref = None
2391 Lazy.force self#compute ;
2392 match proofw_ref with
2393 None -> assert false
2394 | Some proofw -> proofw
2395 method content = vbox1
2397 match compute_ref with
2398 None -> assert false
2399 | Some compute -> compute
2403 let scrolled_window1 =
2404 GBin.scrolled_window ~border_width:10
2405 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2407 TermViewer.sequent_viewer ~width:400 ~height:275
2408 ~packing:(scrolled_window1#add) () in
2409 let _ = proofw_ref <- Some proofw in
2411 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2413 GButton.button ~label:"Ring"
2414 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2416 GButton.button ~label:"Fourier"
2417 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2419 GButton.button ~label:"Reflexivity"
2420 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2422 GButton.button ~label:"Symmetry"
2423 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2425 GButton.button ~label:"Assumption"
2426 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2427 let contradictionb =
2428 GButton.button ~label:"Contradiction"
2429 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2431 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2433 GButton.button ~label:"Exists"
2434 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2436 GButton.button ~label:"Split"
2437 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2439 GButton.button ~label:"Left"
2440 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2442 GButton.button ~label:"Right"
2443 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2444 let searchpatternb =
2445 GButton.button ~label:"SearchPattern_Apply"
2446 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2448 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2450 GButton.button ~label:"Exact"
2451 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2453 GButton.button ~label:"Intros"
2454 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2456 GButton.button ~label:"Apply"
2457 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2458 let elimintrossimplb =
2459 GButton.button ~label:"ElimIntrosSimpl"
2460 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2462 GButton.button ~label:"ElimType"
2463 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2465 GButton.button ~label:"Fold_whd"
2466 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2468 GButton.button ~label:"Fold_reduce"
2469 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2471 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2473 GButton.button ~label:"Fold_simpl"
2474 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2476 GButton.button ~label:"Cut"
2477 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2479 GButton.button ~label:"Change"
2480 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2482 GButton.button ~label:"Let ... In"
2483 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2485 GButton.button ~label:"RewriteSimpl ->"
2486 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2487 let rewritebacksimplb =
2488 GButton.button ~label:"RewriteSimpl <-"
2489 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2491 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2493 GButton.button ~label:"Absurd"
2494 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2496 GButton.button ~label:"Decompose"
2497 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2499 GButton.button ~label:"Transitivity"
2500 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2502 GButton.button ~label:"Replace"
2503 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2505 GButton.button ~label:"Injection"
2506 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2508 GButton.button ~label:"Discriminate"
2509 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2510 (* Zack: spostare in una toolbar
2512 GButton.button ~label:"Generalize"
2513 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2515 GButton.button ~label:"ClearBody"
2516 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2518 GButton.button ~label:"Clear"
2519 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2521 GButton.button ~label:"Whd"
2522 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2524 GButton.button ~label:"Reduce"
2525 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2527 GButton.button ~label:"Simpl"
2528 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2531 ignore(exactb#connect#clicked InvokeTactics'.exact) ;
2532 ignore(applyb#connect#clicked InvokeTactics'.apply) ;
2533 ignore(elimintrossimplb#connect#clicked InvokeTactics'.elimintrossimpl) ;
2534 ignore(elimtypeb#connect#clicked InvokeTactics'.elimtype) ;
2535 ignore(foldwhdb#connect#clicked InvokeTactics'.fold_whd) ;
2536 ignore(foldreduceb#connect#clicked InvokeTactics'.fold_reduce) ;
2537 ignore(foldsimplb#connect#clicked InvokeTactics'.fold_simpl) ;
2538 ignore(cutb#connect#clicked InvokeTactics'.cut) ;
2539 ignore(changeb#connect#clicked InvokeTactics'.change) ;
2540 ignore(letinb#connect#clicked InvokeTactics'.letin) ;
2541 ignore(ringb#connect#clicked InvokeTactics'.ring) ;
2542 ignore(fourierb#connect#clicked InvokeTactics'.fourier) ;
2543 ignore(rewritesimplb#connect#clicked InvokeTactics'.rewritesimpl) ;
2544 ignore(rewritebacksimplb#connect#clicked InvokeTactics'.rewritebacksimpl) ;
2545 ignore(replaceb#connect#clicked InvokeTactics'.replace) ;
2546 ignore(reflexivityb#connect#clicked InvokeTactics'.reflexivity) ;
2547 ignore(symmetryb#connect#clicked InvokeTactics'.symmetry) ;
2548 ignore(transitivityb#connect#clicked InvokeTactics'.transitivity) ;
2549 ignore(existsb#connect#clicked InvokeTactics'.exists) ;
2550 ignore(splitb#connect#clicked InvokeTactics'.split) ;
2551 ignore(leftb#connect#clicked InvokeTactics'.left) ;
2552 ignore(rightb#connect#clicked InvokeTactics'.right) ;
2553 ignore(assumptionb#connect#clicked InvokeTactics'.assumption) ;
2554 ignore(absurdb#connect#clicked InvokeTactics'.absurd) ;
2555 ignore(contradictionb#connect#clicked InvokeTactics'.contradiction) ;
2556 ignore(introsb#connect#clicked InvokeTactics'.intros) ;
2557 ignore(decomposeb#connect#clicked InvokeTactics'.decompose) ;
2558 ignore(searchpatternb#connect#clicked searchPattern) ;
2559 ignore(injectionb#connect#clicked InvokeTactics'.injection) ;
2560 ignore(discriminateb#connect#clicked InvokeTactics'.discriminate) ;
2561 (* Zack: spostare in una toolbar
2562 ignore(whdb#connect#clicked whd) ;
2563 ignore(reduceb#connect#clicked reduce) ;
2564 ignore(simplb#connect#clicked simpl) ;
2565 ignore(clearbodyb#connect#clicked clearbody) ;
2566 ignore(clearb#connect#clicked clear) ;
2567 ignore(generalizeb#connect#clicked generalize) ;
2569 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
2571 ((new GObj.event_ops proofw#as_widget)#connect#button_press
2572 (open_contextual_menu_for_selected_terms proofw)) ;
2578 let vbox1 = GPack.vbox () in
2579 let scrolled_window1 =
2580 GBin.scrolled_window ~border_width:10
2581 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2583 TermViewer.sequent_viewer ~width:400 ~height:275
2584 ~packing:(scrolled_window1#add) () in
2586 method proofw = (assert false : TermViewer.sequent_viewer)
2587 method content = vbox1
2588 method compute = (assert false : unit)
2592 let empty_page = new empty_page;;
2596 val notebook = GPack.notebook ()
2598 val mutable skip_switch_page_event = false
2599 val mutable empty = true
2600 method notebook = notebook
2602 let new_page = new page () in
2604 pages := !pages @ [n,lazy (setgoal n),new_page] ;
2605 notebook#append_page
2606 ~tab_label:((GMisc.label ~text:("?" ^ string_of_int n) ())#coerce)
2607 new_page#content#coerce
2608 method remove_all_pages ~skip_switch_page_event:skip =
2610 notebook#remove_page 0 (* let's remove the empty page *)
2612 List.iter (function _ -> notebook#remove_page 0) !pages ;
2614 skip_switch_page_event <- skip
2615 method set_current_page ~may_skip_switch_page_event n =
2616 let (_,_,page) = List.find (function (m,_,_) -> m=n) !pages in
2617 let new_page = notebook#page_num page#content#coerce in
2618 if may_skip_switch_page_event && new_page <> notebook#current_page then
2619 skip_switch_page_event <- true ;
2620 notebook#goto_page new_page
2621 method set_empty_page =
2624 notebook#append_page
2625 ~tab_label:((GMisc.label ~text:"No proof in progress" ())#coerce)
2626 empty_page#content#coerce
2628 let (_,_,page) = List.nth !pages notebook#current_page in
2632 (notebook#connect#switch_page
2634 let skip = skip_switch_page_event in
2635 skip_switch_page_event <- false ;
2638 let (metano,setgoal,page) = List.nth !pages i in
2639 ProofEngine.goal := Some metano ;
2640 Lazy.force (page#compute) ;
2649 class rendering_window output (notebook : notebook) =
2650 let scratch_window = new scratch_window in
2653 ~title:"gTopLevel - Helm's Proof Assistant"
2654 ~border_width:0 ~allow_shrink:false () in
2655 let vbox_for_menu = GPack.vbox ~packing:window#add () in
2657 let handle_box = GBin.handle_box ~border_width:2
2658 ~packing:(vbox_for_menu#pack ~padding:0) () in
2659 let menubar = GMenu.menu_bar ~packing:handle_box#add () in
2660 let factory0 = new GMenu.factory menubar in
2661 let accel_group = factory0#accel_group in
2663 let file_menu = factory0#add_submenu "File" in
2664 let factory1 = new GMenu.factory file_menu ~accel_group in
2665 let export_to_postscript_menu_item =
2668 factory1#add_item "New Block of (Co)Inductive Definitions..."
2669 ~key:GdkKeysyms._B ~callback:new_inductive
2672 factory1#add_item "New Proof or Definition..." ~key:GdkKeysyms._N
2675 let reopen_menu_item =
2676 factory1#add_item "Reopen a Finished Proof..." ~key:GdkKeysyms._R
2680 factory1#add_item "Qed" ~key:GdkKeysyms._E ~callback:qed in
2681 ignore (factory1#add_separator ()) ;
2683 (factory1#add_item "Load Unfinished Proof..." ~key:GdkKeysyms._L
2684 ~callback:load_unfinished_proof) ;
2685 let save_menu_item =
2686 factory1#add_item "Save Unfinished Proof" ~key:GdkKeysyms._S
2687 ~callback:save_unfinished_proof
2690 (save_set_sensitive := function b -> save_menu_item#misc#set_sensitive b);
2691 ignore (!save_set_sensitive false);
2692 ignore (qed_set_sensitive:=function b -> qed_menu_item#misc#set_sensitive b);
2693 ignore (!qed_set_sensitive false);
2694 ignore (factory1#add_separator ()) ;
2695 let export_to_postscript_menu_item =
2696 factory1#add_item "Export to PostScript..."
2697 ~callback:(export_to_postscript output) in
2698 ignore (factory1#add_separator ()) ;
2700 (factory1#add_item "Exit" ~key:GdkKeysyms._Q ~callback:GMain.Main.quit) ;
2701 export_to_postscript_menu_item
2704 let edit_menu = factory0#add_submenu "Edit Current Proof" in
2705 let factory2 = new GMenu.factory edit_menu ~accel_group in
2706 let focus_and_proveit_set_sensitive = ref (function _ -> assert false) in
2707 let proveit_menu_item =
2708 factory2#add_item "Prove It" ~key:GdkKeysyms._I
2709 ~callback:(function () -> proveit ();!focus_and_proveit_set_sensitive false)
2711 let focus_menu_item =
2712 factory2#add_item "Focus" ~key:GdkKeysyms._F
2713 ~callback:(function () -> focus () ; !focus_and_proveit_set_sensitive false)
2716 focus_and_proveit_set_sensitive :=
2718 proveit_menu_item#misc#set_sensitive b ;
2719 focus_menu_item#misc#set_sensitive b
2721 let _ = !focus_and_proveit_set_sensitive false in
2722 (* edit term menu *)
2723 let edit_term_menu = factory0#add_submenu "Edit Term" in
2724 let factory5 = new GMenu.factory edit_term_menu ~accel_group in
2725 let check_menu_item =
2726 factory5#add_item "Check Term" ~key:GdkKeysyms._C
2727 ~callback:(check scratch_window) in
2728 let _ = check_menu_item#misc#set_sensitive false in
2730 let search_menu = factory0#add_submenu "Search" in
2731 let factory4 = new GMenu.factory search_menu ~accel_group in
2733 factory4#add_item "Locate..." ~key:GdkKeysyms._T
2735 let searchPattern_menu_item =
2736 factory4#add_item "SearchPattern..." ~key:GdkKeysyms._D
2737 ~callback:completeSearchPattern in
2738 let _ = searchPattern_menu_item#misc#set_sensitive false in
2739 let show_menu_item =
2740 factory4#add_item "Show..." ~key:GdkKeysyms._H ~callback:show
2742 let insert_query_item =
2743 factory4#add_item "Insert Query (Experts Only)..." ~key:GdkKeysyms._Y
2744 ~callback:insertQuery in
2746 let hbugs_menu = factory0#add_submenu "HBugs" in
2747 let factory6 = new GMenu.factory hbugs_menu ~accel_group in
2749 factory6#add_check_item
2750 ~active:false ~key:GdkKeysyms._F5 ~callback:Hbugs.toggle "HBugs enabled"
2752 let _ = factory6#add_item ~callback:Hbugs.notify "(Re)Submit status!" in
2753 let _ = factory6#add_separator () in
2755 factory6#add_item ~callback:Hbugs.start_web_services "Start Web Services"
2758 factory6#add_item ~callback:Hbugs.stop_web_services "Stop Web Services"
2761 let settings_menu = factory0#add_submenu "Settings" in
2762 let factory3 = new GMenu.factory settings_menu ~accel_group in
2764 factory3#add_item "Edit Aliases..." ~key:GdkKeysyms._A
2765 ~callback:edit_aliases in
2766 let _ = factory3#add_separator () in
2768 factory3#add_item "MathML Widget Preferences..." ~key:GdkKeysyms._P
2769 ~callback:(function _ -> (settings_window ())#show ()) in
2770 let _ = factory3#add_separator () in
2772 factory3#add_item "Reload Stylesheets"
2775 ApplyStylesheets.reload_stylesheets () ;
2776 if !ProofEngine.proof <> None then
2778 refresh_goals notebook ;
2779 refresh_proof output
2781 InvokeTactics.RefreshSequentException e ->
2782 output_html (outputhtml ())
2783 ("<h1 color=\"red\">An error occurred while refreshing the " ^
2784 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
2785 (*notebook#remove_all_pages ~skip_switch_page_event:false ;*)
2786 notebook#set_empty_page
2787 | InvokeTactics.RefreshProofException e ->
2788 output_html (outputhtml ())
2789 ("<h1 color=\"red\">An error occurred while refreshing the proof: " ^ Printexc.to_string e ^ "</h1>") ;
2793 let _ = window#add_accel_group accel_group in
2797 ~packing:(vbox_for_menu#pack ~expand:true ~fill:true ~padding:5) () in
2799 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2800 let scrolled_window0 =
2801 GBin.scrolled_window ~border_width:10
2802 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2803 let _ = scrolled_window0#add output#coerce in
2805 GBin.frame ~label:"Insert Term"
2806 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2807 let scrolled_window1 =
2808 GBin.scrolled_window ~border_width:5
2809 ~packing:frame#add () in
2811 TexTermEditor'.term_editor
2813 ~width:400 ~height:100 ~packing:scrolled_window1#add ()
2814 ~isnotempty_callback:
2816 check_menu_item#misc#set_sensitive b ;
2817 searchPattern_menu_item#misc#set_sensitive b) in
2819 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2821 vboxl#pack ~expand:true ~fill:true ~padding:5 notebook#notebook#coerce in
2823 GBin.frame ~shadow_type:`IN ~packing:(vboxl#pack ~expand:true ~padding:5) ()
2827 ~source:"<html><body bgColor=\"white\"></body></html>"
2828 ~width:400 ~height: 100
2833 method outputhtml = outputhtml
2834 method inputt = inputt
2835 method output = (output : TermViewer.proof_viewer)
2836 method scratch_window = scratch_window
2837 method notebook = notebook
2838 method show = window#show
2840 notebook#set_empty_page ;
2841 export_to_postscript_menu_item#misc#set_sensitive false ;
2842 check_term := (check_term_in_scratch scratch_window) ;
2844 (* signal handlers here *)
2845 ignore(output#connect#selection_changed
2847 choose_selection output elem ;
2848 !focus_and_proveit_set_sensitive true
2850 ignore (output#connect#click (show_in_show_window_callback output)) ;
2851 let settings_window = new settings_window output scrolled_window0
2852 export_to_postscript_menu_item (choose_selection output) in
2853 set_settings_window settings_window ;
2854 set_outputhtml outputhtml ;
2855 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
2856 Logger.log_callback :=
2857 (Logger.log_to_html ~print_and_flush:(output_html outputhtml))
2862 let initialize_everything () =
2863 let module U = Unix in
2864 let output = TermViewer.proof_viewer ~width:350 ~height:280 () in
2865 let notebook = new notebook in
2866 let rendering_window' = new rendering_window output notebook in
2867 set_rendering_window rendering_window' ;
2868 let print_error_as_html prefix msg =
2869 output_html (outputhtml ())
2870 ("<h1 color=\"red\">" ^ prefix ^ msg ^ "</h1>")
2872 Gdome_xslt.setErrorCallback (Some (print_error_as_html "XSLT Error: "));
2873 Gdome_xslt.setDebugCallback
2874 (Some (print_error_as_html "XSLT Debug Message: "));
2875 rendering_window'#show () ;
2876 (* Hbugs.toggle true; *)
2881 ignore (GtkMain.Main.init ()) ;
2882 initialize_everything () ;
2883 MQIC.close mqi_handle;
2888 Sys.catch_break true;
2890 with Sys.Break -> () (* exit nicely, invoking at_exit functions *)