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 let bo_fixed = Eta_fixing.eta_fix metasenv bo in
565 let ty_fixed = Eta_fixing.eta_fix metasenv ty in
566 ProofEngine.proof := Some(uri,metasenv,bo_fixed,ty_fixed);
567 if List.length metasenv = 0 then
569 !qed_set_sensitive true ;
570 prerr_endline "CSC: ###### REFRESH_PROOF, Hbugs.clear ()" ;
575 prerr_endline "CSC: ###### REFRESH_PROOF, Hbugs.notify ()" ;
578 (*CSC: Wrong: [] is just plainly wrong *)
580 (Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo_fixed, ty_fixed, []))
582 ignore (output#load_proof uri currentproof)
585 match !ProofEngine.proof with
587 | Some (uri,metasenv,bo,ty) ->
588 prerr_endline ("Offending proof: " ^ CicPp.ppobj (Cic.CurrentProof ("questa",metasenv,bo,ty,[]))) ; flush stderr ;
589 raise (InvokeTactics.RefreshProofException e)
591 let refresh_goals ?(empty_notebook=true) notebook =
593 match !ProofEngine.goal with
595 if empty_notebook then
597 notebook#remove_all_pages ~skip_switch_page_event:false ;
598 notebook#set_empty_page
601 notebook#proofw#unload
604 match !ProofEngine.proof with
606 | Some (_,metasenv,_,_) -> metasenv
609 List.find (function (m,_,_) -> m=metano) metasenv
611 let regenerate_notebook () =
612 let skip_switch_page_event =
614 (m,_,_)::_ when m = metano -> false
617 notebook#remove_all_pages ~skip_switch_page_event ;
618 List.iter (function (m,_,_) -> notebook#add_page m) metasenv ;
620 if empty_notebook then
622 regenerate_notebook () ;
623 notebook#set_current_page
624 ~may_skip_switch_page_event:false metano
628 notebook#set_current_page
629 ~may_skip_switch_page_event:true metano ;
630 notebook#proofw#load_sequent metasenv currentsequent
635 match !ProofEngine.goal with
640 match !ProofEngine.proof with
642 | Some (_,metasenv,_,_) -> metasenv
645 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
646 prerr_endline ("Offending sequent: " ^ SequentPp.TextualPp.print_sequent currentsequent) ; flush stderr ;
647 raise (InvokeTactics.RefreshSequentException e)
648 with Not_found -> prerr_endline ("Offending sequent " ^ string_of_int metano ^ " unknown."); raise (InvokeTactics.RefreshSequentException e)
650 module InvokeTacticsCallbacks =
652 let sequent_viewer () = (rendering_window ())#notebook#proofw
653 let term_editor () = (rendering_window ())#inputt
654 let scratch_window () = (rendering_window ())#scratch_window
656 let refresh_proof () =
657 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
660 let refresh_goals () =
661 let notebook = (rendering_window ())#notebook in
662 refresh_goals notebook
664 let decompose_uris_choice_callback = decompose_uris_choice_callback
665 let mk_fresh_name_callback = mk_fresh_name_callback
666 let output_html msg = output_html (outputhtml ()) msg
669 module InvokeTactics' = InvokeTactics.Make (InvokeTacticsCallbacks);;
670 (* Just to initialize the Hbugs module *)
671 module Ignore = Hbugs.Initialize (InvokeTactics');;
673 (** load an unfinished proof from filesystem *)
674 let load_unfinished_proof () =
675 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
676 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
677 let notebook = (rendering_window ())#notebook in
680 GToolbox.input_string ~title:"Load Unfinished Proof" ~text:"/dummy.con"
683 None -> raise NoChoice
685 let uri = UriManager.uri_of_string ("cic:" ^ uri0) in
686 match CicParser.obj_of_xml prooffiletype (Some prooffile) with
687 Cic.CurrentProof (_,metasenv,bo,ty,_) ->
688 typecheck_loaded_proof metasenv bo ty ;
690 Some (uri, metasenv, bo, ty) ;
694 | (metano,_,_)::_ -> Some metano
696 refresh_proof output ;
697 refresh_goals notebook ;
698 output_html outputhtml
699 ("<h1 color=\"Green\">Current proof type loaded from " ^
700 prooffiletype ^ "</h1>") ;
701 output_html outputhtml
702 ("<h1 color=\"Green\">Current proof body loaded from " ^
703 prooffile ^ "</h1>") ;
704 !save_set_sensitive true;
707 InvokeTactics.RefreshSequentException e ->
708 output_html outputhtml
709 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
710 "sequent: " ^ Printexc.to_string e ^ "</h1>")
711 | InvokeTactics.RefreshProofException e ->
712 output_html outputhtml
713 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
714 "proof: " ^ Printexc.to_string e ^ "</h1>")
716 output_html outputhtml
717 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
720 let edit_aliases () =
721 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
722 let id_to_uris = inputt#id_to_uris in
723 let chosen = ref false in
726 ~width:400 ~modal:true ~title:"Edit Aliases..." ~border_width:2 () in
728 GPack.vbox ~border_width:0 ~packing:window#add () in
729 let scrolled_window =
730 GBin.scrolled_window ~border_width:10
731 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
732 let input = GEdit.text ~editable:true ~width:400 ~height:100
733 ~packing:scrolled_window#add () in
735 GPack.hbox ~border_width:0
736 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
738 GButton.button ~label:"Ok"
739 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
741 GButton.button ~label:"Cancel"
742 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
743 ignore (window#connect#destroy GMain.Main.quit) ;
744 ignore (cancelb#connect#clicked window#destroy) ;
746 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
747 let dom,resolve_id = !id_to_uris in
749 (input#insert_text ~pos:0
754 match resolve_id v with
756 | Some (CicTextualParser0.Uri uri) -> uri
757 | Some (CicTextualParser0.Term _)
758 | Some CicTextualParser0.Implicit -> assert false
762 CicTextualParser0.Id id -> id
763 | CicTextualParser0.Symbol (descr,_) ->
764 (* CSC: To be implemented *)
766 )^ " " ^ (string_of_cic_textual_parser_uri uri)
772 let inputtext = input#get_chars 0 input#length in
774 let alfa = "[a-zA-Z_-]" in
775 let digit = "[0-9]" in
776 let ident = alfa ^ "\(" ^ alfa ^ "\|" ^ digit ^ "\)*" in
777 let blanks = "\( \|\t\|\n\)+" in
778 let nonblanks = "[^ \t\n]+" in
779 let uri = "/\(" ^ ident ^ "/\)*" ^ nonblanks in (* not very strict check *)
781 ("alias" ^ blanks ^ "\(" ^ ident ^ "\)" ^ blanks ^ "\(" ^ uri ^ "\)")
785 let n' = Str.search_forward regexpr inputtext n in
786 let id = CicTextualParser0.Id (Str.matched_group 2 inputtext) in
788 MQueryMisc.cic_textual_parser_uri_of_string
789 ("cic:" ^ (Str.matched_group 5 inputtext))
791 let dom,resolve_id = aux (n' + 1) in
792 if List.mem id dom then
798 Some (CicTextualParser0.Uri uri)
801 Not_found -> TermEditor.empty_id_to_uris
805 id_to_uris := (dom,resolve_id)
809 let module L = LogicalOperations in
810 let module G = Gdome in
811 let notebook = (rendering_window ())#notebook in
812 let output = (rendering_window ())#output in
813 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
815 output#make_sequent_of_selected_term ;
816 refresh_proof output ;
817 refresh_goals notebook
819 InvokeTactics.RefreshSequentException e ->
820 output_html outputhtml
821 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
822 "sequent: " ^ Printexc.to_string e ^ "</h1>")
823 | InvokeTactics.RefreshProofException e ->
824 output_html outputhtml
825 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
826 "proof: " ^ Printexc.to_string e ^ "</h1>")
828 output_html outputhtml
829 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
833 let module L = LogicalOperations in
834 let module G = Gdome in
835 let notebook = (rendering_window ())#notebook in
836 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
837 let output = (rendering_window ())#output in
839 output#focus_sequent_of_selected_term ;
840 refresh_goals notebook
842 InvokeTactics.RefreshSequentException e ->
843 output_html outputhtml
844 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
845 "sequent: " ^ Printexc.to_string e ^ "</h1>")
846 | InvokeTactics.RefreshProofException e ->
847 output_html outputhtml
848 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
849 "proof: " ^ Printexc.to_string e ^ "</h1>")
851 output_html outputhtml
852 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
855 exception NoPrevGoal;;
856 exception NoNextGoal;;
859 let module L = LogicalOperations in
860 let module G = Gdome in
861 let notebook = (rendering_window ())#notebook in
862 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
864 match !ProofEngine.proof with
866 | Some (_,metasenv,_,_) -> metasenv
869 refresh_goals ~empty_notebook:false notebook
871 InvokeTactics.RefreshSequentException e ->
872 output_html outputhtml
873 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
874 "sequent: " ^ Printexc.to_string e ^ "</h1>")
876 output_html outputhtml
877 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
881 show_in_show_window_obj, show_in_show_window_uri, show_in_show_window_callback
884 GWindow.window ~width:800 ~border_width:2 () in
885 let scrolled_window =
886 GBin.scrolled_window ~border_width:10 ~packing:window#add () in
888 GMathViewAux.single_selection_math_view
889 ~packing:scrolled_window#add ~width:600 ~height:400 ()
891 let _ = window#event#connect#delete (fun _ -> window#misc#hide () ; true ) in
892 let href = Gdome.domString "href" in
893 let show_in_show_window_obj uri obj =
894 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
897 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
898 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
900 Cic2acic.acic_object_of_cic_object obj
903 ApplyStylesheets.mml_of_cic_object
904 ~explode_all:false uri acic ids_to_inner_sorts ids_to_inner_types
906 window#set_title (UriManager.string_of_uri uri) ;
907 window#misc#hide () ; window#show () ;
908 mmlwidget#load_doc mml ;
911 output_html outputhtml
912 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
914 let show_in_show_window_uri uri =
915 let obj = CicEnvironment.get_obj uri in
916 show_in_show_window_obj uri obj
918 let show_in_show_window_callback mmlwidget (n : Gdome.element option) _ =
922 if n'#hasAttributeNS ~namespaceURI:xlinkns ~localName:href then
924 (n'#getAttributeNS ~namespaceURI:xlinkns ~localName:href)#to_string
926 show_in_show_window_uri (UriManager.uri_of_string uri)
928 ignore (mmlwidget#action_toggle n')
931 mmlwidget#connect#click (show_in_show_window_callback mmlwidget)
933 show_in_show_window_obj, show_in_show_window_uri,
934 show_in_show_window_callback
937 exception NoObjectsLocated;;
939 let user_uri_choice ~title ~msg uris =
942 [] -> raise NoObjectsLocated
946 interactive_user_uri_choice ~selection_mode:`SINGLE ~title ~msg uris
951 String.sub uri 4 (String.length uri - 4)
954 let locate_callback id =
955 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
956 let out = output_html outputhtml in
957 let query = MQG.locate id in
958 let result = MQI.execute mqi_handle query in
962 MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format' uri)
964 out "<h1>Locate Query: </h1><pre>";
965 MQueryUtil.text_of_query out query "";
966 out "<h1>Result:</h1>";
967 MQueryUtil.text_of_result out result "<br>";
968 user_uri_choice ~title:"Ambiguous input."
970 ("Ambiguous input \"" ^ id ^
971 "\". Please, choose one interpetation:")
976 let input_or_locate_uri ~title =
977 let uri = ref None in
980 ~width:400 ~modal:true ~title ~border_width:2 () in
981 let vbox = GPack.vbox ~packing:window#add () in
983 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
985 GMisc.label ~text:"Enter a valid URI:" ~packing:(hbox1#pack ~padding:5) () in
987 GEdit.entry ~editable:true
988 ~packing:(hbox1#pack ~expand:true ~fill:true ~padding:5) () in
990 GButton.button ~label:"Check"
991 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
992 let _ = checkb#misc#set_sensitive false in
994 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
996 GMisc.label ~text:"You can also enter an indentifier to locate:"
997 ~packing:(hbox2#pack ~padding:5) () in
999 GEdit.entry ~editable:true
1000 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1002 GButton.button ~label:"Locate"
1003 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1004 let _ = locateb#misc#set_sensitive false in
1006 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1008 GButton.button ~label:"Ok"
1009 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1010 let _ = okb#misc#set_sensitive false in
1012 GButton.button ~label:"Cancel"
1013 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) ()
1015 ignore (window#connect#destroy GMain.Main.quit) ;
1017 (cancelb#connect#clicked (function () -> uri := None ; window#destroy ())) ;
1018 let check_callback () =
1019 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1020 let uri = "cic:" ^ manual_input#text in
1022 ignore (Getter.resolve (UriManager.uri_of_string uri)) ;
1023 output_html outputhtml "<h1 color=\"Green\">OK</h1>" ;
1026 Getter.Unresolved ->
1027 output_html outputhtml
1028 ("<h1 color=\"Red\">URI " ^ uri ^
1029 " does not correspond to any object.</h1>") ;
1031 | UriManager.IllFormedUri _ ->
1032 output_html outputhtml
1033 ("<h1 color=\"Red\">URI " ^ uri ^ " is not well-formed.</h1>") ;
1036 output_html outputhtml
1037 ("<h1 color=\"Red\">" ^ Printexc.to_string e ^ "</h1>") ;
1041 (okb#connect#clicked
1043 if check_callback () then
1045 uri := Some manual_input#text ;
1049 ignore (checkb#connect#clicked (function () -> ignore (check_callback ()))) ;
1051 (manual_input#connect#changed
1053 if manual_input#text = "" then
1055 checkb#misc#set_sensitive false ;
1056 okb#misc#set_sensitive false
1060 checkb#misc#set_sensitive true ;
1061 okb#misc#set_sensitive true
1064 (locate_input#connect#changed
1065 (fun _ -> locateb#misc#set_sensitive (locate_input#text <> ""))) ;
1067 (locateb#connect#clicked
1069 let id = locate_input#text in
1070 manual_input#set_text (locate_callback id) ;
1071 locate_input#delete_text 0 (String.length id)
1076 None -> raise NoChoice
1077 | Some uri -> UriManager.uri_of_string ("cic:" ^ uri)
1080 exception AmbiguousInput;;
1082 (* A WIDGET TO ENTER CIC TERMS *)
1084 module ChosenTermEditor = TexTermEditor;;
1085 module ChosenTextualParser0 = TexCicTextualParser0;;
1087 module ChosenTermEditor = TermEditor;;
1088 module ChosenTextualParser0 = CicTextualParser0;;
1093 let get_metasenv () = !ChosenTextualParser0.metasenv
1094 let set_metasenv metasenv = ChosenTextualParser0.metasenv := metasenv
1096 let output_html msg = output_html (outputhtml ()) msg;;
1097 let interactive_user_uri_choice =
1098 fun ~selection_mode ?ok ?enable_button_for_non_vars ~title ~msg ~id ->
1099 interactive_user_uri_choice ~selection_mode ?ok
1100 ?enable_button_for_non_vars ~title ~msg;;
1101 let interactive_interpretation_choice = interactive_interpretation_choice;;
1102 let input_or_locate_uri = input_or_locate_uri;;
1106 module TexTermEditor' = ChosenTermEditor.Make(Callbacks);;
1108 (* OTHER FUNCTIONS *)
1111 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1112 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1115 GToolbox.input_string ~title:"Locate" "Enter an identifier to locate:"
1117 None -> raise NoChoice
1119 let uri = locate_callback input in
1123 output_html outputhtml
1124 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
1128 exception UriAlreadyInUse;;
1129 exception NotAUriToAConstant;;
1131 let new_inductive () =
1132 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1133 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1134 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1135 let notebook = (rendering_window ())#notebook in
1137 let chosen = ref false in
1138 let inductive = ref true in
1139 let paramsno = ref 0 in
1140 let get_uri = ref (function _ -> assert false) in
1141 let get_base_uri = ref (function _ -> assert false) in
1142 let get_names = ref (function _ -> assert false) in
1143 let get_types_and_cons = ref (function _ -> assert false) in
1144 let get_context_and_subst = ref (function _ -> assert false) in
1147 ~width:600 ~modal:true ~position:`CENTER
1148 ~title:"New Block of Mutual (Co)Inductive Definitions"
1149 ~border_width:2 () in
1150 let vbox = GPack.vbox ~packing:window#add () in
1152 GPack.hbox ~border_width:0
1153 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1155 GMisc.label ~text:"Enter the URI for the new block:"
1156 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1158 GEdit.entry ~editable:true
1159 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1161 GPack.hbox ~border_width:0
1162 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1166 "Enter the number of left parameters in every arity and constructor type:"
1167 ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1168 let paramsno_entry =
1169 GEdit.entry ~editable:true ~text:"0"
1170 ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
1172 GPack.hbox ~border_width:0
1173 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1175 GMisc.label ~text:"Are the definitions inductive or coinductive?"
1176 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1178 GButton.radio_button ~label:"Inductive"
1179 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1181 GButton.radio_button ~label:"Coinductive"
1182 ~group:inductiveb#group
1183 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1185 GPack.hbox ~border_width:0
1186 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1188 GMisc.label ~text:"Enter the list of the names of the types:"
1189 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1191 GEdit.entry ~editable:true
1192 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1194 GPack.hbox ~border_width:0
1195 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1197 GButton.button ~label:"> Next"
1198 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1199 let _ = okb#misc#set_sensitive true in
1201 GButton.button ~label:"Abort"
1202 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1203 ignore (window#connect#destroy GMain.Main.quit) ;
1204 ignore (cancelb#connect#clicked window#destroy) ;
1208 (okb#connect#clicked
1211 let uristr = "cic:" ^ uri_entry#text in
1212 let namesstr = names_entry#text in
1213 let paramsno' = int_of_string (paramsno_entry#text) in
1214 match Str.split (Str.regexp " +") namesstr with
1216 | (he::tl) as names ->
1217 let uri = UriManager.uri_of_string (uristr ^ "/" ^ he ^ ".ind") in
1220 ignore (Getter.resolve uri) ;
1221 raise UriAlreadyInUse
1223 Getter.Unresolved ->
1224 get_uri := (function () -> uri) ;
1225 get_names := (function () -> names) ;
1226 inductive := inductiveb#active ;
1227 paramsno := paramsno' ;
1232 output_html outputhtml
1233 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1241 GBin.frame ~label:name
1242 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1243 let vbox = GPack.vbox ~packing:frame#add () in
1244 let hbox = GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false) () in
1246 GMisc.label ~text:("Enter its type:")
1247 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1248 let scrolled_window =
1249 GBin.scrolled_window ~border_width:5
1250 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1252 TexTermEditor'.term_editor
1254 ~width:400 ~height:20 ~packing:scrolled_window#add
1255 ~share_id_to_uris_with:inputt ()
1256 ~isnotempty_callback:
1258 (*non_empty_type := b ;*)
1259 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*)
1262 GPack.hbox ~border_width:0
1263 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1265 GMisc.label ~text:("Enter the list of its constructors:")
1266 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1267 let cons_names_entry =
1268 GEdit.entry ~editable:true
1269 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1270 (newinputt,cons_names_entry)
1273 vbox#remove hboxn#coerce ;
1275 GPack.hbox ~border_width:0
1276 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1278 GButton.button ~label:"> Next"
1279 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1281 GButton.button ~label:"Abort"
1282 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1283 ignore (cancelb#connect#clicked window#destroy) ;
1285 (okb#connect#clicked
1288 let names = !get_names () in
1289 let types_and_cons =
1291 (fun name (newinputt,cons_names_entry) ->
1292 let consnamesstr = cons_names_entry#text in
1293 let cons_names = Str.split (Str.regexp " +") consnamesstr in
1295 newinputt#get_metasenv_and_term ~context:[] ~metasenv:[]
1298 [] -> expr,cons_names
1299 | _ -> raise AmbiguousInput
1300 ) names type_widgets
1302 let uri = !get_uri () in
1304 (* Let's see if so far the definition is well-typed *)
1307 (* To test if the arities of the inductive types are well *)
1308 (* typed, we check the inductive block definition where *)
1309 (* no constructor is given to each type. *)
1312 (fun name (ty,cons) -> (name, !inductive, ty, []))
1313 names types_and_cons
1315 CicTypeChecker.typecheck_mutual_inductive_defs uri
1316 (tys,params,paramsno)
1318 get_context_and_subst :=
1322 (fun (context,subst) name (ty,_) ->
1324 (Some (Cic.Name name, Cic.Decl ty))::context,
1325 (Cic.MutInd (uri,!i,[]))::subst
1328 ) ([],[]) names types_and_cons) ;
1329 let types_and_cons' =
1331 (fun name (ty,cons) -> (name, !inductive, ty, phase3 name cons))
1332 names types_and_cons
1334 get_types_and_cons := (function () -> types_and_cons') ;
1339 output_html outputhtml
1340 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1343 and phase3 name cons =
1344 let get_cons_types = ref (function () -> assert false) in
1347 ~width:600 ~modal:true ~position:`CENTER
1348 ~title:(name ^ " Constructors")
1349 ~border_width:2 () in
1350 let vbox = GPack.vbox ~packing:window2#add () in
1351 let cons_type_widgets =
1353 (function consname ->
1355 GPack.hbox ~border_width:0
1356 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1358 GMisc.label ~text:("Enter the type of " ^ consname ^ ":")
1359 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1360 let scrolled_window =
1361 GBin.scrolled_window ~border_width:5
1362 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1364 TexTermEditor'.term_editor
1366 ~width:400 ~height:20 ~packing:scrolled_window#add
1367 ~share_id_to_uris_with:inputt ()
1368 ~isnotempty_callback:
1370 (* (*non_empty_type := b ;*)
1371 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*) *)())
1376 GPack.hbox ~border_width:0
1377 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1379 GButton.button ~label:"> Next"
1380 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1381 let _ = okb#misc#set_sensitive true in
1383 GButton.button ~label:"Abort"
1384 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1385 ignore (window2#connect#destroy GMain.Main.quit) ;
1386 ignore (cancelb#connect#clicked window2#destroy) ;
1388 (okb#connect#clicked
1392 let context,subst= !get_context_and_subst () in
1397 inputt#get_metasenv_and_term ~context ~metasenv:[]
1401 let undebrujined_expr =
1403 (fun expr t -> CicSubstitution.subst t expr) expr subst
1405 name, undebrujined_expr
1406 | _ -> raise AmbiguousInput
1407 ) cons cons_type_widgets
1409 get_cons_types := (function () -> cons_types) ;
1413 output_html outputhtml
1414 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1418 let okb_pressed = !chosen in
1420 if (not okb_pressed) then
1423 assert false (* The control never reaches this point *)
1426 (!get_cons_types ())
1429 (* No more phases left or Abort pressed *)
1435 let uri = !get_uri () in
1438 let tys = !get_types_and_cons () in
1439 let obj = Cic.InductiveDefinition tys params !paramsno in
1442 prerr_endline (CicPp.ppobj obj) ;
1443 CicTypeChecker.typecheck_mutual_inductive_defs uri
1444 (tys,params,!paramsno) ;
1447 prerr_endline "Offending mutual (co)inductive type declaration:" ;
1448 prerr_endline (CicPp.ppobj obj) ;
1450 (* We already know that obj is well-typed. We need to add it to the *)
1451 (* environment in order to compute the inner-types without having to *)
1452 (* debrujin it or having to modify lots of other functions to avoid *)
1453 (* asking the environment for the MUTINDs we are defining now. *)
1454 CicEnvironment.put_inductive_definition uri obj ;
1456 show_in_show_window_obj uri obj
1459 output_html outputhtml
1460 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1464 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1465 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1466 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1467 let notebook = (rendering_window ())#notebook in
1469 let chosen = ref false in
1470 let get_metasenv_and_term = ref (function _ -> assert false) in
1471 let get_uri = ref (function _ -> assert false) in
1472 let non_empty_type = ref false in
1475 ~width:600 ~modal:true ~title:"New Proof or Definition"
1476 ~border_width:2 () in
1477 let vbox = GPack.vbox ~packing:window#add () in
1479 GPack.hbox ~border_width:0
1480 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1482 GMisc.label ~text:"Enter the URI for the new theorem or definition:"
1483 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1485 GEdit.entry ~editable:true
1486 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1488 GPack.hbox ~border_width:0
1489 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1491 GMisc.label ~text:"Enter the theorem or definition type:"
1492 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1493 let scrolled_window =
1494 GBin.scrolled_window ~border_width:5
1495 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1496 (* the content of the scrolled_window is moved below (see comment) *)
1498 GPack.hbox ~border_width:0
1499 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1501 GButton.button ~label:"Ok"
1502 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1503 let _ = okb#misc#set_sensitive false in
1505 GButton.button ~label:"Cancel"
1506 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1507 (* moved here to have visibility of the ok button *)
1509 TexTermEditor'.term_editor
1511 ~width:400 ~height:100 ~packing:scrolled_window#add
1512 ~share_id_to_uris_with:inputt ()
1513 ~isnotempty_callback:
1515 non_empty_type := b ;
1516 okb#misc#set_sensitive (b && uri_entry#text <> ""))
1519 let xxx = inputt#get_as_string in
1520 prerr_endline ("######################## " ^ xxx) ;
1521 newinputt#set_term xxx ;
1523 newinputt#set_term inputt#get_as_string ;
1527 uri_entry#connect#changed
1529 okb#misc#set_sensitive (!non_empty_type && uri_entry#text <> ""))
1531 ignore (window#connect#destroy GMain.Main.quit) ;
1532 ignore (cancelb#connect#clicked window#destroy) ;
1534 (okb#connect#clicked
1538 let metasenv,parsed = newinputt#get_metasenv_and_term [] [] in
1539 let uristr = "cic:" ^ uri_entry#text in
1540 let uri = UriManager.uri_of_string uristr in
1541 if String.sub uristr (String.length uristr - 4) 4 <> ".con" then
1542 raise NotAUriToAConstant
1546 ignore (Getter.resolve uri) ;
1547 raise UriAlreadyInUse
1549 Getter.Unresolved ->
1550 get_metasenv_and_term := (function () -> metasenv,parsed) ;
1551 get_uri := (function () -> uri) ;
1556 output_html outputhtml
1557 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1563 let metasenv,expr = !get_metasenv_and_term () in
1564 let _ = CicTypeChecker.type_of_aux' metasenv [] expr in
1565 ProofEngine.proof :=
1566 Some (!get_uri (), (1,[],expr)::metasenv, Cic.Meta (1,[]), expr) ;
1567 ProofEngine.goal := Some 1 ;
1568 refresh_goals notebook ;
1569 refresh_proof output ;
1570 !save_set_sensitive true ;
1572 ProofEngine.intros ~mk_fresh_name_callback () ;
1573 refresh_goals notebook ;
1574 refresh_proof output
1576 InvokeTactics.RefreshSequentException e ->
1577 output_html outputhtml
1578 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1579 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1580 | InvokeTactics.RefreshProofException e ->
1581 output_html outputhtml
1582 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1583 "proof: " ^ Printexc.to_string e ^ "</h1>")
1585 output_html outputhtml
1586 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1589 let check_term_in_scratch scratch_window metasenv context expr =
1591 let ty = CicTypeChecker.type_of_aux' metasenv context expr in
1592 let expr = Cic.Cast (expr,ty) in
1593 scratch_window#show () ;
1594 scratch_window#set_term expr ;
1595 scratch_window#set_context context ;
1596 scratch_window#set_metasenv metasenv ;
1597 scratch_window#sequent_viewer#load_sequent metasenv (111,context,expr)
1600 print_endline ("? " ^ CicPp.ppterm expr) ;
1604 let check scratch_window () =
1605 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1606 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1608 match !ProofEngine.proof with
1610 | Some (_,metasenv,_,_) -> metasenv
1613 match !ProofEngine.goal with
1616 let (_,canonical_context,_) =
1617 List.find (function (m,_,_) -> m=metano) metasenv
1622 let metasenv',expr = inputt#get_metasenv_and_term context metasenv in
1623 check_term_in_scratch scratch_window metasenv' context expr
1626 output_html outputhtml
1627 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1631 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1633 show_in_show_window_uri (input_or_locate_uri ~title:"Show")
1636 output_html outputhtml
1637 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1640 exception NotADefinition;;
1643 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1644 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1645 let notebook = (rendering_window ())#notebook in
1647 let uri = input_or_locate_uri ~title:"Open" in
1648 CicTypeChecker.typecheck uri ;
1649 let metasenv,bo,ty =
1650 match CicEnvironment.get_cooked_obj uri with
1651 Cic.Constant (_,Some bo,ty,_) -> [],bo,ty
1652 | Cic.CurrentProof (_,metasenv,bo,ty,_) -> metasenv,bo,ty
1655 | Cic.InductiveDefinition _ -> raise NotADefinition
1657 ProofEngine.proof :=
1658 Some (uri, metasenv, bo, ty) ;
1659 ProofEngine.goal := None ;
1660 refresh_goals notebook ;
1661 refresh_proof output ;
1662 !save_set_sensitive true
1664 InvokeTactics.RefreshSequentException e ->
1665 output_html outputhtml
1666 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1667 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1668 | InvokeTactics.RefreshProofException e ->
1669 output_html outputhtml
1670 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1671 "proof: " ^ Printexc.to_string e ^ "</h1>")
1673 output_html outputhtml
1674 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1677 let show_query_results results =
1680 ~modal:false ~title:"Query results." ~border_width:2 () in
1681 let vbox = GPack.vbox ~packing:window#add () in
1683 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1686 ~text:"Click on a URI to show that object"
1687 ~packing:hbox#add () in
1688 let scrolled_window =
1689 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1690 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1691 let clist = GList.clist ~columns:1 ~packing:scrolled_window#add () in
1694 (function (uri,_) ->
1698 clist#set_row ~selectable:false n
1701 clist#columns_autosize () ;
1703 (clist#connect#select_row
1704 (fun ~row ~column ~event ->
1705 let (uristr,_) = List.nth results row in
1707 MQueryMisc.cic_textual_parser_uri_of_string
1708 (MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format'
1711 CicTextualParser0.ConUri uri
1712 | CicTextualParser0.VarUri uri
1713 | CicTextualParser0.IndTyUri (uri,_)
1714 | CicTextualParser0.IndConUri (uri,_,_) ->
1715 show_in_show_window_uri uri
1721 let refine_constraints (must_obj,must_rel,must_sort) =
1722 let chosen = ref false in
1723 let use_only = ref false in
1726 ~modal:true ~title:"Constraints refinement."
1727 ~width:800 ~border_width:2 () in
1728 let vbox = GPack.vbox ~packing:window#add () in
1730 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1733 ~text: "\"Only\" constraints can be enforced or not."
1734 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1736 GButton.toggle_button ~label:"Enforce \"only\" constraints"
1737 ~active:false ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1740 (onlyb#connect#toggled (function () -> use_only := onlyb#active)) ;
1741 (* Notebook for the constraints choice *)
1743 GPack.notebook ~scrollable:true
1744 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1745 (* Rel constraints *)
1748 ~text: "Constraints on Rels" () in
1750 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1753 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1756 ~text: "You can now specify the constraints on Rels."
1757 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1758 let expected_height = 25 * (List.length must_rel + 2) in
1759 let height = if expected_height > 400 then 400 else expected_height in
1760 let scrolled_window =
1761 GBin.scrolled_window ~border_width:10 ~height ~width:600
1762 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1763 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1764 let mk_depth_button (hbox:GPack.box) d =
1765 let mutable_ref = ref (Some d) in
1767 GButton.toggle_button
1768 ~label:("depth = " ^ string_of_int d)
1770 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1773 (depthb#connect#toggled
1775 let sel_depth = if depthb#active then Some d else None in
1776 mutable_ref := sel_depth
1779 let rel_constraints =
1784 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1787 ~text:(MQGU.text_of_position (p:>MQGT.full_position))
1788 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1790 | `MainHypothesis None
1791 | `MainConclusion None -> p, ref None
1792 | `MainHypothesis (Some depth')
1793 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth'
1795 (* Sort constraints *)
1798 ~text: "Constraints on Sorts" () in
1800 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1803 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1806 ~text: "You can now specify the constraints on Sorts."
1807 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1808 let expected_height = 25 * (List.length must_sort + 2) in
1809 let height = if expected_height > 400 then 400 else expected_height in
1810 let scrolled_window =
1811 GBin.scrolled_window ~border_width:10 ~height ~width:600
1812 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1813 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1814 let sort_constraints =
1816 (function (p, sort) ->
1819 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1822 ~text:(MQGU.text_of_sort sort ^ " " ^ MQGU.text_of_position (p:>MQGT.full_position))
1823 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1825 | `MainHypothesis None
1826 | `MainConclusion None -> p, ref None, sort
1827 | `MainHypothesis (Some depth')
1828 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', sort
1830 (* Obj constraints *)
1833 ~text: "Constraints on constants" () in
1835 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1838 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1841 ~text: "You can now specify the constraints on constants."
1842 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1843 let expected_height = 25 * (List.length must_obj + 2) in
1844 let height = if expected_height > 400 then 400 else expected_height in
1845 let scrolled_window =
1846 GBin.scrolled_window ~border_width:10 ~height ~width:600
1847 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1848 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1849 let obj_constraints =
1851 (function (p, uri) ->
1854 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1857 ~text:(uri ^ " " ^ (MQGU.text_of_position p))
1858 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1863 | `MainHypothesis None
1864 | `MainConclusion None -> p, ref None, uri
1865 | `MainHypothesis (Some depth')
1866 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', uri
1868 (* Confirm/abort buttons *)
1870 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1872 GButton.button ~label:"Ok"
1873 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1875 GButton.button ~label:"Abort"
1876 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1878 ignore (window#connect#destroy GMain.Main.quit) ;
1879 ignore (cancelb#connect#clicked window#destroy) ;
1881 (okb#connect#clicked (function () -> chosen := true ; window#destroy ()));
1882 window#set_position `CENTER ;
1886 let chosen_must_rel =
1888 (function (position, ref_depth) -> MQGU.set_main_position position !ref_depth)
1891 let chosen_must_sort =
1893 (function (position, ref_depth, sort) ->
1894 MQGU.set_main_position position !ref_depth,sort)
1897 let chosen_must_obj =
1899 (function (position, ref_depth, uri) -> MQGU.set_full_position position !ref_depth, uri)
1902 (chosen_must_obj,chosen_must_rel,chosen_must_sort),
1904 (*CSC: ???????????????????????? I assume that must and only are the same... *)
1905 Some chosen_must_obj,Some chosen_must_rel,Some chosen_must_sort
1913 let completeSearchPattern () =
1914 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1915 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1917 let metasenv,expr = inputt#get_metasenv_and_term ~context:[] ~metasenv:[] in
1918 let must = CGSearchPattern.get_constraints expr in
1919 let must',only = refine_constraints must in
1921 MQG.query_of_constraints (Some MQGU.universe_for_search_pattern) must' only
1923 let results = MQI.execute mqi_handle query in
1924 show_query_results results
1927 output_html outputhtml
1928 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1931 let insertQuery () =
1932 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1934 let chosen = ref None in
1937 ~modal:true ~title:"Insert Query (Experts Only)" ~border_width:2 () in
1938 let vbox = GPack.vbox ~packing:window#add () in
1940 GMisc.label ~text:"Insert Query. For Experts Only."
1941 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1942 let scrolled_window =
1943 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1944 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1945 let input = GEdit.text ~editable:true
1946 ~packing:scrolled_window#add () in
1948 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1950 GButton.button ~label:"Ok"
1951 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1953 GButton.button ~label:"Load from file..."
1954 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1956 GButton.button ~label:"Abort"
1957 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1958 ignore (window#connect#destroy GMain.Main.quit) ;
1959 ignore (cancelb#connect#clicked window#destroy) ;
1961 (okb#connect#clicked
1963 chosen := Some (input#get_chars 0 input#length) ; window#destroy ())) ;
1965 (loadb#connect#clicked
1968 GToolbox.select_file ~title:"Select Query File" ()
1972 let inch = open_in filename in
1973 let rec read_file () =
1975 let line = input_line inch in
1976 line ^ "\n" ^ read_file ()
1980 let text = read_file () in
1981 input#delete_text 0 input#length ;
1982 ignore (input#insert_text text ~pos:0))) ;
1983 window#set_position `CENTER ;
1990 MQI.execute mqi_handle (MQueryUtil.query_of_text (Lexing.from_string q))
1992 show_query_results results
1995 output_html outputhtml
1996 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1999 let choose_must list_of_must only =
2000 let chosen = ref None in
2001 let user_constraints = ref [] in
2004 ~modal:true ~title:"Query refinement." ~border_width:2 () in
2005 let vbox = GPack.vbox ~packing:window#add () in
2007 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2011 ("You can now specify the genericity of the query. " ^
2012 "The more generic the slower.")
2013 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2015 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2019 "Suggestion: start with faster queries before moving to more generic ones."
2020 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2022 GPack.notebook ~scrollable:true
2023 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2026 let last = List.length list_of_must in
2032 (if !page = 1 then "More generic" else
2033 if !page = last then "More precise" else " ") () in
2034 let expected_height = 25 * (List.length must + 2) in
2035 let height = if expected_height > 400 then 400 else expected_height in
2036 let scrolled_window =
2037 GBin.scrolled_window ~border_width:10 ~height ~width:600
2038 ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2040 GList.clist ~columns:2 ~packing:scrolled_window#add
2041 ~titles:["URI" ; "Position"] ()
2045 (function (position, uri) ->
2048 [uri; MQGUtil.text_of_position position]
2050 clist#set_row ~selectable:false n
2053 clist#columns_autosize ()
2056 let label = GMisc.label ~text:"User provided" () in
2058 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2060 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2063 ~text:"Select the constraints that must be satisfied and press OK."
2064 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2065 let expected_height = 25 * (List.length only + 2) in
2066 let height = if expected_height > 400 then 400 else expected_height in
2067 let scrolled_window =
2068 GBin.scrolled_window ~border_width:10 ~height ~width:600
2069 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2071 GList.clist ~columns:2 ~packing:scrolled_window#add
2072 ~selection_mode:`EXTENDED
2073 ~titles:["URI" ; "Position"] ()
2077 (function (position, uri) ->
2080 [uri; MQGUtil.text_of_position position]
2082 clist#set_row ~selectable:true n
2085 clist#columns_autosize () ;
2087 (clist#connect#select_row
2088 (fun ~row ~column ~event ->
2089 user_constraints := (List.nth only row)::!user_constraints)) ;
2091 (clist#connect#unselect_row
2092 (fun ~row ~column ~event ->
2095 (function uri -> uri != (List.nth only row)) !user_constraints)) ;
2098 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2100 GButton.button ~label:"Ok"
2101 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2103 GButton.button ~label:"Abort"
2104 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2106 ignore (window#connect#destroy GMain.Main.quit) ;
2107 ignore (cancelb#connect#clicked window#destroy) ;
2109 (okb#connect#clicked
2110 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
2111 window#set_position `CENTER ;
2115 None -> raise NoChoice
2117 if n = List.length list_of_must then
2118 (* user provided constraints *)
2121 List.nth list_of_must n
2124 let searchPattern () =
2125 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
2126 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
2129 match !ProofEngine.proof with
2130 None -> assert false
2131 | Some proof -> proof
2133 match !ProofEngine.goal with
2137 TacticChaser.matchConclusion
2139 ~output_html:(output_html outputhtml) ~choose_must ()
2140 ~status:(proof, metano)
2143 user_uri_choice ~title:"Ambiguous input."
2144 ~msg: "Many lemmas can be successfully applied. Please, choose one:"
2147 inputt#set_term uri' ;
2148 InvokeTactics'.apply ()
2151 output_html outputhtml
2152 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
2155 let choose_selection mmlwidget (element : Gdome.element option) =
2156 let module G = Gdome in
2157 let rec aux element =
2158 if element#hasAttributeNS
2159 ~namespaceURI:Misc.helmns
2160 ~localName:(G.domString "xref")
2162 mmlwidget#set_selection (Some element)
2165 match element#get_parentNode with
2166 None -> assert false
2167 (*CSC: OCAML DIVERGES!
2168 | Some p -> aux (new G.element_of_node p)
2170 | Some p -> aux (new Gdome.element_of_node p)
2172 GdomeInit.DOMCastException _ ->
2174 "******* trying to select above the document root ********"
2178 | None -> mmlwidget#set_selection None
2181 (* STUFF TO BUILD THE GTK INTERFACE *)
2183 (* Stuff for the widget settings *)
2185 let export_to_postscript output =
2186 let lastdir = ref (Unix.getcwd ()) in
2189 GToolbox.select_file ~title:"Export to PostScript"
2190 ~dir:lastdir ~filename:"screenshot.ps" ()
2194 (output :> GMathView.math_view)#export_to_postscript
2195 ~filename:filename ();
2198 let activate_t1 output button_set_anti_aliasing
2199 button_set_transparency export_to_postscript_menu_item
2202 let is_set = button_t1#active in
2203 output#set_font_manager_type
2204 ~fm_type:(if is_set then `font_manager_t1 else `font_manager_gtk) ;
2207 button_set_anti_aliasing#misc#set_sensitive true ;
2208 button_set_transparency#misc#set_sensitive true ;
2209 export_to_postscript_menu_item#misc#set_sensitive true ;
2213 button_set_anti_aliasing#misc#set_sensitive false ;
2214 button_set_transparency#misc#set_sensitive false ;
2215 export_to_postscript_menu_item#misc#set_sensitive false ;
2219 let set_anti_aliasing output button_set_anti_aliasing () =
2220 output#set_anti_aliasing button_set_anti_aliasing#active
2223 let set_transparency output button_set_transparency () =
2224 output#set_transparency button_set_transparency#active
2227 let changefont output font_size_spinb () =
2228 output#set_font_size font_size_spinb#value_as_int
2231 let set_log_verbosity output log_verbosity_spinb () =
2232 output#set_log_verbosity log_verbosity_spinb#value_as_int
2235 class settings_window output sw
2236 export_to_postscript_menu_item selection_changed_callback
2238 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
2240 GPack.vbox ~packing:settings_window#add () in
2243 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2244 ~border_width:5 ~packing:vbox#add () in
2246 GButton.toggle_button ~label:"activate t1 fonts"
2247 ~packing:(table#attach ~left:0 ~top:0) () in
2248 let button_set_anti_aliasing =
2249 GButton.toggle_button ~label:"set_anti_aliasing"
2250 ~packing:(table#attach ~left:0 ~top:1) () in
2251 let button_set_transparency =
2252 GButton.toggle_button ~label:"set_transparency"
2253 ~packing:(table#attach ~left:2 ~top:1) () in
2256 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2257 ~border_width:5 ~packing:vbox#add () in
2258 let font_size_label =
2259 GMisc.label ~text:"font size:"
2260 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
2261 let font_size_spinb =
2263 GData.adjustment ~value:(float_of_int output#get_font_size)
2264 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
2267 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
2268 let log_verbosity_label =
2269 GMisc.label ~text:"log verbosity:"
2270 ~packing:(table#attach ~left:0 ~top:1) () in
2271 let log_verbosity_spinb =
2273 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
2276 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
2278 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2280 GButton.button ~label:"Close"
2281 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2283 method show = settings_window#show
2285 button_set_anti_aliasing#misc#set_sensitive false ;
2286 button_set_transparency#misc#set_sensitive false ;
2287 (* Signals connection *)
2288 ignore(button_t1#connect#clicked
2289 (activate_t1 output button_set_anti_aliasing
2290 button_set_transparency export_to_postscript_menu_item button_t1)) ;
2291 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
2292 ignore(button_set_anti_aliasing#connect#toggled
2293 (set_anti_aliasing output button_set_anti_aliasing));
2294 ignore(button_set_transparency#connect#toggled
2295 (set_transparency output button_set_transparency)) ;
2296 ignore(log_verbosity_spinb#connect#changed
2297 (set_log_verbosity output log_verbosity_spinb)) ;
2298 ignore(closeb#connect#clicked settings_window#misc#hide)
2301 (* Scratch window *)
2303 class scratch_window =
2306 ~title:"MathML viewer"
2307 ~border_width:2 () in
2309 GPack.vbox ~packing:window#add () in
2311 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2313 GButton.button ~label:"Whd"
2314 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2316 GButton.button ~label:"Reduce"
2317 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2319 GButton.button ~label:"Simpl"
2320 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2321 let scrolled_window =
2322 GBin.scrolled_window ~border_width:10
2323 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2324 let sequent_viewer =
2325 TermViewer.sequent_viewer
2326 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
2328 val mutable term = Cic.Rel 1 (* dummy value *)
2329 val mutable context = ([] : Cic.context) (* dummy value *)
2330 val mutable metasenv = ([] : Cic.metasenv) (* dummy value *)
2331 method sequent_viewer = sequent_viewer
2332 method show () = window#misc#hide () ; window#show ()
2334 method set_term t = term <- t
2335 method context = context
2336 method set_context t = context <- t
2337 method metasenv = metasenv
2338 method set_metasenv t = metasenv <- t
2341 (sequent_viewer#connect#selection_changed (choose_selection sequent_viewer));
2342 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
2343 ignore(whdb#connect#clicked InvokeTactics'.whd_in_scratch) ;
2344 ignore(reduceb#connect#clicked InvokeTactics'.reduce_in_scratch) ;
2345 ignore(simplb#connect#clicked InvokeTactics'.simpl_in_scratch)
2348 let open_contextual_menu_for_selected_terms mmlwidget infos =
2349 let button = GdkEvent.Button.button infos in
2350 let terms_selected = List.length mmlwidget#get_selections > 0 in
2353 let time = GdkEvent.Button.time infos in
2354 let menu = GMenu.menu () in
2355 let f = new GMenu.factory menu in
2357 f#add_item "Whd" ~key:GdkKeysyms._W ~callback:InvokeTactics'.whd in
2358 let reduce_menu_item =
2359 f#add_item "Reduce" ~key:GdkKeysyms._R ~callback:InvokeTactics'.reduce in
2360 let simpl_menu_item =
2361 f#add_item "Simpl" ~key:GdkKeysyms._S ~callback:InvokeTactics'.simpl in
2362 let _ = f#add_separator () in
2363 let generalize_menu_item =
2364 f#add_item "Generalize"
2365 ~key:GdkKeysyms._G ~callback:InvokeTactics'.generalize in
2366 let _ = f#add_separator () in
2367 let clear_menu_item =
2368 f#add_item "Clear" ~key:GdkKeysyms._C ~callback:InvokeTactics'.clear in
2369 let clearbody_menu_item =
2370 f#add_item "ClearBody"
2371 ~key:GdkKeysyms._B ~callback:InvokeTactics'.clearbody
2373 whd_menu_item#misc#set_sensitive terms_selected ;
2374 reduce_menu_item#misc#set_sensitive terms_selected ;
2375 simpl_menu_item#misc#set_sensitive terms_selected ;
2376 generalize_menu_item#misc#set_sensitive terms_selected ;
2377 clear_menu_item#misc#set_sensitive terms_selected ;
2378 clearbody_menu_item#misc#set_sensitive terms_selected ;
2379 menu#popup ~button ~time
2385 let vbox1 = GPack.vbox () in
2387 val mutable proofw_ref = None
2388 val mutable compute_ref = None
2390 Lazy.force self#compute ;
2391 match proofw_ref with
2392 None -> assert false
2393 | Some proofw -> proofw
2394 method content = vbox1
2396 match compute_ref with
2397 None -> assert false
2398 | Some compute -> compute
2402 let scrolled_window1 =
2403 GBin.scrolled_window ~border_width:10
2404 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2406 TermViewer.sequent_viewer ~width:400 ~height:275
2407 ~packing:(scrolled_window1#add) () in
2408 let _ = proofw_ref <- Some proofw in
2410 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2412 GButton.button ~label:"Ring"
2413 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2415 GButton.button ~label:"Fourier"
2416 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2418 GButton.button ~label:"Reflexivity"
2419 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2421 GButton.button ~label:"Symmetry"
2422 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2424 GButton.button ~label:"Assumption"
2425 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2426 let contradictionb =
2427 GButton.button ~label:"Contradiction"
2428 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2430 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2432 GButton.button ~label:"Exists"
2433 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2435 GButton.button ~label:"Split"
2436 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2438 GButton.button ~label:"Left"
2439 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2441 GButton.button ~label:"Right"
2442 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2443 let searchpatternb =
2444 GButton.button ~label:"SearchPattern_Apply"
2445 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2447 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2449 GButton.button ~label:"Exact"
2450 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2452 GButton.button ~label:"Intros"
2453 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2455 GButton.button ~label:"Apply"
2456 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2457 let elimintrossimplb =
2458 GButton.button ~label:"ElimIntrosSimpl"
2459 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2461 GButton.button ~label:"ElimType"
2462 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2464 GButton.button ~label:"Fold_whd"
2465 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2467 GButton.button ~label:"Fold_reduce"
2468 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2470 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2472 GButton.button ~label:"Fold_simpl"
2473 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2475 GButton.button ~label:"Cut"
2476 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2478 GButton.button ~label:"Change"
2479 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2481 GButton.button ~label:"Let ... In"
2482 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2484 GButton.button ~label:"RewriteSimpl ->"
2485 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2486 let rewritebacksimplb =
2487 GButton.button ~label:"RewriteSimpl <-"
2488 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2490 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2492 GButton.button ~label:"Absurd"
2493 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2495 GButton.button ~label:"Decompose"
2496 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2498 GButton.button ~label:"Transitivity"
2499 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2501 GButton.button ~label:"Replace"
2502 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2504 GButton.button ~label:"Injection"
2505 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2507 GButton.button ~label:"Discriminate"
2508 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2509 (* Zack: spostare in una toolbar
2511 GButton.button ~label:"Generalize"
2512 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2514 GButton.button ~label:"ClearBody"
2515 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2517 GButton.button ~label:"Clear"
2518 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2520 GButton.button ~label:"Whd"
2521 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2523 GButton.button ~label:"Reduce"
2524 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2526 GButton.button ~label:"Simpl"
2527 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2530 ignore(exactb#connect#clicked InvokeTactics'.exact) ;
2531 ignore(applyb#connect#clicked InvokeTactics'.apply) ;
2532 ignore(elimintrossimplb#connect#clicked InvokeTactics'.elimintrossimpl) ;
2533 ignore(elimtypeb#connect#clicked InvokeTactics'.elimtype) ;
2534 ignore(foldwhdb#connect#clicked InvokeTactics'.fold_whd) ;
2535 ignore(foldreduceb#connect#clicked InvokeTactics'.fold_reduce) ;
2536 ignore(foldsimplb#connect#clicked InvokeTactics'.fold_simpl) ;
2537 ignore(cutb#connect#clicked InvokeTactics'.cut) ;
2538 ignore(changeb#connect#clicked InvokeTactics'.change) ;
2539 ignore(letinb#connect#clicked InvokeTactics'.letin) ;
2540 ignore(ringb#connect#clicked InvokeTactics'.ring) ;
2541 ignore(fourierb#connect#clicked InvokeTactics'.fourier) ;
2542 ignore(rewritesimplb#connect#clicked InvokeTactics'.rewritesimpl) ;
2543 ignore(rewritebacksimplb#connect#clicked InvokeTactics'.rewritebacksimpl) ;
2544 ignore(replaceb#connect#clicked InvokeTactics'.replace) ;
2545 ignore(reflexivityb#connect#clicked InvokeTactics'.reflexivity) ;
2546 ignore(symmetryb#connect#clicked InvokeTactics'.symmetry) ;
2547 ignore(transitivityb#connect#clicked InvokeTactics'.transitivity) ;
2548 ignore(existsb#connect#clicked InvokeTactics'.exists) ;
2549 ignore(splitb#connect#clicked InvokeTactics'.split) ;
2550 ignore(leftb#connect#clicked InvokeTactics'.left) ;
2551 ignore(rightb#connect#clicked InvokeTactics'.right) ;
2552 ignore(assumptionb#connect#clicked InvokeTactics'.assumption) ;
2553 ignore(absurdb#connect#clicked InvokeTactics'.absurd) ;
2554 ignore(contradictionb#connect#clicked InvokeTactics'.contradiction) ;
2555 ignore(introsb#connect#clicked InvokeTactics'.intros) ;
2556 ignore(decomposeb#connect#clicked InvokeTactics'.decompose) ;
2557 ignore(searchpatternb#connect#clicked searchPattern) ;
2558 ignore(injectionb#connect#clicked InvokeTactics'.injection) ;
2559 ignore(discriminateb#connect#clicked InvokeTactics'.discriminate) ;
2560 (* Zack: spostare in una toolbar
2561 ignore(whdb#connect#clicked whd) ;
2562 ignore(reduceb#connect#clicked reduce) ;
2563 ignore(simplb#connect#clicked simpl) ;
2564 ignore(clearbodyb#connect#clicked clearbody) ;
2565 ignore(clearb#connect#clicked clear) ;
2566 ignore(generalizeb#connect#clicked generalize) ;
2568 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
2570 ((new GObj.event_ops proofw#as_widget)#connect#button_press
2571 (open_contextual_menu_for_selected_terms proofw)) ;
2577 let vbox1 = GPack.vbox () in
2578 let scrolled_window1 =
2579 GBin.scrolled_window ~border_width:10
2580 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2582 TermViewer.sequent_viewer ~width:400 ~height:275
2583 ~packing:(scrolled_window1#add) () in
2585 method proofw = (assert false : TermViewer.sequent_viewer)
2586 method content = vbox1
2587 method compute = (assert false : unit)
2591 let empty_page = new empty_page;;
2595 val notebook = GPack.notebook ()
2597 val mutable skip_switch_page_event = false
2598 val mutable empty = true
2599 method notebook = notebook
2601 let new_page = new page () in
2603 pages := !pages @ [n,lazy (setgoal n),new_page] ;
2604 notebook#append_page
2605 ~tab_label:((GMisc.label ~text:("?" ^ string_of_int n) ())#coerce)
2606 new_page#content#coerce
2607 method remove_all_pages ~skip_switch_page_event:skip =
2609 notebook#remove_page 0 (* let's remove the empty page *)
2611 List.iter (function _ -> notebook#remove_page 0) !pages ;
2613 skip_switch_page_event <- skip
2614 method set_current_page ~may_skip_switch_page_event n =
2615 let (_,_,page) = List.find (function (m,_,_) -> m=n) !pages in
2616 let new_page = notebook#page_num page#content#coerce in
2617 if may_skip_switch_page_event && new_page <> notebook#current_page then
2618 skip_switch_page_event <- true ;
2619 notebook#goto_page new_page
2620 method set_empty_page =
2623 notebook#append_page
2624 ~tab_label:((GMisc.label ~text:"No proof in progress" ())#coerce)
2625 empty_page#content#coerce
2627 let (_,_,page) = List.nth !pages notebook#current_page in
2631 (notebook#connect#switch_page
2633 let skip = skip_switch_page_event in
2634 skip_switch_page_event <- false ;
2637 let (metano,setgoal,page) = List.nth !pages i in
2638 ProofEngine.goal := Some metano ;
2639 Lazy.force (page#compute) ;
2648 class rendering_window output (notebook : notebook) =
2649 let scratch_window = new scratch_window in
2652 ~title:"gTopLevel - Helm's Proof Assistant"
2653 ~border_width:0 ~allow_shrink:false () in
2654 let vbox_for_menu = GPack.vbox ~packing:window#add () in
2656 let handle_box = GBin.handle_box ~border_width:2
2657 ~packing:(vbox_for_menu#pack ~padding:0) () in
2658 let menubar = GMenu.menu_bar ~packing:handle_box#add () in
2659 let factory0 = new GMenu.factory menubar in
2660 let accel_group = factory0#accel_group in
2662 let file_menu = factory0#add_submenu "File" in
2663 let factory1 = new GMenu.factory file_menu ~accel_group in
2664 let export_to_postscript_menu_item =
2667 factory1#add_item "New Block of (Co)Inductive Definitions..."
2668 ~key:GdkKeysyms._B ~callback:new_inductive
2671 factory1#add_item "New Proof or Definition..." ~key:GdkKeysyms._N
2674 let reopen_menu_item =
2675 factory1#add_item "Reopen a Finished Proof..." ~key:GdkKeysyms._R
2679 factory1#add_item "Qed" ~key:GdkKeysyms._E ~callback:qed in
2680 ignore (factory1#add_separator ()) ;
2682 (factory1#add_item "Load Unfinished Proof..." ~key:GdkKeysyms._L
2683 ~callback:load_unfinished_proof) ;
2684 let save_menu_item =
2685 factory1#add_item "Save Unfinished Proof" ~key:GdkKeysyms._S
2686 ~callback:save_unfinished_proof
2689 (save_set_sensitive := function b -> save_menu_item#misc#set_sensitive b);
2690 ignore (!save_set_sensitive false);
2691 ignore (qed_set_sensitive:=function b -> qed_menu_item#misc#set_sensitive b);
2692 ignore (!qed_set_sensitive false);
2693 ignore (factory1#add_separator ()) ;
2694 let export_to_postscript_menu_item =
2695 factory1#add_item "Export to PostScript..."
2696 ~callback:(export_to_postscript output) in
2697 ignore (factory1#add_separator ()) ;
2699 (factory1#add_item "Exit" ~key:GdkKeysyms._Q ~callback:GMain.Main.quit) ;
2700 export_to_postscript_menu_item
2703 let edit_menu = factory0#add_submenu "Edit Current Proof" in
2704 let factory2 = new GMenu.factory edit_menu ~accel_group in
2705 let focus_and_proveit_set_sensitive = ref (function _ -> assert false) in
2706 let proveit_menu_item =
2707 factory2#add_item "Prove It" ~key:GdkKeysyms._I
2708 ~callback:(function () -> proveit ();!focus_and_proveit_set_sensitive false)
2710 let focus_menu_item =
2711 factory2#add_item "Focus" ~key:GdkKeysyms._F
2712 ~callback:(function () -> focus () ; !focus_and_proveit_set_sensitive false)
2715 focus_and_proveit_set_sensitive :=
2717 proveit_menu_item#misc#set_sensitive b ;
2718 focus_menu_item#misc#set_sensitive b
2720 let _ = !focus_and_proveit_set_sensitive false in
2721 (* edit term menu *)
2722 let edit_term_menu = factory0#add_submenu "Edit Term" in
2723 let factory5 = new GMenu.factory edit_term_menu ~accel_group in
2724 let check_menu_item =
2725 factory5#add_item "Check Term" ~key:GdkKeysyms._C
2726 ~callback:(check scratch_window) in
2727 let _ = check_menu_item#misc#set_sensitive false in
2729 let search_menu = factory0#add_submenu "Search" in
2730 let factory4 = new GMenu.factory search_menu ~accel_group in
2732 factory4#add_item "Locate..." ~key:GdkKeysyms._T
2734 let searchPattern_menu_item =
2735 factory4#add_item "SearchPattern..." ~key:GdkKeysyms._D
2736 ~callback:completeSearchPattern in
2737 let _ = searchPattern_menu_item#misc#set_sensitive false in
2738 let show_menu_item =
2739 factory4#add_item "Show..." ~key:GdkKeysyms._H ~callback:show
2741 let insert_query_item =
2742 factory4#add_item "Insert Query (Experts Only)..." ~key:GdkKeysyms._Y
2743 ~callback:insertQuery in
2745 let hbugs_menu = factory0#add_submenu "HBugs" in
2746 let factory6 = new GMenu.factory hbugs_menu ~accel_group in
2747 let toggle_hbugs_menu_item =
2748 factory6#add_check_item
2749 ~active:false ~key:GdkKeysyms._F5 ~callback:Hbugs.toggle "HBugs enabled"
2752 let settings_menu = factory0#add_submenu "Settings" in
2753 let factory3 = new GMenu.factory settings_menu ~accel_group in
2755 factory3#add_item "Edit Aliases..." ~key:GdkKeysyms._A
2756 ~callback:edit_aliases in
2757 let _ = factory3#add_separator () in
2759 factory3#add_item "MathML Widget Preferences..." ~key:GdkKeysyms._P
2760 ~callback:(function _ -> (settings_window ())#show ()) in
2761 let _ = factory3#add_separator () in
2763 factory3#add_item "Reload Stylesheets"
2766 ApplyStylesheets.reload_stylesheets () ;
2767 if !ProofEngine.proof <> None then
2769 refresh_goals notebook ;
2770 refresh_proof output
2772 InvokeTactics.RefreshSequentException e ->
2773 output_html (outputhtml ())
2774 ("<h1 color=\"red\">An error occurred while refreshing the " ^
2775 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
2776 (*notebook#remove_all_pages ~skip_switch_page_event:false ;*)
2777 notebook#set_empty_page
2778 | InvokeTactics.RefreshProofException e ->
2779 output_html (outputhtml ())
2780 ("<h1 color=\"red\">An error occurred while refreshing the proof: " ^ Printexc.to_string e ^ "</h1>") ;
2784 let _ = window#add_accel_group accel_group in
2788 ~packing:(vbox_for_menu#pack ~expand:true ~fill:true ~padding:5) () in
2790 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2791 let scrolled_window0 =
2792 GBin.scrolled_window ~border_width:10
2793 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2794 let _ = scrolled_window0#add output#coerce in
2796 GBin.frame ~label:"Insert Term"
2797 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2798 let scrolled_window1 =
2799 GBin.scrolled_window ~border_width:5
2800 ~packing:frame#add () in
2802 TexTermEditor'.term_editor
2804 ~width:400 ~height:100 ~packing:scrolled_window1#add ()
2805 ~isnotempty_callback:
2807 check_menu_item#misc#set_sensitive b ;
2808 searchPattern_menu_item#misc#set_sensitive b) in
2810 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2812 vboxl#pack ~expand:true ~fill:true ~padding:5 notebook#notebook#coerce in
2814 GBin.frame ~shadow_type:`IN ~packing:(vboxl#pack ~expand:true ~padding:5) ()
2818 ~source:"<html><body bgColor=\"white\"></body></html>"
2819 ~width:400 ~height: 100
2824 method outputhtml = outputhtml
2825 method inputt = inputt
2826 method output = (output : TermViewer.proof_viewer)
2827 method scratch_window = scratch_window
2828 method notebook = notebook
2829 method show = window#show
2831 notebook#set_empty_page ;
2832 export_to_postscript_menu_item#misc#set_sensitive false ;
2833 check_term := (check_term_in_scratch scratch_window) ;
2835 (* signal handlers here *)
2836 ignore(output#connect#selection_changed
2838 choose_selection output elem ;
2839 !focus_and_proveit_set_sensitive true
2841 ignore (output#connect#click (show_in_show_window_callback output)) ;
2842 let settings_window = new settings_window output scrolled_window0
2843 export_to_postscript_menu_item (choose_selection output) in
2844 set_settings_window settings_window ;
2845 set_outputhtml outputhtml ;
2846 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
2847 Logger.log_callback :=
2848 (Logger.log_to_html ~print_and_flush:(output_html outputhtml))
2853 let initialize_everything () =
2854 let module U = Unix in
2855 let output = TermViewer.proof_viewer ~width:350 ~height:280 () in
2856 let notebook = new notebook in
2857 let rendering_window' = new rendering_window output notebook in
2858 set_rendering_window rendering_window' ;
2859 let print_error_as_html prefix msg =
2860 output_html (outputhtml ())
2861 ("<h1 color=\"red\">" ^ prefix ^ msg ^ "</h1>")
2863 Gdome_xslt.setErrorCallback (Some (print_error_as_html "XSLT Error: "));
2864 Gdome_xslt.setDebugCallback
2865 (Some (print_error_as_html "XSLT Debug Message: "));
2866 rendering_window'#show () ;
2867 (* Hbugs.toggle true; *)
2872 ignore (GtkMain.Main.init ()) ;
2873 initialize_everything () ;
2874 MQIC.close mqi_handle;
2879 Sys.catch_break true;
2881 with Sys.Break -> () (* exit nicely, invoking at_exit functions *)