1 (* Copyright (C) 2000-2002, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 (******************************************************************************)
30 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
34 (******************************************************************************)
37 (* GLOBAL CONSTANTS *)
39 let xlinkns = Gdome.domString "http://www.w3.org/1999/xlink";;
43 " <body bgColor=\"white\">"
53 Sys.getenv "GTOPLEVEL_PROOFFILE"
55 Not_found -> "/public/currentproof"
60 Sys.getenv "GTOPLEVEL_PROOFFILETYPE"
62 Not_found -> "/public/currentprooftype"
65 let postgresqlconnectionstring =
67 Sys.getenv "POSTGRESQL_CONNECTION_STRING"
69 Not_found -> "host=mowgli.cs.unibo.it dbname=helm_mowgli_new_schema user=helm"
72 (* GLOBAL REFERENCES (USED BY CALLBACKS) *)
74 let htmlheader_and_content = ref htmlheader;;
76 let check_term = ref (fun _ _ _ -> assert false);;
78 exception RenderingWindowsNotInitialized;;
80 let set_rendering_window,rendering_window =
81 let rendering_window_ref = ref None in
82 (function rw -> rendering_window_ref := Some rw),
84 match !rendering_window_ref with
85 None -> raise RenderingWindowsNotInitialized
90 exception SettingsWindowsNotInitialized;;
92 let set_settings_window,settings_window =
93 let settings_window_ref = ref None in
94 (function rw -> settings_window_ref := Some rw),
96 match !settings_window_ref with
97 None -> raise SettingsWindowsNotInitialized
102 exception OutputHtmlNotInitialized;;
104 let set_outputhtml,outputhtml =
105 let outputhtml_ref = ref None in
106 (function rw -> outputhtml_ref := Some rw),
108 match !outputhtml_ref with
109 None -> raise OutputHtmlNotInitialized
110 | Some outputhtml -> outputhtml
114 exception QedSetSensitiveNotInitialized;;
115 let qed_set_sensitive =
116 ref (function _ -> raise QedSetSensitiveNotInitialized)
119 exception SaveSetSensitiveNotInitialized;;
120 let save_set_sensitive =
121 ref (function _ -> raise SaveSetSensitiveNotInitialized)
124 (* COMMAND LINE OPTIONS *)
130 "-nodb", Arg.Clear usedb, "disable use of MathQL DB"
133 Arg.parse argspec ignore ""
137 let term_of_cic_textual_parser_uri uri =
138 let module C = Cic in
139 let module CTP = CicTextualParser0 in
141 CTP.ConUri uri -> C.Const (uri,[])
142 | CTP.VarUri uri -> C.Var (uri,[])
143 | CTP.IndTyUri (uri,tyno) -> C.MutInd (uri,tyno,[])
144 | CTP.IndConUri (uri,tyno,consno) -> C.MutConstruct (uri,tyno,consno,[])
147 let string_of_cic_textual_parser_uri uri =
148 let module C = Cic in
149 let module CTP = CicTextualParser0 in
152 CTP.ConUri uri -> UriManager.string_of_uri uri
153 | CTP.VarUri uri -> UriManager.string_of_uri uri
154 | CTP.IndTyUri (uri,tyno) ->
155 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1)
156 | CTP.IndConUri (uri,tyno,consno) ->
157 UriManager.string_of_uri uri ^ "#1/" ^ string_of_int (tyno + 1) ^ "/" ^
160 (* 4 = String.length "cic:" *)
161 String.sub uri' 4 (String.length uri' - 4)
164 let output_html outputhtml msg =
165 htmlheader_and_content := !htmlheader_and_content ^ msg ;
166 outputhtml#source (!htmlheader_and_content ^ htmlfooter) ;
167 outputhtml#set_topline (-1)
170 (* UTILITY FUNCTIONS TO DISAMBIGUATE AN URI *)
174 let check_window outputhtml uris =
177 ~width:800 ~modal:true ~title:"Check" ~border_width:2 () in
179 GPack.notebook ~scrollable:true ~packing:window#add () in
184 let scrolled_window =
185 GBin.scrolled_window ~border_width:10
187 (notebook#append_page ~tab_label:((GMisc.label ~text:uri ())#coerce))
192 TermViewer.sequent_viewer
193 ~packing:scrolled_window#add ~width:400 ~height:280 () in
196 term_of_cic_textual_parser_uri
197 (Misc.cic_textual_parser_uri_of_string uri)
199 (Cic.Cast (term, CicTypeChecker.type_of_aux' [] [] term))
202 mmlwidget#load_sequent [] (111,[],expr)
205 output_html outputhtml
206 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
211 (notebook#connect#switch_page
212 (function i -> Lazy.force (List.nth render_terms i)))
218 interactive_user_uri_choice ~(selection_mode:[`SINGLE|`EXTENDED]) ?(ok="Ok")
219 ?(enable_button_for_non_vars=false) ~title ~msg uris
221 let choices = ref [] in
222 let chosen = ref false in
223 let use_only_constants = ref false in
225 GWindow.dialog ~modal:true ~title ~width:600 () in
227 GMisc.label ~text:msg
228 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
229 let scrolled_window =
230 GBin.scrolled_window ~border_width:10
231 ~packing:(window#vbox#pack ~expand:true ~fill:true ~padding:5) () in
233 let expected_height = 18 * List.length uris in
234 let height = if expected_height > 400 then 400 else expected_height in
235 GList.clist ~columns:1 ~packing:scrolled_window#add
236 ~height ~selection_mode:(selection_mode :> Gtk.Tags.selection_mode) () in
237 let _ = List.map (function x -> clist#append [x]) uris in
239 GPack.hbox ~border_width:0
240 ~packing:(window#vbox#pack ~expand:false ~fill:false ~padding:5) () in
242 GMisc.label ~text:"None of the above. Try this one:"
243 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
245 GEdit.entry ~editable:true
246 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
248 GPack.hbox ~border_width:0 ~packing:window#action_area#add () in
250 GButton.button ~label:ok
251 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
252 let _ = okb#misc#set_sensitive false in
257 if enable_button_for_non_vars then
258 hbox#pack ~expand:false ~fill:false ~padding:5 w)
259 ~label:"Try constants only" () in
261 GButton.button ~label:"Check"
262 ~packing:(hbox#pack ~padding:5) () in
263 let _ = checkb#misc#set_sensitive false in
265 GButton.button ~label:"Abort"
266 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
268 let check_callback () =
269 assert (List.length !choices > 0) ;
270 check_window (outputhtml ()) !choices
272 ignore (window#connect#destroy GMain.Main.quit) ;
273 ignore (cancelb#connect#clicked window#destroy) ;
275 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
277 (nonvarsb#connect#clicked
279 use_only_constants := true ;
283 ignore (checkb#connect#clicked check_callback) ;
285 (clist#connect#select_row
286 (fun ~row ~column ~event ->
287 checkb#misc#set_sensitive true ;
288 okb#misc#set_sensitive true ;
289 choices := (List.nth uris row)::!choices)) ;
291 (clist#connect#unselect_row
292 (fun ~row ~column ~event ->
294 List.filter (function uri -> uri != (List.nth uris row)) !choices)) ;
296 (manual_input#connect#changed
298 if manual_input#text = "" then
301 checkb#misc#set_sensitive false ;
302 okb#misc#set_sensitive false ;
303 clist#misc#set_sensitive true
307 choices := [manual_input#text] ;
308 clist#unselect_all () ;
309 checkb#misc#set_sensitive true ;
310 okb#misc#set_sensitive true ;
311 clist#misc#set_sensitive false
313 window#set_position `CENTER ;
317 if !use_only_constants then
319 (function uri -> not (String.sub uri (String.length uri - 4) 4 = ".var"))
322 if List.length !choices > 0 then !choices else raise NoChoice
327 let interactive_interpretation_choice interpretations =
328 let chosen = ref None in
331 ~modal:true ~title:"Ambiguous well-typed input." ~border_width:2 () in
332 let vbox = GPack.vbox ~packing:window#add () in
336 ("Ambiguous input since there are many well-typed interpretations." ^
337 " Please, choose one of them.")
338 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
340 GPack.notebook ~scrollable:true
341 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
344 (function interpretation ->
346 let expected_height = 18 * List.length interpretation in
347 let height = if expected_height > 400 then 400 else expected_height in
348 GList.clist ~columns:2 ~packing:notebook#append_page ~height
349 ~titles:["id" ; "URI"] ()
353 (function (id,uri) ->
354 let n = clist#append [id;uri] in
355 clist#set_row ~selectable:false n
358 clist#columns_autosize ()
361 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
363 GButton.button ~label:"Ok"
364 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
366 GButton.button ~label:"Abort"
367 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
369 ignore (window#connect#destroy GMain.Main.quit) ;
370 ignore (cancelb#connect#clicked window#destroy) ;
373 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
374 window#set_position `CENTER ;
378 None -> raise NoChoice
385 (* CSC: IMPERATIVE AND NOT VERY CLEAN, TO GET THE LAST ISSUED QUERY *)
386 (* FG : THIS FUNCTION IS BECOMING A REAL NONSENSE *)
388 let query = ref "" in
389 let out s = query := ! query ^ s in
390 MQueryGenerator.set_confirm_query
392 query := ""; MQueryUtil.text_of_query out q ""; true);
394 out (!query ^ " <h1>Result:</h1> "); MQueryUtil.text_of_result out result "<br>";
399 save_object_to_disk uri annobj ids_to_inner_sorts ids_to_inner_types pathname
402 let struri = UriManager.string_of_uri uri in
403 let idx = (String.rindex struri '/') + 1 in
404 String.sub struri idx (String.length struri - idx)
406 let path = pathname ^ "/" ^ name in
408 Cic2Xml.print_object uri ~ids_to_inner_sorts ~ask_dtd_to_the_getter:false
412 Cic2Xml.print_inner_types uri ~ids_to_inner_sorts ~ids_to_inner_types
413 ~ask_dtd_to_the_getter:false
416 let innertypesuri = UriManager.innertypesuri_of_uri uri in
417 Xml.pp ~quiet:true xmlinnertypes (Some (path ^ ".types.xml")) ;
418 Getter.register innertypesuri
419 (Configuration.annotations_url ^
420 Str.replace_first (Str.regexp "^cic:") ""
421 (UriManager.string_of_uri innertypesuri) ^ ".xml"
423 (* constant type / variable / mutual inductive types definition *)
424 Xml.pp ~quiet:true xml (Some (path ^ ".xml")) ;
426 (Configuration.annotations_url ^
427 Str.replace_first (Str.regexp "^cic:") ""
428 (UriManager.string_of_uri uri) ^ ".xml"
435 match UriManager.bodyuri_of_uri uri with
437 | Some bodyuri -> bodyuri
439 Xml.pp ~quiet:true bodyxml' (Some (path ^ ".body.xml")) ;
440 Getter.register bodyuri
441 (Configuration.annotations_url ^
442 Str.replace_first (Str.regexp "^cic:") ""
443 (UriManager.string_of_uri bodyuri) ^ ".xml"
451 ignore(domImpl#saveDocumentToFile ~doc:sequent_doc
452 ~name:"/home/galata/miohelm/guruguru1" ~indent:true ()) ;
455 exception OpenConjecturesStillThere;;
456 exception WrongProof;;
458 let pathname_of_annuri uristring =
459 Configuration.annotations_dir ^
460 Str.replace_first (Str.regexp "^cic:") "" uristring
463 let make_dirs dirpath =
464 ignore (Unix.system ("mkdir -p " ^ dirpath))
467 let save_obj uri obj =
469 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
470 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
472 Cic2acic.acic_object_of_cic_object obj
474 (* let's save the theorem and register it to the getter *)
475 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
477 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
482 match !ProofEngine.proof with
484 | Some (uri,[],bo,ty) ->
486 CicReduction.are_convertible []
487 (CicTypeChecker.type_of_aux' [] [] bo) ty
490 (*CSC: Wrong: [] is just plainly wrong *)
491 let proof = Cic.Constant (UriManager.name_of_uri uri,Some bo,ty,[]) in
492 let (acic,ids_to_inner_types,ids_to_inner_sorts) =
493 (rendering_window ())#output#load_proof uri proof
495 !qed_set_sensitive false ;
496 (* let's save the theorem and register it to the getter *)
497 let pathname = pathname_of_annuri (UriManager.buri_of_uri uri) in
499 save_object_to_disk uri acic ids_to_inner_sorts ids_to_inner_types
504 | _ -> raise OpenConjecturesStillThere
508 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
509 match !ProofEngine.proof with
511 | Some (uri, metasenv, bo, ty) ->
513 (*CSC: Wrong: [] is just plainly wrong *)
514 Cic.CurrentProof (UriManager.name_of_uri uri,metasenv,bo,ty,[])
516 let (acurrentproof,_,_,ids_to_inner_sorts,_,_,_) =
517 Cic2acic.acic_object_of_cic_object currentproof
521 Cic2Xml.print_object uri ~ids_to_inner_sorts
522 ~ask_dtd_to_the_getter:true acurrentproof
524 xml,Some bodyxml -> xml,bodyxml
525 | _,None -> assert false
527 Xml.pp ~quiet:true xml (Some prooffiletype) ;
528 output_html outputhtml
529 ("<h1 color=\"Green\">Current proof type saved to " ^
530 prooffiletype ^ "</h1>") ;
531 Xml.pp ~quiet:true bodyxml (Some prooffile) ;
532 output_html outputhtml
533 ("<h1 color=\"Green\">Current proof body saved to " ^
537 (* Used to typecheck the loaded proofs *)
538 let typecheck_loaded_proof metasenv bo ty =
539 let module T = CicTypeChecker in
542 (fun metasenv ((_,context,ty) as conj) ->
543 ignore (T.type_of_aux' metasenv context ty) ;
546 ignore (T.type_of_aux' metasenv [] ty) ;
547 ignore (T.type_of_aux' metasenv [] bo)
550 let decompose_uris_choice_callback uris =
551 (* N.B.: in questo passaggio perdo l'informazione su exp_named_subst !!!! *)
552 let module U = UriManager in
555 match Misc.cic_textual_parser_uri_of_string uri with
556 CicTextualParser0.IndTyUri (uri,typeno) -> (uri,typeno,[])
558 (interactive_user_uri_choice
559 ~selection_mode:`EXTENDED ~ok:"Ok" ~enable_button_for_non_vars:false
560 ~title:"Decompose" ~msg:"Please, select the Inductive Types to decompose"
562 (function (uri,typeno,_) ->
563 U.string_of_uri uri ^ "#1/" ^ string_of_int (typeno+1)
568 let mk_fresh_name_callback context name ~typ =
570 match ProofEngineHelpers.mk_fresh_name context name ~typ with
571 Cic.Name fresh_name -> fresh_name
572 | Cic.Anonymous -> assert false
575 GToolbox.input_string ~title:"Enter a fresh hypothesis name" ~text:fresh_name
576 ("Enter a fresh name for the hypothesis " ^
578 (List.map (function None -> None | Some (n,_) -> Some n) context))
580 Some fresh_name' -> Cic.Name fresh_name'
581 | None -> raise NoChoice
584 let refresh_proof (output : TermViewer.proof_viewer) =
586 let uri,currentproof =
587 match !ProofEngine.proof with
589 | Some (uri,metasenv,bo,ty) ->
590 !qed_set_sensitive (List.length metasenv = 0) ;
591 (*CSC: Wrong: [] is just plainly wrong *)
593 (Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, []))
595 ignore (output#load_proof uri currentproof)
598 match !ProofEngine.proof with
600 | Some (uri,metasenv,bo,ty) ->
601 prerr_endline ("Offending proof: " ^ CicPp.ppobj (Cic.CurrentProof ("questa",metasenv,bo,ty,[]))) ; flush stderr ;
602 raise (InvokeTactics.RefreshProofException e)
604 let refresh_goals ?(empty_notebook=true) notebook =
606 match !ProofEngine.goal with
608 if empty_notebook then
610 notebook#remove_all_pages ~skip_switch_page_event:false ;
611 notebook#set_empty_page
614 notebook#proofw#unload
617 match !ProofEngine.proof with
619 | Some (_,metasenv,_,_) -> metasenv
622 List.find (function (m,_,_) -> m=metano) metasenv
624 let regenerate_notebook () =
625 let skip_switch_page_event =
627 (m,_,_)::_ when m = metano -> false
630 notebook#remove_all_pages ~skip_switch_page_event ;
631 List.iter (function (m,_,_) -> notebook#add_page m) metasenv ;
633 if empty_notebook then
635 regenerate_notebook () ;
636 notebook#set_current_page
637 ~may_skip_switch_page_event:false metano
641 notebook#set_current_page
642 ~may_skip_switch_page_event:true metano ;
643 notebook#proofw#load_sequent metasenv currentsequent
648 match !ProofEngine.goal with
653 match !ProofEngine.proof with
655 | Some (_,metasenv,_,_) -> metasenv
658 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
659 prerr_endline ("Offending sequent: " ^ SequentPp.TextualPp.print_sequent currentsequent) ; flush stderr ;
660 raise (InvokeTactics.RefreshSequentException e)
661 with Not_found -> prerr_endline ("Offending sequent " ^ string_of_int metano ^ " unknown."); raise (InvokeTactics.RefreshSequentException e)
664 module InvokeTacticsCallbacks =
666 let sequent_viewer () = (rendering_window ())#notebook#proofw
667 let term_editor () = (rendering_window ())#inputt
668 let scratch_window () = (rendering_window ())#scratch_window
670 let refresh_proof () =
671 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
674 let refresh_goals () =
675 let notebook = (rendering_window ())#notebook in
676 refresh_goals notebook
678 let decompose_uris_choice_callback = decompose_uris_choice_callback
679 let mk_fresh_name_callback = mk_fresh_name_callback
680 let output_html msg = output_html (outputhtml ()) msg
684 module InvokeTactics' = InvokeTactics.Make(InvokeTacticsCallbacks);;
688 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
689 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
690 let notebook = (rendering_window ())#notebook in
693 GToolbox.input_string ~title:"Load Unfinished Proof" ~text:"/dummy.con"
696 None -> raise NoChoice
698 let uri = UriManager.uri_of_string ("cic:" ^ uri0) in
699 match CicParser.obj_of_xml prooffiletype (Some prooffile) with
700 Cic.CurrentProof (_,metasenv,bo,ty,_) ->
701 typecheck_loaded_proof metasenv bo ty ;
703 Some (uri, metasenv, bo, ty) ;
707 | (metano,_,_)::_ -> Some metano
709 refresh_proof output ;
710 refresh_goals notebook ;
711 output_html outputhtml
712 ("<h1 color=\"Green\">Current proof type loaded from " ^
713 prooffiletype ^ "</h1>") ;
714 output_html outputhtml
715 ("<h1 color=\"Green\">Current proof body loaded from " ^
716 prooffile ^ "</h1>") ;
717 !save_set_sensitive true
720 InvokeTactics.RefreshSequentException e ->
721 output_html outputhtml
722 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
723 "sequent: " ^ Printexc.to_string e ^ "</h1>")
724 | InvokeTactics.RefreshProofException e ->
725 output_html outputhtml
726 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
727 "proof: " ^ Printexc.to_string e ^ "</h1>")
729 output_html outputhtml
730 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
733 let edit_aliases () =
734 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
735 let id_to_uris = inputt#id_to_uris in
736 let chosen = ref false in
739 ~width:400 ~modal:true ~title:"Edit Aliases..." ~border_width:2 () in
741 GPack.vbox ~border_width:0 ~packing:window#add () in
742 let scrolled_window =
743 GBin.scrolled_window ~border_width:10
744 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
745 let input = GEdit.text ~editable:true ~width:400 ~height:100
746 ~packing:scrolled_window#add () in
748 GPack.hbox ~border_width:0
749 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
751 GButton.button ~label:"Ok"
752 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
754 GButton.button ~label:"Cancel"
755 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
756 ignore (window#connect#destroy GMain.Main.quit) ;
757 ignore (cancelb#connect#clicked window#destroy) ;
759 (okb#connect#clicked (function () -> chosen := true ; window#destroy ())) ;
760 let dom,resolve_id = !id_to_uris in
762 (input#insert_text ~pos:0
767 match resolve_id v with
772 (string_of_cic_textual_parser_uri uri)
778 let inputtext = input#get_chars 0 input#length in
780 let alfa = "[a-zA-Z_-]" in
781 let digit = "[0-9]" in
782 let ident = alfa ^ "\(" ^ alfa ^ "\|" ^ digit ^ "\)*" in
783 let blanks = "\( \|\t\|\n\)+" in
784 let nonblanks = "[^ \t\n]+" in
785 let uri = "/\(" ^ ident ^ "/\)*" ^ nonblanks in (* not very strict check *)
787 ("alias" ^ blanks ^ "\(" ^ ident ^ "\)" ^ blanks ^ "\(" ^ uri ^ "\)")
791 let n' = Str.search_forward regexpr inputtext n in
792 let id = Str.matched_group 2 inputtext in
794 Misc.cic_textual_parser_uri_of_string
795 ("cic:" ^ (Str.matched_group 5 inputtext))
797 let dom,resolve_id = aux (n' + 1) in
798 if List.mem id dom then
802 (function id' -> if id = id' then Some uri else resolve_id id')
804 Not_found -> TermEditor.empty_id_to_uris
808 id_to_uris := (dom,resolve_id)
812 let module L = LogicalOperations in
813 let module G = Gdome in
814 let notebook = (rendering_window ())#notebook in
815 let output = (rendering_window ())#output in
816 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
818 output#make_sequent_of_selected_term ;
819 refresh_proof output ;
820 refresh_goals notebook
822 InvokeTactics.RefreshSequentException e ->
823 output_html outputhtml
824 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
825 "sequent: " ^ Printexc.to_string e ^ "</h1>")
826 | InvokeTactics.RefreshProofException e ->
827 output_html outputhtml
828 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
829 "proof: " ^ Printexc.to_string e ^ "</h1>")
831 output_html outputhtml
832 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
836 let module L = LogicalOperations in
837 let module G = Gdome in
838 let notebook = (rendering_window ())#notebook in
839 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
840 let output = (rendering_window ())#output in
842 output#focus_sequent_of_selected_term ;
843 refresh_goals notebook
845 InvokeTactics.RefreshSequentException e ->
846 output_html outputhtml
847 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
848 "sequent: " ^ Printexc.to_string e ^ "</h1>")
849 | InvokeTactics.RefreshProofException e ->
850 output_html outputhtml
851 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
852 "proof: " ^ Printexc.to_string e ^ "</h1>")
854 output_html outputhtml
855 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
858 exception NoPrevGoal;;
859 exception NoNextGoal;;
862 let module L = LogicalOperations in
863 let module G = Gdome in
864 let notebook = (rendering_window ())#notebook in
865 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
867 match !ProofEngine.proof with
869 | Some (_,metasenv,_,_) -> metasenv
872 refresh_goals ~empty_notebook:false notebook
874 InvokeTactics.RefreshSequentException e ->
875 output_html outputhtml
876 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
877 "sequent: " ^ Printexc.to_string e ^ "</h1>")
879 output_html outputhtml
880 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
884 show_in_show_window_obj, show_in_show_window_uri, show_in_show_window_callback
887 GWindow.window ~width:800 ~border_width:2 () in
888 let scrolled_window =
889 GBin.scrolled_window ~border_width:10 ~packing:window#add () in
891 GMathViewAux.single_selection_math_view ~packing:scrolled_window#add ~width:600 ~height:400 () in
892 let _ = window#event#connect#delete (fun _ -> window#misc#hide () ; true ) in
893 let href = Gdome.domString "href" in
894 let show_in_show_window_obj uri obj =
895 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
898 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
899 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
901 Cic2acic.acic_object_of_cic_object obj
904 ApplyStylesheets.mml_of_cic_object
905 ~explode_all:false uri acic ids_to_inner_sorts ids_to_inner_types
907 window#set_title (UriManager.string_of_uri uri) ;
908 window#misc#hide () ; window#show () ;
909 mmlwidget#load_doc mml ;
912 output_html outputhtml
913 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
915 let show_in_show_window_uri uri =
916 let obj = CicEnvironment.get_obj uri in
917 show_in_show_window_obj uri obj
919 let show_in_show_window_callback mmlwidget (n : Gdome.element) _ =
920 if n#hasAttributeNS ~namespaceURI:xlinkns ~localName:href then
922 (n#getAttributeNS ~namespaceURI:xlinkns ~localName:href)#to_string
924 show_in_show_window_uri (UriManager.uri_of_string uri)
926 ignore (mmlwidget#action_toggle n)
929 mmlwidget#connect#click (show_in_show_window_callback mmlwidget)
931 show_in_show_window_obj, show_in_show_window_uri,
932 show_in_show_window_callback
935 exception NoObjectsLocated;;
937 let user_uri_choice ~title ~msg uris =
940 [] -> raise NoObjectsLocated
944 interactive_user_uri_choice ~selection_mode:`SINGLE ~title ~msg uris
949 String.sub uri 4 (String.length uri - 4)
952 let locate_callback id =
953 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
954 let result = MQueryGenerator.locate id in
958 Misc.wrong_xpointer_format_from_wrong_xpointer_format' uri)
961 (" <h1>Locate Query: </h1><pre>" ^ get_last_query result ^ "</pre>")
963 output_html outputhtml html ;
964 user_uri_choice ~title:"Ambiguous input."
966 ("Ambiguous input \"" ^ id ^
967 "\". Please, choose one interpetation:")
972 let input_or_locate_uri ~title =
973 let uri = ref None in
976 ~width:400 ~modal:true ~title ~border_width:2 () in
977 let vbox = GPack.vbox ~packing:window#add () in
979 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
981 GMisc.label ~text:"Enter a valid URI:" ~packing:(hbox1#pack ~padding:5) () in
983 GEdit.entry ~editable:true
984 ~packing:(hbox1#pack ~expand:true ~fill:true ~padding:5) () in
986 GButton.button ~label:"Check"
987 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
988 let _ = checkb#misc#set_sensitive false in
990 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
992 GMisc.label ~text:"You can also enter an indentifier to locate:"
993 ~packing:(hbox2#pack ~padding:5) () in
995 GEdit.entry ~editable:true
996 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
998 GButton.button ~label:"Locate"
999 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1000 let _ = locateb#misc#set_sensitive false in
1002 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1004 GButton.button ~label:"Ok"
1005 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1006 let _ = okb#misc#set_sensitive false in
1008 GButton.button ~label:"Cancel"
1009 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) ()
1011 ignore (window#connect#destroy GMain.Main.quit) ;
1013 (cancelb#connect#clicked (function () -> uri := None ; window#destroy ())) ;
1014 let check_callback () =
1015 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1016 let uri = "cic:" ^ manual_input#text in
1018 ignore (Getter.resolve (UriManager.uri_of_string uri)) ;
1019 output_html outputhtml "<h1 color=\"Green\">OK</h1>" ;
1022 Getter.Unresolved ->
1023 output_html outputhtml
1024 ("<h1 color=\"Red\">URI " ^ uri ^
1025 " does not correspond to any object.</h1>") ;
1027 | UriManager.IllFormedUri _ ->
1028 output_html outputhtml
1029 ("<h1 color=\"Red\">URI " ^ uri ^ " is not well-formed.</h1>") ;
1032 output_html outputhtml
1033 ("<h1 color=\"Red\">" ^ Printexc.to_string e ^ "</h1>") ;
1037 (okb#connect#clicked
1039 if check_callback () then
1041 uri := Some manual_input#text ;
1045 ignore (checkb#connect#clicked (function () -> ignore (check_callback ()))) ;
1047 (manual_input#connect#changed
1049 if manual_input#text = "" then
1051 checkb#misc#set_sensitive false ;
1052 okb#misc#set_sensitive false
1056 checkb#misc#set_sensitive true ;
1057 okb#misc#set_sensitive true
1060 (locate_input#connect#changed
1061 (fun _ -> locateb#misc#set_sensitive (locate_input#text <> ""))) ;
1063 (locateb#connect#clicked
1065 let id = locate_input#text in
1066 manual_input#set_text (locate_callback id) ;
1067 locate_input#delete_text 0 (String.length id)
1070 GMain.Main.main () ;
1072 None -> raise NoChoice
1073 | Some uri -> UriManager.uri_of_string ("cic:" ^ uri)
1076 exception AmbiguousInput;;
1078 (* A WIDGET TO ENTER CIC TERMS *)
1082 let output_html msg = output_html (outputhtml ()) msg;;
1083 let interactive_user_uri_choice =
1084 fun ~selection_mode ?ok ?enable_button_for_non_vars ~title ~msg ~id ->
1085 interactive_user_uri_choice ~selection_mode ?ok
1086 ?enable_button_for_non_vars ~title ~msg;;
1087 let interactive_interpretation_choice = interactive_interpretation_choice;;
1088 let input_or_locate_uri = input_or_locate_uri;;
1092 module TermEditor' = TermEditor.Make(Callbacks);;
1094 (* OTHER FUNCTIONS *)
1097 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1098 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1101 GToolbox.input_string ~title:"Locate" "Enter an identifier to locate:"
1103 None -> raise NoChoice
1105 let uri = locate_callback input in
1109 output_html outputhtml
1110 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
1114 exception UriAlreadyInUse;;
1115 exception NotAUriToAConstant;;
1117 let new_inductive () =
1118 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1119 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1120 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1121 let notebook = (rendering_window ())#notebook in
1123 let chosen = ref false in
1124 let inductive = ref true in
1125 let paramsno = ref 0 in
1126 let get_uri = ref (function _ -> assert false) in
1127 let get_base_uri = ref (function _ -> assert false) in
1128 let get_names = ref (function _ -> assert false) in
1129 let get_types_and_cons = ref (function _ -> assert false) in
1130 let get_context_and_subst = ref (function _ -> assert false) in
1133 ~width:600 ~modal:true ~position:`CENTER
1134 ~title:"New Block of Mutual (Co)Inductive Definitions"
1135 ~border_width:2 () in
1136 let vbox = GPack.vbox ~packing:window#add () in
1138 GPack.hbox ~border_width:0
1139 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1141 GMisc.label ~text:"Enter the URI for the new block:"
1142 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1144 GEdit.entry ~editable:true
1145 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1147 GPack.hbox ~border_width:0
1148 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1152 "Enter the number of left parameters in every arity and constructor type:"
1153 ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1154 let paramsno_entry =
1155 GEdit.entry ~editable:true ~text:"0"
1156 ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
1158 GPack.hbox ~border_width:0
1159 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1161 GMisc.label ~text:"Are the definitions inductive or coinductive?"
1162 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1164 GButton.radio_button ~label:"Inductive"
1165 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1167 GButton.radio_button ~label:"Coinductive"
1168 ~group:inductiveb#group
1169 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1171 GPack.hbox ~border_width:0
1172 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1174 GMisc.label ~text:"Enter the list of the names of the types:"
1175 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1177 GEdit.entry ~editable:true
1178 ~packing:(hbox2#pack ~expand:true ~fill:true ~padding:5) () in
1180 GPack.hbox ~border_width:0
1181 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1183 GButton.button ~label:"> Next"
1184 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1185 let _ = okb#misc#set_sensitive true in
1187 GButton.button ~label:"Abort"
1188 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1189 ignore (window#connect#destroy GMain.Main.quit) ;
1190 ignore (cancelb#connect#clicked window#destroy) ;
1194 (okb#connect#clicked
1197 let uristr = "cic:" ^ uri_entry#text in
1198 let namesstr = names_entry#text in
1199 let paramsno' = int_of_string (paramsno_entry#text) in
1200 match Str.split (Str.regexp " +") namesstr with
1202 | (he::tl) as names ->
1203 let uri = UriManager.uri_of_string (uristr ^ "/" ^ he ^ ".ind") in
1206 ignore (Getter.resolve uri) ;
1207 raise UriAlreadyInUse
1209 Getter.Unresolved ->
1210 get_uri := (function () -> uri) ;
1211 get_names := (function () -> names) ;
1212 inductive := inductiveb#active ;
1213 paramsno := paramsno' ;
1218 output_html outputhtml
1219 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1227 GBin.frame ~label:name
1228 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1229 let vbox = GPack.vbox ~packing:frame#add () in
1230 let hbox = GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false) () in
1232 GMisc.label ~text:("Enter its type:")
1233 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1234 let scrolled_window =
1235 GBin.scrolled_window ~border_width:5
1236 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1238 TermEditor'.term_editor
1239 ~width:400 ~height:20 ~packing:scrolled_window#add
1240 ~share_id_to_uris_with:inputt ()
1241 ~isnotempty_callback:
1243 (*non_empty_type := b ;*)
1244 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*)
1247 GPack.hbox ~border_width:0
1248 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1250 GMisc.label ~text:("Enter the list of its constructors:")
1251 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1252 let cons_names_entry =
1253 GEdit.entry ~editable:true
1254 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1255 (newinputt,cons_names_entry)
1258 vbox#remove hboxn#coerce ;
1260 GPack.hbox ~border_width:0
1261 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1263 GButton.button ~label:"> Next"
1264 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1266 GButton.button ~label:"Abort"
1267 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1268 ignore (cancelb#connect#clicked window#destroy) ;
1270 (okb#connect#clicked
1273 let names = !get_names () in
1274 let types_and_cons =
1276 (fun name (newinputt,cons_names_entry) ->
1277 let consnamesstr = cons_names_entry#text in
1278 let cons_names = Str.split (Str.regexp " +") consnamesstr in
1280 newinputt#get_metasenv_and_term ~context:[] ~metasenv:[]
1283 [] -> expr,cons_names
1284 | _ -> raise AmbiguousInput
1285 ) names type_widgets
1287 let uri = !get_uri () in
1289 (* Let's see if so far the definition is well-typed *)
1292 (* To test if the arities of the inductive types are well *)
1293 (* typed, we check the inductive block definition where *)
1294 (* no constructor is given to each type. *)
1297 (fun name (ty,cons) -> (name, !inductive, ty, []))
1298 names types_and_cons
1300 CicTypeChecker.typecheck_mutual_inductive_defs uri
1301 (tys,params,paramsno)
1303 get_context_and_subst :=
1307 (fun (context,subst) name (ty,_) ->
1309 (Some (Cic.Name name, Cic.Decl ty))::context,
1310 (Cic.MutInd (uri,!i,[]))::subst
1313 ) ([],[]) names types_and_cons) ;
1314 let types_and_cons' =
1316 (fun name (ty,cons) -> (name, !inductive, ty, phase3 name cons))
1317 names types_and_cons
1319 get_types_and_cons := (function () -> types_and_cons') ;
1324 output_html outputhtml
1325 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1328 and phase3 name cons =
1329 let get_cons_types = ref (function () -> assert false) in
1332 ~width:600 ~modal:true ~position:`CENTER
1333 ~title:(name ^ " Constructors")
1334 ~border_width:2 () in
1335 let vbox = GPack.vbox ~packing:window2#add () in
1336 let cons_type_widgets =
1338 (function consname ->
1340 GPack.hbox ~border_width:0
1341 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1343 GMisc.label ~text:("Enter the type of " ^ consname ^ ":")
1344 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1345 let scrolled_window =
1346 GBin.scrolled_window ~border_width:5
1347 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1349 TermEditor'.term_editor
1350 ~width:400 ~height:20 ~packing:scrolled_window#add
1351 ~share_id_to_uris_with:inputt ()
1352 ~isnotempty_callback:
1354 (* (*non_empty_type := b ;*)
1355 okb#misc#set_sensitive true) (*(b && uri_entry#text <> ""))*) *)())
1360 GPack.hbox ~border_width:0
1361 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1363 GButton.button ~label:"> Next"
1364 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1365 let _ = okb#misc#set_sensitive true in
1367 GButton.button ~label:"Abort"
1368 ~packing:(hboxn#pack ~expand:false ~fill:false ~padding:5) () in
1369 ignore (window2#connect#destroy GMain.Main.quit) ;
1370 ignore (cancelb#connect#clicked window2#destroy) ;
1372 (okb#connect#clicked
1376 let context,subst= !get_context_and_subst () in
1381 inputt#get_metasenv_and_term ~context ~metasenv:[]
1385 let undebrujined_expr =
1387 (fun expr t -> CicSubstitution.subst t expr) expr subst
1389 name, undebrujined_expr
1390 | _ -> raise AmbiguousInput
1391 ) cons cons_type_widgets
1393 get_cons_types := (function () -> cons_types) ;
1397 output_html outputhtml
1398 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1401 GMain.Main.main () ;
1402 let okb_pressed = !chosen in
1404 if (not okb_pressed) then
1407 assert false (* The control never reaches this point *)
1410 (!get_cons_types ())
1413 (* No more phases left or Abort pressed *)
1415 GMain.Main.main () ;
1419 let uri = !get_uri () in
1422 let tys = !get_types_and_cons () in
1423 let obj = Cic.InductiveDefinition tys params !paramsno in
1426 prerr_endline (CicPp.ppobj obj) ;
1427 CicTypeChecker.typecheck_mutual_inductive_defs uri
1428 (tys,params,!paramsno) ;
1431 prerr_endline "Offending mutual (co)inductive type declaration:" ;
1432 prerr_endline (CicPp.ppobj obj) ;
1434 (* We already know that obj is well-typed. We need to add it to the *)
1435 (* environment in order to compute the inner-types without having to *)
1436 (* debrujin it or having to modify lots of other functions to avoid *)
1437 (* asking the environment for the MUTINDs we are defining now. *)
1438 CicEnvironment.put_inductive_definition uri obj ;
1440 show_in_show_window_obj uri obj
1443 output_html outputhtml
1444 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1448 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1449 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1450 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1451 let notebook = (rendering_window ())#notebook in
1453 let chosen = ref false in
1454 let get_metasenv_and_term = ref (function _ -> assert false) in
1455 let get_uri = ref (function _ -> assert false) in
1456 let non_empty_type = ref false in
1459 ~width:600 ~modal:true ~title:"New Proof or Definition"
1460 ~border_width:2 () in
1461 let vbox = GPack.vbox ~packing:window#add () in
1463 GPack.hbox ~border_width:0
1464 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1466 GMisc.label ~text:"Enter the URI for the new theorem or definition:"
1467 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1469 GEdit.entry ~editable:true
1470 ~packing:(hbox#pack ~expand:true ~fill:true ~padding:5) () in
1472 GPack.hbox ~border_width:0
1473 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1475 GMisc.label ~text:"Enter the theorem or definition type:"
1476 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1477 let scrolled_window =
1478 GBin.scrolled_window ~border_width:5
1479 ~packing:(vbox#pack ~expand:true ~padding:0) () in
1480 (* the content of the scrolled_window is moved below (see comment) *)
1482 GPack.hbox ~border_width:0
1483 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1485 GButton.button ~label:"Ok"
1486 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1487 let _ = okb#misc#set_sensitive false in
1489 GButton.button ~label:"Cancel"
1490 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1491 (* moved here to have visibility of the ok button *)
1493 TermEditor'.term_editor ~width:400 ~height:100 ~packing:scrolled_window#add
1494 ~share_id_to_uris_with:inputt ()
1495 ~isnotempty_callback:
1497 non_empty_type := b ;
1498 okb#misc#set_sensitive (b && uri_entry#text <> ""))
1501 newinputt#set_term inputt#get_as_string ;
1504 uri_entry#connect#changed
1506 okb#misc#set_sensitive (!non_empty_type && uri_entry#text <> ""))
1508 ignore (window#connect#destroy GMain.Main.quit) ;
1509 ignore (cancelb#connect#clicked window#destroy) ;
1511 (okb#connect#clicked
1515 let metasenv,parsed = newinputt#get_metasenv_and_term [] [] in
1516 let uristr = "cic:" ^ uri_entry#text in
1517 let uri = UriManager.uri_of_string uristr in
1518 if String.sub uristr (String.length uristr - 4) 4 <> ".con" then
1519 raise NotAUriToAConstant
1523 ignore (Getter.resolve uri) ;
1524 raise UriAlreadyInUse
1526 Getter.Unresolved ->
1527 get_metasenv_and_term := (function () -> metasenv,parsed) ;
1528 get_uri := (function () -> uri) ;
1533 output_html outputhtml
1534 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1537 GMain.Main.main () ;
1540 let metasenv,expr = !get_metasenv_and_term () in
1541 let _ = CicTypeChecker.type_of_aux' metasenv [] expr in
1542 ProofEngine.proof :=
1543 Some (!get_uri (), (1,[],expr)::metasenv, Cic.Meta (1,[]), expr) ;
1544 ProofEngine.goal := Some 1 ;
1545 refresh_goals notebook ;
1546 refresh_proof output ;
1547 !save_set_sensitive true ;
1549 ProofEngine.intros ~mk_fresh_name_callback () ;
1550 refresh_goals notebook ;
1551 refresh_proof output
1553 InvokeTactics.RefreshSequentException e ->
1554 output_html outputhtml
1555 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1556 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1557 | InvokeTactics.RefreshProofException e ->
1558 output_html outputhtml
1559 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1560 "proof: " ^ Printexc.to_string e ^ "</h1>")
1562 output_html outputhtml
1563 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1566 let check_term_in_scratch scratch_window metasenv context expr =
1568 let ty = CicTypeChecker.type_of_aux' metasenv context expr in
1569 let expr = Cic.Cast (expr,ty) in
1570 scratch_window#show () ;
1571 scratch_window#set_term expr ;
1572 scratch_window#set_context context ;
1573 scratch_window#set_metasenv metasenv ;
1574 scratch_window#sequent_viewer#load_sequent metasenv (111,context,expr)
1577 print_endline ("? " ^ CicPp.ppterm expr) ;
1581 let check scratch_window () =
1582 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1583 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1585 match !ProofEngine.proof with
1587 | Some (_,metasenv,_,_) -> metasenv
1590 match !ProofEngine.goal with
1593 let (_,canonical_context,_) =
1594 List.find (function (m,_,_) -> m=metano) metasenv
1599 let metasenv',expr = inputt#get_metasenv_and_term context metasenv in
1600 check_term_in_scratch scratch_window metasenv' context expr
1603 output_html outputhtml
1604 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1608 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1610 show_in_show_window_uri (input_or_locate_uri ~title:"Show")
1613 output_html outputhtml
1614 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1617 exception NotADefinition;;
1620 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1621 let output = ((rendering_window ())#output : TermViewer.proof_viewer) in
1622 let notebook = (rendering_window ())#notebook in
1624 let uri = input_or_locate_uri ~title:"Open" in
1625 CicTypeChecker.typecheck uri ;
1626 let metasenv,bo,ty =
1627 match CicEnvironment.get_cooked_obj uri with
1628 Cic.Constant (_,Some bo,ty,_) -> [],bo,ty
1629 | Cic.CurrentProof (_,metasenv,bo,ty,_) -> metasenv,bo,ty
1632 | Cic.InductiveDefinition _ -> raise NotADefinition
1634 ProofEngine.proof :=
1635 Some (uri, metasenv, bo, ty) ;
1636 ProofEngine.goal := None ;
1637 refresh_goals notebook ;
1638 refresh_proof output
1640 InvokeTactics.RefreshSequentException e ->
1641 output_html outputhtml
1642 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1643 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1644 | InvokeTactics.RefreshProofException e ->
1645 output_html outputhtml
1646 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1647 "proof: " ^ Printexc.to_string e ^ "</h1>")
1649 output_html outputhtml
1650 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1653 let show_query_results results =
1656 ~modal:false ~title:"Query results." ~border_width:2 () in
1657 let vbox = GPack.vbox ~packing:window#add () in
1659 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1662 ~text:"Click on a URI to show that object"
1663 ~packing:hbox#add () in
1664 let scrolled_window =
1665 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1666 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1667 let clist = GList.clist ~columns:1 ~packing:scrolled_window#add () in
1670 (function (uri,_) ->
1674 clist#set_row ~selectable:false n
1677 clist#columns_autosize () ;
1679 (clist#connect#select_row
1680 (fun ~row ~column ~event ->
1681 let (uristr,_) = List.nth results row in
1683 Misc.cic_textual_parser_uri_of_string
1684 (Misc.wrong_xpointer_format_from_wrong_xpointer_format'
1687 CicTextualParser0.ConUri uri
1688 | CicTextualParser0.VarUri uri
1689 | CicTextualParser0.IndTyUri (uri,_)
1690 | CicTextualParser0.IndConUri (uri,_,_) ->
1691 show_in_show_window_uri uri
1697 let refine_constraints (must_obj,must_rel,must_sort) =
1698 let chosen = ref false in
1699 let use_only = ref false in
1702 ~modal:true ~title:"Constraints refinement."
1703 ~width:800 ~border_width:2 () in
1704 let vbox = GPack.vbox ~packing:window#add () in
1706 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1709 ~text: "\"Only\" constraints can be enforced or not."
1710 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1712 GButton.toggle_button ~label:"Enforce \"only\" constraints"
1713 ~active:false ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1716 (onlyb#connect#toggled (function () -> use_only := onlyb#active)) ;
1717 (* Notebook for the constraints choice *)
1719 GPack.notebook ~scrollable:true
1720 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1721 (* Rel constraints *)
1724 ~text: "Constraints on Rels" () in
1726 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1729 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1732 ~text: "You can now specify the constraints on Rels."
1733 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1734 let expected_height = 25 * (List.length must_rel + 2) in
1735 let height = if expected_height > 400 then 400 else expected_height in
1736 let scrolled_window =
1737 GBin.scrolled_window ~border_width:10 ~height ~width:600
1738 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1739 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1740 let rel_constraints =
1742 (function (position,depth) ->
1745 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1749 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1751 None -> position, ref None
1753 let mutable_ref = ref (Some depth') in
1755 GButton.toggle_button
1756 ~label:("depth = " ^ string_of_int depth') ~active:true
1757 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1760 (depthb#connect#toggled
1762 let sel_depth = if depthb#active then Some depth' else None in
1763 mutable_ref := sel_depth
1765 position, mutable_ref
1767 (* Sort constraints *)
1770 ~text: "Constraints on Sorts" () in
1772 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1775 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1778 ~text: "You can now specify the constraints on Sorts."
1779 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1780 let expected_height = 25 * (List.length must_sort + 2) in
1781 let height = if expected_height > 400 then 400 else expected_height in
1782 let scrolled_window =
1783 GBin.scrolled_window ~border_width:10 ~height ~width:600
1784 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1785 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1786 let sort_constraints =
1788 (function (position,depth,sort) ->
1791 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1794 ~text:(sort ^ " " ^ position)
1795 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1797 None -> position, ref None, sort
1799 let mutable_ref = ref (Some depth') in
1801 GButton.toggle_button ~label:("depth = " ^ string_of_int depth')
1803 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1806 (depthb#connect#toggled
1808 let sel_depth = if depthb#active then Some depth' else None in
1809 mutable_ref := sel_depth
1811 position, mutable_ref, sort
1813 (* Obj constraints *)
1816 ~text: "Constraints on constants" () in
1818 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce)
1821 GPack.hbox ~packing:(vbox'#pack ~expand:false ~fill:false ~padding:5) () in
1824 ~text: "You can now specify the constraints on constants."
1825 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1826 let expected_height = 25 * (List.length must_obj + 2) in
1827 let height = if expected_height > 400 then 400 else expected_height in
1828 let scrolled_window =
1829 GBin.scrolled_window ~border_width:10 ~height ~width:600
1830 ~packing:(vbox'#pack ~expand:true ~fill:true ~padding:5) () in
1831 let scrolled_vbox = GPack.vbox ~packing:scrolled_window#add_with_viewport () in
1832 let obj_constraints =
1834 (function (uri,position,depth) ->
1837 ~packing:(scrolled_vbox#pack ~expand:false ~fill:false ~padding:5) () in
1840 ~text:(uri ^ " " ^ position)
1841 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1843 None -> uri, position, ref None
1845 let mutable_ref = ref (Some depth') in
1847 GButton.toggle_button ~label:("depth = " ^ string_of_int depth')
1849 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1852 (depthb#connect#toggled
1854 let sel_depth = if depthb#active then Some depth' else None in
1855 mutable_ref := sel_depth
1857 uri, position, mutable_ref
1859 (* Confirm/abort buttons *)
1861 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1863 GButton.button ~label:"Ok"
1864 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1866 GButton.button ~label:"Abort"
1867 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) ()
1869 ignore (window#connect#destroy GMain.Main.quit) ;
1870 ignore (cancelb#connect#clicked window#destroy) ;
1872 (okb#connect#clicked (function () -> chosen := true ; window#destroy ()));
1873 window#set_position `CENTER ;
1875 GMain.Main.main () ;
1877 let chosen_must_rel =
1879 (function (position,ref_depth) -> position,!ref_depth) rel_constraints in
1880 let chosen_must_sort =
1882 (function (position,ref_depth,sort) -> position,!ref_depth,sort)
1885 let chosen_must_obj =
1887 (function (uri,position,ref_depth) -> uri,position,!ref_depth)
1890 (chosen_must_obj,chosen_must_rel,chosen_must_sort),
1892 (*CSC: ???????????????????????? I assume that must and only are the same... *)
1893 Some chosen_must_obj,Some chosen_must_rel,Some chosen_must_sort
1901 let completeSearchPattern () =
1902 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
1903 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1905 let metasenv,expr = inputt#get_metasenv_and_term ~context:[] ~metasenv:[] in
1906 let must = MQueryLevels2.get_constraints expr in
1907 let must',only = refine_constraints must in
1908 let results = MQueryGenerator.searchPattern must' only in
1909 show_query_results results
1912 output_html outputhtml
1913 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1916 let insertQuery () =
1917 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
1919 let chosen = ref None in
1922 ~modal:true ~title:"Insert Query (Experts Only)" ~border_width:2 () in
1923 let vbox = GPack.vbox ~packing:window#add () in
1925 GMisc.label ~text:"Insert Query. For Experts Only."
1926 ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1927 let scrolled_window =
1928 GBin.scrolled_window ~border_width:10 ~height:400 ~width:600
1929 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
1930 let input = GEdit.text ~editable:true
1931 ~packing:scrolled_window#add () in
1933 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1935 GButton.button ~label:"Ok"
1936 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1938 GButton.button ~label:"Load from file..."
1939 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1941 GButton.button ~label:"Abort"
1942 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1943 ignore (window#connect#destroy GMain.Main.quit) ;
1944 ignore (cancelb#connect#clicked window#destroy) ;
1946 (okb#connect#clicked
1948 chosen := Some (input#get_chars 0 input#length) ; window#destroy ())) ;
1950 (loadb#connect#clicked
1953 GToolbox.select_file ~title:"Select Query File" ()
1957 let inch = open_in filename in
1958 let rec read_file () =
1960 let line = input_line inch in
1961 line ^ "\n" ^ read_file ()
1965 let text = read_file () in
1966 input#delete_text 0 input#length ;
1967 ignore (input#insert_text text ~pos:0))) ;
1968 window#set_position `CENTER ;
1970 GMain.Main.main () ;
1975 Mqint.execute (MQueryUtil.query_of_text (Lexing.from_string q))
1977 show_query_results results
1980 output_html outputhtml
1981 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1984 let choose_must list_of_must only =
1985 let chosen = ref None in
1986 let user_constraints = ref [] in
1989 ~modal:true ~title:"Query refinement." ~border_width:2 () in
1990 let vbox = GPack.vbox ~packing:window#add () in
1992 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1996 ("You can now specify the genericity of the query. " ^
1997 "The more generic the slower.")
1998 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2000 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2004 "Suggestion: start with faster queries before moving to more generic ones."
2005 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2007 GPack.notebook ~scrollable:true
2008 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2011 let last = List.length list_of_must in
2017 (if !page = 1 then "More generic" else
2018 if !page = last then "More precise" else " ") () in
2019 let expected_height = 25 * (List.length must + 2) in
2020 let height = if expected_height > 400 then 400 else expected_height in
2021 let scrolled_window =
2022 GBin.scrolled_window ~border_width:10 ~height ~width:600
2023 ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2025 GList.clist ~columns:2 ~packing:scrolled_window#add
2026 ~titles:["URI" ; "Position"] ()
2030 (function (uri,position) ->
2033 [uri; if position then "MainConclusion" else "Conclusion"]
2035 clist#set_row ~selectable:false n
2038 clist#columns_autosize ()
2041 let label = GMisc.label ~text:"User provided" () in
2043 GPack.vbox ~packing:(notebook#append_page ~tab_label:label#coerce) () in
2045 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2048 ~text:"Select the constraints that must be satisfied and press OK."
2049 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2050 let expected_height = 25 * (List.length only + 2) in
2051 let height = if expected_height > 400 then 400 else expected_height in
2052 let scrolled_window =
2053 GBin.scrolled_window ~border_width:10 ~height ~width:600
2054 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2056 GList.clist ~columns:2 ~packing:scrolled_window#add
2057 ~selection_mode:`EXTENDED
2058 ~titles:["URI" ; "Position"] ()
2062 (function (uri,position) ->
2065 [uri; if position then "MainConclusion" else "Conclusion"]
2067 clist#set_row ~selectable:true n
2070 clist#columns_autosize () ;
2072 (clist#connect#select_row
2073 (fun ~row ~column ~event ->
2074 user_constraints := (List.nth only row)::!user_constraints)) ;
2076 (clist#connect#unselect_row
2077 (fun ~row ~column ~event ->
2080 (function uri -> uri != (List.nth only row)) !user_constraints)) ;
2083 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2085 GButton.button ~label:"Ok"
2086 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2088 GButton.button ~label:"Abort"
2089 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2091 ignore (window#connect#destroy GMain.Main.quit) ;
2092 ignore (cancelb#connect#clicked window#destroy) ;
2094 (okb#connect#clicked
2095 (function () -> chosen := Some notebook#current_page ; window#destroy ())) ;
2096 window#set_position `CENTER ;
2098 GMain.Main.main () ;
2100 None -> raise NoChoice
2102 if n = List.length list_of_must then
2103 (* user provided constraints *)
2106 List.nth list_of_must n
2109 let searchPattern () =
2110 let inputt = ((rendering_window ())#inputt : TermEditor.term_editor) in
2111 let outputhtml = ((rendering_window ())#outputhtml : GHtml.xmhtml) in
2114 match !ProofEngine.proof with
2115 None -> assert false
2116 | Some (_,metasenv,_,_) -> metasenv
2118 match !ProofEngine.goal with
2121 let (_, ey ,ty) = List.find (function (m,_,_) -> m=metano) metasenv in
2122 let list_of_must,only = MQueryLevels.out_restr metasenv ey ty in
2123 let must = choose_must list_of_must only in
2124 let torigth_restriction (u,b) =
2127 "http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion"
2129 "http://www.cs.unibo.it/helm/schemas/schema-helm#InConclusion"
2133 let rigth_must = List.map torigth_restriction must in
2134 let rigth_only = Some (List.map torigth_restriction only) in
2136 MQueryGenerator.searchPattern
2137 (rigth_must,[],[]) (rigth_only,None,None) in
2141 Misc.wrong_xpointer_format_from_wrong_xpointer_format' uri
2144 " <h1>Backward Query: </h1>" ^
2145 " <pre>" ^ get_last_query result ^ "</pre>"
2147 output_html outputhtml html ;
2149 let rec filter_out =
2153 let tl',exc = filter_out tl in
2156 ProofEngine.can_apply
2157 (term_of_cic_textual_parser_uri
2158 (Misc.cic_textual_parser_uri_of_string uri))
2166 "<h1 color=\"red\"> ^ Exception raised trying to apply " ^
2167 uri ^ ": " ^ Printexc.to_string e ^ " </h1>" ^ exc
2174 " <h1>Objects that can actually be applied: </h1> " ^
2175 String.concat "<br>" uris' ^ exc ^
2176 " <h1>Number of false matches: " ^
2177 string_of_int (List.length uris - List.length uris') ^ "</h1>" ^
2178 " <h1>Number of good matches: " ^
2179 string_of_int (List.length uris') ^ "</h1>"
2181 output_html outputhtml html' ;
2183 user_uri_choice ~title:"Ambiguous input."
2185 "Many lemmas can be successfully applied. Please, choose one:"
2188 inputt#set_term uri' ;
2189 InvokeTactics'.apply ()
2192 output_html outputhtml
2193 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
2196 let choose_selection mmlwidget (element : Gdome.element option) =
2197 let module G = Gdome in
2198 let rec aux element =
2199 if element#hasAttributeNS
2200 ~namespaceURI:Misc.helmns
2201 ~localName:(G.domString "xref")
2203 mmlwidget#set_selection (Some element)
2206 match element#get_parentNode with
2207 None -> assert false
2208 (*CSC: OCAML DIVERGES!
2209 | Some p -> aux (new G.element_of_node p)
2211 | Some p -> aux (new Gdome.element_of_node p)
2213 GdomeInit.DOMCastException _ ->
2215 "******* trying to select above the document root ********"
2219 | None -> mmlwidget#set_selection None
2222 (* STUFF TO BUILD THE GTK INTERFACE *)
2224 (* Stuff for the widget settings *)
2226 let export_to_postscript output =
2227 let lastdir = ref (Unix.getcwd ()) in
2230 GToolbox.select_file ~title:"Export to PostScript"
2231 ~dir:lastdir ~filename:"screenshot.ps" ()
2235 (output :> GMathView.math_view)#export_to_postscript
2236 ~filename:filename ();
2239 let activate_t1 output button_set_anti_aliasing
2240 button_set_transparency export_to_postscript_menu_item
2243 let is_set = button_t1#active in
2244 output#set_font_manager_type
2245 ~fm_type:(if is_set then `font_manager_t1 else `font_manager_gtk) ;
2248 button_set_anti_aliasing#misc#set_sensitive true ;
2249 button_set_transparency#misc#set_sensitive true ;
2250 export_to_postscript_menu_item#misc#set_sensitive true ;
2254 button_set_anti_aliasing#misc#set_sensitive false ;
2255 button_set_transparency#misc#set_sensitive false ;
2256 export_to_postscript_menu_item#misc#set_sensitive false ;
2260 let set_anti_aliasing output button_set_anti_aliasing () =
2261 output#set_anti_aliasing button_set_anti_aliasing#active
2264 let set_transparency output button_set_transparency () =
2265 output#set_transparency button_set_transparency#active
2268 let changefont output font_size_spinb () =
2269 output#set_font_size font_size_spinb#value_as_int
2272 let set_log_verbosity output log_verbosity_spinb () =
2273 output#set_log_verbosity log_verbosity_spinb#value_as_int
2276 class settings_window output sw
2277 export_to_postscript_menu_item selection_changed_callback
2279 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
2281 GPack.vbox ~packing:settings_window#add () in
2284 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2285 ~border_width:5 ~packing:vbox#add () in
2287 GButton.toggle_button ~label:"activate t1 fonts"
2288 ~packing:(table#attach ~left:0 ~top:0) () in
2289 let button_set_anti_aliasing =
2290 GButton.toggle_button ~label:"set_anti_aliasing"
2291 ~packing:(table#attach ~left:0 ~top:1) () in
2292 let button_set_transparency =
2293 GButton.toggle_button ~label:"set_transparency"
2294 ~packing:(table#attach ~left:2 ~top:1) () in
2297 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
2298 ~border_width:5 ~packing:vbox#add () in
2299 let font_size_label =
2300 GMisc.label ~text:"font size:"
2301 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
2302 let font_size_spinb =
2304 GData.adjustment ~value:14.0 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
2307 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
2308 let log_verbosity_label =
2309 GMisc.label ~text:"log verbosity:"
2310 ~packing:(table#attach ~left:0 ~top:1) () in
2311 let log_verbosity_spinb =
2313 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
2316 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
2318 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2320 GButton.button ~label:"Close"
2321 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2323 method show = settings_window#show
2325 button_set_anti_aliasing#misc#set_sensitive false ;
2326 button_set_transparency#misc#set_sensitive false ;
2327 (* Signals connection *)
2328 ignore(button_t1#connect#clicked
2329 (activate_t1 output button_set_anti_aliasing
2330 button_set_transparency export_to_postscript_menu_item button_t1)) ;
2331 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
2332 ignore(button_set_anti_aliasing#connect#toggled
2333 (set_anti_aliasing output button_set_anti_aliasing));
2334 ignore(button_set_transparency#connect#toggled
2335 (set_transparency output button_set_transparency)) ;
2336 ignore(log_verbosity_spinb#connect#changed
2337 (set_log_verbosity output log_verbosity_spinb)) ;
2338 ignore(closeb#connect#clicked settings_window#misc#hide)
2341 (* Scratch window *)
2343 class scratch_window =
2345 GWindow.window ~title:"MathML viewer" ~border_width:2 () in
2347 GPack.vbox ~packing:window#add () in
2349 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
2351 GButton.button ~label:"Whd"
2352 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2354 GButton.button ~label:"Reduce"
2355 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2357 GButton.button ~label:"Simpl"
2358 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
2359 let scrolled_window =
2360 GBin.scrolled_window ~border_width:10
2361 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2362 let sequent_viewer =
2363 TermViewer.sequent_viewer
2364 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
2366 val mutable term = Cic.Rel 1 (* dummy value *)
2367 val mutable context = ([] : Cic.context) (* dummy value *)
2368 val mutable metasenv = ([] : Cic.metasenv) (* dummy value *)
2369 method sequent_viewer = sequent_viewer
2370 method show () = window#misc#hide () ; window#show ()
2372 method set_term t = term <- t
2373 method context = context
2374 method set_context t = context <- t
2375 method metasenv = metasenv
2376 method set_metasenv t = metasenv <- t
2379 (sequent_viewer#connect#selection_changed (choose_selection sequent_viewer));
2380 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
2381 ignore(whdb#connect#clicked InvokeTactics'.whd_in_scratch) ;
2382 ignore(reduceb#connect#clicked InvokeTactics'.reduce_in_scratch) ;
2383 ignore(simplb#connect#clicked InvokeTactics'.simpl_in_scratch)
2386 let open_contextual_menu_for_selected_terms mmlwidget infos =
2387 let button = GdkEvent.Button.button infos in
2388 let terms_selected = List.length mmlwidget#get_selections > 0 in
2391 let time = GdkEvent.Button.time infos in
2392 let menu = GMenu.menu () in
2393 let f = new GMenu.factory menu in
2395 f#add_item "Whd" ~key:GdkKeysyms._W ~callback:InvokeTactics'.whd in
2396 let reduce_menu_item =
2397 f#add_item "Reduce" ~key:GdkKeysyms._R ~callback:InvokeTactics'.reduce in
2398 let simpl_menu_item =
2399 f#add_item "Simpl" ~key:GdkKeysyms._S ~callback:InvokeTactics'.simpl in
2400 let _ = f#add_separator () in
2401 let generalize_menu_item =
2402 f#add_item "Generalize"
2403 ~key:GdkKeysyms._G ~callback:InvokeTactics'.generalize in
2404 let _ = f#add_separator () in
2405 let clear_menu_item =
2406 f#add_item "Clear" ~key:GdkKeysyms._C ~callback:InvokeTactics'.clear in
2407 let clearbody_menu_item =
2408 f#add_item "ClearBody"
2409 ~key:GdkKeysyms._B ~callback:InvokeTactics'.clearbody
2411 whd_menu_item#misc#set_sensitive terms_selected ;
2412 reduce_menu_item#misc#set_sensitive terms_selected ;
2413 simpl_menu_item#misc#set_sensitive terms_selected ;
2414 generalize_menu_item#misc#set_sensitive terms_selected ;
2415 clear_menu_item#misc#set_sensitive terms_selected ;
2416 clearbody_menu_item#misc#set_sensitive terms_selected ;
2417 menu#popup ~button ~time
2423 let vbox1 = GPack.vbox () in
2425 val mutable proofw_ref = None
2426 val mutable compute_ref = None
2428 Lazy.force self#compute ;
2429 match proofw_ref with
2430 None -> assert false
2431 | Some proofw -> proofw
2432 method content = vbox1
2434 match compute_ref with
2435 None -> assert false
2436 | Some compute -> compute
2440 let scrolled_window1 =
2441 GBin.scrolled_window ~border_width:10
2442 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2444 TermViewer.sequent_viewer ~width:400 ~height:275
2445 ~packing:(scrolled_window1#add) () in
2446 let _ = proofw_ref <- Some proofw in
2448 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2450 GButton.button ~label:"Ring"
2451 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2453 GButton.button ~label:"Fourier"
2454 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2456 GButton.button ~label:"Reflexivity"
2457 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2459 GButton.button ~label:"Symmetry"
2460 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2462 GButton.button ~label:"Assumption"
2463 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2464 let contradictionb =
2465 GButton.button ~label:"Contradiction"
2466 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2468 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2470 GButton.button ~label:"Exists"
2471 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2473 GButton.button ~label:"Split"
2474 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2476 GButton.button ~label:"Left"
2477 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2479 GButton.button ~label:"Right"
2480 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2481 let searchpatternb =
2482 GButton.button ~label:"SearchPattern_Apply"
2483 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
2485 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2487 GButton.button ~label:"Exact"
2488 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2490 GButton.button ~label:"Intros"
2491 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2493 GButton.button ~label:"Apply"
2494 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2495 let elimintrossimplb =
2496 GButton.button ~label:"ElimIntrosSimpl"
2497 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2499 GButton.button ~label:"ElimType"
2500 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2502 GButton.button ~label:"Fold_whd"
2503 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2505 GButton.button ~label:"Fold_reduce"
2506 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2508 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2510 GButton.button ~label:"Fold_simpl"
2511 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2513 GButton.button ~label:"Cut"
2514 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2516 GButton.button ~label:"Change"
2517 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2519 GButton.button ~label:"Let ... In"
2520 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2522 GButton.button ~label:"RewriteSimpl ->"
2523 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2524 let rewritebacksimplb =
2525 GButton.button ~label:"RewriteSimpl <-"
2526 ~packing:(hbox6#pack ~expand:false ~fill:false ~padding:5) () in
2528 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
2530 GButton.button ~label:"Absurd"
2531 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2533 GButton.button ~label:"Decompose"
2534 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2536 GButton.button ~label:"Transitivity"
2537 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2539 GButton.button ~label:"Replace"
2540 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2542 GButton.button ~label:"Injection"
2543 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2545 GButton.button ~label:"Discriminate"
2546 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2547 (* Zack: spostare in una toolbar
2549 GButton.button ~label:"Generalize"
2550 ~packing:(hbox7#pack ~expand:false ~fill:false ~padding:5) () in
2552 GButton.button ~label:"ClearBody"
2553 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2555 GButton.button ~label:"Clear"
2556 ~packing:(hbox5#pack ~expand:false ~fill:false ~padding:5) () in
2558 GButton.button ~label:"Whd"
2559 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2561 GButton.button ~label:"Reduce"
2562 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2564 GButton.button ~label:"Simpl"
2565 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
2568 ignore(exactb#connect#clicked InvokeTactics'.exact) ;
2569 ignore(applyb#connect#clicked InvokeTactics'.apply) ;
2570 ignore(elimintrossimplb#connect#clicked InvokeTactics'.elimintrossimpl) ;
2571 ignore(elimtypeb#connect#clicked InvokeTactics'.elimtype) ;
2572 ignore(foldwhdb#connect#clicked InvokeTactics'.fold_whd) ;
2573 ignore(foldreduceb#connect#clicked InvokeTactics'.fold_reduce) ;
2574 ignore(foldsimplb#connect#clicked InvokeTactics'.fold_simpl) ;
2575 ignore(cutb#connect#clicked InvokeTactics'.cut) ;
2576 ignore(changeb#connect#clicked InvokeTactics'.change) ;
2577 ignore(letinb#connect#clicked InvokeTactics'.letin) ;
2578 ignore(ringb#connect#clicked InvokeTactics'.ring) ;
2579 ignore(fourierb#connect#clicked InvokeTactics'.fourier) ;
2580 ignore(rewritesimplb#connect#clicked InvokeTactics'.rewritesimpl) ;
2581 ignore(rewritebacksimplb#connect#clicked InvokeTactics'.rewritebacksimpl) ;
2582 ignore(replaceb#connect#clicked InvokeTactics'.replace) ;
2583 ignore(reflexivityb#connect#clicked InvokeTactics'.reflexivity) ;
2584 ignore(symmetryb#connect#clicked InvokeTactics'.symmetry) ;
2585 ignore(transitivityb#connect#clicked InvokeTactics'.transitivity) ;
2586 ignore(existsb#connect#clicked InvokeTactics'.exists) ;
2587 ignore(splitb#connect#clicked InvokeTactics'.split) ;
2588 ignore(leftb#connect#clicked InvokeTactics'.left) ;
2589 ignore(rightb#connect#clicked InvokeTactics'.right) ;
2590 ignore(assumptionb#connect#clicked InvokeTactics'.assumption) ;
2591 ignore(absurdb#connect#clicked InvokeTactics'.absurd) ;
2592 ignore(contradictionb#connect#clicked InvokeTactics'.contradiction) ;
2593 ignore(introsb#connect#clicked InvokeTactics'.intros) ;
2594 ignore(decomposeb#connect#clicked InvokeTactics'.decompose) ;
2595 ignore(searchpatternb#connect#clicked searchPattern) ;
2596 ignore(injectionb#connect#clicked InvokeTactics'.injection) ;
2597 ignore(discriminateb#connect#clicked InvokeTactics'.discriminate) ;
2598 (* Zack: spostare in una toolbar
2599 ignore(whdb#connect#clicked whd) ;
2600 ignore(reduceb#connect#clicked reduce) ;
2601 ignore(simplb#connect#clicked simpl) ;
2602 ignore(clearbodyb#connect#clicked clearbody) ;
2603 ignore(clearb#connect#clicked clear) ;
2604 ignore(generalizeb#connect#clicked generalize) ;
2606 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
2608 ((new GObj.event_ops proofw#as_widget)#connect#button_press
2609 (open_contextual_menu_for_selected_terms proofw)) ;
2615 let vbox1 = GPack.vbox () in
2616 let scrolled_window1 =
2617 GBin.scrolled_window ~border_width:10
2618 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
2620 TermViewer.sequent_viewer ~width:400 ~height:275
2621 ~packing:(scrolled_window1#add) () in
2623 method proofw = (assert false : TermViewer.sequent_viewer)
2624 method content = vbox1
2625 method compute = (assert false : unit)
2629 let empty_page = new empty_page;;
2633 val notebook = GPack.notebook ()
2635 val mutable skip_switch_page_event = false
2636 val mutable empty = true
2637 method notebook = notebook
2639 let new_page = new page () in
2641 pages := !pages @ [n,lazy (setgoal n),new_page] ;
2642 notebook#append_page
2643 ~tab_label:((GMisc.label ~text:("?" ^ string_of_int n) ())#coerce)
2644 new_page#content#coerce
2645 method remove_all_pages ~skip_switch_page_event:skip =
2647 notebook#remove_page 0 (* let's remove the empty page *)
2649 List.iter (function _ -> notebook#remove_page 0) !pages ;
2651 skip_switch_page_event <- skip
2652 method set_current_page ~may_skip_switch_page_event n =
2653 let (_,_,page) = List.find (function (m,_,_) -> m=n) !pages in
2654 let new_page = notebook#page_num page#content#coerce in
2655 if may_skip_switch_page_event && new_page <> notebook#current_page then
2656 skip_switch_page_event <- true ;
2657 notebook#goto_page new_page
2658 method set_empty_page =
2661 notebook#append_page
2662 ~tab_label:((GMisc.label ~text:"No proof in progress" ())#coerce)
2663 empty_page#content#coerce
2665 let (_,_,page) = List.nth !pages notebook#current_page in
2669 (notebook#connect#switch_page
2671 let skip = skip_switch_page_event in
2672 skip_switch_page_event <- false ;
2675 let (metano,setgoal,page) = List.nth !pages i in
2676 ProofEngine.goal := Some metano ;
2677 Lazy.force (page#compute) ;
2686 class rendering_window output (notebook : notebook) =
2687 let scratch_window = new scratch_window in
2689 GWindow.window ~title:"MathML viewer" ~border_width:0
2690 ~allow_shrink:false () in
2691 let vbox_for_menu = GPack.vbox ~packing:window#add () in
2693 let handle_box = GBin.handle_box ~border_width:2
2694 ~packing:(vbox_for_menu#pack ~padding:0) () in
2695 let menubar = GMenu.menu_bar ~packing:handle_box#add () in
2696 let factory0 = new GMenu.factory menubar in
2697 let accel_group = factory0#accel_group in
2699 let file_menu = factory0#add_submenu "File" in
2700 let factory1 = new GMenu.factory file_menu ~accel_group in
2701 let export_to_postscript_menu_item =
2704 factory1#add_item "New Block of (Co)Inductive Definitions..."
2705 ~key:GdkKeysyms._B ~callback:new_inductive
2708 factory1#add_item "New Proof or Definition..." ~key:GdkKeysyms._N
2711 let reopen_menu_item =
2712 factory1#add_item "Reopen a Finished Proof..." ~key:GdkKeysyms._R
2716 factory1#add_item "Qed" ~key:GdkKeysyms._E ~callback:qed in
2717 ignore (factory1#add_separator ()) ;
2719 (factory1#add_item "Load Unfinished Proof..." ~key:GdkKeysyms._L
2721 let save_menu_item =
2722 factory1#add_item "Save Unfinished Proof" ~key:GdkKeysyms._S ~callback:save
2725 (save_set_sensitive := function b -> save_menu_item#misc#set_sensitive b);
2726 ignore (!save_set_sensitive false);
2727 ignore (qed_set_sensitive:=function b -> qed_menu_item#misc#set_sensitive b);
2728 ignore (!qed_set_sensitive false);
2729 ignore (factory1#add_separator ()) ;
2730 let export_to_postscript_menu_item =
2731 factory1#add_item "Export to PostScript..."
2732 ~callback:(export_to_postscript output) in
2733 ignore (factory1#add_separator ()) ;
2735 (factory1#add_item "Exit" ~key:GdkKeysyms._Q ~callback:GMain.Main.quit) ;
2736 export_to_postscript_menu_item
2739 let edit_menu = factory0#add_submenu "Edit Current Proof" in
2740 let factory2 = new GMenu.factory edit_menu ~accel_group in
2741 let focus_and_proveit_set_sensitive = ref (function _ -> assert false) in
2742 let proveit_menu_item =
2743 factory2#add_item "Prove It" ~key:GdkKeysyms._I
2744 ~callback:(function () -> proveit ();!focus_and_proveit_set_sensitive false)
2746 let focus_menu_item =
2747 factory2#add_item "Focus" ~key:GdkKeysyms._F
2748 ~callback:(function () -> focus () ; !focus_and_proveit_set_sensitive false)
2751 focus_and_proveit_set_sensitive :=
2753 proveit_menu_item#misc#set_sensitive b ;
2754 focus_menu_item#misc#set_sensitive b
2756 let _ = !focus_and_proveit_set_sensitive false in
2757 (* edit term menu *)
2758 let edit_term_menu = factory0#add_submenu "Edit Term" in
2759 let factory5 = new GMenu.factory edit_term_menu ~accel_group in
2760 let check_menu_item =
2761 factory5#add_item "Check Term" ~key:GdkKeysyms._C
2762 ~callback:(check scratch_window) in
2763 let _ = check_menu_item#misc#set_sensitive false in
2765 let settings_menu = factory0#add_submenu "Search" in
2766 let factory4 = new GMenu.factory settings_menu ~accel_group in
2768 factory4#add_item "Locate..." ~key:GdkKeysyms._T
2770 let searchPattern_menu_item =
2771 factory4#add_item "SearchPattern..." ~key:GdkKeysyms._D
2772 ~callback:completeSearchPattern in
2773 let _ = searchPattern_menu_item#misc#set_sensitive false in
2774 let show_menu_item =
2775 factory4#add_item "Show..." ~key:GdkKeysyms._H ~callback:show
2777 let insert_query_item =
2778 factory4#add_item "Insert Query (Experts Only)..." ~key:GdkKeysyms._U
2779 ~callback:insertQuery in
2781 let settings_menu = factory0#add_submenu "Settings" in
2782 let factory3 = new GMenu.factory settings_menu ~accel_group in
2784 factory3#add_item "Edit Aliases" ~key:GdkKeysyms._A
2785 ~callback:edit_aliases in
2786 let _ = factory3#add_separator () in
2788 factory3#add_item "MathML Widget Preferences..." ~key:GdkKeysyms._P
2789 ~callback:(function _ -> (settings_window ())#show ()) in
2791 let _ = window#add_accel_group accel_group in
2795 ~packing:(vbox_for_menu#pack ~expand:true ~fill:true ~padding:5) () in
2797 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2798 let scrolled_window0 =
2799 GBin.scrolled_window ~border_width:10
2800 ~packing:(vbox#pack ~expand:true ~padding:5) () in
2801 let _ = scrolled_window0#add output#coerce in
2803 GBin.frame ~label:"Insert Term"
2804 ~packing:(vbox#pack ~expand:true ~fill:true ~padding:5) () in
2805 let scrolled_window1 =
2806 GBin.scrolled_window ~border_width:5
2807 ~packing:frame#add () in
2809 TermEditor'.term_editor
2810 ~width:400 ~height:100 ~packing:scrolled_window1#add ()
2811 ~isnotempty_callback:
2813 check_menu_item#misc#set_sensitive b ;
2814 searchPattern_menu_item#misc#set_sensitive b) in
2816 GPack.vbox ~packing:(hbox0#pack ~expand:true ~fill:true ~padding:5) () in
2818 vboxl#pack ~expand:true ~fill:true ~padding:5 notebook#notebook#coerce in
2820 GBin.frame ~shadow_type:`IN ~packing:(vboxl#pack ~expand:true ~padding:5) ()
2824 ~source:"<html><body bgColor=\"white\"></body></html>"
2825 ~width:400 ~height: 100
2830 method outputhtml = outputhtml
2831 method inputt = inputt
2832 method output = (output : TermViewer.proof_viewer)
2833 method scratch_window = scratch_window
2834 method notebook = notebook
2835 method show = window#show
2837 notebook#set_empty_page ;
2838 export_to_postscript_menu_item#misc#set_sensitive false ;
2839 check_term := (check_term_in_scratch scratch_window) ;
2841 (* signal handlers here *)
2842 ignore(output#connect#selection_changed
2844 choose_selection output elem ;
2845 !focus_and_proveit_set_sensitive true
2847 ignore (output#connect#click (show_in_show_window_callback output)) ;
2848 let settings_window = new settings_window output scrolled_window0
2849 export_to_postscript_menu_item (choose_selection output) in
2850 set_settings_window settings_window ;
2851 set_outputhtml outputhtml ;
2852 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
2853 Logger.log_callback :=
2854 (Logger.log_to_html ~print_and_flush:(output_html outputhtml))
2859 let initialize_everything () =
2860 let module U = Unix in
2861 let output = TermViewer.proof_viewer ~width:350 ~height:280 () in
2862 let notebook = new notebook in
2863 let rendering_window' = new rendering_window output notebook in
2864 set_rendering_window rendering_window' ;
2865 rendering_window'#show () ;
2872 Mqint.set_database Mqint.postgres_db ;
2873 Mqint.init postgresqlconnectionstring ;
2875 ignore (GtkMain.Main.init ()) ;
2876 initialize_everything () ;
2877 if !usedb then Mqint.close ();