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 (******************************************************************************)
36 (* GLOBAL CONSTANTS *)
38 let helmns = Gdome.domString "http://www.cs.unibo.it/helm";;
42 " <body bgColor=\"white\">"
50 let prooffile = "/home/zack/dati/HELM/currentproof.gTopLevel"
52 (* GLOBAL REFERENCES (USED BY CALLBACKS) *)
54 let htmlheader_and_content = ref htmlheader;;
56 let current_cic_infos = ref None;;
57 let current_goal_infos = ref None;;
58 let current_scratch_infos = ref None;;
60 (* COMMAND LINE OPTIONS *)
66 "-nodb", Arg.Clear usedb, "disable use of MathQL DB"
69 Arg.parse argspec ignore ""
73 let domImpl = Gdome.domImplementation ();;
77 domImpl#createDocumentFromURI
79 ~uri:("http://phd.cs.unibo.it:8081/getxslt?uri=" ^ name) ?mode:None
81 ~uri:("styles/" ^ name) ()
83 Gdome_xslt.processStylesheet style
86 let d_c = parseStyle "drop_coercions.xsl";;
87 let tc1 = parseStyle "objtheorycontent.xsl";;
88 let hc2 = parseStyle "content_to_html.xsl";;
89 let l = parseStyle "link.xsl";;
91 let c1 = parseStyle "rootcontent.xsl";;
92 let g = parseStyle "genmmlid.xsl";;
93 let c2 = parseStyle "annotatedpres.xsl";;
96 let getterURL = Configuration.getter_url;;
97 let processorURL = Configuration.processor_url;;
99 let mml_styles = [d_c ; c1 ; g ; c2 ; l];;
101 ["processorURL", "'" ^ processorURL ^ "'" ;
102 "getterURL", "'" ^ getterURL ^ "'" ;
103 "draw_graphURL", "'http%3A//phd.cs.unibo.it%3A8083/'" ;
104 "uri_set_queueURL", "'http%3A//phd.cs.unibo.it%3A8084/'" ;
105 "UNICODEvsSYMBOL", "'symbol'" ;
106 "doctype-public", "'-//W3C//DTD%20XHTML%201.0%20Transitional//EN'" ;
107 "encoding", "'iso-8859-1'" ;
108 "media-type", "'text/html'" ;
109 "keys", "'d_c%2CC1%2CG%2CC2%2CL'" ;
110 "interfaceURL", "'http%3A//phd.cs.unibo.it/helm/html/cic/index.html'" ;
111 "naturalLanguage", "'yes'" ;
112 "annotations", "'no'" ;
113 "explodeall", "'true()'" ;
114 "topurl", "'http://phd.cs.unibo.it/helm'" ;
115 "CICURI", "'cic:/Coq/Init/Datatypes/bool_ind.con'" ]
118 let sequent_styles = [d_c ; c1 ; g ; c2 ; l];;
120 ["processorURL", "'" ^ processorURL ^ "'" ;
121 "getterURL", "'" ^ getterURL ^ "'" ;
122 "draw_graphURL", "'http%3A//phd.cs.unibo.it%3A8083/'" ;
123 "uri_set_queueURL", "'http%3A//phd.cs.unibo.it%3A8084/'" ;
124 "UNICODEvsSYMBOL", "'symbol'" ;
125 "doctype-public", "'-//W3C//DTD%20XHTML%201.0%20Transitional//EN'" ;
126 "encoding", "'iso-8859-1'" ;
127 "media-type", "'text/html'" ;
128 "keys", "'d_c%2CC1%2CG%2CC2%2CL'" ;
129 "interfaceURL", "'http%3A//phd.cs.unibo.it/helm/html/cic/index.html'" ;
130 "naturalLanguage", "'no'" ;
131 "annotations", "'no'" ;
132 "explodeall", "'true()'" ;
133 "topurl", "'http://phd.cs.unibo.it/helm'" ;
134 "CICURI", "'cic:/Coq/Init/Datatypes/bool_ind.con'" ]
137 let parse_file filename =
138 let inch = open_in filename in
139 let rec read_lines () =
141 let line = input_line inch in
149 let applyStylesheets input styles args =
150 List.fold_left (fun i style -> Gdome_xslt.applyStylesheet i style args)
154 let mml_of_cic_object uri annobj ids_to_inner_sorts ids_to_inner_types =
156 Cic2Xml.print_object uri ids_to_inner_sorts annobj
159 Cic2Xml.print_inner_types uri ids_to_inner_sorts
162 let input = Xml2Gdome.document_of_xml domImpl xml in
163 (*CSC: We save the innertypes to disk so that we can retrieve them in the *)
164 (*CSC: stylesheet. This DOES NOT work when UWOBO and/or the getter are not *)
166 Xml.pp xmlinnertypes (Some "/tmp/innertypes") ;
167 let output = applyStylesheets input mml_styles mml_args in
171 (* pretty print on standard output the current sequent *)
174 match !ProofEngine.proof with
175 | None -> assert false
176 | Some (_, metasenv, _, _) -> metasenv
179 match !ProofEngine.goal with
180 | None -> assert false
181 | Some metano -> List.find (function (m,_,_) -> m=metano) metasenv
185 (SequentPp.TextualPp.print_sequent seq) ^
192 exception RefreshSequentException of exn;;
193 exception RefreshProofException of exn;;
195 let refresh_proof (output : GMathView.math_view) =
197 let uri,currentproof =
198 match !ProofEngine.proof with
200 | Some (uri,metasenv,bo,ty) ->
201 uri,(Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty))
204 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
205 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
207 Cic2acic.acic_object_of_cic_object currentproof
210 mml_of_cic_object uri acic ids_to_inner_sorts ids_to_inner_types
212 output#load_tree mml ;
214 Some (ids_to_terms,ids_to_father_ids,ids_to_conjectures,ids_to_hypotheses)
217 match !ProofEngine.proof with
219 | Some (uri,metasenv,bo,ty) ->
220 prerr_endline ("Offending proof: " ^ CicPp.ppobj (Cic.CurrentProof ("questa",metasenv,bo,ty))) ; flush stderr ;
221 raise (RefreshProofException e)
224 let refresh_sequent (proofw : GMathView.math_view) =
226 match !ProofEngine.goal with
227 None -> proofw#unload
230 match !ProofEngine.proof with
232 | Some (_,metasenv,_,_) -> metasenv
234 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
235 let sequent_gdome,ids_to_terms,ids_to_father_ids,ids_to_hypotheses =
236 SequentPp.XmlPp.print_sequent metasenv currentsequent
239 Xml2Gdome.document_of_xml domImpl sequent_gdome
242 applyStylesheets sequent_doc sequent_styles sequent_args
244 proofw#load_tree ~dom:sequent_mml ;
245 current_goal_infos :=
246 Some (ids_to_terms,ids_to_father_ids,ids_to_hypotheses)
250 match !ProofEngine.goal with
255 match !ProofEngine.proof with
257 | Some (_,metasenv,_,_) -> metasenv
259 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
260 prerr_endline ("Offending sequent: " ^ SequentPp.TextualPp.print_sequent currentsequent) ; flush stderr ;
261 raise (RefreshSequentException e)
265 ignore(domImpl#saveDocumentToFile ~doc:sequent_doc
266 ~name:"/public/sacerdot/guruguru1" ~indent:true ()) ;
269 let mml_of_cic_term metano term =
271 match !ProofEngine.proof with
273 | Some (_,metasenv,_,_) -> metasenv
276 match !ProofEngine.goal with
279 let (_,canonical_context,_) =
280 List.find (function (m,_,_) -> m=metano) metasenv
284 let sequent_gdome,ids_to_terms,ids_to_father_ids,ids_to_hypotheses =
285 SequentPp.XmlPp.print_sequent metasenv (metano,context,term)
288 Xml2Gdome.document_of_xml domImpl sequent_gdome
291 applyStylesheets sequent_doc sequent_styles sequent_args ;
293 current_scratch_infos :=
294 Some (term,ids_to_terms,ids_to_father_ids,ids_to_hypotheses) ;
298 let output_html outputhtml msg =
299 htmlheader_and_content := !htmlheader_and_content ^ msg ;
300 outputhtml#source (!htmlheader_and_content ^ htmlfooter) ;
301 outputhtml#set_topline (-1)
304 (***********************)
306 (***********************)
308 let call_tactic tactic rendering_window () =
309 let proofw = (rendering_window#proofw : GMathView.math_view) in
310 let output = (rendering_window#output : GMathView.math_view) in
311 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
312 let savedproof = !ProofEngine.proof in
313 let savedgoal = !ProofEngine.goal in
317 refresh_sequent proofw ;
320 RefreshSequentException e ->
321 output_html outputhtml
322 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
323 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
324 ProofEngine.proof := savedproof ;
325 ProofEngine.goal := savedgoal ;
326 refresh_sequent proofw
327 | RefreshProofException e ->
328 output_html outputhtml
329 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
330 "proof: " ^ Printexc.to_string e ^ "</h1>") ;
331 ProofEngine.proof := savedproof ;
332 ProofEngine.goal := savedgoal ;
333 refresh_sequent proofw ;
336 output_html outputhtml
337 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
338 ProofEngine.proof := savedproof ;
339 ProofEngine.goal := savedgoal ;
343 let call_tactic_with_input tactic rendering_window () =
344 let proofw = (rendering_window#proofw : GMathView.math_view) in
345 let output = (rendering_window#output : GMathView.math_view) in
346 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
347 let inputt = (rendering_window#inputt : GEdit.text) in
348 let savedproof = !ProofEngine.proof in
349 let savedgoal = !ProofEngine.goal in
350 (*CSC: Gran cut&paste da sotto... *)
351 let inputlen = inputt#length in
352 let input = inputt#get_chars 0 inputlen ^ "\n" in
353 let lexbuf = Lexing.from_string input in
355 match !ProofEngine.proof with
357 | Some (curi,_,_,_) -> curi
360 match !ProofEngine.proof with
362 | Some (_,metasenv,_,_) -> metasenv
369 (match !ProofEngine.goal with
372 let (_,canonical_context,_) =
373 List.find (function (m,_,_) -> m=metano) metasenv
381 CicTextualParserContext.main curi context CicTextualLexer.token lexbuf
386 refresh_sequent proofw ;
390 CicTextualParser0.Eof ->
391 inputt#delete_text 0 inputlen
392 | RefreshSequentException e ->
393 output_html outputhtml
394 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
395 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
396 ProofEngine.proof := savedproof ;
397 ProofEngine.goal := savedgoal ;
398 refresh_sequent proofw
399 | RefreshProofException e ->
400 output_html outputhtml
401 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
402 "proof: " ^ Printexc.to_string e ^ "</h1>") ;
403 ProofEngine.proof := savedproof ;
404 ProofEngine.goal := savedgoal ;
405 refresh_sequent proofw ;
408 output_html outputhtml
409 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
410 ProofEngine.proof := savedproof ;
411 ProofEngine.goal := savedgoal ;
414 let call_tactic_with_goal_input tactic rendering_window () =
415 let module L = LogicalOperations in
416 let module G = Gdome in
417 let proofw = (rendering_window#proofw : GMathView.math_view) in
418 let output = (rendering_window#output : GMathView.math_view) in
419 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
420 let savedproof = !ProofEngine.proof in
421 let savedgoal = !ProofEngine.goal in
422 match proofw#get_selection with
425 ((node : Gdome.element)#getAttributeNS
427 ~localName:(G.domString "xref"))#to_string
429 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
433 match !current_goal_infos with
434 Some (ids_to_terms, ids_to_father_ids,_) ->
436 tactic (Hashtbl.find ids_to_terms id) ;
437 refresh_sequent rendering_window#proofw ;
438 refresh_proof rendering_window#output
439 | None -> assert false (* "ERROR: No current term!!!" *)
441 RefreshSequentException e ->
442 output_html outputhtml
443 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
444 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
445 ProofEngine.proof := savedproof ;
446 ProofEngine.goal := savedgoal ;
447 refresh_sequent proofw
448 | RefreshProofException e ->
449 output_html outputhtml
450 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
451 "proof: " ^ Printexc.to_string e ^ "</h1>") ;
452 ProofEngine.proof := savedproof ;
453 ProofEngine.goal := savedgoal ;
454 refresh_sequent proofw ;
457 output_html outputhtml
458 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
459 ProofEngine.proof := savedproof ;
460 ProofEngine.goal := savedgoal ;
463 output_html outputhtml
464 ("<h1 color=\"red\">No term selected</h1>")
467 let call_tactic_with_input_and_goal_input tactic rendering_window () =
468 let module L = LogicalOperations in
469 let module G = Gdome in
470 let proofw = (rendering_window#proofw : GMathView.math_view) in
471 let output = (rendering_window#output : GMathView.math_view) in
472 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
473 let inputt = (rendering_window#inputt : GEdit.text) in
474 let savedproof = !ProofEngine.proof in
475 let savedgoal = !ProofEngine.goal in
476 match proofw#get_selection with
479 ((node : Gdome.element)#getAttributeNS
481 ~localName:(G.domString "xref"))#to_string
483 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
487 match !current_goal_infos with
488 Some (ids_to_terms, ids_to_father_ids,_) ->
490 (* Let's parse the input *)
491 let inputlen = inputt#length in
492 let input = inputt#get_chars 0 inputlen ^ "\n" in
493 let lexbuf = Lexing.from_string input in
495 match !ProofEngine.proof with
497 | Some (curi,_,_,_) -> curi
500 match !ProofEngine.proof with
502 | Some (_,metasenv,_,_) -> metasenv
509 (match !ProofEngine.goal with
512 let (_,canonical_context,_) =
513 List.find (function (m,_,_) -> m=metano) metasenv
522 CicTextualParserContext.main curi context
523 CicTextualLexer.token lexbuf
527 tactic ~goal_input:(Hashtbl.find ids_to_terms id)
529 refresh_sequent proofw ;
533 CicTextualParser0.Eof ->
534 inputt#delete_text 0 inputlen
536 | None -> assert false (* "ERROR: No current term!!!" *)
538 RefreshSequentException e ->
539 output_html outputhtml
540 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
541 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
542 ProofEngine.proof := savedproof ;
543 ProofEngine.goal := savedgoal ;
544 refresh_sequent proofw
545 | RefreshProofException e ->
546 output_html outputhtml
547 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
548 "proof: " ^ Printexc.to_string e ^ "</h1>") ;
549 ProofEngine.proof := savedproof ;
550 ProofEngine.goal := savedgoal ;
551 refresh_sequent proofw ;
554 output_html outputhtml
555 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
556 ProofEngine.proof := savedproof ;
557 ProofEngine.goal := savedgoal ;
560 output_html outputhtml
561 ("<h1 color=\"red\">No term selected</h1>")
564 let call_tactic_with_goal_input_in_scratch tactic scratch_window () =
565 let module L = LogicalOperations in
566 let module G = Gdome in
567 let mmlwidget = (scratch_window#mmlwidget : GMathView.math_view) in
568 let outputhtml = (scratch_window#outputhtml : GHtml.xmhtml) in
569 let savedproof = !ProofEngine.proof in
570 let savedgoal = !ProofEngine.goal in
571 match mmlwidget#get_selection with
574 ((node : Gdome.element)#getAttributeNS
576 ~localName:(G.domString "xref"))#to_string
578 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
582 match !current_scratch_infos with
583 (* term is the whole goal in the scratch_area *)
584 Some (term,ids_to_terms, ids_to_father_ids,_) ->
586 let expr = tactic term (Hashtbl.find ids_to_terms id) in
587 let mml = mml_of_cic_term 111 expr in
588 scratch_window#show () ;
589 scratch_window#mmlwidget#load_tree ~dom:mml
590 | None -> assert false (* "ERROR: No current term!!!" *)
593 output_html outputhtml
594 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
597 output_html outputhtml
598 ("<h1 color=\"red\">No term selected</h1>")
601 let call_tactic_with_hypothesis_input tactic rendering_window () =
602 let module L = LogicalOperations in
603 let module G = Gdome in
604 let proofw = (rendering_window#proofw : GMathView.math_view) in
605 let output = (rendering_window#output : GMathView.math_view) in
606 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
607 let savedproof = !ProofEngine.proof in
608 let savedgoal = !ProofEngine.goal in
609 match proofw#get_selection with
612 ((node : Gdome.element)#getAttributeNS
614 ~localName:(G.domString "xref"))#to_string
616 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
620 match !current_goal_infos with
621 Some (_,_,ids_to_hypotheses) ->
623 tactic (Hashtbl.find ids_to_hypotheses id) ;
624 refresh_sequent rendering_window#proofw ;
625 refresh_proof rendering_window#output
626 | None -> assert false (* "ERROR: No current term!!!" *)
628 RefreshSequentException e ->
629 output_html outputhtml
630 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
631 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
632 ProofEngine.proof := savedproof ;
633 ProofEngine.goal := savedgoal ;
634 refresh_sequent proofw
635 | RefreshProofException e ->
636 output_html outputhtml
637 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
638 "proof: " ^ Printexc.to_string e ^ "</h1>") ;
639 ProofEngine.proof := savedproof ;
640 ProofEngine.goal := savedgoal ;
641 refresh_sequent proofw ;
644 output_html outputhtml
645 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
646 ProofEngine.proof := savedproof ;
647 ProofEngine.goal := savedgoal ;
650 output_html outputhtml
651 ("<h1 color=\"red\">No term selected</h1>")
655 let intros rendering_window = call_tactic ProofEngine.intros rendering_window;;
656 let exact rendering_window =
657 call_tactic_with_input ProofEngine.exact rendering_window
659 let apply rendering_window =
660 call_tactic_with_input ProofEngine.apply rendering_window
662 let elimintrossimpl rendering_window =
663 call_tactic_with_input ProofEngine.elim_intros_simpl rendering_window
665 let elimtype rendering_window =
666 call_tactic_with_input ProofEngine.elim_type rendering_window
668 let whd rendering_window =
669 call_tactic_with_goal_input ProofEngine.whd rendering_window
671 let reduce rendering_window =
672 call_tactic_with_goal_input ProofEngine.reduce rendering_window
674 let simpl rendering_window =
675 call_tactic_with_goal_input ProofEngine.simpl rendering_window
677 let fold rendering_window =
678 call_tactic_with_input ProofEngine.fold rendering_window
680 let cut rendering_window =
681 call_tactic_with_input ProofEngine.cut rendering_window
683 let change rendering_window =
684 call_tactic_with_input_and_goal_input ProofEngine.change rendering_window
686 let letin rendering_window =
687 call_tactic_with_input ProofEngine.letin rendering_window
689 let ring rendering_window = call_tactic ProofEngine.ring rendering_window;;
690 let clearbody rendering_window =
691 call_tactic_with_hypothesis_input ProofEngine.clearbody rendering_window
693 let clear rendering_window =
694 call_tactic_with_hypothesis_input ProofEngine.clear rendering_window
698 let whd_in_scratch scratch_window =
699 call_tactic_with_goal_input_in_scratch ProofEngine.whd_in_scratch
702 let reduce_in_scratch scratch_window =
703 call_tactic_with_goal_input_in_scratch ProofEngine.reduce_in_scratch
706 let simpl_in_scratch scratch_window =
707 call_tactic_with_goal_input_in_scratch ProofEngine.simpl_in_scratch
713 (**********************)
715 (**********************)
717 exception OpenConjecturesStillThere;;
718 exception WrongProof;;
720 let qed rendering_window () =
721 match !ProofEngine.proof with
723 | Some (uri,[],bo,ty) ->
725 CicReduction.are_convertible []
726 (CicTypeChecker.type_of_aux' [] [] bo) ty
729 (*CSC: Wrong: [] is just plainly wrong *)
730 let proof = Cic.Definition (UriManager.name_of_uri uri,bo,ty,[]) in
732 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
733 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
735 Cic2acic.acic_object_of_cic_object proof
738 mml_of_cic_object uri acic ids_to_inner_sorts ids_to_inner_types
740 (rendering_window#output : GMathView.math_view)#load_tree mml ;
743 (ids_to_terms,ids_to_father_ids,ids_to_conjectures,
748 | _ -> raise OpenConjecturesStillThere
752 let dtdname = "http://www.cs.unibo.it/helm/dtd/cic.dtd";;
754 (* let dtdname = "/home/zack/dati/HELM/V7/dtd/cic.dtd";; *)
755 let dtdname = "/public/helm-cvs/helm/dtd/cic.dtd";;
757 let save rendering_window () =
758 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
759 match !ProofEngine.proof with
761 | Some (uri, metasenv, bo, ty) ->
763 Cic.CurrentProof (UriManager.name_of_uri uri,metasenv,bo,ty)
765 let (acurrentproof,_,_,ids_to_inner_sorts,_,_,_) =
766 Cic2acic.acic_object_of_cic_object currentproof
768 let xml = Cic2Xml.print_object uri ids_to_inner_sorts acurrentproof in
770 [< Xml.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
772 ("<!DOCTYPE CurrentProof SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
776 Xml.pp ~quiet:true xml' (Some prooffile) ;
777 output_html outputhtml
778 ("<h1 color=\"Green\">Current proof saved to " ^
782 (* Used to typecheck the loaded proofs *)
783 let typecheck_loaded_proof metasenv bo ty =
784 let module T = CicTypeChecker in
785 (*CSC: bisogna controllare anche il metasenv!!! *)
786 ignore (T.type_of_aux' metasenv [] ty) ;
787 ignore (T.type_of_aux' metasenv [] bo)
790 let load rendering_window () =
791 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
792 let output = (rendering_window#output : GMathView.math_view) in
793 let proofw = (rendering_window#proofw : GMathView.math_view) in
795 let uri = UriManager.uri_of_string "cic:/dummy.con" in
796 match CicParser.obj_of_xml prooffile uri with
797 Cic.CurrentProof (_,metasenv,bo,ty) ->
798 typecheck_loaded_proof metasenv bo ty ;
800 Some (uri, metasenv, bo, ty) ;
804 | (metano,_,_)::_ -> Some metano
806 refresh_proof output ;
807 refresh_sequent proofw ;
808 output_html outputhtml
809 ("<h1 color=\"Green\">Current proof loaded from " ^
813 RefreshSequentException e ->
814 output_html outputhtml
815 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
816 "sequent: " ^ Printexc.to_string e ^ "</h1>")
817 | RefreshProofException e ->
818 output_html outputhtml
819 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
820 "proof: " ^ Printexc.to_string e ^ "</h1>")
822 output_html outputhtml
823 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
826 let proveit rendering_window () =
827 let module L = LogicalOperations in
828 let module G = Gdome in
829 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
830 match rendering_window#output#get_selection with
833 ((node : Gdome.element)#getAttributeNS
835 ((element : G.element)#getAttributeNS
838 ~localName:(G.domString "xref"))#to_string
840 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
844 match !current_cic_infos with
845 Some (ids_to_terms, ids_to_father_ids, _, _) ->
847 L.to_sequent id ids_to_terms ids_to_father_ids ;
848 refresh_proof rendering_window#output ;
849 refresh_sequent rendering_window#proofw
850 | None -> assert false (* "ERROR: No current term!!!" *)
852 RefreshSequentException e ->
853 output_html outputhtml
854 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
855 "sequent: " ^ Printexc.to_string e ^ "</h1>")
856 | RefreshProofException e ->
857 output_html outputhtml
858 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
859 "proof: " ^ Printexc.to_string e ^ "</h1>")
861 output_html outputhtml
862 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
864 | None -> assert false (* "ERROR: No selection!!!" *)
867 let focus rendering_window () =
868 let module L = LogicalOperations in
869 let module G = Gdome in
870 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
871 match rendering_window#output#get_selection with
874 ((node : Gdome.element)#getAttributeNS
876 ((element : G.element)#getAttributeNS
879 ~localName:(G.domString "xref"))#to_string
881 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
885 match !current_cic_infos with
886 Some (ids_to_terms, ids_to_father_ids, _, _) ->
888 L.focus id ids_to_terms ids_to_father_ids ;
889 refresh_sequent rendering_window#proofw
890 | None -> assert false (* "ERROR: No current term!!!" *)
892 RefreshSequentException e ->
893 output_html outputhtml
894 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
895 "sequent: " ^ Printexc.to_string e ^ "</h1>")
896 | RefreshProofException e ->
897 output_html outputhtml
898 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
899 "proof: " ^ Printexc.to_string e ^ "</h1>")
901 output_html outputhtml
902 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
904 | None -> assert false (* "ERROR: No selection!!!" *)
907 exception NoPrevGoal;;
908 exception NoNextGoal;;
910 let prevgoal metasenv metano =
914 | [(m,_,_)] -> raise NoPrevGoal
915 | (n,_,_)::(m,_,_)::_ when m=metano -> n
921 let nextgoal metasenv metano =
925 | [(m,_,_)] when m = metano -> raise NoNextGoal
926 | (m,_,_)::(n,_,_)::_ when m=metano -> n
932 let prev_or_next_goal select_goal rendering_window () =
933 let module L = LogicalOperations in
934 let module G = Gdome in
935 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
937 match !ProofEngine.proof with
939 | Some (_,metasenv,_,_) -> metasenv
942 match !ProofEngine.goal with
947 ProofEngine.goal := Some (select_goal metasenv metano) ;
948 refresh_sequent rendering_window#proofw
950 RefreshSequentException e ->
951 output_html outputhtml
952 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
953 "sequent: " ^ Printexc.to_string e ^ "</h1>")
955 output_html outputhtml
956 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
959 exception NotADefinition;;
961 let open_ rendering_window () =
962 let inputt = (rendering_window#inputt : GEdit.text) in
963 let oldinputt = (rendering_window#oldinputt : GEdit.text) in
964 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
965 let output = (rendering_window#output : GMathView.math_view) in
966 let proofw = (rendering_window#proofw : GMathView.math_view) in
967 let inputlen = inputt#length in
968 let input = inputt#get_chars 0 inputlen ^ "\n" in
970 let uri = UriManager.uri_of_string ("cic:" ^ input) in
971 CicTypeChecker.typecheck uri ;
973 match CicEnvironment.get_cooked_obj uri 0 with
974 Cic.Definition (_,bo,ty,_) -> [],bo,ty
975 | Cic.CurrentProof (_,metasenv,bo,ty) -> metasenv,bo,ty
978 | Cic.InductiveDefinition _ -> raise NotADefinition
981 Some (uri, metasenv, bo, ty) ;
982 ProofEngine.goal := None ;
983 refresh_sequent proofw ;
984 refresh_proof output ;
985 inputt#delete_text 0 inputlen ;
986 ignore(oldinputt#insert_text input oldinputt#length)
988 RefreshSequentException e ->
989 output_html outputhtml
990 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
991 "sequent: " ^ Printexc.to_string e ^ "</h1>")
992 | RefreshProofException e ->
993 output_html outputhtml
994 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
995 "proof: " ^ Printexc.to_string e ^ "</h1>")
997 output_html outputhtml
998 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1001 let state rendering_window () =
1002 let inputt = (rendering_window#inputt : GEdit.text) in
1003 let oldinputt = (rendering_window#oldinputt : GEdit.text) in
1004 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
1005 let output = (rendering_window#output : GMathView.math_view) in
1006 let proofw = (rendering_window#proofw : GMathView.math_view) in
1007 let inputlen = inputt#length in
1008 let input = inputt#get_chars 0 inputlen ^ "\n" in
1009 (* Do something interesting *)
1010 let lexbuf = Lexing.from_string input in
1013 (* Execute the actions *)
1014 match CicTextualParser.main CicTextualLexer.token lexbuf with
1017 let _ = CicTypeChecker.type_of_aux' [] [] expr in
1018 ProofEngine.proof :=
1019 Some (UriManager.uri_of_string "cic:/dummy.con",
1020 [1,[],expr], Cic.Meta (1,[]), expr) ;
1021 ProofEngine.goal := Some 1 ;
1022 refresh_sequent proofw ;
1023 refresh_proof output ;
1026 CicTextualParser0.Eof ->
1027 inputt#delete_text 0 inputlen ;
1028 ignore(oldinputt#insert_text input oldinputt#length)
1029 | RefreshSequentException e ->
1030 output_html outputhtml
1031 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1032 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1033 | RefreshProofException e ->
1034 output_html outputhtml
1035 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1036 "proof: " ^ Printexc.to_string e ^ "</h1>")
1038 output_html outputhtml
1039 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1042 let check rendering_window scratch_window () =
1043 let inputt = (rendering_window#inputt : GEdit.text) in
1044 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
1045 let output = (rendering_window#output : GMathView.math_view) in
1046 let proofw = (rendering_window#proofw : GMathView.math_view) in
1047 let inputlen = inputt#length in
1048 let input = inputt#get_chars 0 inputlen ^ "\n" in
1050 match !ProofEngine.proof with
1051 None -> UriManager.uri_of_string "cic:/dummy.con", []
1052 | Some (curi,metasenv,_,_) -> curi,metasenv
1054 let context,names_context =
1056 match !ProofEngine.goal with
1059 let (_,canonical_context,_) =
1060 List.find (function (m,_,_) -> m=metano) metasenv
1067 Some (n,_) -> Some n
1071 (* Do something interesting *)
1072 let lexbuf = Lexing.from_string input in
1075 (* Execute the actions *)
1077 CicTextualParserContext.main curi names_context CicTextualLexer.token
1083 let ty = CicTypeChecker.type_of_aux' metasenv context expr in
1084 let mml = mml_of_cic_term 111 (Cic.Cast (expr,ty)) in
1085 scratch_window#show () ;
1086 scratch_window#mmlwidget#load_tree ~dom:mml
1089 print_endline ("? " ^ CicPp.ppterm expr) ;
1093 CicTextualParser0.Eof -> ()
1095 output_html outputhtml
1096 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1099 let locate rendering_window () =
1100 let inputt = (rendering_window#inputt : GEdit.text) in
1101 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
1102 let inputlen = inputt#length in
1103 let input = inputt#get_chars 0 inputlen in
1104 output_html outputhtml (
1106 match Str.split (Str.regexp "[ \t]+") input with
1109 inputt#delete_text 0 inputlen;
1110 MQueryGenerator.locate head
1112 e -> "<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>"
1116 let backward rendering_window () =
1117 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
1118 let inputt = (rendering_window#inputt : GEdit.text) in
1119 let inputlen = inputt#length in
1120 let input = inputt#get_chars 0 inputlen in
1121 let level = int_of_string input in
1123 match !ProofEngine.proof with
1124 None -> assert false
1125 | Some (_,metasenv,_,_) -> metasenv
1128 match !ProofEngine.goal with
1132 List.find (function (m,_,_) -> m=metano) metasenv
1134 MQueryGenerator.backward metasenv ey ty level
1136 output_html outputhtml result
1138 let choose_selection
1139 (mmlwidget : GMathView.math_view) (element : Gdome.element option)
1141 let module G = Gdome in
1142 let rec aux element =
1143 if element#hasAttributeNS
1144 ~namespaceURI:helmns
1145 ~localName:(G.domString "xref")
1147 mmlwidget#set_selection (Some element)
1149 match element#get_parentNode with
1150 None -> assert false
1151 (*CSC: OCAML DIVERGES!
1152 | Some p -> aux (new G.element_of_node p)
1154 | Some p -> aux (new Gdome.element_of_node p)
1158 | None -> mmlwidget#set_selection None
1161 (* STUFF TO BUILD THE GTK INTERFACE *)
1163 (* Stuff for the widget settings *)
1165 let export_to_postscript (output : GMathView.math_view) () =
1166 output#export_to_postscript ~filename:"output.ps" ();
1169 let activate_t1 (output : GMathView.math_view) button_set_anti_aliasing
1170 button_set_kerning button_set_transparency button_export_to_postscript
1173 let is_set = button_t1#active in
1174 output#set_font_manager_type
1175 (if is_set then `font_manager_t1 else `font_manager_gtk) ;
1178 button_set_anti_aliasing#misc#set_sensitive true ;
1179 button_set_kerning#misc#set_sensitive true ;
1180 button_set_transparency#misc#set_sensitive true ;
1181 button_export_to_postscript#misc#set_sensitive true ;
1185 button_set_anti_aliasing#misc#set_sensitive false ;
1186 button_set_kerning#misc#set_sensitive false ;
1187 button_set_transparency#misc#set_sensitive false ;
1188 button_export_to_postscript#misc#set_sensitive false ;
1192 let set_anti_aliasing output button_set_anti_aliasing () =
1193 output#set_anti_aliasing button_set_anti_aliasing#active
1196 let set_kerning output button_set_kerning () =
1197 output#set_kerning button_set_kerning#active
1200 let set_transparency output button_set_transparency () =
1201 output#set_transparency button_set_transparency#active
1204 let changefont output font_size_spinb () =
1205 output#set_font_size font_size_spinb#value_as_int
1208 let set_log_verbosity output log_verbosity_spinb () =
1209 output#set_log_verbosity log_verbosity_spinb#value_as_int
1212 class settings_window (output : GMathView.math_view) sw
1213 button_export_to_postscript selection_changed_callback
1215 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
1217 GPack.vbox ~packing:settings_window#add () in
1220 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
1221 ~border_width:5 ~packing:vbox#add () in
1223 GButton.toggle_button ~label:"activate t1 fonts"
1224 ~packing:(table#attach ~left:0 ~top:0) () in
1225 let button_set_anti_aliasing =
1226 GButton.toggle_button ~label:"set_anti_aliasing"
1227 ~packing:(table#attach ~left:0 ~top:1) () in
1228 let button_set_kerning =
1229 GButton.toggle_button ~label:"set_kerning"
1230 ~packing:(table#attach ~left:1 ~top:1) () in
1231 let button_set_transparency =
1232 GButton.toggle_button ~label:"set_transparency"
1233 ~packing:(table#attach ~left:2 ~top:1) () in
1236 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
1237 ~border_width:5 ~packing:vbox#add () in
1238 let font_size_label =
1239 GMisc.label ~text:"font size:"
1240 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
1241 let font_size_spinb =
1243 GData.adjustment ~value:14.0 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
1246 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
1247 let log_verbosity_label =
1248 GMisc.label ~text:"log verbosity:"
1249 ~packing:(table#attach ~left:0 ~top:1) () in
1250 let log_verbosity_spinb =
1252 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
1255 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
1257 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1259 GButton.button ~label:"Close"
1260 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1262 method show = settings_window#show
1264 button_set_anti_aliasing#misc#set_sensitive false ;
1265 button_set_kerning#misc#set_sensitive false ;
1266 button_set_transparency#misc#set_sensitive false ;
1267 (* Signals connection *)
1268 ignore(button_t1#connect#clicked
1269 (activate_t1 output button_set_anti_aliasing button_set_kerning
1270 button_set_transparency button_export_to_postscript button_t1)) ;
1271 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
1272 ignore(button_set_anti_aliasing#connect#toggled
1273 (set_anti_aliasing output button_set_anti_aliasing));
1274 ignore(button_set_kerning#connect#toggled
1275 (set_kerning output button_set_kerning)) ;
1276 ignore(button_set_transparency#connect#toggled
1277 (set_transparency output button_set_transparency)) ;
1278 ignore(log_verbosity_spinb#connect#changed
1279 (set_log_verbosity output log_verbosity_spinb)) ;
1280 ignore(closeb#connect#clicked settings_window#misc#hide)
1283 (* Scratch window *)
1285 class scratch_window outputhtml =
1287 GWindow.window ~title:"MathML viewer" ~border_width:2 () in
1289 GPack.vbox ~packing:window#add () in
1291 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1293 GButton.button ~label:"Whd"
1294 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1296 GButton.button ~label:"Reduce"
1297 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1299 GButton.button ~label:"Simpl"
1300 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1301 let scrolled_window =
1302 GBin.scrolled_window ~border_width:10
1303 ~packing:(vbox#pack ~expand:true ~padding:5) () in
1306 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
1308 method outputhtml = outputhtml
1309 method mmlwidget = mmlwidget
1310 method show () = window#misc#hide () ; window#show ()
1312 ignore(mmlwidget#connect#selection_changed (choose_selection mmlwidget)) ;
1313 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
1314 ignore(whdb#connect#clicked (whd_in_scratch self)) ;
1315 ignore(reduceb#connect#clicked (reduce_in_scratch self)) ;
1316 ignore(simplb#connect#clicked (simpl_in_scratch self))
1321 class rendering_window output proofw (label : GMisc.label) =
1323 GWindow.window ~title:"MathML viewer" ~border_width:2 () in
1325 GPack.hbox ~packing:window#add () in
1327 GPack.vbox ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1328 let _ = vbox#pack ~expand:false ~fill:false ~padding:5 label#coerce in
1329 let scrolled_window0 =
1330 GBin.scrolled_window ~border_width:10
1331 ~packing:(vbox#pack ~expand:true ~padding:5) () in
1332 let _ = scrolled_window0#add output#coerce in
1334 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1336 GButton.button ~label:"Settings"
1337 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1338 let button_export_to_postscript =
1339 GButton.button ~label:"export_to_postscript"
1340 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1342 GButton.button ~label:"Qed"
1343 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1345 GButton.button ~label:"Save"
1346 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1348 GButton.button ~label:"Load"
1349 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1351 GButton.button ~label:"Close"
1352 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1354 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1356 GButton.button ~label:"Prove It"
1357 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1359 GButton.button ~label:"Focus"
1360 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1362 GButton.button ~label:"<"
1363 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1365 GButton.button ~label:">"
1366 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1367 let oldinputt = GEdit.text ~editable:false ~width:400 ~height:180
1368 ~packing:(vbox#pack ~padding:5) () in
1370 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1372 GButton.button ~label:"State"
1373 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1375 GButton.button ~label:"Open"
1376 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1378 GButton.button ~label:"Check"
1379 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1381 GButton.button ~label:"Locate"
1382 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1384 GButton.button ~label:"Backward"
1385 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1386 let inputt = GEdit.text ~editable:true ~width:400 ~height: 100
1387 ~packing:(vbox#pack ~padding:5) () in
1389 GPack.vbox ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1390 let scrolled_window1 =
1391 GBin.scrolled_window ~border_width:10
1392 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
1393 let _ = scrolled_window1#add proofw#coerce in
1395 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
1397 GButton.button ~label:"Exact"
1398 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1400 GButton.button ~label:"Intros"
1401 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1403 GButton.button ~label:"Apply"
1404 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1405 let elimintrossimplb =
1406 GButton.button ~label:"ElimIntrosSimpl"
1407 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1409 GButton.button ~label:"ElimType"
1410 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1412 GButton.button ~label:"Whd"
1413 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1415 GButton.button ~label:"Reduce"
1416 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1418 GButton.button ~label:"Simpl"
1419 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1421 GButton.button ~label:"Fold"
1422 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1424 GButton.button ~label:"Cut"
1425 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1427 GButton.button ~label:"Change"
1428 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1430 GButton.button ~label:"Let ... In"
1431 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1433 GButton.button ~label:"Ring"
1434 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1436 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
1438 GButton.button ~label:"ClearBody"
1439 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1441 GButton.button ~label:"Clear"
1442 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1444 GButton.button ~label:"Dump"
1445 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1448 ~source:"<html><body bgColor=\"white\"></body></html>"
1449 ~width:400 ~height: 200
1450 ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5)
1452 let scratch_window = new scratch_window outputhtml in
1454 method outputhtml = outputhtml
1455 method oldinputt = oldinputt
1456 method inputt = inputt
1457 method output = (output : GMathView.math_view)
1458 method proofw = (proofw : GMathView.math_view)
1459 method show = window#show
1461 button_export_to_postscript#misc#set_sensitive false ;
1463 (* signal handlers here *)
1464 ignore(output#connect#selection_changed
1465 (function elem -> proofw#unload ; choose_selection output elem)) ;
1466 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
1467 ignore(closeb#connect#clicked (fun _ -> GMain.Main.quit ())) ;
1468 let settings_window = new settings_window output scrolled_window0
1469 button_export_to_postscript (choose_selection output) in
1470 ignore(settingsb#connect#clicked settings_window#show) ;
1471 ignore(button_export_to_postscript#connect#clicked (export_to_postscript output)) ;
1472 ignore(qedb#connect#clicked (qed self)) ;
1473 ignore(saveb#connect#clicked (save self)) ;
1474 ignore(loadb#connect#clicked (load self)) ;
1475 ignore(proveitb#connect#clicked (proveit self)) ;
1476 ignore(focusb#connect#clicked (focus self)) ;
1477 ignore(prevgoalb#connect#clicked (prev_or_next_goal prevgoal self)) ;
1478 ignore(nextgoalb#connect#clicked (prev_or_next_goal nextgoal self)) ;
1479 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
1480 ignore(stateb#connect#clicked (state self)) ;
1481 ignore(openb#connect#clicked (open_ self)) ;
1482 ignore(checkb#connect#clicked (check self scratch_window)) ;
1483 ignore(locateb#connect#clicked (locate self)) ;
1484 ignore(backwardb#connect#clicked (backward self)) ;
1485 ignore(exactb#connect#clicked (exact self)) ;
1486 ignore(applyb#connect#clicked (apply self)) ;
1487 ignore(elimintrossimplb#connect#clicked (elimintrossimpl self)) ;
1488 ignore(elimtypeb#connect#clicked (elimtype self)) ;
1489 ignore(whdb#connect#clicked (whd self)) ;
1490 ignore(reduceb#connect#clicked (reduce self)) ;
1491 ignore(simplb#connect#clicked (simpl self)) ;
1492 ignore(foldb#connect#clicked (fold self)) ;
1493 ignore(cutb#connect#clicked (cut self)) ;
1494 ignore(changeb#connect#clicked (change self)) ;
1495 ignore(letinb#connect#clicked (letin self)) ;
1496 ignore(ringb#connect#clicked (ring self)) ;
1497 ignore(clearbodyb#connect#clicked (clearbody self)) ;
1498 ignore(clearb#connect#clicked (clear self)) ;
1499 ignore(dumpb#connect#clicked dumpsequent);
1500 ignore(introsb#connect#clicked (intros self)) ;
1501 Logger.log_callback :=
1502 (Logger.log_to_html ~print_and_flush:(output_html outputhtml))
1507 let initialize_everything () =
1508 let module U = Unix in
1509 let output = GMathView.math_view ~width:400 ~height:280 ()
1510 and proofw = GMathView.math_view ~width:400 ~height:275 ()
1511 and label = GMisc.label ~text:"gTopLevel" () in
1512 let rendering_window =
1513 new rendering_window output proofw label
1515 rendering_window#show () ;
1520 CicCooking.init () ;
1521 if !usedb then MQueryGenerator.init () ;
1522 ignore (GtkMain.Main.init ()) ;
1523 initialize_everything () ;
1524 if !usedb then MQueryGenerator.close ();
1525 MQueryGenerator.close ()