1 (* Copyright (C) 2000-2003, 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"
82 Sys.getenv "GTOPLEVEL_ENVIRONMENTFILE"
84 Not_found -> "/public/environment"
87 let restore_environment_on_boot = true ;;
88 let notify_hbugs_on_goal_change = false ;;
90 (* GLOBAL REFERENCES (USED BY CALLBACKS) *)
92 let htmlheader_and_content = ref htmlheader;;
94 let check_term = ref (fun _ _ _ -> assert false);;
96 exception RenderingWindowsNotInitialized;;
98 let set_rendering_window,rendering_window =
99 let rendering_window_ref = ref None in
100 (function rw -> rendering_window_ref := Some rw),
102 match !rendering_window_ref with
103 None -> raise RenderingWindowsNotInitialized
108 exception SettingsWindowsNotInitialized;;
110 let set_settings_window,settings_window =
111 let settings_window_ref = ref None in
112 (function rw -> settings_window_ref := Some rw),
114 match !settings_window_ref with
115 None -> raise SettingsWindowsNotInitialized
120 exception OutputHtmlNotInitialized;;
122 let set_outputhtml,outputhtml =
123 let outputhtml_ref = ref None in
124 (function rw -> outputhtml_ref := Some rw),
126 match !outputhtml_ref with
127 None -> raise OutputHtmlNotInitialized
128 | Some outputhtml -> outputhtml
132 exception QedSetSensitiveNotInitialized;;
133 let qed_set_sensitive =
134 ref (function _ -> raise QedSetSensitiveNotInitialized)
137 exception SaveSetSensitiveNotInitialized;;
138 let save_set_sensitive =
139 ref (function _ -> raise SaveSetSensitiveNotInitialized)
142 (* COMMAND LINE OPTIONS *)
148 "-nodb", Arg.Clear usedb, "disable use of MathQL DB"
151 Arg.parse argspec ignore ""
155 let term_of_cic_textual_parser_uri uri =
156 let module C = Cic in
157 let module CTP = CicTextualParser0 in
159 CTP.ConUri uri -> C.Const (uri,[])
160 | CTP.VarUri uri -> C.Var (uri,[])
161 | CTP.IndTyUri (uri,tyno) -> C.MutInd (uri,tyno,[])
162 | CTP.IndConUri (uri,tyno,consno) -> C.MutConstruct (uri,tyno,consno,[])
165 let string_of_cic_textual_parser_uri uri =
166 let module C = Cic in
167 let module CTP = CicTextualParser0 in
170 CTP.ConUri uri -> UriManager.string_of_uri uri
171 | CTP.VarUri uri -> UriManager.string_of_uri uri
172 | CTP.IndTyUri (uri,tyno) ->
173 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1)
174 | CTP.IndConUri (uri,tyno,consno) ->
175 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1) ^ "/" ^
178 (* 4 = String.length "cic:" *)
179 String.sub uri' 4 (String.length uri' - 4)
182 let output_html outputhtml msg =
183 htmlheader_and_content := !htmlheader_and_content ^ msg ;
184 outputhtml#source (!htmlheader_and_content ^ htmlfooter) ;
185 outputhtml#set_topline (-1)
188 (* UTILITY FUNCTIONS TO DISAMBIGUATE AN URI *)
192 let check_window outputhtml uris =
195 ~width:800 ~modal:true ~title:"Check" ~border_width:2 () in
197 GPack.notebook ~scrollable:true ~packing:window#add () in
202 let scrolled_window =
203 GBin.scrolled_window ~border_width:10
205 (notebook#append_page ~tab_label:((GMisc.label ~text:uri ())#coerce))
210 TermViewer.sequent_viewer
211 ~packing:scrolled_window#add ~width:400 ~height:280 () in
214 term_of_cic_textual_parser_uri
215 (MQueryMisc.cic_textual_parser_uri_of_string uri)
217 (Cic.Cast (term, CicTypeChecker.type_of_aux' [] [] term))
220 mmlwidget#load_sequent [] (111,[],expr)
223 output_html outputhtml
224 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
229 (notebook#connect#switch_page
231 Lazy.force (List.nth render_terms i)))
237 interactive_user_uri_choice ~(selection_mode:[`MULTIPLE|`SINGLE]) ?(ok="Ok")
238 ?(enable_button_for_non_vars=false) ~title ~msg uris
240 let choices = ref [] in
241 let chosen = ref false in
242 let use_only_constants = ref false in
244 GWindow.dialog ~modal:true ~title ~width:600 () in
246 GMisc.label ~text:msg
247 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
248 let scrolled_window =
249 GBin.scrolled_window ~border_width:10
250 ~packing:(window#vbox#pack ~expand:true ~fill:true ~padding:5) () in
252 let expected_height = 18 * List.length uris in
253 let height = if expected_height > 400 then 400 else expected_height in
254 GList.clist ~columns:1 ~packing:scrolled_window#add
255 ~height ~selection_mode:(selection_mode :> Gtk.Tags.selection_mode) () in
256 let _ = List.map (function x -> clist#append [x]) uris in
258 GPack.hbox ~border_width:0
259 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
261 GMisc.label ~text:"None of the above. Try this one:"
262 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
264 GEdit.entry ~editable:true
265 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
267 GPack.hbox ~border_width:0 ~packing:window#action_area#add () in
269 GButton.button ~label:ok
270 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
271 let _ = okb#misc#set_sensitive false in
276 if enable_button_for_non_vars then
277 hbox#pack ~expand:false ~fill:false ~padding:5 w)
278 ~label:"Try constants only" () in
280 GButton.button ~label:"Check"
281 ~packing:(hbox#pack ~padding:5) () in
282 let _ = checkb#misc#set_sensitive false in
284 GButton.button ~label:"Abort"
285 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
287 let check_callback () =
288 assert (List.length !choices > 0) ;
289 check_window (outputhtml ()) !choices
291 ignore (window#connect#destroy GMain.Main.quit) ;
292 ignore (cancelb#connect#clicked window#destroy) ;
294 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
296 (nonvarsb#connect#clicked
298 use_only_constants := true ;
302 ignore (checkb#connect#clicked check_callback) ;
304 (clist#connect#select_row
305 (fun ~row ~column ~event ->
306 checkb#misc#set_sensitive true ;
307 okb#misc#set_sensitive true ;
308 choices := (List.nth uris row)::!choices)) ;
310 (clist#connect#unselect_row
311 (fun ~row ~column ~event ->
313 List.filter (function uri -> uri != (List.nth uris row)) !choices)) ;
315 (manual_input#connect#changed
317 if manual_input#text = "" then
320 checkb#misc#set_sensitive false ;
321 okb#misc#set_sensitive false ;
322 clist#misc#set_sensitive true
326 choices := [manual_input#text] ;
327 clist#unselect_all () ;
328 checkb#misc#set_sensitive true ;
329 okb#misc#set_sensitive true ;
330 clist#misc#set_sensitive false
332 window#set_position `CENTER ;
336 if !use_only_constants then
338 (function uri -> not (String.sub uri (String.length uri - 4) 4 = ".var"))
341 if List.length !choices > 0 then !choices else raise NoChoice
346 let interactive_interpretation_choice interpretations =
347 let chosen = ref None in
350 ~modal:true ~title:"Ambiguous well-typed input." ~border_width:2 () in
351 let vbox = GPack.vbox ~packing:window#add () in
355 ("Ambiguous input since there are many well-typed interpretations." ^
356 " Please, choose one of them.")
357 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
359 GPack.notebook ~scrollable:true
360 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
363 (function interpretation ->
365 let expected_height = 18 * List.length interpretation in
366 let height = if expected_height > 400 then 400 else expected_height in
367 GList.clist ~columns:2 ~packing:notebook#append_page ~height
368 ~titles:["id" ; "URI"] ()
372 (function (id,uri) ->
373 let n = clist#append [id;uri] in
374 clist#set_row ~selectable:false n
377 clist#columns_autosize ()
380 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
382 GButton.button ~label:"Ok"
383 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
385 GButton.button ~label:"Abort"
386 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
388 ignore (window#connect#destroy GMain.Main.quit) ;
389 ignore (cancelb#connect#clicked window#destroy) ;
392 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
393 window#set_position `CENTER ;
397 None -> raise NoChoice
405 save_object_to_disk uri annobj ids_to_inner_sorts ids_to_inner_types pathname
408 let struri = UriManager.string_of_uri uri in
409 let idx = (String.rindex struri '/') + 1 in
410 String.sub struri idx (String.length struri - idx)
412 let path = pathname ^ "/" ^ name in
414 Cic2Xml.print_object uri ~ids_to_inner_sorts ~ask_dtd_to_the_getter:false
418 Cic2Xml.print_inner_types uri ~ids_to_inner_sorts ~ids_to_inner_types
419 ~ask_dtd_to_the_getter:false
422 let innertypesuri = UriManager.innertypesuri_of_uri uri in
423 Xml.pp ~quiet:true xmlinnertypes (Some (path ^ ".types.xml")) ;
424 Getter.register innertypesuri
425 (Configuration.annotations_url ^
426 Str.replace_first (Str.regexp "^cic:") ""
427 (UriManager.string_of_uri innertypesuri) ^ ".xml"
429 (* constant type / variable / mutual inductive types definition *)
430 Xml.pp ~quiet:true xml (Some (path ^ ".xml")) ;
432 (Configuration.annotations_url ^
433 Str.replace_first (Str.regexp "^cic:") ""
434 (UriManager.string_of_uri uri) ^ ".xml"
441 match UriManager.bodyuri_of_uri uri with
443 | Some bodyuri -> bodyuri
445 Xml.pp ~quiet:true bodyxml' (Some (path ^ ".body.xml")) ;
446 Getter.register bodyuri
447 (Configuration.annotations_url ^
448 Str.replace_first (Str.regexp "^cic:") ""
449 (UriManager.string_of_uri bodyuri) ^ ".xml"
456 exception OpenConjecturesStillThere;;
457 exception WrongProof;;
459 let pathname_of_annuri uristring =
460 Configuration.annotations_dir ^
461 Str.replace_first (Str.regexp "^cic:") "" uristring
464 let make_dirs dirpath =
465 ignore (Unix.system ("mkdir -p " ^ dirpath))
468 let save_obj uri obj =
470 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
471 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
473 Cic2acic.acic_object_of_cic_object obj
475 (* let's save the theorem and register it to the getter *)
476 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
478 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
483 match ProofEngine.get_proof () with
485 | Some (uri,[],bo,ty) ->
487 CicReduction.are_convertible []
488 (CicTypeChecker.type_of_aux' [] [] bo) ty
491 (*CSC: Wrong: [] is just plainly wrong *)
492 let proof = Cic.Constant (UriManager.name_of_uri uri,Some bo,ty,[]) in
493 let (acic,ids_to_inner_types,ids_to_inner_sorts) =
494 (rendering_window ())#output#load_proof uri proof
496 !qed_set_sensitive false ;
497 (* let's save the theorem and register it to the getter *)
498 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
500 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
505 | _ -> raise OpenConjecturesStillThere
508 (** save an unfinished proof on the filesystem *)
509 let save_unfinished_proof () =
510 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
511 let (xml, bodyxml) = ProofEngine.get_current_status_as_xml () in
512 Xml.pp ~quiet:true xml (Some prooffiletype) ;
513 output_html outputhtml
514 ("<h1 color=\"Green\">Current proof type saved to " ^
515 prooffiletype ^ "</h1>") ;
516 Xml.pp ~quiet:true bodyxml (Some prooffile) ;
517 output_html outputhtml
518 ("<h1 color=\"Green\">Current proof body saved to " ^
522 (* Used to typecheck the loaded proofs *)
523 let typecheck_loaded_proof metasenv bo ty =
524 let module T = CicTypeChecker in
527 (fun metasenv ((_,context,ty) as conj) ->
528 ignore (T.type_of_aux' metasenv context ty) ;
531 ignore (T.type_of_aux' metasenv [] ty) ;
532 ignore (T.type_of_aux' metasenv [] bo)
535 let decompose_uris_choice_callback uris =
536 (* N.B.: in questo passaggio perdo l'informazione su exp_named_subst !!!! *)
537 let module U = UriManager in
540 match MQueryMisc.cic_textual_parser_uri_of_string uri with
541 CicTextualParser0.IndTyUri (uri,typeno) -> (uri,typeno,[])
543 (interactive_user_uri_choice
544 ~selection_mode:`MULTIPLE ~ok:"Ok" ~enable_button_for_non_vars:false
545 ~title:"Decompose" ~msg:"Please, select the Inductive Types to decompose"
547 (function (uri,typeno,_) ->
548 U.string_of_uri uri ^ "#1/" ^ string_of_int (typeno+1)
553 let mk_fresh_name_callback context name ~typ =
555 match ProofEngineHelpers.mk_fresh_name context name ~typ with
556 Cic.Name fresh_name -> fresh_name
557 | Cic.Anonymous -> assert false
560 GToolbox.input_string ~title:"Enter a fresh hypothesis name" ~text:fresh_name
561 ("Enter a fresh name for the hypothesis " ^
563 (List.map (function None -> None | Some (n,_) -> Some n) context))
565 Some fresh_name' -> Cic.Name fresh_name'
566 | None -> raise NoChoice
569 let refresh_proof (output : TermViewer.proof_viewer) =
571 let uri,currentproof =
572 match ProofEngine.get_proof () with
574 | Some (uri,metasenv,bo,ty) ->
575 ProofEngine.set_proof (Some (uri,metasenv,bo,ty)) ;
576 if List.length metasenv = 0 then
578 !qed_set_sensitive true ;
582 (*Hbugs.notify*) () ;
583 (*CSC: Wrong: [] is just plainly wrong *)
585 (Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, []))
587 ignore (output#load_proof uri currentproof)
590 match ProofEngine.get_proof () with
592 | Some (uri,metasenv,bo,ty) ->
593 prerr_endline ("Offending proof: " ^ CicPp.ppobj (Cic.CurrentProof ("questa",metasenv,bo,ty,[]))) ; flush stderr ;
594 raise (InvokeTactics.RefreshProofException e)
596 let set_proof_engine_goal g =
597 ProofEngine.goal := g
600 let refresh_goals ?(empty_notebook=true) notebook =
602 match !ProofEngine.goal with
604 if empty_notebook then
606 notebook#remove_all_pages ~skip_switch_page_event:false ;
607 notebook#set_empty_page
610 notebook#proofw#unload
613 match ProofEngine.get_proof () with
615 | Some (_,metasenv,_,_) -> metasenv
618 List.find (function (m,_,_) -> m=metano) metasenv
620 let regenerate_notebook () =
621 let skip_switch_page_event =
623 (m,_,_)::_ when m = metano -> false
626 notebook#remove_all_pages ~skip_switch_page_event ;
627 List.iter (function (m,_,_) -> notebook#add_page m) metasenv ;
629 if empty_notebook then
631 regenerate_notebook () ;
632 notebook#set_current_page
633 ~may_skip_switch_page_event:false metano
637 notebook#set_current_page
638 ~may_skip_switch_page_event:true metano ;
639 notebook#proofw#load_sequent metasenv currentsequent
644 match !ProofEngine.goal with
649 match ProofEngine.get_proof () with
651 | Some (_,metasenv,_,_) -> metasenv
654 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
655 prerr_endline ("Offending sequent: " ^ SequentPp.TextualPp.print_sequent currentsequent) ; flush stderr ;
656 raise (InvokeTactics.RefreshSequentException e)
657 with Not_found -> prerr_endline ("Offending sequent " ^ string_of_int metano ^ " unknown."); raise (InvokeTactics.RefreshSequentException e)
659 module InvokeTacticsCallbacks =
661 let sequent_viewer () = (rendering_window ())#notebook#proofw
662 let term_editor () = (rendering_window ())#inputt
663 let scratch_window () = (rendering_window ())#scratch_window
665 let refresh_proof () =
666 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
669 let refresh_goals () =
670 let notebook = (rendering_window ())#notebook in
671 refresh_goals notebook
673 let decompose_uris_choice_callback = decompose_uris_choice_callback
674 let mk_fresh_name_callback = mk_fresh_name_callback
675 let output_html msg = output_html (outputhtml ()) msg
678 module InvokeTactics' = InvokeTactics.Make (InvokeTacticsCallbacks);;
680 (* Just to initialize the Hbugs module *)
682 module Ignore = Hbugs.Initialize (InvokeTactics');;
683 Hbugs.set_describe_hint_callback (fun hint ->
685 | Hbugs_types.Use_apply_Luke term ->
686 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
687 check_window outputhtml [term]
692 let dummy_uri = "/dummy.con"
694 (** load an unfinished proof from filesystem *)
695 let load_unfinished_proof () =
696 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
697 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
698 let notebook = (rendering_window ())#notebook in
701 GToolbox.input_string ~title:"Load Unfinished Proof" ~text:dummy_uri
704 None -> raise NoChoice
706 let uri = UriManager.uri_of_string ("cic:" ^ uri0) in
707 match CicParser.obj_of_xml prooffiletype (Some prooffile) with
708 Cic.CurrentProof (_,metasenv,bo,ty,_) ->
709 typecheck_loaded_proof metasenv bo ty ;
710 ProofEngine.set_proof (Some (uri, metasenv, bo, ty)) ;
711 refresh_proof output ;
712 set_proof_engine_goal
715 | (metano,_,_)::_ -> Some metano
717 refresh_goals notebook ;
718 output_html outputhtml
719 ("<h1 color=\"Green\">Current proof type loaded from " ^
720 prooffiletype ^ "</h1>") ;
721 output_html outputhtml
722 ("<h1 color=\"Green\">Current proof body loaded from " ^
723 prooffile ^ "</h1>") ;
724 !save_set_sensitive true;
727 InvokeTactics.RefreshSequentException e ->
728 output_html outputhtml
729 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
730 "sequent: " ^ Printexc.to_string e ^ "</h1>")
731 | InvokeTactics.RefreshProofException e ->
732 output_html outputhtml
733 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
734 "proof: " ^ Printexc.to_string e ^ "</h1>")
736 output_html outputhtml
737 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
740 let edit_aliases () =
741 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
742 let id_to_uris = inputt#id_to_uris in
743 let chosen = ref false in
746 ~width:400 ~modal:true ~title:"Edit Aliases..." ~border_width:2 () in
748 GPack.vbox ~border_width:0 ~packing:window#add () in
749 let scrolled_window =
750 GBin.scrolled_window ~border_width:10
751 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
752 let input = GText.view ~editable:true ~width:400 ~height:100
753 ~packing:scrolled_window#add () in
755 GPack.hbox ~border_width:0
756 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
758 GButton.button ~label:"Ok"
759 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
761 GButton.button ~label:"Cancel"
762 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
763 ignore (window#connect#destroy GMain.Main.quit) ;
764 ignore (cancelb#connect#clicked window#destroy) ;
766 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
767 let dom,resolve_id = !id_to_uris in
769 (input#buffer#insert ~iter:(input#buffer#get_iter_at_char 0)
774 match resolve_id v with
776 | Some (CicTextualParser0.Uri uri) -> uri
777 | Some (CicTextualParser0.Term _)
778 | Some CicTextualParser0.Implicit -> assert false
782 CicTextualParser0.Id id -> id
783 | CicTextualParser0.Symbol (descr,_) ->
784 (* CSC: To be implemented *)
786 )^ " " ^ (string_of_cic_textual_parser_uri uri)
792 let inputtext = input#buffer#get_text () in
794 let alfa = "[a-zA-Z_-]" in
795 let digit = "[0-9]" in
796 let ident = alfa ^ "\(" ^ alfa ^ "\|" ^ digit ^ "\)*" in
797 let blanks = "\( \|\t\|\n\)+" in
798 let nonblanks = "[^ \t\n]+" in
799 let uri = "/\(" ^ ident ^ "/\)*" ^ nonblanks in (* not very strict check *)
801 ("alias" ^ blanks ^ "\(" ^ ident ^ "\)" ^ blanks ^ "\(" ^ uri ^ "\)")
805 let n' = Str.search_forward regexpr inputtext n in
806 let id = CicTextualParser0.Id (Str.matched_group 2 inputtext) in
808 MQueryMisc.cic_textual_parser_uri_of_string
809 ("cic:" ^ (Str.matched_group 5 inputtext))
811 let dom,resolve_id = aux (n' + 1) in
812 if List.mem id dom then
818 Some (CicTextualParser0.Uri uri)
821 Not_found -> TermEditor.empty_id_to_uris
825 id_to_uris := (dom,resolve_id)
829 let module L = LogicalOperations in
830 let module G = Gdome in
831 let notebook = (rendering_window ())#notebook in
832 let output = (rendering_window ())#output in
833 let outputhtml = ((rendering_window ())#outputhtml (*: GHtml.xmhtml*)) in
835 output#make_sequent_of_selected_term ;
836 refresh_proof output ;
837 refresh_goals notebook
839 InvokeTactics.RefreshSequentException e ->
840 output_html outputhtml
841 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
842 "sequent: " ^ Printexc.to_string e ^ "</h1>")
843 | InvokeTactics.RefreshProofException e ->
844 output_html outputhtml
845 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
846 "proof: " ^ Printexc.to_string e ^ "</h1>")
848 output_html outputhtml
849 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
853 let module L = LogicalOperations in
854 let module G = Gdome in
855 let notebook = (rendering_window ())#notebook in
856 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
857 let output = (rendering_window ())#output in
859 output#focus_sequent_of_selected_term ;
860 refresh_goals notebook
862 InvokeTactics.RefreshSequentException e ->
863 output_html outputhtml
864 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
865 "sequent: " ^ Printexc.to_string e ^ "</h1>")
866 | InvokeTactics.RefreshProofException e ->
867 output_html outputhtml
868 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
869 "proof: " ^ Printexc.to_string e ^ "</h1>")
871 output_html outputhtml
872 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
875 exception NoPrevGoal;;
876 exception NoNextGoal;;
879 let module L = LogicalOperations in
880 let module G = Gdome in
881 let notebook = (rendering_window ())#notebook in
882 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
884 match ProofEngine.get_proof () with
886 | Some (_,metasenv,_,_) -> metasenv
889 refresh_goals ~empty_notebook:false notebook
891 InvokeTactics.RefreshSequentException e ->
892 output_html outputhtml
893 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
894 "sequent: " ^ Printexc.to_string e ^ "</h1>")
896 output_html outputhtml
897 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
901 show_in_show_window_obj, show_in_show_window_uri, show_in_show_window_callback
904 GWindow.window ~width:800 ~border_width:2 () in
905 let scrolled_window =
906 GBin.scrolled_window ~border_width:10 ~packing:window#add () in
908 GMathViewAux.single_selection_math_view
909 ~packing:scrolled_window#add ~width:600 ~height:400 ()
911 let _ = window#event#connect#delete (fun _ -> window#misc#hide () ; true ) in
912 let href = Gdome.domString "href" in
913 let show_in_show_window_obj uri obj =
914 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
917 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
918 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
920 Cic2acic.acic_object_of_cic_object obj
923 ApplyStylesheets.mml_of_cic_object
924 ~explode_all:false uri acic ids_to_inner_sorts ids_to_inner_types
926 window#set_title (UriManager.string_of_uri uri) ;
927 window#misc#hide () ; window#show () ;
928 mmlwidget#load_doc mml ;
931 output_html outputhtml
932 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
934 let show_in_show_window_uri uri =
935 let obj = CicEnvironment.get_obj uri in
936 show_in_show_window_obj uri obj
938 let show_in_show_window_callback mmlwidget (n : Gdome.element option) _ =
942 if n'#hasAttributeNS ~namespaceURI:xlinkns ~localName:href then
944 (n'#getAttributeNS ~namespaceURI:xlinkns ~localName:href)#to_string
946 show_in_show_window_uri (UriManager.uri_of_string uri)
948 ignore (mmlwidget#action_toggle n')
951 mmlwidget#connect#click (show_in_show_window_callback mmlwidget)
953 show_in_show_window_obj, show_in_show_window_uri,
954 show_in_show_window_callback
957 exception NoObjectsLocated;;
959 let user_uri_choice ~title ~msg uris =
962 [] -> raise NoObjectsLocated
966 interactive_user_uri_choice ~selection_mode:`SINGLE ~title ~msg uris
971 String.sub uri 4 (String.length uri - 4)
974 let locate_callback id =
975 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
976 let out = output_html outputhtml in
977 let query = MQG.locate id in
978 let result = MQI.execute mqi_handle query in
982 MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format' uri)
984 out "<h1>Locate Query: </h1><pre>";
985 MQueryUtil.text_of_query out query "";
986 out "<h1>Result:</h1>";
987 MQueryUtil.text_of_result out result "<br>";
988 user_uri_choice ~title:"Ambiguous input."
990 ("Ambiguous input \"" ^ id ^
991 "\". Please, choose one interpetation:")
996 let input_or_locate_uri ~title =
997 let uri = ref None in
1000 ~width:400 ~modal:true ~title ~border_width:2 () in
1001 let vbox = GPack.vbox ~packing:window#add () in
1003 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1005 GMisc.label ~text:"Enter a valid URI:" ~packing:(hbox1#pack ~padding:5) () in
1007 GEdit.entry ~editable:true
1008 ~packing:(hbox1#pack ~expand:true ~fill:true ~padding:5) () in
1010 GButton.button ~label:"Check"
1011 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1012 let _ = checkb#misc#set_sensitive false in
1014 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1016 GMisc.label ~text:"You can also enter an indentifier to locate:"
1017 ~packing:(hbox2#pack ~padding:5) () in
1019 GEdit.entry ~editable:true
1020 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1022 GButton.button ~label:"Locate"
1023 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1024 let _ = locateb#misc#set_sensitive false in
1026 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1028 GButton.button ~label:"Ok"
1029 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1030 let _ = okb#misc#set_sensitive false in
1032 GButton.button ~label:"Cancel"
1033 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) ()
1035 ignore (window#connect#destroy GMain.Main.quit) ;
1037 (cancelb#connect#clicked (function () -> uri := None ; window#destroy ())) ;
1038 let check_callback () =
1039 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1040 let uri = "cic:" ^ manual_input#text in
1042 ignore (Getter.resolve (UriManager.uri_of_string uri)) ;
1043 output_html outputhtml "<h1 color=\"Green\">OK</h1>" ;
1046 Getter.Unresolved ->
1047 output_html outputhtml
1048 ("<h1 color=\"Red\">URI " ^ uri ^
1049 " does not correspond to any object.</h1>") ;
1051 | UriManager.IllFormedUri _ ->
1052 output_html outputhtml
1053 ("<h1 color=\"Red\">URI " ^ uri ^ " is not well-formed.</h1>") ;
1056 output_html outputhtml
1057 ("<h1 color=\"Red\">" ^ Printexc.to_string e ^ "</h1>") ;
1061 (okb#connect#clicked
1063 if check_callback () then
1065 uri := Some manual_input#text ;
1069 ignore (checkb#connect#clicked (function () -> ignore (check_callback ()))) ;
1071 (manual_input#connect#changed
1073 if manual_input#text = "" then
1075 checkb#misc#set_sensitive false ;
1076 okb#misc#set_sensitive false
1080 checkb#misc#set_sensitive true ;
1081 okb#misc#set_sensitive true
1084 (locate_input#connect#changed
1085 (fun _ -> locateb#misc#set_sensitive (locate_input#text <> ""))) ;
1087 (locateb#connect#clicked
1089 let id = locate_input#text in
1090 manual_input#set_text (locate_callback id) ;
1091 locate_input#delete_text 0 (String.length id)
1096 None -> raise NoChoice
1097 | Some uri -> UriManager.uri_of_string ("cic:" ^ uri)
1100 exception AmbiguousInput;;
1102 (* A WIDGET TO ENTER CIC TERMS *)
1104 module ChosenTermEditor = TexTermEditor;;
1105 module ChosenTextualParser0 = TexCicTextualParser0;;
1107 module ChosenTermEditor = TermEditor;;
1108 module ChosenTextualParser0 = CicTextualParser0;;
1113 let get_metasenv () = !ChosenTextualParser0.metasenv
1114 let set_metasenv metasenv = ChosenTextualParser0.metasenv := metasenv
1116 let output_html msg = output_html (outputhtml ()) msg;;
1117 let interactive_user_uri_choice =
1118 fun ~selection_mode ?ok ?enable_button_for_non_vars ~title ~msg ~id ->
1119 interactive_user_uri_choice ~selection_mode ?ok
1120 ?enable_button_for_non_vars ~title ~msg;;
1121 let interactive_interpretation_choice = interactive_interpretation_choice;;
1122 let input_or_locate_uri = input_or_locate_uri;;
1126 module TexTermEditor' = ChosenTermEditor.Make(Callbacks);;
1128 (* OTHER FUNCTIONS *)
1131 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1132 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1135 GToolbox.input_string ~title:"Locate" "Enter an identifier to locate:"
1137 None -> raise NoChoice
1139 let uri = locate_callback input in
1143 output_html outputhtml
1144 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
1148 exception UriAlreadyInUse;;
1149 exception NotAUriToAConstant;;
1151 let new_inductive () =
1152 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1153 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1154 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1155 let notebook = (rendering_window ())#notebook in
1157 let chosen = ref false in
1158 let inductive = ref true in
1159 let paramsno = ref 0 in
1160 let get_uri = ref (function _ -> assert false) in
1161 let get_base_uri = ref (function _ -> assert false) in
1162 let get_names = ref (function _ -> assert false) in
1163 let get_types_and_cons = ref (function _ -> assert false) in
1164 let get_context_and_subst = ref (function _ -> assert false) in
1167 ~width:600 ~modal:true ~position:`CENTER
1168 ~title:"New Block of Mutual (Co)Inductive Definitions"
1169 ~border_width:2 () in
1170 let vbox = GPack.vbox ~packing:window#add () in
1172 GPack.hbox ~border_width:0
1173 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1175 GMisc.label ~text:"Enter the URI for the new block:"
1176 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1178 GEdit.entry ~editable:true
1179 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1181 GPack.hbox ~border_width:0
1182 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1186 "Enter the number of left parameters in every arity and constructor type:"
1187 ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1188 let paramsno_entry =
1189 GEdit.entry ~editable:true ~text:"0"
1190 ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
1192 GPack.hbox ~border_width:0
1193 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1195 GMisc.label ~text:"Are the definitions inductive or coinductive?"
1196 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1198 GButton.radio_button ~label:"Inductive"
1199 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1201 GButton.radio_button ~label:"Coinductive"
1202 ~group:inductiveb#group
1203 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1205 GPack.hbox ~border_width:0
1206 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1208 GMisc.label ~text:"Enter the list of the names of the types:"
1209 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1211 GEdit.entry ~editable:true
1212 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1214 GPack.hbox ~border_width:0
1215 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1217 GButton.button ~label:"> Next"
1218 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1219 let _ = okb#misc#set_sensitive true in
1221 GButton.button ~label:"Abort"
1222 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1223 ignore (window#connect#destroy GMain.Main.quit) ;
1224 ignore (cancelb#connect#clicked window#destroy) ;
1228 (okb#connect#clicked
1231 let uristr = "cic:" ^ uri_entry#text in
1232 let namesstr = names_entry#text in
1233 let paramsno' = int_of_string (paramsno_entry#text) in
1234 match Str.split (Str.regexp " +") namesstr with
1236 | (he::tl) as names ->
1237 let uri = UriManager.uri_of_string (uristr ^ "/" ^ he ^ ".ind") in
1240 ignore (Getter.resolve uri) ;
1241 raise UriAlreadyInUse
1243 Getter.Unresolved ->
1244 get_uri := (function () -> uri) ;
1245 get_names := (function () -> names) ;
1246 inductive := inductiveb#active ;
1247 paramsno := paramsno' ;
1252 output_html outputhtml
1253 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1261 GBin.frame ~label:name
1262 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1263 let vbox = GPack.vbox ~packing:frame#add () in
1264 let hbox = GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false) () in
1266 GMisc.label ~text:("Enter its type:")
1267 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1268 let scrolled_window =
1269 GBin.scrolled_window ~border_width:5
1270 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1272 TexTermEditor'.term_editor
1274 ~width:400 ~height:20 ~packing:scrolled_window#add
1275 ~share_id_to_uris_with:inputt ()
1276 ~isnotempty_callback:
1278 (*non_empty_type := b ;*)
1279 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*)
1282 GPack.hbox ~border_width:0
1283 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1285 GMisc.label ~text:("Enter the list of its constructors:")
1286 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1287 let cons_names_entry =
1288 GEdit.entry ~editable:true
1289 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1290 (newinputt,cons_names_entry)
1293 vbox#remove hboxn#coerce ;
1295 GPack.hbox ~border_width:0
1296 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1298 GButton.button ~label:"> Next"
1299 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1301 GButton.button ~label:"Abort"
1302 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1303 ignore (cancelb#connect#clicked window#destroy) ;
1305 (okb#connect#clicked
1308 let names = !get_names () in
1309 let types_and_cons =
1311 (fun name (newinputt,cons_names_entry) ->
1312 let consnamesstr = cons_names_entry#text in
1313 let cons_names = Str.split (Str.regexp " +") consnamesstr in
1315 newinputt#get_metasenv_and_term ~context:[] ~metasenv:[]
1318 [] -> expr,cons_names
1319 | _ -> raise AmbiguousInput
1320 ) names type_widgets
1322 let uri = !get_uri () in
1324 (* Let's see if so far the definition is well-typed *)
1327 (* To test if the arities of the inductive types are well *)
1328 (* typed, we check the inductive block definition where *)
1329 (* no constructor is given to each type. *)
1332 (fun name (ty,cons) -> (name, !inductive, ty, []))
1333 names types_and_cons
1335 CicTypeChecker.typecheck_mutual_inductive_defs uri
1336 (tys,params,paramsno)
1338 get_context_and_subst :=
1342 (fun (context,subst) name (ty,_) ->
1344 (Some (Cic.Name name, Cic.Decl ty))::context,
1345 (Cic.MutInd (uri,!i,[]))::subst
1348 ) ([],[]) names types_and_cons) ;
1349 let types_and_cons' =
1351 (fun name (ty,cons) -> (name, !inductive, ty, phase3 name cons))
1352 names types_and_cons
1354 get_types_and_cons := (function () -> types_and_cons') ;
1359 output_html outputhtml
1360 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1363 and phase3 name cons =
1364 let get_cons_types = ref (function () -> assert false) in
1367 ~width:600 ~modal:true ~position:`CENTER
1368 ~title:(name ^ " Constructors")
1369 ~border_width:2 () in
1370 let vbox = GPack.vbox ~packing:window2#add () in
1371 let cons_type_widgets =
1373 (function consname ->
1375 GPack.hbox ~border_width:0
1376 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1378 GMisc.label ~text:("Enter the type of " ^ consname ^ ":")
1379 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1380 let scrolled_window =
1381 GBin.scrolled_window ~border_width:5
1382 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1384 TexTermEditor'.term_editor
1386 ~width:400 ~height:20 ~packing:scrolled_window#add
1387 ~share_id_to_uris_with:inputt ()
1388 ~isnotempty_callback:
1390 (* (*non_empty_type := b ;*)
1391 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*) *)())
1396 GPack.hbox ~border_width:0
1397 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1399 GButton.button ~label:"> Next"
1400 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1401 let _ = okb#misc#set_sensitive true in
1403 GButton.button ~label:"Abort"
1404 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1405 ignore (window2#connect#destroy GMain.Main.quit) ;
1406 ignore (cancelb#connect#clicked window2#destroy) ;
1408 (okb#connect#clicked
1412 let context,subst= !get_context_and_subst () in
1417 inputt#get_metasenv_and_term ~context ~metasenv:[]
1421 let undebrujined_expr =
1423 (fun expr t -> CicSubstitution.subst t expr) expr subst
1425 name, undebrujined_expr
1426 | _ -> raise AmbiguousInput
1427 ) cons cons_type_widgets
1429 get_cons_types := (function () -> cons_types) ;
1433 output_html outputhtml
1434 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1438 let okb_pressed = !chosen in
1440 if (not okb_pressed) then
1443 assert false (* The control never reaches this point *)
1446 (!get_cons_types ())
1449 (* No more phases left or Abort pressed *)
1455 let uri = !get_uri () in
1458 let tys = !get_types_and_cons () in
1459 let obj = Cic.InductiveDefinition(tys,params,!paramsno) in
1462 prerr_endline (CicPp.ppobj obj) ;
1463 CicTypeChecker.typecheck_mutual_inductive_defs uri
1464 (tys,params,!paramsno) ;
1467 prerr_endline "Offending mutual (co)inductive type declaration:" ;
1468 prerr_endline (CicPp.ppobj obj) ;
1470 (* We already know that obj is well-typed. We need to add it to the *)
1471 (* environment in order to compute the inner-types without having to *)
1472 (* debrujin it or having to modify lots of other functions to avoid *)
1473 (* asking the environment for the MUTINDs we are defining now. *)
1474 CicEnvironment.put_inductive_definition uri obj ;
1476 show_in_show_window_obj uri obj
1479 output_html outputhtml
1480 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1484 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1485 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1486 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1487 let notebook = (rendering_window ())#notebook in
1489 let chosen = ref false in
1490 let get_metasenv_and_term = ref (function _ -> assert false) in
1491 let get_uri = ref (function _ -> assert false) in
1492 let non_empty_type = ref false in
1495 ~width:600 ~modal:true ~title:"New Proof or Definition"
1496 ~border_width:2 () in
1497 let vbox = GPack.vbox ~packing:window#add () in
1499 GPack.hbox ~border_width:0
1500 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1502 GMisc.label ~text:"Enter the URI for the new theorem or definition:"
1503 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1505 GEdit.entry ~editable:true
1506 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1507 uri_entry#set_text dummy_uri;
1508 uri_entry#select_region ~start:1 ~stop:(String.length dummy_uri);
1510 GPack.hbox ~border_width:0
1511 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1513 GMisc.label ~text:"Enter the theorem or definition type:"
1514 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1515 let scrolled_window =
1516 GBin.scrolled_window ~border_width:5
1517 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1518 (* the content of the scrolled_window is moved below (see comment) *)
1520 GPack.hbox ~border_width:0
1521 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1523 GButton.button ~label:"Ok"
1524 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1525 let _ = okb#misc#set_sensitive false in
1527 GButton.button ~label:"Cancel"
1528 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1529 (* moved here to have visibility of the ok button *)
1531 TexTermEditor'.term_editor
1533 ~width:400 ~height:100 ~packing:scrolled_window#add
1534 ~share_id_to_uris_with:inputt ()
1535 ~isnotempty_callback:
1537 non_empty_type := b ;
1538 okb#misc#set_sensitive (b && uri_entry#text <> ""))
1541 let xxx = inputt#get_as_string in
1542 prerr_endline ("######################## " ^ xxx) ;
1543 newinputt#set_term xxx ;
1545 newinputt#set_term inputt#get_as_string ;
1549 uri_entry#connect#changed
1551 okb#misc#set_sensitive (!non_empty_type && uri_entry#text <> ""))
1553 ignore (window#connect#destroy GMain.Main.quit) ;
1554 ignore (cancelb#connect#clicked window#destroy) ;
1556 (okb#connect#clicked
1560 let metasenv,parsed = newinputt#get_metasenv_and_term [] [] in
1561 let uristr = "cic:" ^ uri_entry#text in
1562 let uri = UriManager.uri_of_string uristr in
1563 if String.sub uristr (String.length uristr - 4) 4 <> ".con" then
1564 raise NotAUriToAConstant
1568 ignore (Getter.resolve uri) ;
1569 raise UriAlreadyInUse
1571 Getter.Unresolved ->
1572 get_metasenv_and_term := (function () -> metasenv,parsed) ;
1573 get_uri := (function () -> uri) ;
1578 output_html outputhtml
1579 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1585 let metasenv,expr = !get_metasenv_and_term () in
1586 let _ = CicTypeChecker.type_of_aux' metasenv [] expr in
1587 ProofEngine.set_proof
1588 (Some (!get_uri (), (1,[],expr)::metasenv, Cic.Meta (1,[]), expr)) ;
1589 set_proof_engine_goal (Some 1) ;
1590 refresh_goals notebook ;
1591 refresh_proof output ;
1592 !save_set_sensitive true ;
1594 ProofEngine.intros ~mk_fresh_name_callback () ;
1595 refresh_goals notebook ;
1596 refresh_proof output
1598 InvokeTactics.RefreshSequentException e ->
1599 output_html outputhtml
1600 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1601 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1602 | InvokeTactics.RefreshProofException e ->
1603 output_html outputhtml
1604 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1605 "proof: " ^ Printexc.to_string e ^ "</h1>")
1607 output_html outputhtml
1608 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1611 let check_term_in_scratch scratch_window metasenv context expr =
1613 let ty = CicTypeChecker.type_of_aux' metasenv context expr in
1614 let expr = Cic.Cast (expr,ty) in
1615 scratch_window#show () ;
1616 scratch_window#set_term expr ;
1617 scratch_window#set_context context ;
1618 scratch_window#set_metasenv metasenv ;
1619 scratch_window#sequent_viewer#load_sequent metasenv (111,context,expr)
1622 print_endline ("? " ^ CicPp.ppterm expr) ;
1626 let check scratch_window () =
1627 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1628 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1630 match ProofEngine.get_proof () with
1632 | Some (_,metasenv,_,_) -> metasenv
1635 match !ProofEngine.goal with
1638 let (_,canonical_context,_) =
1639 List.find (function (m,_,_) -> m=metano) metasenv
1644 let metasenv',expr = inputt#get_metasenv_and_term context metasenv in
1645 check_term_in_scratch scratch_window metasenv' context expr
1648 output_html outputhtml
1649 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1653 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1655 show_in_show_window_uri (input_or_locate_uri ~title:"Show")
1658 output_html outputhtml
1659 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1662 exception NotADefinition;;
1665 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1666 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1667 let notebook = (rendering_window ())#notebook in
1669 let uri = input_or_locate_uri ~title:"Open" in
1670 CicTypeChecker.typecheck uri ;
1671 let metasenv,bo,ty =
1672 match CicEnvironment.get_cooked_obj uri with
1673 Cic.Constant (_,Some bo,ty,_) -> [],bo,ty
1674 | Cic.CurrentProof (_,metasenv,bo,ty,_) -> metasenv,bo,ty
1677 | Cic.InductiveDefinition _ -> raise NotADefinition
1679 ProofEngine.set_proof (Some (uri, metasenv, bo, ty)) ;
1680 set_proof_engine_goal None ;
1681 refresh_goals notebook ;
1682 refresh_proof output ;
1683 !save_set_sensitive true
1685 InvokeTactics.RefreshSequentException e ->
1686 output_html outputhtml
1687 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1688 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1689 | InvokeTactics.RefreshProofException e ->
1690 output_html outputhtml
1691 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1692 "proof: " ^ Printexc.to_string e ^ "</h1>")
1694 output_html outputhtml
1695 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1698 let show_query_results results =
1701 ~modal:false ~title:"Query results." ~border_width:2 () in
1702 let vbox = GPack.vbox ~packing:window#add () in
1704 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1707 ~text:"Click on a URI to show that object"
1708 ~packing:hbox#add () in
1709 let scrolled_window =
1710 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1711 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1712 let clist = GList.clist ~columns:1 ~packing:scrolled_window#add () in
1715 (function (uri,_) ->
1719 clist#set_row ~selectable:false n
1722 clist#columns_autosize () ;
1724 (clist#connect#select_row
1725 (fun ~row ~column ~event ->
1726 let (uristr,_) = List.nth results row in
1728 MQueryMisc.cic_textual_parser_uri_of_string
1729 (MQueryMisc.wrong_xpointer_format_from_wrong_xpointer_format'
1732 CicTextualParser0.ConUri uri
1733 | CicTextualParser0.VarUri uri
1734 | CicTextualParser0.IndTyUri (uri,_)
1735 | CicTextualParser0.IndConUri (uri,_,_) ->
1736 show_in_show_window_uri uri
1742 let refine_constraints (must_obj,must_rel,must_sort) =
1743 let chosen = ref false in
1744 let use_only = ref false in
1747 ~modal:true ~title:"Constraints refinement."
1748 ~width:800 ~border_width:2 () in
1749 let vbox = GPack.vbox ~packing:window#add () in
1751 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1754 ~text: "\"Only\" constraints can be enforced or not."
1755 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1757 GButton.toggle_button ~label:"Enforce \"only\" constraints"
1758 ~active:false ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1761 (onlyb#connect#toggled (function () -> use_only := onlyb#active)) ;
1762 (* Notebook for the constraints choice *)
1764 GPack.notebook ~scrollable:true
1765 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1766 (* Rel constraints *)
1769 ~text: "Constraints on Rels" () in
1771 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1774 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1777 ~text: "You can now specify the constraints on Rels."
1778 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1779 let expected_height = 25 * (List.length must_rel + 2) in
1780 let height = if expected_height > 400 then 400 else expected_height in
1781 let scrolled_window =
1782 GBin.scrolled_window ~border_width:10 ~height ~width:600
1783 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1784 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1785 let mk_depth_button (hbox:GPack.box) d =
1786 let mutable_ref = ref (Some d) in
1788 GButton.toggle_button
1789 ~label:("depth = " ^ string_of_int d)
1791 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1794 (depthb#connect#toggled
1796 let sel_depth = if depthb#active then Some d else None in
1797 mutable_ref := sel_depth
1800 let rel_constraints =
1805 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1808 ~text:(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
1813 | `MainHypothesis (Some depth')
1814 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth'
1816 (* Sort constraints *)
1819 ~text: "Constraints on Sorts" () 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 Sorts."
1828 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1829 let expected_height = 25 * (List.length must_sort + 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 sort_constraints =
1837 (function (p, sort) ->
1840 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1843 ~text:(MQGU.text_of_sort sort ^ " " ^ MQGU.text_of_position (p:>MQGT.full_position))
1844 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1846 | `MainHypothesis None
1847 | `MainConclusion None -> p, ref None, sort
1848 | `MainHypothesis (Some depth')
1849 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', sort
1851 (* Obj constraints *)
1854 ~text: "Constraints on constants" () in
1856 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1859 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1862 ~text: "You can now specify the constraints on constants."
1863 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1864 let expected_height = 25 * (List.length must_obj + 2) in
1865 let height = if expected_height > 400 then 400 else expected_height in
1866 let scrolled_window =
1867 GBin.scrolled_window ~border_width:10 ~height ~width:600
1868 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1869 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1870 let obj_constraints =
1872 (function (p, uri) ->
1875 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1878 ~text:(uri ^ " " ^ (MQGU.text_of_position p))
1879 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1884 | `MainHypothesis None
1885 | `MainConclusion None -> p, ref None, uri
1886 | `MainHypothesis (Some depth')
1887 | `MainConclusion (Some depth') -> p, mk_depth_button hbox depth', uri
1889 (* Confirm/abort buttons *)
1891 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1893 GButton.button ~label:"Ok"
1894 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1896 GButton.button ~label:"Abort"
1897 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1899 ignore (window#connect#destroy GMain.Main.quit) ;
1900 ignore (cancelb#connect#clicked window#destroy) ;
1902 (okb#connect#clicked (function () -> chosen := true ; window#destroy ()));
1903 window#set_position `CENTER ;
1907 let chosen_must_rel =
1909 (function (position, ref_depth) -> MQGU.set_main_position position !ref_depth)
1912 let chosen_must_sort =
1914 (function (position, ref_depth, sort) ->
1915 MQGU.set_main_position position !ref_depth,sort)
1918 let chosen_must_obj =
1920 (function (position, ref_depth, uri) -> MQGU.set_full_position position !ref_depth, uri)
1923 (chosen_must_obj,chosen_must_rel,chosen_must_sort),
1925 (*CSC: ???????????????????????? I assume that must and only are the same... *)
1926 Some chosen_must_obj,Some chosen_must_rel,Some chosen_must_sort
1934 let completeSearchPattern () =
1935 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1936 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1938 let metasenv,expr = inputt#get_metasenv_and_term ~context:[] ~metasenv:[] in
1939 let must = CGSearchPattern.get_constraints expr in
1940 let must',only = refine_constraints must in
1942 MQG.query_of_constraints (Some CGSearchPattern.universe) must' only
1944 let results = MQI.execute mqi_handle query in
1945 show_query_results results
1948 output_html outputhtml
1949 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1952 let insertQuery () =
1953 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
1955 let chosen = ref None in
1958 ~modal:true ~title:"Insert Query (Experts Only)" ~border_width:2 () in
1959 let vbox = GPack.vbox ~packing:window#add () in
1961 GMisc.label ~text:"Insert Query. For Experts Only."
1962 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1963 let scrolled_window =
1964 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1965 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1966 let input = GText.view ~editable:true
1967 ~packing:scrolled_window#add () in
1969 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1971 GButton.button ~label:"Ok"
1972 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1974 GButton.button ~label:"Load from file..."
1975 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1977 GButton.button ~label:"Abort"
1978 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1979 ignore (window#connect#destroy GMain.Main.quit) ;
1980 ignore (cancelb#connect#clicked window#destroy) ;
1982 (okb#connect#clicked
1984 chosen := Some (input#buffer#get_text ()) ; window#destroy ())) ;
1986 (loadb#connect#clicked
1989 GToolbox.select_file ~title:"Select Query File" ()
1993 let inch = open_in filename in
1994 let rec read_file () =
1996 let line = input_line inch in
1997 line ^ "\n" ^ read_file ()
2001 let text = read_file () in
2002 input#buffer#delete input#buffer#start_iter input#buffer#end_iter ;
2003 ignore (input#buffer#insert text))) ;
2004 window#set_position `CENTER ;
2011 MQI.execute mqi_handle (MQueryUtil.query_of_text (Lexing.from_string q))
2013 show_query_results results
2016 output_html outputhtml
2017 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
2020 let choose_must list_of_must only =
2021 let chosen = ref None in
2022 let user_constraints = ref [] in
2025 ~modal:true ~title:"Query refinement." ~border_width:2 () in
2026 let vbox = GPack.vbox ~packing:window#add () in
2028 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2032 ("You can now specify the genericity of the query. " ^
2033 "The more generic the slower.")
2034 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2036 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2040 "Suggestion: start with faster queries before moving to more generic ones."
2041 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2043 GPack.notebook ~scrollable:true
2044 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2047 let last = List.length list_of_must in
2053 (if !page = 1 then "More generic" else
2054 if !page = last then "More precise" else " ") () in
2055 let expected_height = 25 * (List.length must + 2) in
2056 let height = if expected_height > 400 then 400 else expected_height in
2057 let scrolled_window =
2058 GBin.scrolled_window ~border_width:10 ~height ~width:600
2059 ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2061 GList.clist ~columns:2 ~packing:scrolled_window#add
2062 ~titles:["URI" ; "Position"] ()
2066 (function (position, uri) ->
2069 [uri; MQGUtil.text_of_position position]
2071 clist#set_row ~selectable:false n
2074 clist#columns_autosize ()
2077 let label = GMisc.label ~text:"User provided" () in
2079 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2081 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2084 ~text:"Select the constraints that must be satisfied and press OK."
2085 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2086 let expected_height = 25 * (List.length only + 2) in
2087 let height = if expected_height > 400 then 400 else expected_height in
2088 let scrolled_window =
2089 GBin.scrolled_window ~border_width:10 ~height ~width:600
2090 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2092 GList.clist ~columns:2 ~packing:scrolled_window#add
2093 ~selection_mode:`MULTIPLE
2094 ~titles:["URI" ; "Position"] ()
2098 (function (position, uri) ->
2101 [uri; MQGUtil.text_of_position position]
2103 clist#set_row ~selectable:true n
2106 clist#columns_autosize () ;
2108 (clist#connect#select_row
2109 (fun ~row ~column ~event ->
2110 user_constraints := (List.nth only row)::!user_constraints)) ;
2112 (clist#connect#unselect_row
2113 (fun ~row ~column ~event ->
2116 (function uri -> uri != (List.nth only row)) !user_constraints)) ;
2119 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2121 GButton.button ~label:"Ok"
2122 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2124 GButton.button ~label:"Abort"
2125 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2127 ignore (window#connect#destroy GMain.Main.quit) ;
2128 ignore (cancelb#connect#clicked window#destroy) ;
2130 (okb#connect#clicked
2131 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
2132 window#set_position `CENTER ;
2136 None -> raise NoChoice
2138 if n = List.length list_of_must then
2139 (* user provided constraints *)
2142 List.nth list_of_must n
2145 let searchPattern () =
2146 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
2147 let outputhtml = ((rendering_window ())#outputhtml(* : GHtml.xmhtml*)) in
2150 match ProofEngine.get_proof () with
2151 None -> assert false
2152 | Some proof -> proof
2154 match !ProofEngine.goal with
2158 TacticChaser.matchConclusion
2160 ~output_html:(output_html outputhtml) ~choose_must ()
2161 ~status:(proof, metano)
2164 user_uri_choice ~title:"Ambiguous input."
2165 ~msg: "Many lemmas can be successfully applied. Please, choose one:"
2168 inputt#set_term uri' ;
2169 InvokeTactics'.apply ()
2172 output_html outputhtml
2173 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
2176 let choose_selection mmlwidget (element : Gdome.element option) =
2177 let module G = Gdome in
2178 prerr_endline "Il bandolo" ;
2179 let rec aux element =
2180 if element#hasAttributeNS
2181 ~namespaceURI:Misc.helmns
2182 ~localName:(G.domString "xref")
2184 mmlwidget#set_selection (Some element)
2187 match element#get_parentNode with
2188 None -> assert false
2189 (*CSC: OCAML DIVERGES!
2190 | Some p -> aux (new G.element_of_node p)
2192 | Some p -> aux (new Gdome.element_of_node p)
2194 GdomeInit.DOMCastException _ ->
2196 "******* trying to select above the document root ********"
2200 | None -> mmlwidget#set_selection None
2203 (* STUFF TO BUILD THE GTK INTERFACE *)
2205 (* Stuff for the widget settings *)
2208 let export_to_postscript output =
2209 let lastdir = ref (Unix.getcwd ()) in
2212 GToolbox.select_file ~title:"Export to PostScript"
2213 ~dir:lastdir ~filename:"screenshot.ps" ()
2217 (output :> GMathView.math_view)#export_to_postscript
2218 ~filename:filename ();
2223 let activate_t1 output button_set_anti_aliasing
2224 button_set_transparency export_to_postscript_menu_item
2227 let is_set = button_t1#active in
2228 output#set_font_manager_type
2229 ~fm_type:(if is_set then `font_manager_t1 else `font_manager_gtk) ;
2232 button_set_anti_aliasing#misc#set_sensitive true ;
2233 button_set_transparency#misc#set_sensitive true ;
2234 export_to_postscript_menu_item#misc#set_sensitive true ;
2238 button_set_anti_aliasing#misc#set_sensitive false ;
2239 button_set_transparency#misc#set_sensitive false ;
2240 export_to_postscript_menu_item#misc#set_sensitive false ;
2244 let set_anti_aliasing output button_set_anti_aliasing () =
2245 output#set_anti_aliasing button_set_anti_aliasing#active
2248 let set_transparency output button_set_transparency () =
2249 output#set_transparency button_set_transparency#active
2253 let changefont output font_size_spinb () =
2254 output#set_font_size font_size_spinb#value_as_int
2257 let set_log_verbosity output log_verbosity_spinb () =
2258 output#set_log_verbosity log_verbosity_spinb#value_as_int
2261 class settings_window output sw
2262 export_to_postscript_menu_item selection_changed_callback
2264 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
2266 GPack.vbox ~packing:settings_window#add () in
2269 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2270 ~border_width:5 ~packing:vbox#add () in
2272 GButton.toggle_button ~label:"activate t1 fonts"
2273 ~packing:(table#attach ~left:0 ~top:0) () in
2274 let button_set_anti_aliasing =
2275 GButton.toggle_button ~label:"set_anti_aliasing"
2276 ~packing:(table#attach ~left:0 ~top:1) () in
2277 let button_set_transparency =
2278 GButton.toggle_button ~label:"set_transparency"
2279 ~packing:(table#attach ~left:2 ~top:1) () in
2282 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2283 ~border_width:5 ~packing:vbox#add () in
2284 let font_size_label =
2285 GMisc.label ~text:"font size:"
2286 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
2287 let font_size_spinb =
2289 GData.adjustment ~value:(float_of_int output#get_font_size)
2290 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
2293 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
2294 let log_verbosity_label =
2295 GMisc.label ~text:"log verbosity:"
2296 ~packing:(table#attach ~left:0 ~top:1) () in
2297 let log_verbosity_spinb =
2299 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
2302 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
2304 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2306 GButton.button ~label:"Close"
2307 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2309 method show = settings_window#show
2311 button_set_anti_aliasing#misc#set_sensitive false ;
2312 button_set_transparency#misc#set_sensitive false ;
2313 (* Signals connection *)
2315 ignore(button_t1#connect#clicked
2316 (activate_t1 output button_set_anti_aliasing
2317 button_set_transparency export_to_postscript_menu_item button_t1)) ;
2319 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
2321 ignore(button_set_anti_aliasing#connect#toggled
2322 (set_anti_aliasing output button_set_anti_aliasing));
2323 ignore(button_set_transparency#connect#toggled
2324 (set_transparency output button_set_transparency)) ;
2326 ignore(log_verbosity_spinb#connect#changed
2327 (set_log_verbosity output log_verbosity_spinb)) ;
2328 ignore(closeb#connect#clicked settings_window#misc#hide)
2331 (* Scratch window *)
2333 class scratch_window =
2336 ~title:"MathML viewer"
2337 ~border_width:2 () in
2339 GPack.vbox ~packing:window#add () in
2341 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2343 GButton.button ~label:"Whd"
2344 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2346 GButton.button ~label:"Reduce"
2347 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2349 GButton.button ~label:"Simpl"
2350 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2351 let scrolled_window =
2352 GBin.scrolled_window ~border_width:10
2353 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2354 let sequent_viewer =
2355 TermViewer.sequent_viewer
2356 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
2358 val mutable term = Cic.Rel 1 (* dummy value *)
2359 val mutable context = ([] : Cic.context) (* dummy value *)
2360 val mutable metasenv = ([] : Cic.metasenv) (* dummy value *)
2361 method sequent_viewer = sequent_viewer
2362 method show () = window#misc#hide () ; window#show ()
2364 method set_term t = term <- t
2365 method context = context
2366 method set_context t = context <- t
2367 method metasenv = metasenv
2368 method set_metasenv t = metasenv <- t
2371 (sequent_viewer#connect#selection_changed (choose_selection sequent_viewer));
2372 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
2373 ignore(whdb#connect#clicked InvokeTactics'.whd_in_scratch) ;
2374 ignore(reduceb#connect#clicked InvokeTactics'.reduce_in_scratch) ;
2375 ignore(simplb#connect#clicked InvokeTactics'.simpl_in_scratch)
2378 let open_contextual_menu_for_selected_terms mmlwidget infos =
2379 let button = GdkEvent.Button.button infos in
2380 let terms_selected = List.length mmlwidget#get_selections > 0 in
2383 let time = GdkEvent.Button.time infos in
2384 let menu = GMenu.menu () in
2385 let f = new GMenu.factory menu in
2387 f#add_item "Whd" ~key:GdkKeysyms._W ~callback:InvokeTactics'.whd in
2388 let reduce_menu_item =
2389 f#add_item "Reduce" ~key:GdkKeysyms._R ~callback:InvokeTactics'.reduce in
2390 let simpl_menu_item =
2391 f#add_item "Simpl" ~key:GdkKeysyms._S ~callback:InvokeTactics'.simpl in
2392 let _ = f#add_separator () in
2393 let generalize_menu_item =
2394 f#add_item "Generalize"
2395 ~key:GdkKeysyms._G ~callback:InvokeTactics'.generalize in
2396 let _ = f#add_separator () in
2397 let clear_menu_item =
2398 f#add_item "Clear" ~key:GdkKeysyms._C ~callback:InvokeTactics'.clear in
2399 let clearbody_menu_item =
2400 f#add_item "ClearBody"
2401 ~key:GdkKeysyms._B ~callback:InvokeTactics'.clearbody
2403 whd_menu_item#misc#set_sensitive terms_selected ;
2404 reduce_menu_item#misc#set_sensitive terms_selected ;
2405 simpl_menu_item#misc#set_sensitive terms_selected ;
2406 generalize_menu_item#misc#set_sensitive terms_selected ;
2407 clear_menu_item#misc#set_sensitive terms_selected ;
2408 clearbody_menu_item#misc#set_sensitive terms_selected ;
2409 menu#popup ~button ~time
2415 let vbox1 = GPack.vbox () in
2417 val mutable proofw_ref = None
2418 val mutable compute_ref = None
2420 Lazy.force self#compute ;
2421 match proofw_ref with
2422 None -> assert false
2423 | Some proofw -> proofw
2424 method content = vbox1
2426 match compute_ref with
2427 None -> assert false
2428 | Some compute -> compute
2432 let scrolled_window1 =
2433 GBin.scrolled_window ~border_width:10
2434 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2436 TermViewer.sequent_viewer ~width:400 ~height:275
2437 ~packing:(scrolled_window1#add) () in
2438 let _ = proofw_ref <- Some proofw in
2440 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2442 GButton.button ~label:"Ring"
2443 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2445 GButton.button ~label:"Fourier"
2446 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2448 GButton.button ~label:"Reflexivity"
2449 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2451 GButton.button ~label:"Symmetry"
2452 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2454 GButton.button ~label:"Assumption"
2455 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2456 let contradictionb =
2457 GButton.button ~label:"Contradiction"
2458 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2460 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2462 GButton.button ~label:"Exists"
2463 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2465 GButton.button ~label:"Split"
2466 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2468 GButton.button ~label:"Left"
2469 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2471 GButton.button ~label:"Right"
2472 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2473 let searchpatternb =
2474 GButton.button ~label:"SearchPattern_Apply"
2475 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2477 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2479 GButton.button ~label:"Exact"
2480 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2482 GButton.button ~label:"Intros"
2483 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2485 GButton.button ~label:"Apply"
2486 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2487 let elimintrossimplb =
2488 GButton.button ~label:"ElimIntrosSimpl"
2489 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2491 GButton.button ~label:"ElimType"
2492 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2494 GButton.button ~label:"Fold_whd"
2495 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2497 GButton.button ~label:"Fold_reduce"
2498 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2500 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2502 GButton.button ~label:"Fold_simpl"
2503 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2505 GButton.button ~label:"Cut"
2506 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2508 GButton.button ~label:"Change"
2509 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2511 GButton.button ~label:"Let ... In"
2512 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2514 GButton.button ~label:"RewriteSimpl ->"
2515 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2516 let rewritebacksimplb =
2517 GButton.button ~label:"RewriteSimpl <-"
2518 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2520 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2522 GButton.button ~label:"Absurd"
2523 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2525 GButton.button ~label:"Decompose"
2526 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2528 GButton.button ~label:"Transitivity"
2529 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2531 GButton.button ~label:"Replace"
2532 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2534 GButton.button ~label:"Injection"
2535 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2537 GButton.button ~label:"Discriminate"
2538 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2539 (* Zack: spostare in una toolbar
2541 GButton.button ~label:"Generalize"
2542 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2544 GButton.button ~label:"ClearBody"
2545 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2547 GButton.button ~label:"Clear"
2548 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2550 GButton.button ~label:"Whd"
2551 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2553 GButton.button ~label:"Reduce"
2554 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2556 GButton.button ~label:"Simpl"
2557 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2560 ignore(exactb#connect#clicked InvokeTactics'.exact) ;
2561 ignore(applyb#connect#clicked InvokeTactics'.apply) ;
2562 ignore(elimintrossimplb#connect#clicked InvokeTactics'.elimintrossimpl) ;
2563 ignore(elimtypeb#connect#clicked InvokeTactics'.elimtype) ;
2564 ignore(foldwhdb#connect#clicked InvokeTactics'.fold_whd) ;
2565 ignore(foldreduceb#connect#clicked InvokeTactics'.fold_reduce) ;
2566 ignore(foldsimplb#connect#clicked InvokeTactics'.fold_simpl) ;
2567 ignore(cutb#connect#clicked InvokeTactics'.cut) ;
2568 ignore(changeb#connect#clicked InvokeTactics'.change) ;
2569 ignore(letinb#connect#clicked InvokeTactics'.letin) ;
2570 ignore(ringb#connect#clicked InvokeTactics'.ring) ;
2571 ignore(fourierb#connect#clicked InvokeTactics'.fourier) ;
2572 ignore(rewritesimplb#connect#clicked InvokeTactics'.rewritesimpl) ;
2573 ignore(rewritebacksimplb#connect#clicked InvokeTactics'.rewritebacksimpl) ;
2574 ignore(replaceb#connect#clicked InvokeTactics'.replace) ;
2575 ignore(reflexivityb#connect#clicked InvokeTactics'.reflexivity) ;
2576 ignore(symmetryb#connect#clicked InvokeTactics'.symmetry) ;
2577 ignore(transitivityb#connect#clicked InvokeTactics'.transitivity) ;
2578 ignore(existsb#connect#clicked InvokeTactics'.exists) ;
2579 ignore(splitb#connect#clicked InvokeTactics'.split) ;
2580 ignore(leftb#connect#clicked InvokeTactics'.left) ;
2581 ignore(rightb#connect#clicked InvokeTactics'.right) ;
2582 ignore(assumptionb#connect#clicked InvokeTactics'.assumption) ;
2583 ignore(absurdb#connect#clicked InvokeTactics'.absurd) ;
2584 ignore(contradictionb#connect#clicked InvokeTactics'.contradiction) ;
2585 ignore(introsb#connect#clicked InvokeTactics'.intros) ;
2586 ignore(decomposeb#connect#clicked InvokeTactics'.decompose) ;
2587 ignore(searchpatternb#connect#clicked searchPattern) ;
2588 ignore(injectionb#connect#clicked InvokeTactics'.injection) ;
2589 ignore(discriminateb#connect#clicked InvokeTactics'.discriminate) ;
2590 (* Zack: spostare in una toolbar
2591 ignore(whdb#connect#clicked whd) ;
2592 ignore(reduceb#connect#clicked reduce) ;
2593 ignore(simplb#connect#clicked simpl) ;
2594 ignore(clearbodyb#connect#clicked clearbody) ;
2595 ignore(clearb#connect#clicked clear) ;
2596 ignore(generalizeb#connect#clicked generalize) ;
2598 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
2600 ((new GObj.event_ops proofw#as_widget)#connect#button_press
2601 (open_contextual_menu_for_selected_terms proofw)) ;
2607 let vbox1 = GPack.vbox () in
2608 let scrolled_window1 =
2609 GBin.scrolled_window ~border_width:10
2610 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2612 TermViewer.sequent_viewer ~width:400 ~height:275
2613 ~packing:(scrolled_window1#add) () in
2615 method proofw = (assert false : TermViewer.sequent_viewer)
2616 method content = vbox1
2617 method compute = (assert false : unit)
2621 let empty_page = new empty_page;;
2625 val notebook = GPack.notebook ()
2627 val mutable skip_switch_page_event = false
2628 val mutable empty = true
2629 method notebook = notebook
2631 let new_page = new page () in
2633 pages := !pages @ [n,lazy (setgoal n),new_page] ;
2634 notebook#append_page
2635 ~tab_label:((GMisc.label ~text:("?" ^ string_of_int n) ())#coerce)
2636 new_page#content#coerce
2637 method remove_all_pages ~skip_switch_page_event:skip =
2639 notebook#remove_page 0 (* let's remove the empty page *)
2641 List.iter (function _ -> notebook#remove_page 0) !pages ;
2643 skip_switch_page_event <- skip
2644 method set_current_page ~may_skip_switch_page_event n =
2645 let (_,_,page) = List.find (function (m,_,_) -> m=n) !pages in
2646 let new_page = notebook#page_num page#content#coerce in
2647 if may_skip_switch_page_event && new_page <> notebook#current_page then
2648 skip_switch_page_event <- true ;
2649 notebook#goto_page new_page
2650 method set_empty_page =
2653 notebook#append_page
2654 ~tab_label:((GMisc.label ~text:"No proof in progress" ())#coerce)
2655 empty_page#content#coerce
2657 let (_,_,page) = List.nth !pages notebook#current_page in
2661 (notebook#connect#switch_page
2663 let skip = skip_switch_page_event in
2664 skip_switch_page_event <- false ;
2667 let (metano,setgoal,page) = List.nth !pages i in
2668 set_proof_engine_goal (Some metano) ;
2669 Lazy.force (page#compute) ;
2671 if notify_hbugs_on_goal_change then
2672 (*Hbugs.notify *) ()
2678 let dump_environment () =
2680 let oc = open_out environmentfile in
2681 output_html (outputhtml ()) "<b>Dumping environment ... </b><br />";
2682 CicEnvironment.dump_to_channel
2683 ~callback:(fun uri -> output_html (outputhtml ()) (uri ^ "<br />"))
2685 output_html (outputhtml ()) "<b>... done!</b><br />";
2688 output_html (outputhtml ())
2690 "<h1 color=\"red\">Dump failure, uncaught exception:%s</h1>"
2691 (Printexc.to_string exc))
2693 let restore_environment () =
2695 let ic = open_in environmentfile in
2696 output_html (outputhtml ()) "<b>Restoring environment ... </b><br />";
2697 CicEnvironment.restore_from_channel
2698 ~callback:(fun uri -> output_html (outputhtml ()) (uri ^ "<br />"))
2700 output_html (outputhtml ()) "<b>... done!</b><br />";
2703 output_html (outputhtml ())
2705 "<h1 color=\"red\">Restore failure, uncaught exception:%s</h1>"
2706 (Printexc.to_string exc))
2709 (* HTML simulator (first in its kind) *)
2711 class fake_xmhtml ~source ~width ~height ~border_width ~packing ~show () =
2712 let tv = GText.view ~width ~height ~border_width ~packing ~show () in
2714 method set_topline (_:int) = ()
2715 method source s = tv#buffer#insert s
2721 class rendering_window output (notebook : notebook) =
2722 let scratch_window = new scratch_window in
2725 ~title:"gTopLevel - Helm's Proof Assistant"
2726 ~border_width:0 ~allow_shrink:false () in
2727 let vbox_for_menu = GPack.vbox ~packing:window#add () in
2729 let handle_box = GBin.handle_box ~border_width:2
2730 ~packing:(vbox_for_menu#pack ~padding:0) () in
2731 let menubar = GMenu.menu_bar ~packing:handle_box#add () in
2732 let factory0 = new GMenu.factory menubar in
2733 let accel_group = factory0#accel_group in
2735 let file_menu = factory0#add_submenu "File" in
2736 let factory1 = new GMenu.factory file_menu ~accel_group in
2737 (* let export_to_postscript_menu_item = *)
2741 factory1#add_item "New Block of (Co)Inductive Definitions..."
2742 ~key:GdkKeysyms._B ~callback:new_inductive
2745 factory1#add_item "New Proof or Definition..." ~key:GdkKeysyms._N
2748 let reopen_menu_item =
2749 factory1#add_item "Reopen a Finished Proof..." ~key:GdkKeysyms._R
2753 factory1#add_item "Qed" ~key:GdkKeysyms._E ~callback:qed in
2754 ignore (factory1#add_separator ()) ;
2756 (factory1#add_item "Load Unfinished Proof..." ~key:GdkKeysyms._L
2757 ~callback:load_unfinished_proof) ;
2758 let save_menu_item =
2759 factory1#add_item "Save Unfinished Proof" ~key:GdkKeysyms._S
2760 ~callback:save_unfinished_proof
2762 ignore (factory1#add_separator ()) ;
2763 ignore (factory1#add_item "Clear Environment" ~callback:CicEnvironment.empty);
2764 ignore (factory1#add_item "Dump Environment" ~callback:dump_environment);
2766 (factory1#add_item "Restore Environment" ~callback:restore_environment);
2768 (save_set_sensitive := function b -> save_menu_item#misc#set_sensitive b);
2769 ignore (!save_set_sensitive false);
2770 ignore (qed_set_sensitive:=function b -> qed_menu_item#misc#set_sensitive b);
2771 ignore (!qed_set_sensitive false);
2772 ignore (factory1#add_separator ()) ;
2774 let export_to_postscript_menu_item =
2775 factory1#add_item "Export to PostScript..."
2776 ~callback:(export_to_postscript output) in
2778 ignore (factory1#add_separator ()) ;
2780 (factory1#add_item "Exit" ~key:GdkKeysyms._Q ~callback:GMain.Main.quit) (*;
2781 export_to_postscript_menu_item *)
2784 let edit_menu = factory0#add_submenu "Edit Current Proof" in
2785 let factory2 = new GMenu.factory edit_menu ~accel_group in
2786 let focus_and_proveit_set_sensitive = ref (function _ -> assert false) in
2787 let proveit_menu_item =
2788 factory2#add_item "Prove It" ~key:GdkKeysyms._I
2789 ~callback:(function () -> proveit ();!focus_and_proveit_set_sensitive false)
2791 let focus_menu_item =
2792 factory2#add_item "Focus" ~key:GdkKeysyms._F
2793 ~callback:(function () -> focus () ; !focus_and_proveit_set_sensitive false)
2796 focus_and_proveit_set_sensitive :=
2798 proveit_menu_item#misc#set_sensitive b ;
2799 focus_menu_item#misc#set_sensitive b
2801 let _ = !focus_and_proveit_set_sensitive false in
2802 (* edit term menu *)
2803 let edit_term_menu = factory0#add_submenu "Edit Term" in
2804 let factory5 = new GMenu.factory edit_term_menu ~accel_group in
2805 let check_menu_item =
2806 factory5#add_item "Check Term" ~key:GdkKeysyms._C
2807 ~callback:(check scratch_window) in
2808 let _ = check_menu_item#misc#set_sensitive false in
2810 let search_menu = factory0#add_submenu "Search" in
2811 let factory4 = new GMenu.factory search_menu ~accel_group in
2813 factory4#add_item "Locate..." ~key:GdkKeysyms._T
2815 let searchPattern_menu_item =
2816 factory4#add_item "SearchPattern..." ~key:GdkKeysyms._D
2817 ~callback:completeSearchPattern in
2818 let _ = searchPattern_menu_item#misc#set_sensitive false in
2819 let show_menu_item =
2820 factory4#add_item "Show..." ~key:GdkKeysyms._H ~callback:show
2822 let insert_query_item =
2823 factory4#add_item "Insert Query (Experts Only)..." ~key:GdkKeysyms._Y
2824 ~callback:insertQuery in
2826 let hbugs_menu = factory0#add_submenu "HBugs" in
2827 let factory6 = new GMenu.factory hbugs_menu ~accel_group in
2829 factory6#add_check_item
2830 ~active:false ~key:GdkKeysyms._F5 ~callback:(*Hbugs.toggle*)(fun _ -> ()) "HBugs enabled"
2833 factory6#add_item ~key:GdkKeysyms._Return ~callback:(*Hbugs.notify*)(fun _ -> ())
2834 "(Re)Submit status!"
2836 let _ = factory6#add_separator () in
2838 factory6#add_item ~callback:(*Hbugs.start_web_services*)(fun _ -> ()) "Start Web Services"
2841 factory6#add_item ~callback:(*Hbugs.stop_web_services*)(fun _ -> ()) "Stop Web Services"
2844 let settings_menu = factory0#add_submenu "Settings" in
2845 let factory3 = new GMenu.factory settings_menu ~accel_group in
2847 factory3#add_item "Edit Aliases..." ~key:GdkKeysyms._A
2848 ~callback:edit_aliases in
2849 let _ = factory3#add_separator () in
2851 factory3#add_item "MathML Widget Preferences..." ~key:GdkKeysyms._P
2852 ~callback:(function _ -> (settings_window ())#show ()) in
2853 let _ = factory3#add_separator () in
2855 factory3#add_item "Reload Stylesheets"
2858 ApplyStylesheets.reload_stylesheets () ;
2859 if ProofEngine.get_proof () <> None then
2861 refresh_goals notebook ;
2862 refresh_proof output
2864 InvokeTactics.RefreshSequentException e ->
2865 output_html (outputhtml ())
2866 ("<h1 color=\"red\">An error occurred while refreshing the " ^
2867 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
2868 (*notebook#remove_all_pages ~skip_switch_page_event:false ;*)
2869 notebook#set_empty_page
2870 | InvokeTactics.RefreshProofException e ->
2871 output_html (outputhtml ())
2872 ("<h1 color=\"red\">An error occurred while refreshing the proof: " ^ Printexc.to_string e ^ "</h1>") ;
2876 let _ = window#add_accel_group accel_group in
2880 ~packing:(vbox_for_menu#pack ~expand:true ~fill:true ~padding:5) () in
2882 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2883 let scrolled_window0 =
2884 GBin.scrolled_window ~border_width:10
2885 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2886 let _ = scrolled_window0#add output#coerce in
2888 GBin.frame ~label:"Insert Term"
2889 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2890 let scrolled_window1 =
2891 GBin.scrolled_window ~border_width:5
2892 ~packing:frame#add () in
2894 TexTermEditor'.term_editor
2896 ~width:400 ~height:100 ~packing:scrolled_window1#add ()
2897 ~isnotempty_callback:
2899 check_menu_item#misc#set_sensitive b ;
2900 searchPattern_menu_item#misc#set_sensitive b) in
2902 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2904 vboxl#pack ~expand:true ~fill:true ~padding:5 notebook#notebook#coerce in
2906 GBin.frame ~shadow_type:`IN ~packing:(vboxl#pack ~expand:true ~padding:5) ()
2913 ~source:"<html><body bgColor=\"white\"></body></html>"
2914 ~width:400 ~height: 100
2919 method outputhtml = outputhtml
2920 method inputt = inputt
2921 method output = (output : TermViewer.proof_viewer)
2922 method scratch_window = scratch_window
2923 method notebook = notebook
2924 method show = window#show
2926 notebook#set_empty_page ;
2927 (*export_to_postscript_menu_item#misc#set_sensitive false ;*)
2928 check_term := (check_term_in_scratch scratch_window) ;
2930 (* signal handlers here *)
2931 ignore(output#connect#selection_changed
2933 choose_selection output elem ;
2934 !focus_and_proveit_set_sensitive true
2936 ignore (output#connect#click (show_in_show_window_callback output)) ;
2937 let settings_window = new settings_window output scrolled_window0
2938 (*export_to_postscript_menu_item*)() (choose_selection output) in
2939 set_settings_window settings_window ;
2940 set_outputhtml outputhtml ;
2941 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
2942 Logger.log_callback :=
2943 (Logger.log_to_html ~print_and_flush:(output_html outputhtml))
2948 let initialize_everything () =
2949 let module U = Unix in
2950 let output = TermViewer.proof_viewer ~width:350 ~height:280 () in
2951 let notebook = new notebook in
2952 let rendering_window' = new rendering_window output notebook in
2953 set_rendering_window rendering_window' ;
2954 let print_error_as_html prefix msg =
2955 output_html (outputhtml ())
2956 ("<h1 color=\"red\">" ^ prefix ^ msg ^ "</h1>")
2958 Gdome_xslt.setErrorCallback (Some (print_error_as_html "XSLT Error: "));
2959 Gdome_xslt.setDebugCallback
2960 (Some (print_error_as_html "XSLT Debug Message: "));
2961 rendering_window'#show () ;
2962 if restore_environment_on_boot && Sys.file_exists environmentfile then
2963 restore_environment ();
2968 ignore (GtkMain.Main.init ()) ;
2969 initialize_everything () ;
2970 MQIC.close mqi_handle(*;
2975 Sys.catch_break true;
2977 with Sys.Break -> () (* exit nicely, invoking at_exit functions *)