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 if List.length metasenv = 0 then
566 !qed_set_sensitive true ;
567 prerr_endline "CSC: ###### REFRESH_PROOF, Hbugs.clear ()" ;
572 prerr_endline "CSC: ###### REFRESH_PROOF, Hbugs.notify ()" ;
575 (*CSC: Wrong: [] is just plainly wrong *)
577 (Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, []))
579 ignore (output#load_proof uri currentproof)
582 match !ProofEngine.proof with
584 | Some (uri,metasenv,bo,ty) ->
585 prerr_endline ("Offending proof: " ^ CicPp.ppobj (Cic.CurrentProof ("questa",metasenv,bo,ty,[]))) ; flush stderr ;
586 raise (InvokeTactics.RefreshProofException e)
588 let refresh_goals ?(empty_notebook=true) notebook =
590 match !ProofEngine.goal with
592 if empty_notebook then
594 notebook#remove_all_pages ~skip_switch_page_event:false ;
595 notebook#set_empty_page
598 notebook#proofw#unload
601 match !ProofEngine.proof with
603 | Some (_,metasenv,_,_) -> metasenv
606 List.find (function (m,_,_) -> m=metano) metasenv
608 let regenerate_notebook () =
609 let skip_switch_page_event =
611 (m,_,_)::_ when m = metano -> false
614 notebook#remove_all_pages ~skip_switch_page_event ;
615 List.iter (function (m,_,_) -> notebook#add_page m) metasenv ;
617 if empty_notebook then
619 regenerate_notebook () ;
620 notebook#set_current_page
621 ~may_skip_switch_page_event:false metano
625 notebook#set_current_page
626 ~may_skip_switch_page_event:true metano ;
627 notebook#proofw#load_sequent metasenv currentsequent
632 match !ProofEngine.goal with
637 match !ProofEngine.proof with
639 | Some (_,metasenv,_,_) -> metasenv
642 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
643 prerr_endline ("Offending sequent: " ^ SequentPp.TextualPp.print_sequent currentsequent) ; flush stderr ;
644 raise (InvokeTactics.RefreshSequentException e)
645 with Not_found -> prerr_endline ("Offending sequent " ^ string_of_int metano ^ " unknown."); raise (InvokeTactics.RefreshSequentException e)
647 module InvokeTacticsCallbacks =
649 let sequent_viewer () = (rendering_window ())#notebook#proofw
650 let term_editor () = (rendering_window ())#inputt
651 let scratch_window () = (rendering_window ())#scratch_window
653 let refresh_proof () =
654 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
657 let refresh_goals () =
658 let notebook = (rendering_window ())#notebook in
659 refresh_goals notebook
661 let decompose_uris_choice_callback = decompose_uris_choice_callback
662 let mk_fresh_name_callback = mk_fresh_name_callback
663 let output_html msg = output_html (outputhtml ()) msg
666 module InvokeTactics' = InvokeTactics.Make (InvokeTacticsCallbacks);;
667 (* Just to initialize the Hbugs module *)
668 module Ignore = Hbugs.Initialize (InvokeTactics');;
670 (** load an unfinished proof from filesystem *)
671 let load_unfinished_proof () =
672 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
673 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
674 let notebook = (rendering_window ())#notebook in
677 GToolbox.input_string ~title:"Load Unfinished Proof" ~text:"/dummy.con"
680 None -> raise NoChoice
682 let uri = UriManager.uri_of_string ("cic:" ^ uri0) in
683 match CicParser.obj_of_xml prooffiletype (Some prooffile) with
684 Cic.CurrentProof (_,metasenv,bo,ty,_) ->
685 typecheck_loaded_proof metasenv bo ty ;
687 Some (uri, metasenv, bo, ty) ;
691 | (metano,_,_)::_ -> Some metano
693 refresh_proof output ;
694 refresh_goals notebook ;
695 output_html outputhtml
696 ("<h1 color=\"Green\">Current proof type loaded from " ^
697 prooffiletype ^ "</h1>") ;
698 output_html outputhtml
699 ("<h1 color=\"Green\">Current proof body loaded from " ^
700 prooffile ^ "</h1>") ;
701 !save_set_sensitive true;
704 InvokeTactics.RefreshSequentException e ->
705 output_html outputhtml
706 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
707 "sequent: " ^ Printexc.to_string e ^ "</h1>")
708 | InvokeTactics.RefreshProofException e ->
709 output_html outputhtml
710 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
711 "proof: " ^ Printexc.to_string e ^ "</h1>")
713 output_html outputhtml
714 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
717 let edit_aliases () =
718 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
719 let id_to_uris = inputt#id_to_uris in
720 let chosen = ref false in
723 ~width:400 ~modal:true ~title:"Edit Aliases..." ~border_width:2 () in
725 GPack.vbox ~border_width:0 ~packing:window#add () in
726 let scrolled_window =
727 GBin.scrolled_window ~border_width:10
728 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
729 let input = GEdit.text ~editable:true ~width:400 ~height:100
730 ~packing:scrolled_window#add () in
732 GPack.hbox ~border_width:0
733 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
735 GButton.button ~label:"Ok"
736 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
738 GButton.button ~label:"Cancel"
739 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
740 ignore (window#connect#destroy GMain.Main.quit) ;
741 ignore (cancelb#connect#clicked window#destroy) ;
743 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
744 let dom,resolve_id = !id_to_uris in
746 (input#insert_text ~pos:0
751 match resolve_id v with
753 | Some (CicTextualParser0.Uri uri) -> uri
754 | Some (CicTextualParser0.Term _)
755 | Some CicTextualParser0.Implicit -> assert false
759 CicTextualParser0.Id id -> id
760 | CicTextualParser0.Symbol (descr,_) ->
761 (* CSC: To be implemented *)
763 )^ " " ^ (string_of_cic_textual_parser_uri uri)
769 let inputtext = input#get_chars 0 input#length in
771 let alfa = "[a-zA-Z_-]" in
772 let digit = "[0-9]" in
773 let ident = alfa ^ "\(" ^ alfa ^ "\|" ^ digit ^ "\)*" in
774 let blanks = "\( \|\t\|\n\)+" in
775 let nonblanks = "[^ \t\n]+" in
776 let uri = "/\(" ^ ident ^ "/\)*" ^ nonblanks in (* not very strict check *)
778 ("alias" ^ blanks ^ "\(" ^ ident ^ "\)" ^ blanks ^ "\(" ^ uri ^ "\)")
782 let n' = Str.search_forward regexpr inputtext n in
783 let id = CicTextualParser0.Id (Str.matched_group 2 inputtext) in
785 MQueryMisc.cic_textual_parser_uri_of_string
786 ("cic:" ^ (Str.matched_group 5 inputtext))
788 let dom,resolve_id = aux (n' + 1) in
789 if List.mem id dom then
795 Some (CicTextualParser0.Uri uri)
798 Not_found -> TermEditor.empty_id_to_uris
802 id_to_uris := (dom,resolve_id)
806 let module L = LogicalOperations in
807 let module G = Gdome in
808 let notebook = (rendering_window ())#notebook in
809 let output = (rendering_window ())#output in
810 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
812 output#make_sequent_of_selected_term ;
813 refresh_proof output ;
814 refresh_goals notebook
816 InvokeTactics.RefreshSequentException e ->
817 output_html outputhtml
818 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
819 "sequent: " ^ Printexc.to_string e ^ "</h1>")
820 | InvokeTactics.RefreshProofException e ->
821 output_html outputhtml
822 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
823 "proof: " ^ Printexc.to_string e ^ "</h1>")
825 output_html outputhtml
826 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
830 let module L = LogicalOperations in
831 let module G = Gdome in
832 let notebook = (rendering_window ())#notebook in
833 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
834 let output = (rendering_window ())#output in
836 output#focus_sequent_of_selected_term ;
837 refresh_goals notebook
839 InvokeTactics.RefreshSequentException e ->
840 output_html outputhtml
841 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
842 "sequent: " ^ Printexc.to_string e ^ "</h1>")
843 | InvokeTactics.RefreshProofException e ->
844 output_html outputhtml
845 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
846 "proof: " ^ Printexc.to_string e ^ "</h1>")
848 output_html outputhtml
849 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
852 exception NoPrevGoal;;
853 exception NoNextGoal;;
856 let module L = LogicalOperations in
857 let module G = Gdome in
858 let notebook = (rendering_window ())#notebook in
859 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
861 match !ProofEngine.proof with
863 | Some (_,metasenv,_,_) -> metasenv
866 refresh_goals ~empty_notebook:false notebook
868 InvokeTactics.RefreshSequentException e ->
869 output_html outputhtml
870 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
871 "sequent: " ^ Printexc.to_string e ^ "</h1>")
873 output_html outputhtml
874 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
878 show_in_show_window_obj, show_in_show_window_uri, show_in_show_window_callback
881 GWindow.window ~width:800 ~border_width:2 () in
882 let scrolled_window =
883 GBin.scrolled_window ~border_width:10 ~packing:window#add () in
885 GMathViewAux.single_selection_math_view
886 ~packing:scrolled_window#add ~width:600 ~height:400 ()
888 let _ = window#event#connect#delete (fun _ -> window#misc#hide () ; true ) in
889 let href = Gdome.domString "href" in
890 let show_in_show_window_obj uri obj =
891 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
894 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
895 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
897 Cic2acic.acic_object_of_cic_object obj
900 ApplyStylesheets.mml_of_cic_object
901 ~explode_all:false uri acic ids_to_inner_sorts ids_to_inner_types
903 window#set_title (UriManager.string_of_uri uri) ;
904 window#misc#hide () ; window#show () ;
905 mmlwidget#load_doc mml ;
908 output_html outputhtml
909 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
911 let show_in_show_window_uri uri =
912 let obj = CicEnvironment.get_obj uri in
913 show_in_show_window_obj uri obj
915 let show_in_show_window_callback mmlwidget (n : Gdome.element option) _ =
919 if n'#hasAttributeNS ~namespaceURI:xlinkns ~localName:href then
921 (n'#getAttributeNS ~namespaceURI:xlinkns ~localName:href)#to_string
923 show_in_show_window_uri (UriManager.uri_of_string uri)
925 ignore (mmlwidget#action_toggle n')
928 mmlwidget#connect#click (show_in_show_window_callback mmlwidget)
930 show_in_show_window_obj, show_in_show_window_uri,
931 show_in_show_window_callback
934 exception NoObjectsLocated;;
936 let user_uri_choice ~title ~msg uris =
939 [] -> raise NoObjectsLocated
943 interactive_user_uri_choice ~selection_mode:`SINGLE ~title ~msg uris
948 String.sub uri 4 (String.length uri - 4)
951 let locate_callback id =
952 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
953 let out = output_html outputhtml in
954 let query = MQG.locate id in
955 let result = MQI.execute mqi_handle query in
959 MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format' uri)
961 out "<h1>Locate Query: </h1><pre>";
962 MQueryUtil.text_of_query out query "";
963 out "<h1>Result:</h1>";
964 MQueryUtil.text_of_result out result "<br>";
965 user_uri_choice ~title:"Ambiguous input."
967 ("Ambiguous input \"" ^ id ^
968 "\". Please, choose one interpetation:")
973 let input_or_locate_uri ~title =
974 let uri = ref None in
977 ~width:400 ~modal:true ~title ~border_width:2 () in
978 let vbox = GPack.vbox ~packing:window#add () in
980 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
982 GMisc.label ~text:"Enter a valid URI:" ~packing:(hbox1#pack ~padding:5) () in
984 GEdit.entry ~editable:true
985 ~packing:(hbox1#pack ~expand:true ~fill:true ~padding:5) () in
987 GButton.button ~label:"Check"
988 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
989 let _ = checkb#misc#set_sensitive false in
991 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
993 GMisc.label ~text:"You can also enter an indentifier to locate:"
994 ~packing:(hbox2#pack ~padding:5) () in
996 GEdit.entry ~editable:true
997 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
999 GButton.button ~label:"Locate"
1000 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1001 let _ = locateb#misc#set_sensitive false in
1003 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1005 GButton.button ~label:"Ok"
1006 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1007 let _ = okb#misc#set_sensitive false in
1009 GButton.button ~label:"Cancel"
1010 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) ()
1012 ignore (window#connect#destroy GMain.Main.quit) ;
1014 (cancelb#connect#clicked (function () -> uri := None ; window#destroy ())) ;
1015 let check_callback () =
1016 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1017 let uri = "cic:" ^ manual_input#text in
1019 ignore (Getter.resolve (UriManager.uri_of_string uri)) ;
1020 output_html outputhtml "<h1 color=\"Green\">OK</h1>" ;
1023 Getter.Unresolved ->
1024 output_html outputhtml
1025 ("<h1 color=\"Red\">URI " ^ uri ^
1026 " does not correspond to any object.</h1>") ;
1028 | UriManager.IllFormedUri _ ->
1029 output_html outputhtml
1030 ("<h1 color=\"Red\">URI " ^ uri ^ " is not well-formed.</h1>") ;
1033 output_html outputhtml
1034 ("<h1 color=\"Red\">" ^ Printexc.to_string e ^ "</h1>") ;
1038 (okb#connect#clicked
1040 if check_callback () then
1042 uri := Some manual_input#text ;
1046 ignore (checkb#connect#clicked (function () -> ignore (check_callback ()))) ;
1048 (manual_input#connect#changed
1050 if manual_input#text = "" then
1052 checkb#misc#set_sensitive false ;
1053 okb#misc#set_sensitive false
1057 checkb#misc#set_sensitive true ;
1058 okb#misc#set_sensitive true
1061 (locate_input#connect#changed
1062 (fun _ -> locateb#misc#set_sensitive (locate_input#text <> ""))) ;
1064 (locateb#connect#clicked
1066 let id = locate_input#text in
1067 manual_input#set_text (locate_callback id) ;
1068 locate_input#delete_text 0 (String.length id)
1073 None -> raise NoChoice
1074 | Some uri -> UriManager.uri_of_string ("cic:" ^ uri)
1077 exception AmbiguousInput;;
1079 (* A WIDGET TO ENTER CIC TERMS *)
1081 module ChosenTermEditor = TexTermEditor;;
1082 module ChosenTextualParser0 = TexCicTextualParser0;;
1084 module ChosenTermEditor = TermEditor;;
1085 module ChosenTextualParser0 = CicTextualParser0;;
1090 let get_metasenv () = !ChosenTextualParser0.metasenv
1091 let set_metasenv metasenv = ChosenTextualParser0.metasenv := metasenv
1093 let output_html msg = output_html (outputhtml ()) msg;;
1094 let interactive_user_uri_choice =
1095 fun ~selection_mode ?ok ?enable_button_for_non_vars ~title ~msg ~id ->
1096 interactive_user_uri_choice ~selection_mode ?ok
1097 ?enable_button_for_non_vars ~title ~msg;;
1098 let interactive_interpretation_choice = interactive_interpretation_choice;;
1099 let input_or_locate_uri = input_or_locate_uri;;
1103 module TexTermEditor' = ChosenTermEditor.Make(Callbacks);;
1105 (* OTHER FUNCTIONS *)
1108 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1109 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1112 GToolbox.input_string ~title:"Locate" "Enter an identifier to locate:"
1114 None -> raise NoChoice
1116 let uri = locate_callback input in
1120 output_html outputhtml
1121 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
1125 exception UriAlreadyInUse;;
1126 exception NotAUriToAConstant;;
1128 let new_inductive () =
1129 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1130 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1131 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1132 let notebook = (rendering_window ())#notebook in
1134 let chosen = ref false in
1135 let inductive = ref true in
1136 let paramsno = ref 0 in
1137 let get_uri = ref (function _ -> assert false) in
1138 let get_base_uri = ref (function _ -> assert false) in
1139 let get_names = ref (function _ -> assert false) in
1140 let get_types_and_cons = ref (function _ -> assert false) in
1141 let get_context_and_subst = ref (function _ -> assert false) in
1144 ~width:600 ~modal:true ~position:`CENTER
1145 ~title:"New Block of Mutual (Co)Inductive Definitions"
1146 ~border_width:2 () in
1147 let vbox = GPack.vbox ~packing:window#add () in
1149 GPack.hbox ~border_width:0
1150 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1152 GMisc.label ~text:"Enter the URI for the new block:"
1153 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1155 GEdit.entry ~editable:true
1156 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1158 GPack.hbox ~border_width:0
1159 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1163 "Enter the number of left parameters in every arity and constructor type:"
1164 ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1165 let paramsno_entry =
1166 GEdit.entry ~editable:true ~text:"0"
1167 ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
1169 GPack.hbox ~border_width:0
1170 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1172 GMisc.label ~text:"Are the definitions inductive or coinductive?"
1173 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1175 GButton.radio_button ~label:"Inductive"
1176 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1178 GButton.radio_button ~label:"Coinductive"
1179 ~group:inductiveb#group
1180 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1182 GPack.hbox ~border_width:0
1183 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1185 GMisc.label ~text:"Enter the list of the names of the types:"
1186 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1188 GEdit.entry ~editable:true
1189 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1191 GPack.hbox ~border_width:0
1192 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1194 GButton.button ~label:"> Next"
1195 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1196 let _ = okb#misc#set_sensitive true in
1198 GButton.button ~label:"Abort"
1199 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1200 ignore (window#connect#destroy GMain.Main.quit) ;
1201 ignore (cancelb#connect#clicked window#destroy) ;
1205 (okb#connect#clicked
1208 let uristr = "cic:" ^ uri_entry#text in
1209 let namesstr = names_entry#text in
1210 let paramsno' = int_of_string (paramsno_entry#text) in
1211 match Str.split (Str.regexp " +") namesstr with
1213 | (he::tl) as names ->
1214 let uri = UriManager.uri_of_string (uristr ^ "/" ^ he ^ ".ind") in
1217 ignore (Getter.resolve uri) ;
1218 raise UriAlreadyInUse
1220 Getter.Unresolved ->
1221 get_uri := (function () -> uri) ;
1222 get_names := (function () -> names) ;
1223 inductive := inductiveb#active ;
1224 paramsno := paramsno' ;
1229 output_html outputhtml
1230 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1238 GBin.frame ~label:name
1239 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1240 let vbox = GPack.vbox ~packing:frame#add () in
1241 let hbox = GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false) () in
1243 GMisc.label ~text:("Enter its type:")
1244 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1245 let scrolled_window =
1246 GBin.scrolled_window ~border_width:5
1247 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1249 TexTermEditor'.term_editor
1251 ~width:400 ~height:20 ~packing:scrolled_window#add
1252 ~share_id_to_uris_with:inputt ()
1253 ~isnotempty_callback:
1255 (*non_empty_type := b ;*)
1256 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*)
1259 GPack.hbox ~border_width:0
1260 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1262 GMisc.label ~text:("Enter the list of its constructors:")
1263 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1264 let cons_names_entry =
1265 GEdit.entry ~editable:true
1266 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1267 (newinputt,cons_names_entry)
1270 vbox#remove hboxn#coerce ;
1272 GPack.hbox ~border_width:0
1273 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1275 GButton.button ~label:"> Next"
1276 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1278 GButton.button ~label:"Abort"
1279 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1280 ignore (cancelb#connect#clicked window#destroy) ;
1282 (okb#connect#clicked
1285 let names = !get_names () in
1286 let types_and_cons =
1288 (fun name (newinputt,cons_names_entry) ->
1289 let consnamesstr = cons_names_entry#text in
1290 let cons_names = Str.split (Str.regexp " +") consnamesstr in
1292 newinputt#get_metasenv_and_term ~context:[] ~metasenv:[]
1295 [] -> expr,cons_names
1296 | _ -> raise AmbiguousInput
1297 ) names type_widgets
1299 let uri = !get_uri () in
1301 (* Let's see if so far the definition is well-typed *)
1304 (* To test if the arities of the inductive types are well *)
1305 (* typed, we check the inductive block definition where *)
1306 (* no constructor is given to each type. *)
1309 (fun name (ty,cons) -> (name, !inductive, ty, []))
1310 names types_and_cons
1312 CicTypeChecker.typecheck_mutual_inductive_defs uri
1313 (tys,params,paramsno)
1315 get_context_and_subst :=
1319 (fun (context,subst) name (ty,_) ->
1321 (Some (Cic.Name name, Cic.Decl ty))::context,
1322 (Cic.MutInd (uri,!i,[]))::subst
1325 ) ([],[]) names types_and_cons) ;
1326 let types_and_cons' =
1328 (fun name (ty,cons) -> (name, !inductive, ty, phase3 name cons))
1329 names types_and_cons
1331 get_types_and_cons := (function () -> types_and_cons') ;
1336 output_html outputhtml
1337 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1340 and phase3 name cons =
1341 let get_cons_types = ref (function () -> assert false) in
1344 ~width:600 ~modal:true ~position:`CENTER
1345 ~title:(name ^ " Constructors")
1346 ~border_width:2 () in
1347 let vbox = GPack.vbox ~packing:window2#add () in
1348 let cons_type_widgets =
1350 (function consname ->
1352 GPack.hbox ~border_width:0
1353 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1355 GMisc.label ~text:("Enter the type of " ^ consname ^ ":")
1356 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1357 let scrolled_window =
1358 GBin.scrolled_window ~border_width:5
1359 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1361 TexTermEditor'.term_editor
1363 ~width:400 ~height:20 ~packing:scrolled_window#add
1364 ~share_id_to_uris_with:inputt ()
1365 ~isnotempty_callback:
1367 (* (*non_empty_type := b ;*)
1368 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*) *)())
1373 GPack.hbox ~border_width:0
1374 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1376 GButton.button ~label:"> Next"
1377 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1378 let _ = okb#misc#set_sensitive true in
1380 GButton.button ~label:"Abort"
1381 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1382 ignore (window2#connect#destroy GMain.Main.quit) ;
1383 ignore (cancelb#connect#clicked window2#destroy) ;
1385 (okb#connect#clicked
1389 let context,subst= !get_context_and_subst () in
1394 inputt#get_metasenv_and_term ~context ~metasenv:[]
1398 let undebrujined_expr =
1400 (fun expr t -> CicSubstitution.subst t expr) expr subst
1402 name, undebrujined_expr
1403 | _ -> raise AmbiguousInput
1404 ) cons cons_type_widgets
1406 get_cons_types := (function () -> cons_types) ;
1410 output_html outputhtml
1411 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1415 let okb_pressed = !chosen in
1417 if (not okb_pressed) then
1420 assert false (* The control never reaches this point *)
1423 (!get_cons_types ())
1426 (* No more phases left or Abort pressed *)
1432 let uri = !get_uri () in
1435 let tys = !get_types_and_cons () in
1436 let obj = Cic.InductiveDefinition tys params !paramsno in
1439 prerr_endline (CicPp.ppobj obj) ;
1440 CicTypeChecker.typecheck_mutual_inductive_defs uri
1441 (tys,params,!paramsno) ;
1444 prerr_endline "Offending mutual (co)inductive type declaration:" ;
1445 prerr_endline (CicPp.ppobj obj) ;
1447 (* We already know that obj is well-typed. We need to add it to the *)
1448 (* environment in order to compute the inner-types without having to *)
1449 (* debrujin it or having to modify lots of other functions to avoid *)
1450 (* asking the environment for the MUTINDs we are defining now. *)
1451 CicEnvironment.put_inductive_definition uri obj ;
1453 show_in_show_window_obj uri obj
1456 output_html outputhtml
1457 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1461 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1462 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1463 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1464 let notebook = (rendering_window ())#notebook in
1466 let chosen = ref false in
1467 let get_metasenv_and_term = ref (function _ -> assert false) in
1468 let get_uri = ref (function _ -> assert false) in
1469 let non_empty_type = ref false in
1472 ~width:600 ~modal:true ~title:"New Proof or Definition"
1473 ~border_width:2 () in
1474 let vbox = GPack.vbox ~packing:window#add () in
1476 GPack.hbox ~border_width:0
1477 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1479 GMisc.label ~text:"Enter the URI for the new theorem or definition:"
1480 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1482 GEdit.entry ~editable:true
1483 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1485 GPack.hbox ~border_width:0
1486 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1488 GMisc.label ~text:"Enter the theorem or definition type:"
1489 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1490 let scrolled_window =
1491 GBin.scrolled_window ~border_width:5
1492 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1493 (* the content of the scrolled_window is moved below (see comment) *)
1495 GPack.hbox ~border_width:0
1496 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1498 GButton.button ~label:"Ok"
1499 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1500 let _ = okb#misc#set_sensitive false in
1502 GButton.button ~label:"Cancel"
1503 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1504 (* moved here to have visibility of the ok button *)
1506 TexTermEditor'.term_editor
1508 ~width:400 ~height:100 ~packing:scrolled_window#add
1509 ~share_id_to_uris_with:inputt ()
1510 ~isnotempty_callback:
1512 non_empty_type := b ;
1513 okb#misc#set_sensitive (b && uri_entry#text <> ""))
1516 let xxx = inputt#get_as_string in
1517 prerr_endline ("######################## " ^ xxx) ;
1518 newinputt#set_term xxx ;
1520 newinputt#set_term inputt#get_as_string ;
1524 uri_entry#connect#changed
1526 okb#misc#set_sensitive (!non_empty_type && uri_entry#text <> ""))
1528 ignore (window#connect#destroy GMain.Main.quit) ;
1529 ignore (cancelb#connect#clicked window#destroy) ;
1531 (okb#connect#clicked
1535 let metasenv,parsed = newinputt#get_metasenv_and_term [] [] in
1536 let uristr = "cic:" ^ uri_entry#text in
1537 let uri = UriManager.uri_of_string uristr in
1538 if String.sub uristr (String.length uristr - 4) 4 <> ".con" then
1539 raise NotAUriToAConstant
1543 ignore (Getter.resolve uri) ;
1544 raise UriAlreadyInUse
1546 Getter.Unresolved ->
1547 get_metasenv_and_term := (function () -> metasenv,parsed) ;
1548 get_uri := (function () -> uri) ;
1553 output_html outputhtml
1554 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1560 let metasenv,expr = !get_metasenv_and_term () in
1561 let _ = CicTypeChecker.type_of_aux' metasenv [] expr in
1562 ProofEngine.proof :=
1563 Some (!get_uri (), (1,[],expr)::metasenv, Cic.Meta (1,[]), expr) ;
1564 ProofEngine.goal := Some 1 ;
1565 refresh_goals notebook ;
1566 refresh_proof output ;
1567 !save_set_sensitive true ;
1569 ProofEngine.intros ~mk_fresh_name_callback () ;
1570 refresh_goals notebook ;
1571 refresh_proof output
1573 InvokeTactics.RefreshSequentException e ->
1574 output_html outputhtml
1575 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1576 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1577 | InvokeTactics.RefreshProofException e ->
1578 output_html outputhtml
1579 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1580 "proof: " ^ Printexc.to_string e ^ "</h1>")
1582 output_html outputhtml
1583 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1586 let check_term_in_scratch scratch_window metasenv context expr =
1588 let ty = CicTypeChecker.type_of_aux' metasenv context expr in
1589 let expr = Cic.Cast (expr,ty) in
1590 scratch_window#show () ;
1591 scratch_window#set_term expr ;
1592 scratch_window#set_context context ;
1593 scratch_window#set_metasenv metasenv ;
1594 scratch_window#sequent_viewer#load_sequent metasenv (111,context,expr)
1597 print_endline ("? " ^ CicPp.ppterm expr) ;
1601 let check scratch_window () =
1602 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1603 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1605 match !ProofEngine.proof with
1607 | Some (_,metasenv,_,_) -> metasenv
1610 match !ProofEngine.goal with
1613 let (_,canonical_context,_) =
1614 List.find (function (m,_,_) -> m=metano) metasenv
1619 let metasenv',expr = inputt#get_metasenv_and_term context metasenv in
1620 check_term_in_scratch scratch_window metasenv' context expr
1623 output_html outputhtml
1624 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1628 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1630 show_in_show_window_uri (input_or_locate_uri ~title:"Show")
1633 output_html outputhtml
1634 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1637 exception NotADefinition;;
1640 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1641 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1642 let notebook = (rendering_window ())#notebook in
1644 let uri = input_or_locate_uri ~title:"Open" in
1645 CicTypeChecker.typecheck uri ;
1646 let metasenv,bo,ty =
1647 match CicEnvironment.get_cooked_obj uri with
1648 Cic.Constant (_,Some bo,ty,_) -> [],bo,ty
1649 | Cic.CurrentProof (_,metasenv,bo,ty,_) -> metasenv,bo,ty
1652 | Cic.InductiveDefinition _ -> raise NotADefinition
1654 ProofEngine.proof :=
1655 Some (uri, metasenv, bo, ty) ;
1656 ProofEngine.goal := None ;
1657 refresh_goals notebook ;
1658 refresh_proof output ;
1659 !save_set_sensitive true
1661 InvokeTactics.RefreshSequentException e ->
1662 output_html outputhtml
1663 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1664 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1665 | InvokeTactics.RefreshProofException e ->
1666 output_html outputhtml
1667 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1668 "proof: " ^ Printexc.to_string e ^ "</h1>")
1670 output_html outputhtml
1671 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1674 let show_query_results results =
1677 ~modal:false ~title:"Query results." ~border_width:2 () in
1678 let vbox = GPack.vbox ~packing:window#add () in
1680 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1683 ~text:"Click on a URI to show that object"
1684 ~packing:hbox#add () in
1685 let scrolled_window =
1686 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1687 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1688 let clist = GList.clist ~columns:1 ~packing:scrolled_window#add () in
1691 (function (uri,_) ->
1695 clist#set_row ~selectable:false n
1698 clist#columns_autosize () ;
1700 (clist#connect#select_row
1701 (fun ~row ~column ~event ->
1702 let (uristr,_) = List.nth results row in
1704 MQueryMisc.cic_textual_parser_uri_of_string
1705 (MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format'
1708 CicTextualParser0.ConUri uri
1709 | CicTextualParser0.VarUri uri
1710 | CicTextualParser0.IndTyUri (uri,_)
1711 | CicTextualParser0.IndConUri (uri,_,_) ->
1712 show_in_show_window_uri uri
1718 let refine_constraints (must_obj,must_rel,must_sort) =
1719 let chosen = ref false in
1720 let use_only = ref false in
1723 ~modal:true ~title:"Constraints refinement."
1724 ~width:800 ~border_width:2 () in
1725 let vbox = GPack.vbox ~packing:window#add () in
1727 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1730 ~text: "\"Only\" constraints can be enforced or not."
1731 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1733 GButton.toggle_button ~label:"Enforce \"only\" constraints"
1734 ~active:false ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1737 (onlyb#connect#toggled (function () -> use_only := onlyb#active)) ;
1738 (* Notebook for the constraints choice *)
1740 GPack.notebook ~scrollable:true
1741 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1742 (* Rel constraints *)
1745 ~text: "Constraints on Rels" () in
1747 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1750 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1753 ~text: "You can now specify the constraints on Rels."
1754 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1755 let expected_height = 25 * (List.length must_rel + 2) in
1756 let height = if expected_height > 400 then 400 else expected_height in
1757 let scrolled_window =
1758 GBin.scrolled_window ~border_width:10 ~height ~width:600
1759 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1760 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1761 let mk_depth_button (hbox:GPack.box) d =
1762 let mutable_ref = ref (Some d) in
1764 GButton.toggle_button
1765 ~label:("depth = " ^ string_of_int d)
1767 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1770 (depthb#connect#toggled
1772 let sel_depth = if depthb#active then Some d else None in
1773 mutable_ref := sel_depth
1776 let rel_constraints =
1781 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1784 ~text:(MQGU.text_of_position (p:>MQGT.full_position))
1785 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1787 | `MainHypothesis None
1788 | `MainConclusion None -> p, ref None
1789 | `MainHypothesis (Some depth')
1790 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth'
1792 (* Sort constraints *)
1795 ~text: "Constraints on Sorts" () in
1797 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1800 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1803 ~text: "You can now specify the constraints on Sorts."
1804 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1805 let expected_height = 25 * (List.length must_sort + 2) in
1806 let height = if expected_height > 400 then 400 else expected_height in
1807 let scrolled_window =
1808 GBin.scrolled_window ~border_width:10 ~height ~width:600
1809 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1810 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1811 let sort_constraints =
1813 (function (p, sort) ->
1816 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1819 ~text:(MQGU.text_of_sort sort ^ " " ^ MQGU.text_of_position (p:>MQGT.full_position))
1820 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1822 | `MainHypothesis None
1823 | `MainConclusion None -> p, ref None, sort
1824 | `MainHypothesis (Some depth')
1825 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', sort
1827 (* Obj constraints *)
1830 ~text: "Constraints on constants" () in
1832 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1835 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1838 ~text: "You can now specify the constraints on constants."
1839 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1840 let expected_height = 25 * (List.length must_obj + 2) in
1841 let height = if expected_height > 400 then 400 else expected_height in
1842 let scrolled_window =
1843 GBin.scrolled_window ~border_width:10 ~height ~width:600
1844 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1845 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1846 let obj_constraints =
1848 (function (p, uri) ->
1851 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1854 ~text:(uri ^ " " ^ (MQGU.text_of_position p))
1855 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1860 | `MainHypothesis None
1861 | `MainConclusion None -> p, ref None, uri
1862 | `MainHypothesis (Some depth')
1863 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', uri
1865 (* Confirm/abort buttons *)
1867 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1869 GButton.button ~label:"Ok"
1870 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1872 GButton.button ~label:"Abort"
1873 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1875 ignore (window#connect#destroy GMain.Main.quit) ;
1876 ignore (cancelb#connect#clicked window#destroy) ;
1878 (okb#connect#clicked (function () -> chosen := true ; window#destroy ()));
1879 window#set_position `CENTER ;
1883 let chosen_must_rel =
1885 (function (position, ref_depth) -> MQGU.set_main_position position !ref_depth)
1888 let chosen_must_sort =
1890 (function (position, ref_depth, sort) ->
1891 MQGU.set_main_position position !ref_depth,sort)
1894 let chosen_must_obj =
1896 (function (position, ref_depth, uri) -> MQGU.set_full_position position !ref_depth, uri)
1899 (chosen_must_obj,chosen_must_rel,chosen_must_sort),
1901 (*CSC: ???????????????????????? I assume that must and only are the same... *)
1902 Some chosen_must_obj,Some chosen_must_rel,Some chosen_must_sort
1910 let completeSearchPattern () =
1911 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1912 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1914 let metasenv,expr = inputt#get_metasenv_and_term ~context:[] ~metasenv:[] in
1915 let must = MQueryLevels2.get_constraints expr in
1916 let must',only = refine_constraints must in
1918 MQG.query_of_constraints (Some MQGU.universe_for_search_pattern) must' only
1920 let results = MQI.execute mqi_handle query in
1921 show_query_results results
1924 output_html outputhtml
1925 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1928 let insertQuery () =
1929 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1931 let chosen = ref None in
1934 ~modal:true ~title:"Insert Query (Experts Only)" ~border_width:2 () in
1935 let vbox = GPack.vbox ~packing:window#add () in
1937 GMisc.label ~text:"Insert Query. For Experts Only."
1938 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1939 let scrolled_window =
1940 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1941 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1942 let input = GEdit.text ~editable:true
1943 ~packing:scrolled_window#add () in
1945 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1947 GButton.button ~label:"Ok"
1948 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1950 GButton.button ~label:"Load from file..."
1951 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1953 GButton.button ~label:"Abort"
1954 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1955 ignore (window#connect#destroy GMain.Main.quit) ;
1956 ignore (cancelb#connect#clicked window#destroy) ;
1958 (okb#connect#clicked
1960 chosen := Some (input#get_chars 0 input#length) ; window#destroy ())) ;
1962 (loadb#connect#clicked
1965 GToolbox.select_file ~title:"Select Query File" ()
1969 let inch = open_in filename in
1970 let rec read_file () =
1972 let line = input_line inch in
1973 line ^ "\n" ^ read_file ()
1977 let text = read_file () in
1978 input#delete_text 0 input#length ;
1979 ignore (input#insert_text text ~pos:0))) ;
1980 window#set_position `CENTER ;
1987 MQI.execute mqi_handle (MQueryUtil.query_of_text (Lexing.from_string q))
1989 show_query_results results
1992 output_html outputhtml
1993 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1996 let choose_must list_of_must only =
1997 let chosen = ref None in
1998 let user_constraints = ref [] in
2001 ~modal:true ~title:"Query refinement." ~border_width:2 () in
2002 let vbox = GPack.vbox ~packing:window#add () in
2004 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2008 ("You can now specify the genericity of the query. " ^
2009 "The more generic the slower.")
2010 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2012 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2016 "Suggestion: start with faster queries before moving to more generic ones."
2017 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2019 GPack.notebook ~scrollable:true
2020 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2023 let last = List.length list_of_must in
2029 (if !page = 1 then "More generic" else
2030 if !page = last then "More precise" else " ") () in
2031 let expected_height = 25 * (List.length must + 2) in
2032 let height = if expected_height > 400 then 400 else expected_height in
2033 let scrolled_window =
2034 GBin.scrolled_window ~border_width:10 ~height ~width:600
2035 ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2037 GList.clist ~columns:2 ~packing:scrolled_window#add
2038 ~titles:["URI" ; "Position"] ()
2042 (function (uri,position) ->
2045 [uri; if position then "MainConclusion" else "Conclusion"]
2047 clist#set_row ~selectable:false n
2050 clist#columns_autosize ()
2053 let label = GMisc.label ~text:"User provided" () in
2055 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2057 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2060 ~text:"Select the constraints that must be satisfied and press OK."
2061 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2062 let expected_height = 25 * (List.length only + 2) in
2063 let height = if expected_height > 400 then 400 else expected_height in
2064 let scrolled_window =
2065 GBin.scrolled_window ~border_width:10 ~height ~width:600
2066 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2068 GList.clist ~columns:2 ~packing:scrolled_window#add
2069 ~selection_mode:`EXTENDED
2070 ~titles:["URI" ; "Position"] ()
2074 (function (uri,position) ->
2077 [uri; if position then "MainConclusion" else "Conclusion"]
2079 clist#set_row ~selectable:true n
2082 clist#columns_autosize () ;
2084 (clist#connect#select_row
2085 (fun ~row ~column ~event ->
2086 user_constraints := (List.nth only row)::!user_constraints)) ;
2088 (clist#connect#unselect_row
2089 (fun ~row ~column ~event ->
2092 (function uri -> uri != (List.nth only row)) !user_constraints)) ;
2095 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2097 GButton.button ~label:"Ok"
2098 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2100 GButton.button ~label:"Abort"
2101 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2103 ignore (window#connect#destroy GMain.Main.quit) ;
2104 ignore (cancelb#connect#clicked window#destroy) ;
2106 (okb#connect#clicked
2107 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
2108 window#set_position `CENTER ;
2112 None -> raise NoChoice
2114 if n = List.length list_of_must then
2115 (* user provided constraints *)
2118 List.nth list_of_must n
2121 let searchPattern () =
2122 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
2123 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
2126 match !ProofEngine.proof with
2127 None -> assert false
2128 | Some proof -> proof
2130 match !ProofEngine.goal with
2134 TacticChaser.matchConclusion
2136 ~output_html:(output_html outputhtml) ~choose_must ()
2137 ~status:(proof, metano)
2140 user_uri_choice ~title:"Ambiguous input."
2141 ~msg: "Many lemmas can be successfully applied. Please, choose one:"
2144 inputt#set_term uri' ;
2145 InvokeTactics'.apply ()
2148 output_html outputhtml
2149 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
2152 let choose_selection mmlwidget (element : Gdome.element option) =
2153 let module G = Gdome in
2154 let rec aux element =
2155 if element#hasAttributeNS
2156 ~namespaceURI:Misc.helmns
2157 ~localName:(G.domString "xref")
2159 mmlwidget#set_selection (Some element)
2162 match element#get_parentNode with
2163 None -> assert false
2164 (*CSC: OCAML DIVERGES!
2165 | Some p -> aux (new G.element_of_node p)
2167 | Some p -> aux (new Gdome.element_of_node p)
2169 GdomeInit.DOMCastException _ ->
2171 "******* trying to select above the document root ********"
2175 | None -> mmlwidget#set_selection None
2178 (* STUFF TO BUILD THE GTK INTERFACE *)
2180 (* Stuff for the widget settings *)
2182 let export_to_postscript output =
2183 let lastdir = ref (Unix.getcwd ()) in
2186 GToolbox.select_file ~title:"Export to PostScript"
2187 ~dir:lastdir ~filename:"screenshot.ps" ()
2191 (output :> GMathView.math_view)#export_to_postscript
2192 ~filename:filename ();
2195 let activate_t1 output button_set_anti_aliasing
2196 button_set_transparency export_to_postscript_menu_item
2199 let is_set = button_t1#active in
2200 output#set_font_manager_type
2201 ~fm_type:(if is_set then `font_manager_t1 else `font_manager_gtk) ;
2204 button_set_anti_aliasing#misc#set_sensitive true ;
2205 button_set_transparency#misc#set_sensitive true ;
2206 export_to_postscript_menu_item#misc#set_sensitive true ;
2210 button_set_anti_aliasing#misc#set_sensitive false ;
2211 button_set_transparency#misc#set_sensitive false ;
2212 export_to_postscript_menu_item#misc#set_sensitive false ;
2216 let set_anti_aliasing output button_set_anti_aliasing () =
2217 output#set_anti_aliasing button_set_anti_aliasing#active
2220 let set_transparency output button_set_transparency () =
2221 output#set_transparency button_set_transparency#active
2224 let changefont output font_size_spinb () =
2225 output#set_font_size font_size_spinb#value_as_int
2228 let set_log_verbosity output log_verbosity_spinb () =
2229 output#set_log_verbosity log_verbosity_spinb#value_as_int
2232 class settings_window output sw
2233 export_to_postscript_menu_item selection_changed_callback
2235 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
2237 GPack.vbox ~packing:settings_window#add () in
2240 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2241 ~border_width:5 ~packing:vbox#add () in
2243 GButton.toggle_button ~label:"activate t1 fonts"
2244 ~packing:(table#attach ~left:0 ~top:0) () in
2245 let button_set_anti_aliasing =
2246 GButton.toggle_button ~label:"set_anti_aliasing"
2247 ~packing:(table#attach ~left:0 ~top:1) () in
2248 let button_set_transparency =
2249 GButton.toggle_button ~label:"set_transparency"
2250 ~packing:(table#attach ~left:2 ~top:1) () in
2253 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2254 ~border_width:5 ~packing:vbox#add () in
2255 let font_size_label =
2256 GMisc.label ~text:"font size:"
2257 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
2258 let font_size_spinb =
2260 GData.adjustment ~value:(float_of_int output#get_font_size)
2261 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
2264 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
2265 let log_verbosity_label =
2266 GMisc.label ~text:"log verbosity:"
2267 ~packing:(table#attach ~left:0 ~top:1) () in
2268 let log_verbosity_spinb =
2270 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
2273 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
2275 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2277 GButton.button ~label:"Close"
2278 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2280 method show = settings_window#show
2282 button_set_anti_aliasing#misc#set_sensitive false ;
2283 button_set_transparency#misc#set_sensitive false ;
2284 (* Signals connection *)
2285 ignore(button_t1#connect#clicked
2286 (activate_t1 output button_set_anti_aliasing
2287 button_set_transparency export_to_postscript_menu_item button_t1)) ;
2288 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
2289 ignore(button_set_anti_aliasing#connect#toggled
2290 (set_anti_aliasing output button_set_anti_aliasing));
2291 ignore(button_set_transparency#connect#toggled
2292 (set_transparency output button_set_transparency)) ;
2293 ignore(log_verbosity_spinb#connect#changed
2294 (set_log_verbosity output log_verbosity_spinb)) ;
2295 ignore(closeb#connect#clicked settings_window#misc#hide)
2298 (* Scratch window *)
2300 class scratch_window =
2303 ~title:"MathML viewer"
2304 ~border_width:2 () in
2306 GPack.vbox ~packing:window#add () in
2308 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2310 GButton.button ~label:"Whd"
2311 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2313 GButton.button ~label:"Reduce"
2314 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2316 GButton.button ~label:"Simpl"
2317 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2318 let scrolled_window =
2319 GBin.scrolled_window ~border_width:10
2320 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2321 let sequent_viewer =
2322 TermViewer.sequent_viewer
2323 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
2325 val mutable term = Cic.Rel 1 (* dummy value *)
2326 val mutable context = ([] : Cic.context) (* dummy value *)
2327 val mutable metasenv = ([] : Cic.metasenv) (* dummy value *)
2328 method sequent_viewer = sequent_viewer
2329 method show () = window#misc#hide () ; window#show ()
2331 method set_term t = term <- t
2332 method context = context
2333 method set_context t = context <- t
2334 method metasenv = metasenv
2335 method set_metasenv t = metasenv <- t
2338 (sequent_viewer#connect#selection_changed (choose_selection sequent_viewer));
2339 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
2340 ignore(whdb#connect#clicked InvokeTactics'.whd_in_scratch) ;
2341 ignore(reduceb#connect#clicked InvokeTactics'.reduce_in_scratch) ;
2342 ignore(simplb#connect#clicked InvokeTactics'.simpl_in_scratch)
2345 let open_contextual_menu_for_selected_terms mmlwidget infos =
2346 let button = GdkEvent.Button.button infos in
2347 let terms_selected = List.length mmlwidget#get_selections > 0 in
2350 let time = GdkEvent.Button.time infos in
2351 let menu = GMenu.menu () in
2352 let f = new GMenu.factory menu in
2354 f#add_item "Whd" ~key:GdkKeysyms._W ~callback:InvokeTactics'.whd in
2355 let reduce_menu_item =
2356 f#add_item "Reduce" ~key:GdkKeysyms._R ~callback:InvokeTactics'.reduce in
2357 let simpl_menu_item =
2358 f#add_item "Simpl" ~key:GdkKeysyms._S ~callback:InvokeTactics'.simpl in
2359 let _ = f#add_separator () in
2360 let generalize_menu_item =
2361 f#add_item "Generalize"
2362 ~key:GdkKeysyms._G ~callback:InvokeTactics'.generalize in
2363 let _ = f#add_separator () in
2364 let clear_menu_item =
2365 f#add_item "Clear" ~key:GdkKeysyms._C ~callback:InvokeTactics'.clear in
2366 let clearbody_menu_item =
2367 f#add_item "ClearBody"
2368 ~key:GdkKeysyms._B ~callback:InvokeTactics'.clearbody
2370 whd_menu_item#misc#set_sensitive terms_selected ;
2371 reduce_menu_item#misc#set_sensitive terms_selected ;
2372 simpl_menu_item#misc#set_sensitive terms_selected ;
2373 generalize_menu_item#misc#set_sensitive terms_selected ;
2374 clear_menu_item#misc#set_sensitive terms_selected ;
2375 clearbody_menu_item#misc#set_sensitive terms_selected ;
2376 menu#popup ~button ~time
2382 let vbox1 = GPack.vbox () in
2384 val mutable proofw_ref = None
2385 val mutable compute_ref = None
2387 Lazy.force self#compute ;
2388 match proofw_ref with
2389 None -> assert false
2390 | Some proofw -> proofw
2391 method content = vbox1
2393 match compute_ref with
2394 None -> assert false
2395 | Some compute -> compute
2399 let scrolled_window1 =
2400 GBin.scrolled_window ~border_width:10
2401 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2403 TermViewer.sequent_viewer ~width:400 ~height:275
2404 ~packing:(scrolled_window1#add) () in
2405 let _ = proofw_ref <- Some proofw in
2407 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2409 GButton.button ~label:"Ring"
2410 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2412 GButton.button ~label:"Fourier"
2413 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2415 GButton.button ~label:"Reflexivity"
2416 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2418 GButton.button ~label:"Symmetry"
2419 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2421 GButton.button ~label:"Assumption"
2422 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2423 let contradictionb =
2424 GButton.button ~label:"Contradiction"
2425 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2427 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2429 GButton.button ~label:"Exists"
2430 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2432 GButton.button ~label:"Split"
2433 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2435 GButton.button ~label:"Left"
2436 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2438 GButton.button ~label:"Right"
2439 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2440 let searchpatternb =
2441 GButton.button ~label:"SearchPattern_Apply"
2442 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2444 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2446 GButton.button ~label:"Exact"
2447 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2449 GButton.button ~label:"Intros"
2450 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2452 GButton.button ~label:"Apply"
2453 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2454 let elimintrossimplb =
2455 GButton.button ~label:"ElimIntrosSimpl"
2456 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2458 GButton.button ~label:"ElimType"
2459 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2461 GButton.button ~label:"Fold_whd"
2462 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2464 GButton.button ~label:"Fold_reduce"
2465 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2467 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2469 GButton.button ~label:"Fold_simpl"
2470 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2472 GButton.button ~label:"Cut"
2473 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2475 GButton.button ~label:"Change"
2476 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2478 GButton.button ~label:"Let ... In"
2479 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2481 GButton.button ~label:"RewriteSimpl ->"
2482 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2483 let rewritebacksimplb =
2484 GButton.button ~label:"RewriteSimpl <-"
2485 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2487 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2489 GButton.button ~label:"Absurd"
2490 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2492 GButton.button ~label:"Decompose"
2493 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2495 GButton.button ~label:"Transitivity"
2496 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2498 GButton.button ~label:"Replace"
2499 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2501 GButton.button ~label:"Injection"
2502 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2504 GButton.button ~label:"Discriminate"
2505 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2506 (* Zack: spostare in una toolbar
2508 GButton.button ~label:"Generalize"
2509 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2511 GButton.button ~label:"ClearBody"
2512 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2514 GButton.button ~label:"Clear"
2515 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2517 GButton.button ~label:"Whd"
2518 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2520 GButton.button ~label:"Reduce"
2521 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2523 GButton.button ~label:"Simpl"
2524 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2527 ignore(exactb#connect#clicked InvokeTactics'.exact) ;
2528 ignore(applyb#connect#clicked InvokeTactics'.apply) ;
2529 ignore(elimintrossimplb#connect#clicked InvokeTactics'.elimintrossimpl) ;
2530 ignore(elimtypeb#connect#clicked InvokeTactics'.elimtype) ;
2531 ignore(foldwhdb#connect#clicked InvokeTactics'.fold_whd) ;
2532 ignore(foldreduceb#connect#clicked InvokeTactics'.fold_reduce) ;
2533 ignore(foldsimplb#connect#clicked InvokeTactics'.fold_simpl) ;
2534 ignore(cutb#connect#clicked InvokeTactics'.cut) ;
2535 ignore(changeb#connect#clicked InvokeTactics'.change) ;
2536 ignore(letinb#connect#clicked InvokeTactics'.letin) ;
2537 ignore(ringb#connect#clicked InvokeTactics'.ring) ;
2538 ignore(fourierb#connect#clicked InvokeTactics'.fourier) ;
2539 ignore(rewritesimplb#connect#clicked InvokeTactics'.rewritesimpl) ;
2540 ignore(rewritebacksimplb#connect#clicked InvokeTactics'.rewritebacksimpl) ;
2541 ignore(replaceb#connect#clicked InvokeTactics'.replace) ;
2542 ignore(reflexivityb#connect#clicked InvokeTactics'.reflexivity) ;
2543 ignore(symmetryb#connect#clicked InvokeTactics'.symmetry) ;
2544 ignore(transitivityb#connect#clicked InvokeTactics'.transitivity) ;
2545 ignore(existsb#connect#clicked InvokeTactics'.exists) ;
2546 ignore(splitb#connect#clicked InvokeTactics'.split) ;
2547 ignore(leftb#connect#clicked InvokeTactics'.left) ;
2548 ignore(rightb#connect#clicked InvokeTactics'.right) ;
2549 ignore(assumptionb#connect#clicked InvokeTactics'.assumption) ;
2550 ignore(absurdb#connect#clicked InvokeTactics'.absurd) ;
2551 ignore(contradictionb#connect#clicked InvokeTactics'.contradiction) ;
2552 ignore(introsb#connect#clicked InvokeTactics'.intros) ;
2553 ignore(decomposeb#connect#clicked InvokeTactics'.decompose) ;
2554 ignore(searchpatternb#connect#clicked searchPattern) ;
2555 ignore(injectionb#connect#clicked InvokeTactics'.injection) ;
2556 ignore(discriminateb#connect#clicked InvokeTactics'.discriminate) ;
2557 (* Zack: spostare in una toolbar
2558 ignore(whdb#connect#clicked whd) ;
2559 ignore(reduceb#connect#clicked reduce) ;
2560 ignore(simplb#connect#clicked simpl) ;
2561 ignore(clearbodyb#connect#clicked clearbody) ;
2562 ignore(clearb#connect#clicked clear) ;
2563 ignore(generalizeb#connect#clicked generalize) ;
2565 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
2567 ((new GObj.event_ops proofw#as_widget)#connect#button_press
2568 (open_contextual_menu_for_selected_terms proofw)) ;
2574 let vbox1 = GPack.vbox () in
2575 let scrolled_window1 =
2576 GBin.scrolled_window ~border_width:10
2577 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2579 TermViewer.sequent_viewer ~width:400 ~height:275
2580 ~packing:(scrolled_window1#add) () in
2582 method proofw = (assert false : TermViewer.sequent_viewer)
2583 method content = vbox1
2584 method compute = (assert false : unit)
2588 let empty_page = new empty_page;;
2592 val notebook = GPack.notebook ()
2594 val mutable skip_switch_page_event = false
2595 val mutable empty = true
2596 method notebook = notebook
2598 let new_page = new page () in
2600 pages := !pages @ [n,lazy (setgoal n),new_page] ;
2601 notebook#append_page
2602 ~tab_label:((GMisc.label ~text:("?" ^ string_of_int n) ())#coerce)
2603 new_page#content#coerce
2604 method remove_all_pages ~skip_switch_page_event:skip =
2606 notebook#remove_page 0 (* let's remove the empty page *)
2608 List.iter (function _ -> notebook#remove_page 0) !pages ;
2610 skip_switch_page_event <- skip
2611 method set_current_page ~may_skip_switch_page_event n =
2612 let (_,_,page) = List.find (function (m,_,_) -> m=n) !pages in
2613 let new_page = notebook#page_num page#content#coerce in
2614 if may_skip_switch_page_event && new_page <> notebook#current_page then
2615 skip_switch_page_event <- true ;
2616 notebook#goto_page new_page
2617 method set_empty_page =
2620 notebook#append_page
2621 ~tab_label:((GMisc.label ~text:"No proof in progress" ())#coerce)
2622 empty_page#content#coerce
2624 let (_,_,page) = List.nth !pages notebook#current_page in
2628 (notebook#connect#switch_page
2630 let skip = skip_switch_page_event in
2631 skip_switch_page_event <- false ;
2634 let (metano,setgoal,page) = List.nth !pages i in
2635 ProofEngine.goal := Some metano ;
2636 Lazy.force (page#compute) ;
2645 class rendering_window output (notebook : notebook) =
2646 let scratch_window = new scratch_window in
2649 ~title:"gTopLevel - Helm's Proof Assistant"
2650 ~border_width:0 ~allow_shrink:false () in
2651 let vbox_for_menu = GPack.vbox ~packing:window#add () in
2653 let handle_box = GBin.handle_box ~border_width:2
2654 ~packing:(vbox_for_menu#pack ~padding:0) () in
2655 let menubar = GMenu.menu_bar ~packing:handle_box#add () in
2656 let factory0 = new GMenu.factory menubar in
2657 let accel_group = factory0#accel_group in
2659 let file_menu = factory0#add_submenu "File" in
2660 let factory1 = new GMenu.factory file_menu ~accel_group in
2661 let export_to_postscript_menu_item =
2664 factory1#add_item "New Block of (Co)Inductive Definitions..."
2665 ~key:GdkKeysyms._B ~callback:new_inductive
2668 factory1#add_item "New Proof or Definition..." ~key:GdkKeysyms._N
2671 let reopen_menu_item =
2672 factory1#add_item "Reopen a Finished Proof..." ~key:GdkKeysyms._R
2676 factory1#add_item "Qed" ~key:GdkKeysyms._E ~callback:qed in
2677 ignore (factory1#add_separator ()) ;
2679 (factory1#add_item "Load Unfinished Proof..." ~key:GdkKeysyms._L
2680 ~callback:load_unfinished_proof) ;
2681 let save_menu_item =
2682 factory1#add_item "Save Unfinished Proof" ~key:GdkKeysyms._S
2683 ~callback:save_unfinished_proof
2686 (save_set_sensitive := function b -> save_menu_item#misc#set_sensitive b);
2687 ignore (!save_set_sensitive false);
2688 ignore (qed_set_sensitive:=function b -> qed_menu_item#misc#set_sensitive b);
2689 ignore (!qed_set_sensitive false);
2690 ignore (factory1#add_separator ()) ;
2691 let export_to_postscript_menu_item =
2692 factory1#add_item "Export to PostScript..."
2693 ~callback:(export_to_postscript output) in
2694 ignore (factory1#add_separator ()) ;
2696 (factory1#add_item "Exit" ~key:GdkKeysyms._Q ~callback:GMain.Main.quit) ;
2697 export_to_postscript_menu_item
2700 let edit_menu = factory0#add_submenu "Edit Current Proof" in
2701 let factory2 = new GMenu.factory edit_menu ~accel_group in
2702 let focus_and_proveit_set_sensitive = ref (function _ -> assert false) in
2703 let proveit_menu_item =
2704 factory2#add_item "Prove It" ~key:GdkKeysyms._I
2705 ~callback:(function () -> proveit ();!focus_and_proveit_set_sensitive false)
2707 let focus_menu_item =
2708 factory2#add_item "Focus" ~key:GdkKeysyms._F
2709 ~callback:(function () -> focus () ; !focus_and_proveit_set_sensitive false)
2712 focus_and_proveit_set_sensitive :=
2714 proveit_menu_item#misc#set_sensitive b ;
2715 focus_menu_item#misc#set_sensitive b
2717 let _ = !focus_and_proveit_set_sensitive false in
2718 (* edit term menu *)
2719 let edit_term_menu = factory0#add_submenu "Edit Term" in
2720 let factory5 = new GMenu.factory edit_term_menu ~accel_group in
2721 let check_menu_item =
2722 factory5#add_item "Check Term" ~key:GdkKeysyms._C
2723 ~callback:(check scratch_window) in
2724 let _ = check_menu_item#misc#set_sensitive false in
2726 let search_menu = factory0#add_submenu "Search" in
2727 let factory4 = new GMenu.factory search_menu ~accel_group in
2729 factory4#add_item "Locate..." ~key:GdkKeysyms._T
2731 let searchPattern_menu_item =
2732 factory4#add_item "SearchPattern..." ~key:GdkKeysyms._D
2733 ~callback:completeSearchPattern in
2734 let _ = searchPattern_menu_item#misc#set_sensitive false in
2735 let show_menu_item =
2736 factory4#add_item "Show..." ~key:GdkKeysyms._H ~callback:show
2738 let insert_query_item =
2739 factory4#add_item "Insert Query (Experts Only)..." ~key:GdkKeysyms._Y
2740 ~callback:insertQuery in
2742 let hbugs_menu = factory0#add_submenu "HBugs" in
2743 let factory6 = new GMenu.factory hbugs_menu ~accel_group in
2744 let toggle_hbugs_menu_item =
2745 factory6#add_check_item
2746 ~active:false ~key:GdkKeysyms._F5 ~callback:Hbugs.toggle "HBugs enabled"
2749 let settings_menu = factory0#add_submenu "Settings" in
2750 let factory3 = new GMenu.factory settings_menu ~accel_group in
2752 factory3#add_item "Edit Aliases..." ~key:GdkKeysyms._A
2753 ~callback:edit_aliases in
2754 let _ = factory3#add_separator () in
2756 factory3#add_item "MathML Widget Preferences..." ~key:GdkKeysyms._P
2757 ~callback:(function _ -> (settings_window ())#show ()) in
2758 let _ = factory3#add_separator () in
2760 factory3#add_item "Reload Stylesheets"
2763 ApplyStylesheets.reload_stylesheets () ;
2764 if !ProofEngine.proof <> None then
2766 refresh_goals notebook ;
2767 refresh_proof output
2769 InvokeTactics.RefreshSequentException e ->
2770 output_html (outputhtml ())
2771 ("<h1 color=\"red\">An error occurred while refreshing the " ^
2772 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
2773 (*notebook#remove_all_pages ~skip_switch_page_event:false ;*)
2774 notebook#set_empty_page
2775 | InvokeTactics.RefreshProofException e ->
2776 output_html (outputhtml ())
2777 ("<h1 color=\"red\">An error occurred while refreshing the proof: " ^ Printexc.to_string e ^ "</h1>") ;
2781 let _ = window#add_accel_group accel_group in
2785 ~packing:(vbox_for_menu#pack ~expand:true ~fill:true ~padding:5) () in
2787 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2788 let scrolled_window0 =
2789 GBin.scrolled_window ~border_width:10
2790 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2791 let _ = scrolled_window0#add output#coerce in
2793 GBin.frame ~label:"Insert Term"
2794 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2795 let scrolled_window1 =
2796 GBin.scrolled_window ~border_width:5
2797 ~packing:frame#add () in
2799 TexTermEditor'.term_editor
2801 ~width:400 ~height:100 ~packing:scrolled_window1#add ()
2802 ~isnotempty_callback:
2804 check_menu_item#misc#set_sensitive b ;
2805 searchPattern_menu_item#misc#set_sensitive b) in
2807 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2809 vboxl#pack ~expand:true ~fill:true ~padding:5 notebook#notebook#coerce in
2811 GBin.frame ~shadow_type:`IN ~packing:(vboxl#pack ~expand:true ~padding:5) ()
2815 ~source:"<html><body bgColor=\"white\"></body></html>"
2816 ~width:400 ~height: 100
2821 method outputhtml = outputhtml
2822 method inputt = inputt
2823 method output = (output : TermViewer.proof_viewer)
2824 method scratch_window = scratch_window
2825 method notebook = notebook
2826 method show = window#show
2828 notebook#set_empty_page ;
2829 export_to_postscript_menu_item#misc#set_sensitive false ;
2830 check_term := (check_term_in_scratch scratch_window) ;
2832 (* signal handlers here *)
2833 ignore(output#connect#selection_changed
2835 choose_selection output elem ;
2836 !focus_and_proveit_set_sensitive true
2838 ignore (output#connect#click (show_in_show_window_callback output)) ;
2839 let settings_window = new settings_window output scrolled_window0
2840 export_to_postscript_menu_item (choose_selection output) in
2841 set_settings_window settings_window ;
2842 set_outputhtml outputhtml ;
2843 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
2844 Logger.log_callback :=
2845 (Logger.log_to_html ~print_and_flush:(output_html outputhtml))
2850 let initialize_everything () =
2851 let module U = Unix in
2852 let output = TermViewer.proof_viewer ~width:350 ~height:280 () in
2853 let notebook = new notebook in
2854 let rendering_window' = new rendering_window output notebook in
2855 set_rendering_window rendering_window' ;
2856 let print_error_as_html prefix msg =
2857 output_html (outputhtml ())
2858 ("<h1 color=\"red\">" ^ prefix ^ msg ^ "</h1>")
2860 Gdome_xslt.setErrorCallback (Some (print_error_as_html "XSLT Error: "));
2861 Gdome_xslt.setDebugCallback
2862 (Some (print_error_as_html "XSLT Debug Message: "));
2863 rendering_window'#show () ;
2864 (* Hbugs.toggle true; *)
2869 ignore (GtkMain.Main.init ()) ;
2870 initialize_everything () ;
2871 MQIC.close mqi_handle;
2876 Sys.catch_break true;
2878 with Sys.Break -> () (* exit nicely, invoking at_exit functions *)