1 (* Copyright (C) 2000-2004, 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 (******************************************************************************)
36 let debug_level = ref 1
37 let debug_print ?(level = 1) s = if !debug_level >= level then prerr_endline s
43 module MQI = MQueryInterpreter
45 module MQGT = MQGTypes
47 module MQG = MQueryGenerator
49 (* GLOBAL CONSTANTS *)
51 let mqi_debug_fun s = debug_print ~level:2 s
52 let mqi_flags = [MQIC.Postgres ; MQIC.Stat ; MQIC.Warn ; MQIC.Log]
53 let mqi_handle = MQIC.init mqi_flags mqi_debug_fun
55 let xlinkns = Gdome.domString "http://www.w3.org/1999/xlink";;
59 Sys.getenv "GTOPLEVEL_PROOFFILE"
61 Not_found -> "/public/currentproof"
66 Sys.getenv "GTOPLEVEL_PROOFFILETYPE"
68 Not_found -> "/public/currentprooftype"
73 Sys.getenv "GTOPLEVEL_ENVIRONMENTFILE"
75 Not_found -> "/public/environment"
78 let restore_environment_on_boot = true ;;
79 let notify_hbugs_on_goal_change = false ;;
81 let auto_disambiguation = ref true ;;
83 (* GLOBAL REFERENCES (USED BY CALLBACKS) *)
85 let check_term = ref (fun _ _ _ -> assert false);;
87 exception RenderingWindowsNotInitialized;;
89 let set_rendering_window,rendering_window =
90 let rendering_window_ref = ref None in
91 (function rw -> rendering_window_ref := Some rw),
93 match !rendering_window_ref with
94 None -> raise RenderingWindowsNotInitialized
99 exception SettingsWindowsNotInitialized;;
101 let set_settings_window,settings_window =
102 let settings_window_ref = ref None in
103 (function rw -> settings_window_ref := Some rw),
105 match !settings_window_ref with
106 None -> raise SettingsWindowsNotInitialized
111 exception OutputHtmlNotInitialized;;
113 let set_outputhtml,outputhtml =
114 let outputhtml_ref = ref None in
115 (function (rw: Ui_logger.html_logger) -> outputhtml_ref := Some rw),
117 match !outputhtml_ref with
118 | None -> raise OutputHtmlNotInitialized
119 | Some outputhtml -> (outputhtml: Ui_logger.html_logger)
123 exception QedSetSensitiveNotInitialized;;
124 let qed_set_sensitive =
125 ref (function _ -> raise QedSetSensitiveNotInitialized)
128 exception SaveSetSensitiveNotInitialized;;
129 let save_set_sensitive =
130 ref (function _ -> raise SaveSetSensitiveNotInitialized)
133 (* COMMAND LINE OPTIONS *)
139 "-nodb", Arg.Clear usedb, "disable use of MathQL DB"
142 Arg.parse argspec ignore ""
146 let term_of_cic_textual_parser_uri uri =
147 let module C = Cic in
148 let module CTP = CicTextualParser0 in
150 CTP.ConUri uri -> C.Const (uri,[])
151 | CTP.VarUri uri -> C.Var (uri,[])
152 | CTP.IndTyUri (uri,tyno) -> C.MutInd (uri,tyno,[])
153 | CTP.IndConUri (uri,tyno,consno) -> C.MutConstruct (uri,tyno,consno,[])
156 let string_of_cic_textual_parser_uri uri =
157 let module C = Cic in
158 let module CTP = CicTextualParser0 in
161 CTP.ConUri uri -> UriManager.string_of_uri uri
162 | CTP.VarUri uri -> UriManager.string_of_uri uri
163 | CTP.IndTyUri (uri,tyno) ->
164 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1)
165 | CTP.IndConUri (uri,tyno,consno) ->
166 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1) ^ "/" ^
169 (* 4 = String.length "cic:" *)
170 String.sub uri' 4 (String.length uri' - 4)
173 let output_html ?(append_NL = true) (outputhtml: Ui_logger.html_logger) =
174 outputhtml#log ~append_NL
176 (* UTILITY FUNCTIONS TO DISAMBIGUATE AN URI *)
180 let check_window (outputhtml: Ui_logger.html_logger) uris =
183 ~width:800 ~modal:true ~title:"Check" ~border_width:2 () in
185 GPack.notebook ~scrollable:true ~packing:window#add () in
190 let scrolled_window =
191 GBin.scrolled_window ~border_width:10
193 (notebook#append_page ~tab_label:((GMisc.label ~text:uri ())#coerce))
198 TermViewer.sequent_viewer
199 ~packing:scrolled_window#add ~width:400 ~height:280 () in
202 term_of_cic_textual_parser_uri
203 (MQueryMisc.cic_textual_parser_uri_of_string uri)
205 (Cic.Cast (term, CicTypeChecker.type_of_aux' [] [] term))
208 mmlwidget#load_sequent [] (111,[],expr)
211 output_html outputhtml (`Error (`T (Printexc.to_string e)))
216 (notebook#connect#switch_page
218 Lazy.force (List.nth render_terms i)))
224 interactive_user_uri_choice ~(selection_mode:[`MULTIPLE|`SINGLE]) ?(ok="Ok")
225 ?(enable_button_for_non_vars=false) ~title ~msg uris
227 let only_constant_choices =
230 (fun uri -> not (String.sub uri (String.length uri - 4) 4 = ".var"))
233 if !auto_disambiguation then
234 Lazy.force only_constant_choices
236 let choices = ref [] in
237 let chosen = ref false in
238 let use_only_constants = ref false in
240 GWindow.dialog ~modal:true ~title ~width:600 () in
242 GMisc.label ~text:msg
243 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
244 let scrolled_window =
245 GBin.scrolled_window ~border_width:10
246 ~packing:(window#vbox#pack ~expand:true ~fill:true ~padding:5) () in
248 let expected_height = 18 * List.length uris in
249 let height = if expected_height > 400 then 400 else expected_height in
250 GList.clist ~columns:1 ~packing:scrolled_window#add
251 ~height ~selection_mode:(selection_mode :> Gtk.Tags.selection_mode) () in
252 let _ = List.map (function x -> clist#append [x]) uris in
254 GPack.hbox ~border_width:0
255 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
257 GMisc.label ~text:"None of the above. Try this one:"
258 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
260 GEdit.entry ~editable:true
261 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
263 GPack.hbox ~border_width:0 ~packing:window#action_area#add () in
265 GButton.button ~label:ok
266 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
267 let _ = okb#misc#set_sensitive false in
272 if enable_button_for_non_vars then
273 hbox#pack ~expand:false ~fill:false ~padding:5 w)
274 ~label:"Try constants only" () in
279 if enable_button_for_non_vars then
280 hbox#pack ~expand:false ~fill:false ~padding:5 w)
283 GButton.button ~label:"Check"
284 ~packing:(hbox#pack ~padding:5) () in
285 let _ = checkb#misc#set_sensitive false in
287 GButton.button ~label:"Abort"
288 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
290 let check_callback () =
291 assert (List.length !choices > 0) ;
292 check_window (outputhtml ()) !choices
294 ignore (window#connect#destroy GMain.Main.quit) ;
295 ignore (cancelb#connect#clicked window#destroy) ;
297 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
299 (nonvarsb#connect#clicked
301 use_only_constants := true ;
305 ignore (autob#connect#clicked (fun () ->
306 auto_disambiguation := true;
307 (rendering_window ())#set_auto_disambiguation true;
308 use_only_constants := true ;
311 ignore (checkb#connect#clicked check_callback) ;
313 (clist#connect#select_row
314 (fun ~row ~column ~event ->
315 checkb#misc#set_sensitive true ;
316 okb#misc#set_sensitive true ;
317 choices := (List.nth uris row)::!choices)) ;
319 (clist#connect#unselect_row
320 (fun ~row ~column ~event ->
322 List.filter (function uri -> uri != (List.nth uris row)) !choices)) ;
324 (manual_input#connect#changed
326 if manual_input#text = "" then
329 checkb#misc#set_sensitive false ;
330 okb#misc#set_sensitive false ;
331 clist#misc#set_sensitive true
335 choices := [manual_input#text] ;
336 clist#unselect_all () ;
337 checkb#misc#set_sensitive true ;
338 okb#misc#set_sensitive true ;
339 clist#misc#set_sensitive false
341 window#set_position `CENTER ;
345 if !use_only_constants then
346 Lazy.force only_constant_choices
348 if List.length !choices > 0 then !choices else raise NoChoice
354 let interactive_interpretation_choice interpretations =
355 let chosen = ref None in
358 ~modal:true ~title:"Ambiguous well-typed input." ~border_width:2 () in
359 let vbox = GPack.vbox ~packing:window#add () in
363 ("Ambiguous input since there are many well-typed interpretations." ^
364 " Please, choose one of them.")
365 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
367 GPack.notebook ~scrollable:true
368 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
371 (function interpretation ->
373 let expected_height = 18 * List.length interpretation in
374 let height = if expected_height > 400 then 400 else expected_height in
375 GList.clist ~columns:2 ~packing:notebook#append_page ~height
376 ~titles:["id" ; "URI"] ()
380 (function (id,uri) ->
381 let n = clist#append [id;uri] in
382 clist#set_row ~selectable:false n
385 clist#columns_autosize ()
388 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
390 GButton.button ~label:"Ok"
391 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
393 GButton.button ~label:"Abort"
394 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
396 ignore (window#connect#destroy GMain.Main.quit) ;
397 ignore (cancelb#connect#clicked window#destroy) ;
400 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
401 window#set_position `CENTER ;
405 None -> raise NoChoice
413 save_object_to_disk uri annobj ids_to_inner_sorts ids_to_inner_types pathname
416 let struri = UriManager.string_of_uri uri in
417 let idx = (String.rindex struri '/') + 1 in
418 String.sub struri idx (String.length struri - idx)
420 let path = pathname ^ "/" ^ name in
422 Cic2Xml.print_object uri ~ids_to_inner_sorts ~ask_dtd_to_the_getter:false
426 Cic2Xml.print_inner_types uri ~ids_to_inner_sorts ~ids_to_inner_types
427 ~ask_dtd_to_the_getter:false
430 let innertypesuri = UriManager.innertypesuri_of_uri uri in
431 Xml.pp ~quiet:true xmlinnertypes (Some (path ^ ".types.xml")) ;
432 Getter.register innertypesuri
433 (Configuration.annotations_url ^
434 Str.replace_first (Str.regexp "^cic:") ""
435 (UriManager.string_of_uri innertypesuri) ^ ".xml"
437 (* constant type / variable / mutual inductive types definition *)
438 Xml.pp ~quiet:true xml (Some (path ^ ".xml")) ;
440 (Configuration.annotations_url ^
441 Str.replace_first (Str.regexp "^cic:") ""
442 (UriManager.string_of_uri uri) ^ ".xml"
449 match UriManager.bodyuri_of_uri uri with
451 | Some bodyuri -> bodyuri
453 Xml.pp ~quiet:true bodyxml' (Some (path ^ ".body.xml")) ;
454 Getter.register bodyuri
455 (Configuration.annotations_url ^
456 Str.replace_first (Str.regexp "^cic:") ""
457 (UriManager.string_of_uri bodyuri) ^ ".xml"
464 exception OpenConjecturesStillThere;;
465 exception WrongProof;;
467 let pathname_of_annuri uristring =
468 Configuration.annotations_dir ^
469 Str.replace_first (Str.regexp "^cic:") "" uristring
472 let make_dirs dirpath =
473 ignore (Unix.system ("mkdir -p " ^ dirpath))
476 let save_obj uri obj =
478 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
479 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
481 Cic2acic.acic_object_of_cic_object obj
483 (* let's save the theorem and register it to the getter *)
484 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
486 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
491 match ProofEngine.get_proof () with
493 | Some (uri,[],bo,ty) ->
495 CicReduction.are_convertible []
496 (CicTypeChecker.type_of_aux' [] [] bo) ty
499 (*CSC: Wrong: [] is just plainly wrong *)
500 let proof = Cic.Constant (UriManager.name_of_uri uri,Some bo,ty,[]) in
501 let (acic,ids_to_inner_types,ids_to_inner_sorts) =
502 (rendering_window ())#output#load_proof uri proof
504 !qed_set_sensitive false ;
505 (* let's save the theorem and register it to the getter *)
506 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
508 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
513 | _ -> raise OpenConjecturesStillThere
516 (** save an unfinished proof on the filesystem *)
517 let save_unfinished_proof () =
518 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
519 let (xml, bodyxml) = ProofEngine.get_current_status_as_xml () in
520 Xml.pp ~quiet:true xml (Some prooffiletype) ;
521 output_html outputhtml
522 (`Msg (`T ("Current proof type saved to " ^ prooffiletype))) ;
523 Xml.pp ~quiet:true bodyxml (Some prooffile) ;
524 output_html outputhtml
525 (`Msg (`T ("Current proof body saved to " ^ prooffile)))
528 (* Used to typecheck the loaded proofs *)
529 let typecheck_loaded_proof metasenv bo ty =
530 let module T = CicTypeChecker in
533 (fun metasenv ((_,context,ty) as conj) ->
534 ignore (T.type_of_aux' metasenv context ty) ;
537 ignore (T.type_of_aux' metasenv [] ty) ;
538 ignore (T.type_of_aux' metasenv [] bo)
541 let decompose_uris_choice_callback uris =
542 (* N.B.: in questo passaggio perdo l'informazione su exp_named_subst !!!! *)
543 let module U = UriManager in
546 match MQueryMisc.cic_textual_parser_uri_of_string uri with
547 CicTextualParser0.IndTyUri (uri,typeno) -> (uri,typeno,[])
549 (interactive_user_uri_choice
550 ~selection_mode:`MULTIPLE ~ok:"Ok" ~enable_button_for_non_vars:false
551 ~title:"Decompose" ~msg:"Please, select the Inductive Types to decompose"
553 (function (uri,typeno,_) ->
554 U.string_of_uri uri ^ "#1/" ^ string_of_int (typeno+1)
559 let mk_fresh_name_callback metasenv context name ~typ =
561 match FreshNamesGenerator.mk_fresh_name metasenv context name ~typ with
562 Cic.Name fresh_name -> fresh_name
563 | Cic.Anonymous -> assert false
566 GToolbox.input_string ~title:"Enter a fresh hypothesis name" ~text:fresh_name
567 ("Enter a fresh name for the hypothesis " ^
569 (List.map (function None -> None | Some (n,_) -> Some n) context))
571 Some fresh_name' -> Cic.Name fresh_name'
572 | None -> raise NoChoice
575 let refresh_proof (output : TermViewer.proof_viewer) =
577 let uri,currentproof =
578 match ProofEngine.get_proof () with
580 | Some (uri,metasenv,bo,ty) ->
581 ProofEngine.set_proof (Some (uri,metasenv,bo,ty)) ;
582 if List.length metasenv = 0 then
584 !qed_set_sensitive true ;
589 (*CSC: Wrong: [] is just plainly wrong *)
591 (Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, []))
593 ignore (output#load_proof uri currentproof)
596 match ProofEngine.get_proof () with
598 | Some (uri,metasenv,bo,ty) ->
599 debug_print ("Offending proof: " ^ CicPp.ppobj (Cic.CurrentProof ("questa",metasenv,bo,ty,[])));
600 raise (InvokeTactics.RefreshProofException e)
602 let set_proof_engine_goal g =
603 ProofEngine.goal := g
606 let refresh_goals ?(empty_notebook=true) notebook =
608 match !ProofEngine.goal with
610 if empty_notebook then
612 notebook#remove_all_pages ~skip_switch_page_event:false ;
613 notebook#set_empty_page
616 notebook#proofw#unload
619 match ProofEngine.get_proof () with
621 | Some (_,metasenv,_,_) -> metasenv
624 List.find (function (m,_,_) -> m=metano) metasenv
626 let regenerate_notebook () =
627 let skip_switch_page_event =
629 (m,_,_)::_ when m = metano -> false
632 notebook#remove_all_pages ~skip_switch_page_event ;
633 List.iter (function (m,_,_) -> notebook#add_page m) metasenv ;
635 if empty_notebook then
637 regenerate_notebook () ;
638 notebook#set_current_page
639 ~may_skip_switch_page_event:false metano
643 notebook#set_current_page
644 ~may_skip_switch_page_event:true metano ;
645 notebook#proofw#load_sequent metasenv currentsequent
650 match !ProofEngine.goal with
655 match ProofEngine.get_proof () with
657 | Some (_,metasenv,_,_) -> metasenv
660 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
662 ("Offending sequent: " ^ SequentPp.TextualPp.print_sequent currentsequent);
663 raise (InvokeTactics.RefreshSequentException e)
665 debug_print ("Offending sequent " ^ string_of_int metano ^ " unknown.");
666 raise (InvokeTactics.RefreshSequentException e)
668 module InvokeTacticsCallbacks =
670 let sequent_viewer () = (rendering_window ())#notebook#proofw
671 let term_editor () = (rendering_window ())#inputt
672 let scratch_window () = (rendering_window ())#scratch_window
674 let refresh_proof () =
675 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
678 let refresh_goals () =
679 let notebook = (rendering_window ())#notebook in
680 refresh_goals notebook
682 let decompose_uris_choice_callback = decompose_uris_choice_callback
683 let mk_fresh_name_callback = mk_fresh_name_callback
684 let output_html msg = output_html (outputhtml ()) msg
687 module InvokeTactics' = InvokeTactics.Make (InvokeTacticsCallbacks);;
689 (* Just to initialize the Hbugs module *)
690 module Ignore = Hbugs.Initialize (InvokeTactics');;
691 Hbugs.set_describe_hint_callback (fun hint ->
693 | Hbugs_types.Use_apply_Luke term ->
694 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
695 check_window outputhtml [term]
699 let dummy_uri = "/dummy.con"
701 (** load an unfinished proof from filesystem *)
702 let load_unfinished_proof () =
703 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
704 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
705 let notebook = (rendering_window ())#notebook in
708 GToolbox.input_string ~title:"Load Unfinished Proof" ~text:dummy_uri
711 None -> raise NoChoice
713 let uri = UriManager.uri_of_string ("cic:" ^ uri0) in
714 match CicParser.obj_of_xml prooffiletype (Some prooffile) with
715 Cic.CurrentProof (_,metasenv,bo,ty,_) ->
716 typecheck_loaded_proof metasenv bo ty ;
717 ProofEngine.set_proof (Some (uri, metasenv, bo, ty)) ;
718 refresh_proof output ;
719 set_proof_engine_goal
722 | (metano,_,_)::_ -> Some metano
724 refresh_goals notebook ;
725 output_html outputhtml
726 (`Msg (`T ("Current proof type loaded from " ^
728 output_html outputhtml
729 (`Msg (`T ("Current proof body loaded from " ^
731 !save_set_sensitive true;
734 InvokeTactics.RefreshSequentException e ->
735 output_html outputhtml
736 (`Error (`T ("Exception raised during the refresh of the " ^
737 "sequent: " ^ Printexc.to_string e)))
738 | InvokeTactics.RefreshProofException e ->
739 output_html outputhtml
740 (`Error (`T ("Exception raised during the refresh of the " ^
741 "proof: " ^ Printexc.to_string e)))
743 output_html outputhtml
744 (`Error (`T (Printexc.to_string e)))
747 let clear_aliases () =
748 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
749 inputt#environment :=
750 DisambiguatingParser.EnvironmentP3.of_string
751 DisambiguatingParser.EnvironmentP3.empty
754 let edit_aliases () =
755 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
756 let disambiguation_env = inputt#environment in
757 let chosen_aliases = ref None in
760 ~width:400 ~modal:true ~title:"Edit Aliases..." ~border_width:2 () in
762 GPack.vbox ~border_width:0 ~packing:window#add () in
763 let scrolled_window =
764 GBin.scrolled_window ~border_width:10
765 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
766 let input = GText.view ~editable:true ~width:400 ~height:100
767 ~packing:scrolled_window#add () in
769 GPack.hbox ~border_width:0
770 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
772 GButton.button ~label:"Ok"
773 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
775 GButton.button ~label:"Clear"
776 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
778 GButton.button ~label:"Cancel"
779 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
780 ignore (window#connect#destroy GMain.Main.quit) ;
781 ignore (cancelb#connect#clicked window#destroy) ;
782 ignore (clearb#connect#clicked (fun () ->
783 input#buffer#set_text DisambiguatingParser.EnvironmentP3.empty)) ;
784 ignore (okb#connect#clicked (fun () ->
785 chosen_aliases := Some (input#buffer#get_text ());
788 (input#buffer#insert ~iter:(input#buffer#get_iter_at_char 0)
789 (DisambiguatingParser.EnvironmentP3.to_string !disambiguation_env ^ "\n"));
792 match !chosen_aliases with
794 | Some raw_aliases ->
795 let new_disambiguation_env =
797 DisambiguatingParser.EnvironmentP3.of_string raw_aliases
799 output_html (outputhtml ())
801 ("Error while parsing aliases: " ^ Printexc.to_string e)));
804 disambiguation_env := new_disambiguation_env
808 let module L = LogicalOperations in
809 let module G = Gdome in
810 let notebook = (rendering_window ())#notebook in
811 let output = (rendering_window ())#output in
812 let outputhtml = (rendering_window ())#outputhtml in
814 output#make_sequent_of_selected_term ;
815 refresh_proof output ;
816 refresh_goals notebook
818 InvokeTactics.RefreshSequentException e ->
819 output_html outputhtml
820 (`Error (`T ("Exception raised during the refresh of the " ^
821 "sequent: " ^ Printexc.to_string e)))
822 | InvokeTactics.RefreshProofException e ->
823 output_html outputhtml
824 (`Error (`T ("Exception raised during the refresh of the " ^
825 "proof: " ^ Printexc.to_string e)))
827 output_html outputhtml
828 (`Error (`T (Printexc.to_string e)))
832 let module L = LogicalOperations in
833 let module G = Gdome in
834 let notebook = (rendering_window ())#notebook in
835 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
836 let output = (rendering_window ())#output in
838 output#focus_sequent_of_selected_term ;
839 refresh_goals notebook
841 InvokeTactics.RefreshSequentException e ->
842 output_html outputhtml
843 (`Error (`T ("Exception raised during the refresh of the " ^
844 "sequent: " ^ Printexc.to_string e)))
845 | InvokeTactics.RefreshProofException e ->
846 output_html outputhtml
847 (`Error (`T ("Exception raised during the refresh of the " ^
848 "proof: " ^ Printexc.to_string e)))
850 output_html outputhtml
851 (`Error (`T (Printexc.to_string e)))
854 exception NoPrevGoal;;
855 exception NoNextGoal;;
858 let module L = LogicalOperations in
859 let module G = Gdome in
860 let notebook = (rendering_window ())#notebook in
861 let output = (rendering_window ())#output in
862 let outputhtml = (rendering_window ())#outputhtml in
864 match ProofEngine.get_proof () with
866 | Some (_,metasenv,_,_) -> metasenv
869 refresh_goals ~empty_notebook:false notebook
871 InvokeTactics.RefreshSequentException e ->
872 output_html outputhtml
873 (`Error (`T ("Exception raised during the refresh of the " ^
874 "sequent: " ^ Printexc.to_string e)))
876 output_html outputhtml
877 (`Error (`T (Printexc.to_string e)))
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 ChosenTransformer.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 (`Error (`T (Printexc.to_string e)))
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 (`Msg (`T "Locate Query:")) ;
965 MQueryUtil.text_of_query (fun m -> out (`Msg (`T m))) "" query;
966 out (`Msg (`T "Result:")) ;
967 MQueryUtil.text_of_result (fun m -> out (`Msg (`T m))) "" result;
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 (`Msg (`T "OK")) ;
1026 Getter.Unresolved ->
1027 output_html outputhtml
1028 (`Error (`T ("URI " ^ uri ^
1029 " does not correspond to any object."))) ;
1031 | UriManager.IllFormedUri _ ->
1032 output_html outputhtml
1033 (`Error (`T ("URI " ^ uri ^ " is not well-formed."))) ;
1036 output_html outputhtml
1037 (`Error (`T (Printexc.to_string e))) ;
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 DisambiguateCallbacks =
1086 let output_html ?append_NL = output_html ?append_NL (outputhtml ())
1087 let interactive_user_uri_choice =
1088 fun ~selection_mode ?ok ?enable_button_for_non_vars ~title ~msg ~id ->
1089 interactive_user_uri_choice ~selection_mode ?ok
1090 ?enable_button_for_non_vars ~title ~msg
1091 let interactive_interpretation_choice = interactive_interpretation_choice
1092 let input_or_locate_uri = input_or_locate_uri
1096 module TermEditor' = ChosenTermEditor.Make (DisambiguateCallbacks);;
1098 (* OTHER FUNCTIONS *)
1101 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1102 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1105 GToolbox.input_string ~title:"Locate" "Enter an identifier to locate:"
1107 None -> raise NoChoice
1109 let uri = locate_callback input in
1113 output_html outputhtml
1114 (`Error (`T (Printexc.to_string e)))
1118 exception UriAlreadyInUse;;
1119 exception NotAUriToAConstant;;
1121 let new_inductive () =
1122 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1123 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1124 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1125 let notebook = (rendering_window ())#notebook in
1127 let chosen = ref false in
1128 let inductive = ref true in
1129 let paramsno = ref 0 in
1130 let get_uri = ref (function _ -> assert false) in
1131 let get_base_uri = ref (function _ -> assert false) in
1132 let get_names = ref (function _ -> assert false) in
1133 let get_types_and_cons = ref (function _ -> assert false) in
1134 let get_context_and_subst = ref (function _ -> assert false) in
1137 ~width:600 ~modal:true ~position:`CENTER
1138 ~title:"New Block of Mutual (Co)Inductive Definitions"
1139 ~border_width:2 () in
1140 let vbox = GPack.vbox ~packing:window#add () in
1142 GPack.hbox ~border_width:0
1143 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1145 GMisc.label ~text:"Enter the URI for the new block:"
1146 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1148 GEdit.entry ~editable:true
1149 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1151 GPack.hbox ~border_width:0
1152 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1156 "Enter the number of left parameters in every arity and constructor type:"
1157 ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1158 let paramsno_entry =
1159 GEdit.entry ~editable:true ~text:"0"
1160 ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
1162 GPack.hbox ~border_width:0
1163 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1165 GMisc.label ~text:"Are the definitions inductive or coinductive?"
1166 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1168 GButton.radio_button ~label:"Inductive"
1169 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1171 GButton.radio_button ~label:"Coinductive"
1172 ~group:inductiveb#group
1173 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1175 GPack.hbox ~border_width:0
1176 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1178 GMisc.label ~text:"Enter the list of the names of the types:"
1179 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1181 GEdit.entry ~editable:true
1182 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1184 GPack.hbox ~border_width:0
1185 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1187 GButton.button ~label:"> Next"
1188 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1189 let _ = okb#misc#set_sensitive true in
1191 GButton.button ~label:"Abort"
1192 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1193 ignore (window#connect#destroy GMain.Main.quit) ;
1194 ignore (cancelb#connect#clicked window#destroy) ;
1198 (okb#connect#clicked
1201 let uristr = "cic:" ^ uri_entry#text in
1202 let namesstr = names_entry#text in
1203 let paramsno' = int_of_string (paramsno_entry#text) in
1204 match Str.split (Str.regexp " +") namesstr with
1206 | (he::tl) as names ->
1207 let uri = UriManager.uri_of_string (uristr ^ "/" ^ he ^ ".ind") in
1210 ignore (Getter.resolve uri) ;
1211 raise UriAlreadyInUse
1213 Getter.Unresolved ->
1214 get_uri := (function () -> uri) ;
1215 get_names := (function () -> names) ;
1216 inductive := inductiveb#active ;
1217 paramsno := paramsno' ;
1222 output_html outputhtml
1223 (`Error (`T (Printexc.to_string e)))
1231 GBin.frame ~label:name
1232 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1233 let vbox = GPack.vbox ~packing:frame#add () in
1234 let hbox = GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false) () in
1236 GMisc.label ~text:("Enter its type:")
1237 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1238 let scrolled_window =
1239 GBin.scrolled_window ~border_width:5
1240 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1242 TermEditor'.term_editor
1244 ~width:400 ~height:20 ~packing:scrolled_window#add
1245 ~share_environment_with:inputt ()
1246 ~isnotempty_callback:
1248 (*non_empty_type := b ;*)
1249 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*)
1252 GPack.hbox ~border_width:0
1253 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1255 GMisc.label ~text:("Enter the list of its constructors:")
1256 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1257 let cons_names_entry =
1258 GEdit.entry ~editable:true
1259 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1260 (newinputt,cons_names_entry)
1263 vbox#remove hboxn#coerce ;
1265 GPack.hbox ~border_width:0
1266 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1268 GButton.button ~label:"> Next"
1269 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1271 GButton.button ~label:"Abort"
1272 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1273 ignore (cancelb#connect#clicked window#destroy) ;
1275 (okb#connect#clicked
1278 let names = !get_names () in
1279 let types_and_cons =
1281 (fun name (newinputt,cons_names_entry) ->
1282 let consnamesstr = cons_names_entry#text in
1283 let cons_names = Str.split (Str.regexp " +") consnamesstr in
1285 newinputt#get_metasenv_and_term ~context:[] ~metasenv:[]
1288 [] -> expr,cons_names
1289 | _ -> raise AmbiguousInput
1290 ) names type_widgets
1292 let uri = !get_uri () in
1294 (* Let's see if so far the definition is well-typed *)
1297 (* To test if the arities of the inductive types are well *)
1298 (* typed, we check the inductive block definition where *)
1299 (* no constructor is given to each type. *)
1302 (fun name (ty,cons) -> (name, !inductive, ty, []))
1303 names types_and_cons
1305 CicTypeChecker.typecheck_mutual_inductive_defs uri
1306 (tys,params,paramsno)
1308 get_context_and_subst :=
1312 (fun (context,subst) name (ty,_) ->
1314 (Some (Cic.Name name, Cic.Decl ty))::context,
1315 (Cic.MutInd (uri,!i,[]))::subst
1318 ) ([],[]) names types_and_cons) ;
1319 let types_and_cons' =
1321 (fun name (ty,cons) -> (name, !inductive, ty, phase3 name cons))
1322 names types_and_cons
1324 get_types_and_cons := (function () -> types_and_cons') ;
1329 output_html outputhtml
1330 (`Error (`T (Printexc.to_string e)))
1333 and phase3 name cons =
1334 let get_cons_types = ref (function () -> assert false) in
1337 ~width:600 ~modal:true ~position:`CENTER
1338 ~title:(name ^ " Constructors")
1339 ~border_width:2 () in
1340 let vbox = GPack.vbox ~packing:window2#add () in
1341 let cons_type_widgets =
1343 (function consname ->
1345 GPack.hbox ~border_width:0
1346 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1348 GMisc.label ~text:("Enter the type of " ^ consname ^ ":")
1349 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1350 let scrolled_window =
1351 GBin.scrolled_window ~border_width:5
1352 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1354 TermEditor'.term_editor
1356 ~width:400 ~height:20 ~packing:scrolled_window#add
1357 ~share_environment_with:inputt ()
1358 ~isnotempty_callback:
1360 (* (*non_empty_type := b ;*)
1361 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*) *)())
1366 GPack.hbox ~border_width:0
1367 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1369 GButton.button ~label:"> Next"
1370 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1371 let _ = okb#misc#set_sensitive true in
1373 GButton.button ~label:"Abort"
1374 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1375 ignore (window2#connect#destroy GMain.Main.quit) ;
1376 ignore (cancelb#connect#clicked window2#destroy) ;
1378 (okb#connect#clicked
1382 let context,subst= !get_context_and_subst () in
1387 inputt#get_metasenv_and_term ~context ~metasenv:[]
1391 let undebrujined_expr =
1393 (fun expr t -> CicSubstitution.subst t expr) expr subst
1395 name, undebrujined_expr
1396 | _ -> raise AmbiguousInput
1397 ) cons cons_type_widgets
1399 get_cons_types := (function () -> cons_types) ;
1403 output_html outputhtml
1404 (`Error (`T (Printexc.to_string e)))
1408 let okb_pressed = !chosen in
1410 if (not okb_pressed) then
1413 assert false (* The control never reaches this point *)
1416 (!get_cons_types ())
1419 (* No more phases left or Abort pressed *)
1425 let uri = !get_uri () in
1428 let tys = !get_types_and_cons () in
1429 let obj = Cic.InductiveDefinition(tys,params,!paramsno) in
1432 debug_print (CicPp.ppobj obj);
1433 CicTypeChecker.typecheck_mutual_inductive_defs uri
1434 (tys,params,!paramsno) ;
1437 debug_print "Offending mutual (co)inductive type declaration:" ;
1438 debug_print (CicPp.ppobj obj) ;
1440 (* We already know that obj is well-typed. We need to add it to the *)
1441 (* environment in order to compute the inner-types without having to *)
1442 (* debrujin it or having to modify lots of other functions to avoid *)
1443 (* asking the environment for the MUTINDs we are defining now. *)
1444 CicEnvironment.put_inductive_definition uri obj ;
1446 show_in_show_window_obj uri obj
1449 output_html outputhtml
1450 (`Error (`T (Printexc.to_string e)))
1454 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1455 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1456 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1457 let notebook = (rendering_window ())#notebook in
1459 let chosen = ref false in
1460 let get_metasenv_and_term = ref (function _ -> assert false) in
1461 let get_uri = ref (function _ -> assert false) in
1462 let non_empty_type = ref false in
1465 ~width:600 ~modal:true ~title:"New Proof or Definition"
1466 ~border_width:2 () in
1467 let vbox = GPack.vbox ~packing:window#add () in
1469 GPack.hbox ~border_width:0
1470 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1472 GMisc.label ~text:"Enter the URI for the new theorem or definition:"
1473 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1475 GEdit.entry ~editable:true
1476 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1477 uri_entry#set_text dummy_uri;
1478 uri_entry#select_region ~start:1 ~stop:(String.length dummy_uri);
1480 GPack.hbox ~border_width:0
1481 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1483 GMisc.label ~text:"Enter the theorem or definition type:"
1484 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1485 let scrolled_window =
1486 GBin.scrolled_window ~border_width:5
1487 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1488 (* the content of the scrolled_window is moved below (see comment) *)
1490 GPack.hbox ~border_width:0
1491 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1493 GButton.button ~label:"Ok"
1494 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1495 let _ = okb#misc#set_sensitive false in
1497 GButton.button ~label:"Cancel"
1498 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1499 (* moved here to have visibility of the ok button *)
1501 TermEditor'.term_editor
1503 ~width:400 ~height:100 ~packing:scrolled_window#add
1504 ~share_environment_with:inputt ()
1505 ~isnotempty_callback:
1507 non_empty_type := b ;
1508 okb#misc#set_sensitive (b && uri_entry#text <> ""))
1511 newinputt#set_term inputt#get_as_string ;
1514 uri_entry#connect#changed
1516 okb#misc#set_sensitive (!non_empty_type && uri_entry#text <> ""))
1518 ignore (window#connect#destroy GMain.Main.quit) ;
1519 ignore (cancelb#connect#clicked window#destroy) ;
1521 (okb#connect#clicked
1525 let metasenv,parsed = newinputt#get_metasenv_and_term [] [] in
1526 let uristr = "cic:" ^ uri_entry#text in
1527 let uri = UriManager.uri_of_string uristr in
1528 if String.sub uristr (String.length uristr - 4) 4 <> ".con" then
1529 raise NotAUriToAConstant
1533 ignore (Getter.resolve uri) ;
1534 raise UriAlreadyInUse
1536 Getter.Unresolved ->
1537 get_metasenv_and_term := (function () -> metasenv,parsed) ;
1538 get_uri := (function () -> uri) ;
1543 output_html outputhtml
1544 (`Error (`T (Printexc.to_string e)))
1550 let metasenv,expr = !get_metasenv_and_term () in
1551 let _ = CicTypeChecker.type_of_aux' metasenv [] expr in
1552 ProofEngine.set_proof
1553 (Some (!get_uri (), (1,[],expr)::metasenv, Cic.Meta (1,[]), expr)) ;
1554 set_proof_engine_goal (Some 1) ;
1555 refresh_goals notebook ;
1556 refresh_proof output ;
1557 !save_set_sensitive true ;
1559 ProofEngine.intros ~mk_fresh_name_callback () ;
1560 refresh_goals notebook ;
1561 refresh_proof output
1563 InvokeTactics.RefreshSequentException e ->
1564 output_html outputhtml
1565 (`Error (`T ("Exception raised during the refresh of the " ^
1566 "sequent: " ^ Printexc.to_string e)))
1567 | InvokeTactics.RefreshProofException e ->
1568 output_html outputhtml
1569 (`Error (`T ("Exception raised during the refresh of the " ^
1570 "proof: " ^ Printexc.to_string e)))
1572 output_html outputhtml
1573 (`Error (`T (Printexc.to_string e)))
1576 let check_term_in_scratch scratch_window metasenv context expr =
1578 let ty = CicTypeChecker.type_of_aux' metasenv context expr in
1579 let expr = Cic.Cast (expr,ty) in
1580 scratch_window#show () ;
1581 scratch_window#set_term expr ;
1582 scratch_window#set_context context ;
1583 scratch_window#set_metasenv metasenv ;
1584 scratch_window#sequent_viewer#load_sequent metasenv (111,context,expr)
1587 print_endline ("? " ^ CicPp.ppterm expr) ;
1591 let check scratch_window () =
1592 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1593 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1595 match ProofEngine.get_proof () with
1597 | Some (_,metasenv,_,_) -> metasenv
1600 match !ProofEngine.goal with
1603 let (_,canonical_context,_) =
1604 List.find (function (m,_,_) -> m=metano) metasenv
1609 let metasenv',expr = inputt#get_metasenv_and_term context metasenv in
1610 check_term_in_scratch scratch_window metasenv' context expr
1613 output_html outputhtml
1614 (`Error (`T (Printexc.to_string e)))
1618 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1620 show_in_show_window_uri (input_or_locate_uri ~title:"Show")
1623 output_html outputhtml
1624 (`Error (`T (Printexc.to_string e)))
1627 exception NotADefinition;;
1630 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1631 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1632 let notebook = (rendering_window ())#notebook in
1634 let uri = input_or_locate_uri ~title:"Open" in
1635 CicTypeChecker.typecheck uri ;
1636 let metasenv,bo,ty =
1637 match CicEnvironment.get_cooked_obj uri with
1638 Cic.Constant (_,Some bo,ty,_) -> [],bo,ty
1639 | Cic.CurrentProof (_,metasenv,bo,ty,_) -> metasenv,bo,ty
1642 | Cic.InductiveDefinition _ -> raise NotADefinition
1644 ProofEngine.set_proof (Some (uri, metasenv, bo, ty)) ;
1645 set_proof_engine_goal None ;
1646 refresh_goals notebook ;
1647 refresh_proof output ;
1648 !save_set_sensitive true
1650 InvokeTactics.RefreshSequentException e ->
1651 output_html outputhtml
1652 (`Error (`T ("Exception raised during the refresh of the " ^
1653 "sequent: " ^ Printexc.to_string e)))
1654 | InvokeTactics.RefreshProofException e ->
1655 output_html outputhtml
1656 (`Error (`T ("Exception raised during the refresh of the " ^
1657 "proof: " ^ Printexc.to_string e)))
1659 output_html outputhtml
1660 (`Error (`T (Printexc.to_string e)))
1663 let show_query_results results =
1666 ~modal:false ~title:"Query results." ~border_width:2 () in
1667 let vbox = GPack.vbox ~packing:window#add () in
1669 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1672 ~text:"Click on a URI to show that object"
1673 ~packing:hbox#add () in
1674 let scrolled_window =
1675 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1676 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1677 let clist = GList.clist ~columns:1 ~packing:scrolled_window#add () in
1680 (function (uri,_) ->
1684 clist#set_row ~selectable:false n
1687 clist#columns_autosize () ;
1689 (clist#connect#select_row
1690 (fun ~row ~column ~event ->
1691 let (uristr,_) = List.nth results row in
1693 MQueryMisc.cic_textual_parser_uri_of_string
1694 (MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format'
1697 CicTextualParser0.ConUri uri
1698 | CicTextualParser0.VarUri uri
1699 | CicTextualParser0.IndTyUri (uri,_)
1700 | CicTextualParser0.IndConUri (uri,_,_) ->
1701 show_in_show_window_uri uri
1707 let refine_constraints (must_obj,must_rel,must_sort) =
1708 let chosen = ref false in
1709 let use_only = ref false in
1712 ~modal:true ~title:"Constraints refinement."
1713 ~width:800 ~border_width:2 () in
1714 let vbox = GPack.vbox ~packing:window#add () in
1716 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1719 ~text: "\"Only\" constraints can be enforced or not."
1720 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1722 GButton.toggle_button ~label:"Enforce \"only\" constraints"
1723 ~active:false ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1726 (onlyb#connect#toggled (function () -> use_only := onlyb#active)) ;
1727 (* Notebook for the constraints choice *)
1729 GPack.notebook ~scrollable:true
1730 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1731 (* Rel constraints *)
1734 ~text: "Constraints on Rels" () in
1736 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1739 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1742 ~text: "You can now specify the constraints on Rels."
1743 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1744 let expected_height = 25 * (List.length must_rel + 2) in
1745 let height = if expected_height > 400 then 400 else expected_height in
1746 let scrolled_window =
1747 GBin.scrolled_window ~border_width:10 ~height ~width:600
1748 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1749 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1750 let mk_depth_button (hbox:GPack.box) d =
1751 let mutable_ref = ref (Some d) in
1753 GButton.toggle_button
1754 ~label:("depth = " ^ string_of_int d)
1756 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1759 (depthb#connect#toggled
1761 let sel_depth = if depthb#active then Some d else None in
1762 mutable_ref := sel_depth
1765 let rel_constraints =
1770 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1773 ~text:(MQGU.text_of_position (p:>MQGT.full_position))
1774 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1776 | `MainHypothesis None
1777 | `MainConclusion None -> p, ref None
1778 | `MainHypothesis (Some depth')
1779 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth'
1781 (* Sort constraints *)
1784 ~text: "Constraints on Sorts" () in
1786 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1789 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1792 ~text: "You can now specify the constraints on Sorts."
1793 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1794 let expected_height = 25 * (List.length must_sort + 2) in
1795 let height = if expected_height > 400 then 400 else expected_height in
1796 let scrolled_window =
1797 GBin.scrolled_window ~border_width:10 ~height ~width:600
1798 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1799 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1800 let sort_constraints =
1802 (function (p, sort) ->
1805 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1808 ~text:(MQGU.text_of_sort sort ^ " " ^ MQGU.text_of_position (p:>MQGT.full_position))
1809 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1811 | `MainHypothesis None
1812 | `MainConclusion None -> p, ref None, sort
1813 | `MainHypothesis (Some depth')
1814 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', sort
1816 (* Obj constraints *)
1819 ~text: "Constraints on constants" () in
1821 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1824 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1827 ~text: "You can now specify the constraints on constants."
1828 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1829 let expected_height = 25 * (List.length must_obj + 2) in
1830 let height = if expected_height > 400 then 400 else expected_height in
1831 let scrolled_window =
1832 GBin.scrolled_window ~border_width:10 ~height ~width:600
1833 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1834 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1835 let obj_constraints =
1837 (function (p, uri) ->
1840 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1843 ~text:(uri ^ " " ^ (MQGU.text_of_position p))
1844 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1849 | `MainHypothesis None
1850 | `MainConclusion None -> p, ref None, uri
1851 | `MainHypothesis (Some depth')
1852 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', uri
1854 (* Confirm/abort buttons *)
1856 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1858 GButton.button ~label:"Ok"
1859 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1861 GButton.button ~label:"Abort"
1862 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1864 ignore (window#connect#destroy GMain.Main.quit) ;
1865 ignore (cancelb#connect#clicked window#destroy) ;
1867 (okb#connect#clicked (function () -> chosen := true ; window#destroy ()));
1868 window#set_position `CENTER ;
1872 let chosen_must_rel =
1874 (function (position, ref_depth) -> MQGU.set_main_position position !ref_depth)
1877 let chosen_must_sort =
1879 (function (position, ref_depth, sort) ->
1880 MQGU.set_main_position position !ref_depth,sort)
1883 let chosen_must_obj =
1885 (function (position, ref_depth, uri) -> MQGU.set_full_position position !ref_depth, uri)
1888 (chosen_must_obj,chosen_must_rel,chosen_must_sort),
1890 (*CSC: ???????????????????????? I assume that must and only are the same... *)
1891 Some chosen_must_obj,Some chosen_must_rel,Some chosen_must_sort
1899 let completeSearchPattern () =
1900 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1901 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1903 let metasenv,expr = inputt#get_metasenv_and_term ~context:[] ~metasenv:[] in
1904 let must = CGSearchPattern.get_constraints expr in
1905 let must',only = refine_constraints must in
1907 MQG.query_of_constraints (Some CGSearchPattern.universe) must' only
1909 let results = MQI.execute mqi_handle query in
1910 show_query_results results
1913 output_html outputhtml
1914 (`Error (`T (Printexc.to_string e)))
1917 let insertQuery () =
1918 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1920 let chosen = ref None in
1923 ~modal:true ~title:"Insert Query (Experts Only)" ~border_width:2 () in
1924 let vbox = GPack.vbox ~packing:window#add () in
1926 GMisc.label ~text:"Insert Query. For Experts Only."
1927 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1928 let scrolled_window =
1929 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1930 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1931 let input = GText.view ~editable:true
1932 ~packing:scrolled_window#add () in
1934 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1936 GButton.button ~label:"Ok"
1937 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1939 GButton.button ~label:"Load from file..."
1940 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1942 GButton.button ~label:"Abort"
1943 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1944 ignore (window#connect#destroy GMain.Main.quit) ;
1945 ignore (cancelb#connect#clicked window#destroy) ;
1947 (okb#connect#clicked
1949 chosen := Some (input#buffer#get_text ()) ; window#destroy ())) ;
1951 (loadb#connect#clicked
1954 GToolbox.select_file ~title:"Select Query File" ()
1958 let inch = open_in filename in
1959 let rec read_file () =
1961 let line = input_line inch in
1962 line ^ "\n" ^ read_file ()
1966 let text = read_file () in
1967 input#buffer#delete input#buffer#start_iter input#buffer#end_iter ;
1968 ignore (input#buffer#insert text))) ;
1969 window#set_position `CENTER ;
1976 MQI.execute mqi_handle (MQueryUtil.query_of_text (Lexing.from_string q))
1978 show_query_results results
1981 output_html outputhtml
1982 (`Error (`T (Printexc.to_string e)))
1985 let choose_must list_of_must only =
1986 let chosen = ref None in
1987 let user_constraints = ref [] in
1990 ~modal:true ~title:"Query refinement." ~border_width:2 () in
1991 let vbox = GPack.vbox ~packing:window#add () in
1993 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1997 ("You can now specify the genericity of the query. " ^
1998 "The more generic the slower.")
1999 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2001 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2005 "Suggestion: start with faster queries before moving to more generic ones."
2006 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2008 GPack.notebook ~scrollable:true
2009 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2012 let last = List.length list_of_must in
2018 (if !page = 1 then "More generic" else
2019 if !page = last then "More precise" else " ") () in
2020 let expected_height = 25 * (List.length must + 2) in
2021 let height = if expected_height > 400 then 400 else expected_height in
2022 let scrolled_window =
2023 GBin.scrolled_window ~border_width:10 ~height ~width:600
2024 ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2026 GList.clist ~columns:2 ~packing:scrolled_window#add
2027 ~titles:["URI" ; "Position"] ()
2031 (function (position, uri) ->
2034 [uri; MQGUtil.text_of_position position]
2036 clist#set_row ~selectable:false n
2039 clist#columns_autosize ()
2042 let label = GMisc.label ~text:"User provided" () in
2044 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2046 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2049 ~text:"Select the constraints that must be satisfied and press OK."
2050 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2051 let expected_height = 25 * (List.length only + 2) in
2052 let height = if expected_height > 400 then 400 else expected_height in
2053 let scrolled_window =
2054 GBin.scrolled_window ~border_width:10 ~height ~width:600
2055 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2057 GList.clist ~columns:2 ~packing:scrolled_window#add
2058 ~selection_mode:`MULTIPLE
2059 ~titles:["URI" ; "Position"] ()
2063 (function (position, uri) ->
2066 [uri; MQGUtil.text_of_position position]
2068 clist#set_row ~selectable:true n
2071 clist#columns_autosize () ;
2073 (clist#connect#select_row
2074 (fun ~row ~column ~event ->
2075 user_constraints := (List.nth only row)::!user_constraints)) ;
2077 (clist#connect#unselect_row
2078 (fun ~row ~column ~event ->
2081 (function uri -> uri != (List.nth only row)) !user_constraints)) ;
2084 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2086 GButton.button ~label:"Ok"
2087 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2089 GButton.button ~label:"Abort"
2090 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2092 ignore (window#connect#destroy GMain.Main.quit) ;
2093 ignore (cancelb#connect#clicked window#destroy) ;
2095 (okb#connect#clicked
2096 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
2097 window#set_position `CENTER ;
2101 None -> raise NoChoice
2103 if n = List.length list_of_must then
2104 (* user provided constraints *)
2107 List.nth list_of_must n
2110 let searchPattern () =
2111 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
2112 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
2115 match ProofEngine.get_proof () with
2116 None -> assert false
2117 | Some proof -> proof
2119 match !ProofEngine.goal with
2123 TacticChaser.matchConclusion
2125 ~output_html:(fun m -> output_html outputhtml (`Msg (`T m)))
2126 ~choose_must () ~status:(proof, metano)
2129 user_uri_choice ~title:"Ambiguous input."
2130 ~msg: "Many lemmas can be successfully applied. Please, choose one:"
2133 inputt#set_term uri' ;
2134 InvokeTactics'.apply ()
2137 output_html outputhtml
2138 (`Error (`T (Printexc.to_string e)))
2141 let choose_selection mmlwidget (element : Gdome.element option) =
2142 let module G = Gdome in
2143 let rec aux element =
2144 if element#hasAttributeNS
2145 ~namespaceURI:Misc.helmns
2146 ~localName:(G.domString "xref")
2148 mmlwidget#set_selection (Some element)
2151 match element#get_parentNode with
2152 None -> assert false
2153 (*CSC: OCAML DIVERGES!
2154 | Some p -> aux (new G.element_of_node p)
2156 | Some p -> aux (new Gdome.element_of_node p)
2158 GdomeInit.DOMCastException _ ->
2160 "******* trying to select above the document root ********"
2164 | None -> mmlwidget#set_selection None
2167 (* STUFF TO BUILD THE GTK INTERFACE *)
2169 (* Stuff for the widget settings *)
2172 let export_to_postscript output =
2173 let lastdir = ref (Unix.getcwd ()) in
2176 GToolbox.select_file ~title:"Export to PostScript"
2177 ~dir:lastdir ~filename:"screenshot.ps" ()
2181 (output :> GMathView.math_view)#export_to_postscript
2182 ~filename:filename ();
2187 let activate_t1 output button_set_anti_aliasing
2188 button_set_transparency export_to_postscript_menu_item
2191 let is_set = button_t1#active in
2192 output#set_font_manager_type
2193 ~fm_type:(if is_set then `font_manager_t1 else `font_manager_gtk) ;
2196 button_set_anti_aliasing#misc#set_sensitive true ;
2197 button_set_transparency#misc#set_sensitive true ;
2198 export_to_postscript_menu_item#misc#set_sensitive true ;
2202 button_set_anti_aliasing#misc#set_sensitive false ;
2203 button_set_transparency#misc#set_sensitive false ;
2204 export_to_postscript_menu_item#misc#set_sensitive false ;
2208 let set_anti_aliasing output button_set_anti_aliasing () =
2209 output#set_anti_aliasing button_set_anti_aliasing#active
2212 let set_transparency output button_set_transparency () =
2213 output#set_transparency button_set_transparency#active
2217 let changefont output font_size_spinb () =
2218 output#set_font_size font_size_spinb#value_as_int
2221 let set_log_verbosity output log_verbosity_spinb () =
2222 output#set_log_verbosity log_verbosity_spinb#value_as_int
2225 class settings_window output sw
2226 export_to_postscript_menu_item selection_changed_callback
2228 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
2230 GPack.vbox ~packing:settings_window#add () in
2233 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2234 ~border_width:5 ~packing:vbox#add () in
2236 GButton.toggle_button ~label:"activate t1 fonts"
2237 ~packing:(table#attach ~left:0 ~top:0) () in
2238 let button_set_anti_aliasing =
2239 GButton.toggle_button ~label:"set_anti_aliasing"
2240 ~packing:(table#attach ~left:0 ~top:1) () in
2241 let button_set_transparency =
2242 GButton.toggle_button ~label:"set_transparency"
2243 ~packing:(table#attach ~left:2 ~top:1) () in
2246 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2247 ~border_width:5 ~packing:vbox#add () in
2248 let font_size_label =
2249 GMisc.label ~text:"font size:"
2250 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
2251 let font_size_spinb =
2253 GData.adjustment ~value:(float_of_int output#get_font_size)
2254 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
2257 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
2258 let log_verbosity_label =
2259 GMisc.label ~text:"log verbosity:"
2260 ~packing:(table#attach ~left:0 ~top:1) () in
2261 let log_verbosity_spinb =
2263 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
2266 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
2268 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2270 GButton.button ~label:"Close"
2271 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2273 method show = settings_window#show
2275 button_set_anti_aliasing#misc#set_sensitive false ;
2276 button_set_transparency#misc#set_sensitive false ;
2277 (* Signals connection *)
2279 ignore(button_t1#connect#clicked
2280 (activate_t1 output button_set_anti_aliasing
2281 button_set_transparency export_to_postscript_menu_item button_t1)) ;
2283 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
2285 ignore(button_set_anti_aliasing#connect#toggled
2286 (set_anti_aliasing output button_set_anti_aliasing));
2287 ignore(button_set_transparency#connect#toggled
2288 (set_transparency output button_set_transparency)) ;
2290 ignore(log_verbosity_spinb#connect#changed
2291 (set_log_verbosity output log_verbosity_spinb)) ;
2292 ignore(closeb#connect#clicked settings_window#misc#hide)
2295 (* Scratch window *)
2297 class scratch_window =
2300 ~title:"MathML viewer"
2301 ~border_width:2 () in
2303 GPack.vbox ~packing:window#add () in
2305 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2307 GButton.button ~label:"Whd"
2308 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2310 GButton.button ~label:"Reduce"
2311 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2313 GButton.button ~label:"Simpl"
2314 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2315 let scrolled_window =
2316 GBin.scrolled_window ~border_width:10
2317 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2318 let sequent_viewer =
2319 TermViewer.sequent_viewer
2320 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
2322 val mutable term = Cic.Rel 1 (* dummy value *)
2323 val mutable context = ([] : Cic.context) (* dummy value *)
2324 val mutable metasenv = ([] : Cic.metasenv) (* dummy value *)
2325 method sequent_viewer = sequent_viewer
2326 method show () = window#misc#hide () ; window#show ()
2328 method set_term t = term <- t
2329 method context = context
2330 method set_context t = context <- t
2331 method metasenv = metasenv
2332 method set_metasenv t = metasenv <- t
2335 (sequent_viewer#connect#selection_changed (choose_selection sequent_viewer));
2336 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
2337 ignore(whdb#connect#clicked InvokeTactics'.whd_in_scratch) ;
2338 ignore(reduceb#connect#clicked InvokeTactics'.reduce_in_scratch) ;
2339 ignore(simplb#connect#clicked InvokeTactics'.simpl_in_scratch)
2342 let open_contextual_menu_for_selected_terms mmlwidget infos =
2343 let button = GdkEvent.Button.button infos in
2344 let terms_selected = List.length mmlwidget#get_selections > 0 in
2347 let time = GdkEvent.Button.time infos in
2348 let menu = GMenu.menu () in
2349 let f = new GMenu.factory menu in
2351 f#add_item "Whd" ~key:GdkKeysyms._W ~callback:InvokeTactics'.whd in
2352 let reduce_menu_item =
2353 f#add_item "Reduce" ~key:GdkKeysyms._R ~callback:InvokeTactics'.reduce in
2354 let simpl_menu_item =
2355 f#add_item "Simpl" ~key:GdkKeysyms._S ~callback:InvokeTactics'.simpl in
2356 let _ = f#add_separator () in
2357 let generalize_menu_item =
2358 f#add_item "Generalize"
2359 ~key:GdkKeysyms._G ~callback:InvokeTactics'.generalize in
2360 let _ = f#add_separator () in
2361 let clear_menu_item =
2362 f#add_item "Clear" ~key:GdkKeysyms._C ~callback:InvokeTactics'.clear in
2363 let clearbody_menu_item =
2364 f#add_item "ClearBody"
2365 ~key:GdkKeysyms._B ~callback:InvokeTactics'.clearbody
2367 whd_menu_item#misc#set_sensitive terms_selected ;
2368 reduce_menu_item#misc#set_sensitive terms_selected ;
2369 simpl_menu_item#misc#set_sensitive terms_selected ;
2370 generalize_menu_item#misc#set_sensitive terms_selected ;
2371 clear_menu_item#misc#set_sensitive terms_selected ;
2372 clearbody_menu_item#misc#set_sensitive terms_selected ;
2373 menu#popup ~button ~time
2379 let vbox1 = GPack.vbox () in
2381 val mutable proofw_ref = None
2382 val mutable compute_ref = None
2384 Lazy.force self#compute ;
2385 match proofw_ref with
2386 None -> assert false
2387 | Some proofw -> proofw
2388 method content = vbox1
2390 match compute_ref with
2391 None -> assert false
2392 | Some compute -> compute
2396 let scrolled_window1 =
2397 GBin.scrolled_window ~border_width:10
2398 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2400 TermViewer.sequent_viewer ~width:400 ~height:275
2401 ~packing:(scrolled_window1#add) () in
2402 let _ = proofw_ref <- Some proofw in
2404 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2406 GButton.button ~label:"Ring"
2407 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2409 GButton.button ~label:"Fourier"
2410 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2412 GButton.button ~label:"Reflexivity"
2413 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2415 GButton.button ~label:"Symmetry"
2416 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2418 GButton.button ~label:"Assumption"
2419 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2420 let contradictionb =
2421 GButton.button ~label:"Contradiction"
2422 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2424 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2426 GButton.button ~label:"Exists"
2427 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2429 GButton.button ~label:"Split"
2430 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2432 GButton.button ~label:"Left"
2433 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2435 GButton.button ~label:"Right"
2436 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2437 let searchpatternb =
2438 GButton.button ~label:"SearchPattern_Apply"
2439 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2441 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2443 GButton.button ~label:"Exact"
2444 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2446 GButton.button ~label:"Intros"
2447 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2449 GButton.button ~label:"Apply"
2450 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2451 let elimintrossimplb =
2452 GButton.button ~label:"ElimIntrosSimpl"
2453 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2455 GButton.button ~label:"ElimType"
2456 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2458 GButton.button ~label:"Fold_whd"
2459 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2461 GButton.button ~label:"Fold_reduce"
2462 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2464 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2466 GButton.button ~label:"Fold_simpl"
2467 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2469 GButton.button ~label:"Cut"
2470 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2472 GButton.button ~label:"Change"
2473 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2475 GButton.button ~label:"Let ... In"
2476 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2478 GButton.button ~label:"RewriteSimpl ->"
2479 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2480 let rewritebacksimplb =
2481 GButton.button ~label:"RewriteSimpl <-"
2482 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2484 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2486 GButton.button ~label:"Absurd"
2487 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2489 GButton.button ~label:"Decompose"
2490 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2492 GButton.button ~label:"Transitivity"
2493 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2495 GButton.button ~label:"Replace"
2496 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2498 GButton.button ~label:"Injection"
2499 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2501 GButton.button ~label:"Discriminate"
2502 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2503 (* Zack: spostare in una toolbar
2505 GButton.button ~label:"Generalize"
2506 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2508 GButton.button ~label:"ClearBody"
2509 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2511 GButton.button ~label:"Clear"
2512 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2514 GButton.button ~label:"Whd"
2515 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2517 GButton.button ~label:"Reduce"
2518 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2520 GButton.button ~label:"Simpl"
2521 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2524 ignore(exactb#connect#clicked InvokeTactics'.exact) ;
2525 ignore(applyb#connect#clicked InvokeTactics'.apply) ;
2526 ignore(elimintrossimplb#connect#clicked InvokeTactics'.elimintrossimpl) ;
2527 ignore(elimtypeb#connect#clicked InvokeTactics'.elimtype) ;
2528 ignore(foldwhdb#connect#clicked InvokeTactics'.fold_whd) ;
2529 ignore(foldreduceb#connect#clicked InvokeTactics'.fold_reduce) ;
2530 ignore(foldsimplb#connect#clicked InvokeTactics'.fold_simpl) ;
2531 ignore(cutb#connect#clicked InvokeTactics'.cut) ;
2532 ignore(changeb#connect#clicked InvokeTactics'.change) ;
2533 ignore(letinb#connect#clicked InvokeTactics'.letin) ;
2534 ignore(ringb#connect#clicked InvokeTactics'.ring) ;
2535 ignore(fourierb#connect#clicked InvokeTactics'.fourier) ;
2536 ignore(rewritesimplb#connect#clicked InvokeTactics'.rewritesimpl) ;
2537 ignore(rewritebacksimplb#connect#clicked InvokeTactics'.rewritebacksimpl) ;
2538 ignore(replaceb#connect#clicked InvokeTactics'.replace) ;
2539 ignore(reflexivityb#connect#clicked InvokeTactics'.reflexivity) ;
2540 ignore(symmetryb#connect#clicked InvokeTactics'.symmetry) ;
2541 ignore(transitivityb#connect#clicked InvokeTactics'.transitivity) ;
2542 ignore(existsb#connect#clicked InvokeTactics'.exists) ;
2543 ignore(splitb#connect#clicked InvokeTactics'.split) ;
2544 ignore(leftb#connect#clicked InvokeTactics'.left) ;
2545 ignore(rightb#connect#clicked InvokeTactics'.right) ;
2546 ignore(assumptionb#connect#clicked InvokeTactics'.assumption) ;
2547 ignore(absurdb#connect#clicked InvokeTactics'.absurd) ;
2548 ignore(contradictionb#connect#clicked InvokeTactics'.contradiction) ;
2549 ignore(introsb#connect#clicked InvokeTactics'.intros) ;
2550 ignore(decomposeb#connect#clicked InvokeTactics'.decompose) ;
2551 ignore(searchpatternb#connect#clicked searchPattern) ;
2552 ignore(injectionb#connect#clicked InvokeTactics'.injection) ;
2553 ignore(discriminateb#connect#clicked InvokeTactics'.discriminate) ;
2554 (* Zack: spostare in una toolbar
2555 ignore(whdb#connect#clicked whd) ;
2556 ignore(reduceb#connect#clicked reduce) ;
2557 ignore(simplb#connect#clicked simpl) ;
2558 ignore(clearbodyb#connect#clicked clearbody) ;
2559 ignore(clearb#connect#clicked clear) ;
2560 ignore(generalizeb#connect#clicked generalize) ;
2562 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
2564 ((new GObj.event_ops proofw#as_widget)#connect#button_press
2565 (open_contextual_menu_for_selected_terms proofw)) ;
2571 let vbox1 = GPack.vbox () in
2572 let scrolled_window1 =
2573 GBin.scrolled_window ~border_width:10
2574 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2576 TermViewer.sequent_viewer ~width:400 ~height:275
2577 ~packing:(scrolled_window1#add) () in
2579 method proofw = (assert false : TermViewer.sequent_viewer)
2580 method content = vbox1
2581 method compute = (assert false : unit)
2585 let empty_page = new empty_page;;
2589 val notebook = GPack.notebook ()
2591 val mutable skip_switch_page_event = false
2592 val mutable empty = true
2593 method notebook = notebook
2595 let new_page = new page () in
2597 pages := !pages @ [n,lazy (setgoal n),new_page] ;
2598 notebook#append_page
2599 ~tab_label:((GMisc.label ~text:("?" ^ string_of_int n) ())#coerce)
2600 new_page#content#coerce
2601 method remove_all_pages ~skip_switch_page_event:skip =
2603 notebook#remove_page 0 (* let's remove the empty page *)
2605 List.iter (function _ -> notebook#remove_page 0) !pages ;
2607 skip_switch_page_event <- skip
2608 method set_current_page ~may_skip_switch_page_event n =
2609 let (_,_,page) = List.find (function (m,_,_) -> m=n) !pages in
2610 let new_page = notebook#page_num page#content#coerce in
2611 if may_skip_switch_page_event && new_page <> notebook#current_page then
2612 skip_switch_page_event <- true ;
2613 notebook#goto_page new_page
2614 method set_empty_page =
2617 notebook#append_page
2618 ~tab_label:((GMisc.label ~text:"No proof in progress" ())#coerce)
2619 empty_page#content#coerce
2621 let (_,_,page) = List.nth !pages notebook#current_page in
2625 (notebook#connect#switch_page
2627 let skip = skip_switch_page_event in
2628 skip_switch_page_event <- false ;
2631 let (metano,setgoal,page) = List.nth !pages i in
2632 set_proof_engine_goal (Some metano) ;
2633 Lazy.force (page#compute) ;
2635 if notify_hbugs_on_goal_change then
2642 let dump_environment () =
2644 let oc = open_out environmentfile in
2645 output_html (outputhtml ()) (`Msg (`T "Dumping environment ..."));
2646 CicEnvironment.dump_to_channel
2647 ~callback:(fun uri -> output_html (outputhtml ()) (`Msg (`T uri)))
2649 output_html (outputhtml ()) (`Msg (`T "... done!")) ;
2652 output_html (outputhtml ())
2653 (`Error (`T (Printf.sprintf "Dump failure, uncaught exception:%s"
2654 (Printexc.to_string exc))))
2656 let restore_environment () =
2658 let ic = open_in environmentfile in
2659 output_html (outputhtml ()) (`Msg (`T "Restoring environment ... "));
2660 CicEnvironment.restore_from_channel
2661 ~callback:(fun uri -> output_html (outputhtml ()) (`Msg (`T uri)))
2663 output_html (outputhtml ()) (`Msg (`T "... done!"));
2666 output_html (outputhtml ())
2667 (`Error (`T (Printf.sprintf "Restore failure, uncaught exception:%s"
2668 (Printexc.to_string exc))))
2673 class rendering_window output (notebook : notebook) =
2674 let scratch_window = new scratch_window in
2677 ~title:"gTopLevel - Helm's Proof Assistant"
2678 ~border_width:0 ~allow_shrink:false () in
2679 let vbox_for_menu = GPack.vbox ~packing:window#add () in
2681 let handle_box = GBin.handle_box ~border_width:2
2682 ~packing:(vbox_for_menu#pack ~padding:0) () in
2683 let menubar = GMenu.menu_bar ~packing:handle_box#add () in
2684 let factory0 = new GMenu.factory menubar in
2685 let accel_group = factory0#accel_group in
2687 let file_menu = factory0#add_submenu "File" in
2688 let factory1 = new GMenu.factory file_menu ~accel_group in
2689 (* let export_to_postscript_menu_item = *)
2693 factory1#add_item "New Block of (Co)Inductive Definitions..."
2694 ~key:GdkKeysyms._B ~callback:new_inductive
2697 factory1#add_item "New Proof or Definition..." ~key:GdkKeysyms._N
2700 let reopen_menu_item =
2701 factory1#add_item "Reopen a Finished Proof..." ~key:GdkKeysyms._R
2705 factory1#add_item "Qed" ~key:GdkKeysyms._E ~callback:qed in
2706 ignore (factory1#add_separator ()) ;
2708 (factory1#add_item "Load Unfinished Proof..." ~key:GdkKeysyms._L
2709 ~callback:load_unfinished_proof) ;
2710 let save_menu_item =
2711 factory1#add_item "Save Unfinished Proof" ~key:GdkKeysyms._S
2712 ~callback:save_unfinished_proof
2714 ignore (factory1#add_separator ()) ;
2715 ignore (factory1#add_item "Clear Environment" ~callback:CicEnvironment.empty);
2716 ignore (factory1#add_item "Dump Environment" ~callback:dump_environment);
2718 (factory1#add_item "Restore Environment" ~callback:restore_environment);
2720 (save_set_sensitive := function b -> save_menu_item#misc#set_sensitive b);
2721 ignore (!save_set_sensitive false);
2722 ignore (qed_set_sensitive:=function b -> qed_menu_item#misc#set_sensitive b);
2723 ignore (!qed_set_sensitive false);
2724 ignore (factory1#add_separator ()) ;
2726 let export_to_postscript_menu_item =
2727 factory1#add_item "Export to PostScript..."
2728 ~callback:(export_to_postscript output) in
2730 ignore (factory1#add_separator ()) ;
2732 (factory1#add_item "Exit" ~key:GdkKeysyms._Q ~callback:GMain.Main.quit) (*;
2733 export_to_postscript_menu_item *)
2736 let edit_menu = factory0#add_submenu "Edit Current Proof" in
2737 let factory2 = new GMenu.factory edit_menu ~accel_group in
2738 let focus_and_proveit_set_sensitive = ref (function _ -> assert false) in
2739 let proveit_menu_item =
2740 factory2#add_item "Prove It" ~key:GdkKeysyms._I
2741 ~callback:(function () -> proveit ();!focus_and_proveit_set_sensitive false)
2743 let focus_menu_item =
2744 factory2#add_item "Focus" ~key:GdkKeysyms._F
2745 ~callback:(function () -> focus () ; !focus_and_proveit_set_sensitive false)
2748 focus_and_proveit_set_sensitive :=
2750 proveit_menu_item#misc#set_sensitive b ;
2751 focus_menu_item#misc#set_sensitive b
2753 let _ = !focus_and_proveit_set_sensitive false in
2754 (* edit term menu *)
2755 let edit_term_menu = factory0#add_submenu "Edit Term" in
2756 let factory5 = new GMenu.factory edit_term_menu ~accel_group in
2757 let check_menu_item =
2758 factory5#add_item "Check Term" ~key:GdkKeysyms._C
2759 ~callback:(check scratch_window) in
2760 let _ = check_menu_item#misc#set_sensitive false in
2762 let search_menu = factory0#add_submenu "Search" in
2763 let factory4 = new GMenu.factory search_menu ~accel_group in
2765 factory4#add_item "Locate..." ~key:GdkKeysyms._T
2767 let searchPattern_menu_item =
2768 factory4#add_item "SearchPattern..." ~key:GdkKeysyms._D
2769 ~callback:completeSearchPattern in
2770 let _ = searchPattern_menu_item#misc#set_sensitive false in
2771 let show_menu_item =
2772 factory4#add_item "Show..." ~key:GdkKeysyms._H ~callback:show
2774 let insert_query_item =
2775 factory4#add_item "Insert Query (Experts Only)..." ~key:GdkKeysyms._Y
2776 ~callback:insertQuery in
2778 let hbugs_menu = factory0#add_submenu "HBugs" in
2779 let factory6 = new GMenu.factory hbugs_menu ~accel_group in
2781 factory6#add_check_item
2782 ~active:false ~key:GdkKeysyms._F5 ~callback:Hbugs.toggle "HBugs enabled"
2785 factory6#add_item ~key:GdkKeysyms._Return ~callback:Hbugs.notify
2786 "(Re)Submit status!"
2788 let _ = factory6#add_separator () in
2790 factory6#add_item ~callback:Hbugs.start_web_services "Start Web Services"
2793 factory6#add_item ~callback:Hbugs.stop_web_services "Stop Web Services"
2796 let settings_menu = factory0#add_submenu "Settings" in
2797 let factory3 = new GMenu.factory settings_menu ~accel_group in
2799 factory3#add_item "Edit Aliases..." ~key:GdkKeysyms._A
2800 ~callback:edit_aliases in
2802 factory3#add_item "Clear Aliases" ~key:GdkKeysyms._K
2803 ~callback:clear_aliases in
2805 factory3#add_check_item "Auto disambiguation"
2806 ~callback:(fun checked -> auto_disambiguation := checked) in
2807 let _ = factory3#add_separator () in
2809 factory3#add_item "MathML Widget Preferences..." ~key:GdkKeysyms._P
2810 ~callback:(function _ -> (settings_window ())#show ()) in
2811 let _ = factory3#add_separator () in
2813 factory3#add_item "Reload Stylesheets"
2816 ChosenTransformer.reload_stylesheets () ;
2817 if ProofEngine.get_proof () <> None then
2819 refresh_goals notebook ;
2820 refresh_proof output
2822 InvokeTactics.RefreshSequentException e ->
2823 output_html (outputhtml ())
2824 (`Error (`T ("An error occurred while refreshing the " ^
2825 "sequent: " ^ Printexc.to_string e))) ;
2826 (*notebook#remove_all_pages ~skip_switch_page_event:false ;*)
2827 notebook#set_empty_page
2828 | InvokeTactics.RefreshProofException e ->
2829 output_html (outputhtml ())
2830 (`Error (`T ("An error occurred while refreshing the proof: " ^ Printexc.to_string e))) ;
2834 let _ = window#add_accel_group accel_group in
2838 ~packing:(vbox_for_menu#pack ~expand:true ~fill:true ~padding:5) () in
2840 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2841 let scrolled_window0 =
2842 GBin.scrolled_window ~border_width:10
2843 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2844 let _ = scrolled_window0#add output#coerce in
2846 GBin.frame ~label:"Insert Term"
2847 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2848 let scrolled_window1 =
2849 GBin.scrolled_window ~border_width:5
2850 ~packing:frame#add () in
2852 TermEditor'.term_editor
2854 ~width:400 ~height:100 ~packing:scrolled_window1#add ()
2855 ~isnotempty_callback:
2857 check_menu_item#misc#set_sensitive b ;
2858 searchPattern_menu_item#misc#set_sensitive b) in
2860 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2862 vboxl#pack ~expand:true ~fill:true ~padding:5 notebook#notebook#coerce in
2864 GBin.frame ~shadow_type:`IN ~packing:(vboxl#pack ~expand:true ~padding:5) ()
2867 new Ui_logger.html_logger
2868 ~width:400 ~height: 100 ~show:true ~packing:frame#add ()
2871 method outputhtml = outputhtml
2872 method inputt = inputt
2873 method output = (output : TermViewer.proof_viewer)
2874 method scratch_window = scratch_window
2875 method notebook = notebook
2876 method show = window#show
2877 method set_auto_disambiguation set = autoitem#set_active set
2879 notebook#set_empty_page ;
2880 (*export_to_postscript_menu_item#misc#set_sensitive false ;*)
2881 check_term := (check_term_in_scratch scratch_window) ;
2883 (* signal handlers here *)
2884 ignore(output#connect#selection_changed
2886 choose_selection output elem ;
2887 !focus_and_proveit_set_sensitive true
2889 ignore (output#connect#click (show_in_show_window_callback output)) ;
2890 let settings_window = new settings_window output scrolled_window0
2891 (*export_to_postscript_menu_item*)() (choose_selection output) in
2892 set_settings_window settings_window ;
2893 set_outputhtml outputhtml ;
2894 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
2895 CicLogger.log_callback := (outputhtml#log_cic_msg ~append_NL:true)
2900 let initialize_everything () =
2901 let module U = Unix in
2902 let output = TermViewer.proof_viewer ~width:350 ~height:280 () in
2903 let notebook = new notebook in
2904 let rendering_window' = new rendering_window output notebook in
2905 rendering_window'#set_auto_disambiguation !auto_disambiguation;
2906 set_rendering_window rendering_window' ;
2907 let print_error_as_html prefix msg =
2908 output_html (outputhtml ()) (`Error (`T (prefix ^ msg)))
2910 Gdome_xslt.setErrorCallback (Some (print_error_as_html "XSLT Error: "));
2911 Gdome_xslt.setDebugCallback
2912 (Some (print_error_as_html "XSLT Debug Message: "));
2913 rendering_window'#show () ;
2914 if restore_environment_on_boot && Sys.file_exists environmentfile then
2915 restore_environment ();
2920 ignore (GtkMain.Main.init ()) ;
2921 initialize_everything () ;
2922 MQIC.close mqi_handle;
2927 Sys.catch_break true;
2929 with Sys.Break -> () (* exit nicely, invoking at_exit functions *)