1 (* Copyright (C) 2000, 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 (* GLOBAL REFERENCES (USED BY CALLBACKS) *)
52 let htmlheader_and_content = ref htmlheader;;
54 let current_cic_infos = ref None;;
55 let current_goal_infos = ref None;;
56 let current_scratch_infos = ref None;;
61 let domImpl = Gdome.domImplementation ();;
65 domImpl#createDocumentFromURI
67 ~uri:("http://phd.cs.unibo.it:8081/getxslt?uri=" ^ name) ?mode:None
69 ~uri:("styles/" ^ name) ()
71 Gdome_xslt.processStylesheet style
74 let d_c = parseStyle "drop_coercions.xsl";;
75 let tc1 = parseStyle "objtheorycontent.xsl";;
76 let hc2 = parseStyle "content_to_html.xsl";;
77 let l = parseStyle "link.xsl";;
79 let c1 = parseStyle "rootcontent.xsl";;
80 let g = parseStyle "genmmlid.xsl";;
81 let c2 = parseStyle "annotatedpres.xsl";;
84 let getterURL = Configuration.getter_url;;
85 let processorURL = Configuration.processor_url;;
87 let processorURL = "http://phd.cs.unibo.it:8080/helm/servelt/uwobo/";;
88 let getterURL = "http://phd.cs.unibo.it:8081/";;
89 let processorURL = "http://localhost:8080/helm/servelt/uwobo/";;
90 let getterURL = "http://localhost:8081/";;
93 let mml_styles = [d_c ; c1 ; g ; c2 ; l];;
95 ["processorURL", "'" ^ processorURL ^ "'" ;
96 "getterURL", "'" ^ getterURL ^ "'" ;
97 "draw_graphURL", "'http%3A//phd.cs.unibo.it%3A8083/'" ;
98 "uri_set_queueURL", "'http%3A//phd.cs.unibo.it%3A8084/'" ;
99 "UNICODEvsSYMBOL", "'symbol'" ;
100 "doctype-public", "'-//W3C//DTD%20XHTML%201.0%20Transitional//EN'" ;
101 "encoding", "'iso-8859-1'" ;
102 "media-type", "'text/html'" ;
103 "keys", "'d_c%2CC1%2CG%2CC2%2CL'" ;
104 "interfaceURL", "'http%3A//phd.cs.unibo.it/helm/html/cic/index.html'" ;
105 "naturalLanguage", "'yes'" ;
106 "annotations", "'no'" ;
107 "explodeall", "'true()'" ;
108 "topurl", "'http://phd.cs.unibo.it/helm'" ;
109 "CICURI", "'cic:/Coq/Init/Datatypes/bool_ind.con'" ]
112 let sequent_styles = [d_c ; c1 ; g ; c2 ; l];;
114 ["processorURL", "'" ^ processorURL ^ "'" ;
115 "getterURL", "'" ^ getterURL ^ "'" ;
116 "draw_graphURL", "'http%3A//phd.cs.unibo.it%3A8083/'" ;
117 "uri_set_queueURL", "'http%3A//phd.cs.unibo.it%3A8084/'" ;
118 "UNICODEvsSYMBOL", "'symbol'" ;
119 "doctype-public", "'-//W3C//DTD%20XHTML%201.0%20Transitional//EN'" ;
120 "encoding", "'iso-8859-1'" ;
121 "media-type", "'text/html'" ;
122 "keys", "'d_c%2CC1%2CG%2CC2%2CL'" ;
123 "interfaceURL", "'http%3A//phd.cs.unibo.it/helm/html/cic/index.html'" ;
124 "naturalLanguage", "'no'" ;
125 "annotations", "'no'" ;
126 "explodeall", "'true()'" ;
127 "topurl", "'http://phd.cs.unibo.it/helm'" ;
128 "CICURI", "'cic:/Coq/Init/Datatypes/bool_ind.con'" ]
131 let parse_file filename =
132 let inch = open_in filename in
133 let rec read_lines () =
135 let line = input_line inch in
143 let applyStylesheets input styles args =
144 List.fold_left (fun i style -> Gdome_xslt.applyStylesheet i style args)
148 let mml_of_cic_object uri annobj ids_to_inner_sorts ids_to_inner_types =
150 Cic2Xml.print_object uri ids_to_inner_sorts annobj
153 Cic2Xml.print_inner_types uri ids_to_inner_sorts
156 let input = Xml2Gdome.document_of_xml domImpl xml in
157 (*CSC: We save the innertypes to disk so that we can retrieve them in the *)
158 (*CSC: stylesheet. This DOES NOT work when UWOBO and/or the getter are not *)
160 Xml.pp xmlinnertypes (Some "/public/sacerdot/innertypes") ;
161 let output = applyStylesheets input mml_styles mml_args in
168 let refresh_proof (output : GMathView.math_view) =
169 let uri,currentproof =
170 match !ProofEngine.proof with
172 | Some (uri,metasenv,bo,ty) ->
173 uri,(Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty))
176 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,ids_to_inner_types)
178 Cic2acic.acic_object_of_cic_object currentproof
180 let mml = mml_of_cic_object uri acic ids_to_inner_sorts ids_to_inner_types in
181 output#load_tree mml ;
182 current_cic_infos := Some (ids_to_terms,ids_to_father_ids)
185 let refresh_sequent (proofw : GMathView.math_view) =
186 match !ProofEngine.goal with
187 None -> proofw#unload
188 | Some (_,currentsequent) ->
190 match !ProofEngine.proof with
192 | Some (_,metasenv,_,_) -> metasenv
194 let sequent_gdome,ids_to_terms,ids_to_father_ids =
195 SequentPp.XmlPp.print_sequent metasenv currentsequent
198 Xml2Gdome.document_of_xml domImpl sequent_gdome
201 applyStylesheets sequent_doc sequent_styles sequent_args
203 proofw#load_tree ~dom:sequent_mml ;
204 current_goal_infos := Some (ids_to_terms,ids_to_father_ids)
206 ignore(domImpl#saveDocumentToFile ~doc:sequent_doc
207 ~name:"/public/sacerdot/guruguru1" ~indent:true ()) ;
208 ignore(domImpl#saveDocumentToFile ~doc:sequent_mml
209 ~name:"/public/sacerdot/guruguru2" ~indent:true ())
213 let mml_of_cic_term term =
215 match !ProofEngine.goal with
217 | Some (_,(context,_)) -> context
220 match !ProofEngine.proof with
222 | Some (_,metasenv,_,_) -> metasenv
224 let sequent_gdome,ids_to_terms,ids_to_father_ids =
225 SequentPp.XmlPp.print_sequent metasenv (context,term)
228 Xml2Gdome.document_of_xml domImpl sequent_gdome
231 applyStylesheets sequent_doc sequent_styles sequent_args ;
233 current_scratch_infos := Some (term,ids_to_terms,ids_to_father_ids) ;
237 let output_html outputhtml msg =
238 htmlheader_and_content := !htmlheader_and_content ^ msg ;
239 outputhtml#source (!htmlheader_and_content ^ htmlfooter) ;
240 outputhtml#set_topline (-1)
243 (***********************)
245 (***********************)
247 let call_tactic tactic rendering_window () =
248 let proofw = (rendering_window#proofw : GMathView.math_view) in
249 let output = (rendering_window#output : GMathView.math_view) in
250 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
251 let savedproof = !ProofEngine.proof in
252 let savedgoal = !ProofEngine.goal in
256 refresh_sequent proofw ;
260 output_html outputhtml
261 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
262 ProofEngine.proof := savedproof ;
263 ProofEngine.goal := savedgoal ;
267 let call_tactic_with_input tactic rendering_window () =
268 let proofw = (rendering_window#proofw : GMathView.math_view) in
269 let output = (rendering_window#output : GMathView.math_view) in
270 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
271 let inputt = (rendering_window#inputt : GEdit.text) in
272 let savedproof = !ProofEngine.proof in
273 let savedgoal = !ProofEngine.goal in
274 (*CSC: Gran cut&paste da sotto... *)
275 let inputlen = inputt#length in
276 let input = inputt#get_chars 0 inputlen ^ "\n" in
277 let lexbuf = Lexing.from_string input in
279 match !ProofEngine.proof with
281 | Some (curi,_,_,_) -> curi
285 (function (_,n,_) -> n)
286 (match !ProofEngine.goal with
288 | Some (_,(ctx,_)) -> ctx
294 CicTextualParserContext.main curi context CicTextualLexer.token lexbuf
299 refresh_sequent proofw ;
303 CicTextualParser0.Eof ->
304 inputt#delete_text 0 inputlen
306 output_html outputhtml
307 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>");
308 ProofEngine.proof := savedproof ;
309 ProofEngine.goal := savedgoal
312 let call_tactic_with_goal_input tactic rendering_window () =
313 let module L = LogicalOperations in
314 let module G = Gdome in
315 let proofw = (rendering_window#proofw : GMathView.math_view) in
316 let output = (rendering_window#output : GMathView.math_view) in
317 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
318 let savedproof = !ProofEngine.proof in
319 let savedgoal = !ProofEngine.goal in
320 match proofw#get_selection with
323 ((node : Gdome.element)#getAttributeNS
325 ~localName:(G.domString "xref"))#to_string
327 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
331 match !current_goal_infos with
332 Some (ids_to_terms, ids_to_father_ids) ->
334 tactic (Hashtbl.find ids_to_terms id) ;
335 refresh_sequent rendering_window#proofw ;
336 refresh_proof rendering_window#output
337 | None -> assert false (* "ERROR: No current term!!!" *)
340 output_html outputhtml
341 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
344 output_html outputhtml
345 ("<h1 color=\"red\">No term selected</h1>")
348 let call_tactic_with_input_and_goal_input tactic rendering_window () =
349 let module L = LogicalOperations in
350 let module G = Gdome in
351 let proofw = (rendering_window#proofw : GMathView.math_view) in
352 let output = (rendering_window#output : GMathView.math_view) in
353 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
354 let inputt = (rendering_window#inputt : GEdit.text) in
355 let savedproof = !ProofEngine.proof in
356 let savedgoal = !ProofEngine.goal in
357 match proofw#get_selection with
360 ((node : Gdome.element)#getAttributeNS
362 ~localName:(G.domString "xref"))#to_string
364 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
368 match !current_goal_infos with
369 Some (ids_to_terms, ids_to_father_ids) ->
371 (* Let's parse the input *)
372 let inputlen = inputt#length in
373 let input = inputt#get_chars 0 inputlen ^ "\n" in
374 let lexbuf = Lexing.from_string input in
376 match !ProofEngine.proof with
378 | Some (curi,_,_,_) -> curi
382 (function (_,n,_) -> n)
383 (match !ProofEngine.goal with
385 | Some (_,(ctx,_)) -> ctx
392 CicTextualParserContext.main curi context
393 CicTextualLexer.token lexbuf
397 tactic ~goal_input:(Hashtbl.find ids_to_terms id)
399 refresh_sequent proofw ;
403 CicTextualParser0.Eof ->
404 inputt#delete_text 0 inputlen
406 | None -> assert false (* "ERROR: No current term!!!" *)
409 output_html outputhtml
410 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
413 output_html outputhtml
414 ("<h1 color=\"red\">No term selected</h1>")
417 let call_tactic_with_goal_input_in_scratch tactic scratch_window () =
418 let module L = LogicalOperations in
419 let module G = Gdome in
420 let mmlwidget = (scratch_window#mmlwidget : GMathView.math_view) in
421 let outputhtml = (scratch_window#outputhtml : GHtml.xmhtml) in
422 let savedproof = !ProofEngine.proof in
423 let savedgoal = !ProofEngine.goal in
424 match mmlwidget#get_selection with
427 ((node : Gdome.element)#getAttributeNS
429 ~localName:(G.domString "xref"))#to_string
431 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
435 match !current_scratch_infos with
436 (* term is the whole goal in the scratch_area *)
437 Some (term,ids_to_terms, ids_to_father_ids) ->
439 let expr = tactic term (Hashtbl.find ids_to_terms id) in
440 let mml = mml_of_cic_term expr in
441 scratch_window#show () ;
442 scratch_window#mmlwidget#load_tree ~dom:mml
443 | None -> assert false (* "ERROR: No current term!!!" *)
446 output_html outputhtml
447 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
450 output_html outputhtml
451 ("<h1 color=\"red\">No term selected</h1>")
454 let intros rendering_window = call_tactic ProofEngine.intros rendering_window;;
455 let exact rendering_window =
456 call_tactic_with_input ProofEngine.exact rendering_window
458 let apply rendering_window =
459 call_tactic_with_input ProofEngine.apply rendering_window
461 let elimintros rendering_window =
462 call_tactic_with_input ProofEngine.elim_intros rendering_window
464 let whd rendering_window =
465 call_tactic_with_goal_input ProofEngine.whd rendering_window
467 let reduce rendering_window =
468 call_tactic_with_goal_input ProofEngine.reduce rendering_window
470 let simpl rendering_window =
471 call_tactic_with_goal_input ProofEngine.simpl rendering_window
473 let fold rendering_window =
474 call_tactic_with_input ProofEngine.fold rendering_window
476 let cut rendering_window =
477 call_tactic_with_input ProofEngine.cut rendering_window
479 let change rendering_window =
480 call_tactic_with_input_and_goal_input ProofEngine.change rendering_window
484 let whd_in_scratch scratch_window =
485 call_tactic_with_goal_input_in_scratch ProofEngine.whd_in_scratch
488 let reduce_in_scratch scratch_window =
489 call_tactic_with_goal_input_in_scratch ProofEngine.reduce_in_scratch
492 let simpl_in_scratch scratch_window =
493 call_tactic_with_goal_input_in_scratch ProofEngine.simpl_in_scratch
499 (**********************)
501 (**********************)
503 exception OpenConjecturesStillThere;;
504 exception WrongProof;;
506 let save rendering_window () =
507 match !ProofEngine.proof with
509 | Some (uri,[],bo,ty) ->
510 if CicReduction.are_convertible (CicTypeChecker.type_of_aux' [] [] bo) ty then
512 (*CSC: Wrong: [] is just plainly wrong *)
513 let proof = Cic.Definition (UriManager.name_of_uri uri,bo,ty,[]) in
515 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
518 Cic2acic.acic_object_of_cic_object proof
521 mml_of_cic_object uri acic ids_to_inner_sorts ids_to_inner_types
523 (rendering_window#output : GMathView.math_view)#load_tree mml ;
524 current_cic_infos := Some (ids_to_terms,ids_to_father_ids)
528 | _ -> raise OpenConjecturesStillThere
531 let proveit rendering_window () =
532 let module L = LogicalOperations in
533 let module G = Gdome in
534 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
535 match rendering_window#output#get_selection with
538 ((node : Gdome.element)#getAttributeNS
540 ((element : G.element)#getAttributeNS
543 ~localName:(G.domString "xref"))#to_string
545 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
549 match !current_cic_infos with
550 Some (ids_to_terms, ids_to_father_ids) ->
552 if L.to_sequent id ids_to_terms ids_to_father_ids then
553 refresh_proof rendering_window#output ;
554 refresh_sequent rendering_window#proofw
555 | None -> assert false (* "ERROR: No current term!!!" *)
558 output_html outputhtml
559 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
561 | None -> assert false (* "ERROR: No selection!!!" *)
564 exception NotADefinition;;
566 let open_ rendering_window () =
567 let inputt = (rendering_window#inputt : GEdit.text) in
568 let oldinputt = (rendering_window#oldinputt : GEdit.text) in
569 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
570 let output = (rendering_window#output : GMathView.math_view) in
571 let proofw = (rendering_window#proofw : GMathView.math_view) in
572 let inputlen = inputt#length in
573 let input = inputt#get_chars 0 inputlen ^ "\n" in
575 let uri = UriManager.uri_of_string ("cic:" ^ input) in
576 CicTypeChecker.typecheck uri ;
578 match CicEnvironment.get_cooked_obj uri 0 with
579 Cic.Definition (_,bo,ty,_) -> [],bo,ty
580 | Cic.CurrentProof (_,metasenv,bo,ty) -> metasenv,bo,ty
583 | Cic.InductiveDefinition _ -> raise NotADefinition
586 Some (uri, metasenv, bo, ty) ;
587 ProofEngine.goal := None ;
588 inputt#delete_text 0 inputlen ;
589 ignore(oldinputt#insert_text input oldinputt#length) ;
590 refresh_sequent proofw ;
591 refresh_proof output ;
594 output_html outputhtml
595 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
598 let state rendering_window () =
599 let inputt = (rendering_window#inputt : GEdit.text) in
600 let oldinputt = (rendering_window#oldinputt : GEdit.text) in
601 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
602 let output = (rendering_window#output : GMathView.math_view) in
603 let proofw = (rendering_window#proofw : GMathView.math_view) in
604 let inputlen = inputt#length in
605 let input = inputt#get_chars 0 inputlen ^ "\n" in
606 (* Do something interesting *)
607 let lexbuf = Lexing.from_string input in
610 (* Execute the actions *)
611 match CicTextualParser.main CicTextualLexer.token lexbuf with
615 let _ = CicTypeChecker.type_of_aux' [] [] expr in
617 Some (UriManager.uri_of_string "cic:/dummy.con",
618 [1,expr], Cic.Meta 1, expr) ;
619 ProofEngine.goal := Some (1,([],expr)) ;
620 refresh_sequent proofw ;
621 refresh_proof output ;
624 print_endline ("? " ^ CicPp.ppterm expr) ;
628 CicTextualParser0.Eof ->
629 inputt#delete_text 0 inputlen ;
630 ignore(oldinputt#insert_text input oldinputt#length)
632 output_html outputhtml
633 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
636 let check rendering_window scratch_window () =
637 let inputt = (rendering_window#inputt : GEdit.text) in
638 let oldinputt = (rendering_window#oldinputt : GEdit.text) in
639 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
640 let output = (rendering_window#output : GMathView.math_view) in
641 let proofw = (rendering_window#proofw : GMathView.math_view) in
642 let inputlen = inputt#length in
643 let input = inputt#get_chars 0 inputlen ^ "\n" in
645 match !ProofEngine.proof with
646 None -> UriManager.uri_of_string "cic:/dummy.con", []
647 | Some (curi,metasenv,_,_) -> curi,metasenv
649 let ciccontext,names_context =
651 match !ProofEngine.goal with
653 | Some (_,(ctx,_)) -> ctx
655 ProofEngine.cic_context_of_context context,
656 List.map (function (_,n,_) -> n) context
658 (* Do something interesting *)
659 let lexbuf = Lexing.from_string input in
662 (* Execute the actions *)
664 CicTextualParserContext.main curi names_context CicTextualLexer.token
670 let ty = CicTypeChecker.type_of_aux' metasenv ciccontext expr in
671 let mml = mml_of_cic_term (Cic.Cast (expr,ty)) in
672 scratch_window#show () ;
673 scratch_window#mmlwidget#load_tree ~dom:mml
676 print_endline ("? " ^ CicPp.ppterm expr) ;
680 CicTextualParser0.Eof ->
681 inputt#delete_text 0 inputlen ;
682 ignore(oldinputt#insert_text input oldinputt#length)
684 output_html outputhtml
685 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
689 (mmlwidget : GMathView.math_view) (element : Gdome.element option)
691 let module G = Gdome in
692 let rec aux element =
693 if element#hasAttributeNS
695 ~localName:(G.domString "xref")
697 mmlwidget#set_selection (Some element)
699 match element#get_parentNode with
701 (*CSC: OCAML DIVERGES!
702 | Some p -> aux (new G.element_of_node p)
704 | Some p -> aux (new Gdome.element_of_node p)
708 | None -> mmlwidget#set_selection None
711 (* STUFF TO BUILD THE GTK INTERFACE *)
713 (* Stuff for the widget settings *)
715 let export_to_postscript (output : GMathView.math_view) () =
716 output#export_to_postscript ~filename:"output.ps" ();
719 let activate_t1 (output : GMathView.math_view) button_set_anti_aliasing
720 button_set_kerning button_set_transparency button_export_to_postscript
723 let is_set = button_t1#active in
724 output#set_font_manager_type
725 (if is_set then `font_manager_t1 else `font_manager_gtk) ;
728 button_set_anti_aliasing#misc#set_sensitive true ;
729 button_set_kerning#misc#set_sensitive true ;
730 button_set_transparency#misc#set_sensitive true ;
731 button_export_to_postscript#misc#set_sensitive true ;
735 button_set_anti_aliasing#misc#set_sensitive false ;
736 button_set_kerning#misc#set_sensitive false ;
737 button_set_transparency#misc#set_sensitive false ;
738 button_export_to_postscript#misc#set_sensitive false ;
742 let set_anti_aliasing output button_set_anti_aliasing () =
743 output#set_anti_aliasing button_set_anti_aliasing#active
746 let set_kerning output button_set_kerning () =
747 output#set_kerning button_set_kerning#active
750 let set_transparency output button_set_transparency () =
751 output#set_transparency button_set_transparency#active
754 let changefont output font_size_spinb () =
755 output#set_font_size font_size_spinb#value_as_int
758 let set_log_verbosity output log_verbosity_spinb () =
759 output#set_log_verbosity log_verbosity_spinb#value_as_int
762 class settings_window (output : GMathView.math_view) sw
763 button_export_to_postscript selection_changed_callback
765 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
767 GPack.vbox ~packing:settings_window#add () in
770 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
771 ~border_width:5 ~packing:vbox#add () in
773 GButton.toggle_button ~label:"activate t1 fonts"
774 ~packing:(table#attach ~left:0 ~top:0) () in
775 let button_set_anti_aliasing =
776 GButton.toggle_button ~label:"set_anti_aliasing"
777 ~packing:(table#attach ~left:0 ~top:1) () in
778 let button_set_kerning =
779 GButton.toggle_button ~label:"set_kerning"
780 ~packing:(table#attach ~left:1 ~top:1) () in
781 let button_set_transparency =
782 GButton.toggle_button ~label:"set_transparency"
783 ~packing:(table#attach ~left:2 ~top:1) () in
786 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
787 ~border_width:5 ~packing:vbox#add () in
788 let font_size_label =
789 GMisc.label ~text:"font size:"
790 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
791 let font_size_spinb =
793 GData.adjustment ~value:14.0 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
796 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
797 let log_verbosity_label =
798 GMisc.label ~text:"log verbosity:"
799 ~packing:(table#attach ~left:0 ~top:1) () in
800 let log_verbosity_spinb =
802 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
805 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
807 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
809 GButton.button ~label:"Close"
810 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
812 method show = settings_window#show
814 button_set_anti_aliasing#misc#set_sensitive false ;
815 button_set_kerning#misc#set_sensitive false ;
816 button_set_transparency#misc#set_sensitive false ;
817 (* Signals connection *)
818 ignore(button_t1#connect#clicked
819 (activate_t1 output button_set_anti_aliasing button_set_kerning
820 button_set_transparency button_export_to_postscript button_t1)) ;
821 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
822 ignore(button_set_anti_aliasing#connect#toggled
823 (set_anti_aliasing output button_set_anti_aliasing));
824 ignore(button_set_kerning#connect#toggled
825 (set_kerning output button_set_kerning)) ;
826 ignore(button_set_transparency#connect#toggled
827 (set_transparency output button_set_transparency)) ;
828 ignore(log_verbosity_spinb#connect#changed
829 (set_log_verbosity output log_verbosity_spinb)) ;
830 ignore(closeb#connect#clicked settings_window#misc#hide)
835 class scratch_window outputhtml =
837 GWindow.window ~title:"MathML viewer" ~border_width:2 () in
839 GPack.vbox ~packing:window#add () in
841 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
843 GButton.button ~label:"Whd"
844 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
846 GButton.button ~label:"Reduce"
847 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
849 GButton.button ~label:"Simpl"
850 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
851 let scrolled_window =
852 GBin.scrolled_window ~border_width:10
853 ~packing:(vbox#pack ~expand:true ~padding:5) () in
856 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
858 method outputhtml = outputhtml
859 method mmlwidget = mmlwidget
860 method show () = window#misc#hide () ; window#show ()
862 ignore(mmlwidget#connect#selection_changed (choose_selection mmlwidget)) ;
863 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
864 ignore(whdb#connect#clicked (whd_in_scratch self)) ;
865 ignore(reduceb#connect#clicked (reduce_in_scratch self)) ;
866 ignore(simplb#connect#clicked (simpl_in_scratch self))
871 class rendering_window output proofw (label : GMisc.label) =
873 GWindow.window ~title:"MathML viewer" ~border_width:2 () in
875 GPack.hbox ~packing:window#add () in
877 GPack.vbox ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
878 let _ = vbox#pack ~expand:false ~fill:false ~padding:5 label#coerce in
879 let scrolled_window0 =
880 GBin.scrolled_window ~border_width:10
881 ~packing:(vbox#pack ~expand:true ~padding:5) () in
882 let _ = scrolled_window0#add output#coerce in
884 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
886 GButton.button ~label:"Settings"
887 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
888 let button_export_to_postscript =
889 GButton.button ~label:"export_to_postscript"
890 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
892 GButton.button ~label:"Save"
893 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
895 GButton.button ~label:"Close"
896 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
898 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
900 GButton.button ~label:"Prove It"
901 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
902 let oldinputt = GEdit.text ~editable:false ~width:400 ~height:180
903 ~packing:(vbox#pack ~padding:5) () in
905 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
907 GButton.button ~label:"State"
908 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
910 GButton.button ~label:"Open"
911 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
913 GButton.button ~label:"Check"
914 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
915 let inputt = GEdit.text ~editable:true ~width:400 ~height: 100
916 ~packing:(vbox#pack ~padding:5) () in
918 GPack.vbox ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
919 let scrolled_window1 =
920 GBin.scrolled_window ~border_width:10
921 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
922 let _ = scrolled_window1#add proofw#coerce in
924 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
926 GButton.button ~label:"Exact"
927 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
929 GButton.button ~label:"Intros"
930 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
932 GButton.button ~label:"Apply"
933 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
935 GButton.button ~label:"ElimIntros"
936 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
938 GButton.button ~label:"Whd"
939 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
941 GButton.button ~label:"Reduce"
942 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
944 GButton.button ~label:"Simpl"
945 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
947 GButton.button ~label:"Fold"
948 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
950 GButton.button ~label:"Cut"
951 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
953 GButton.button ~label:"Change"
954 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
957 ~source:"<html><body bgColor=\"white\"></body></html>"
958 ~width:400 ~height: 200
959 ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5)
961 let scratch_window = new scratch_window outputhtml in
963 method outputhtml = outputhtml
964 method oldinputt = oldinputt
965 method inputt = inputt
966 method output = (output : GMathView.math_view)
967 method proofw = (proofw : GMathView.math_view)
968 method show = window#show
970 button_export_to_postscript#misc#set_sensitive false ;
972 (* signal handlers here *)
973 ignore(output#connect#selection_changed
974 (function elem -> proofw#unload ; choose_selection output elem)) ;
975 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
976 ignore(closeb#connect#clicked (fun _ -> GMain.Main.quit ())) ;
977 let settings_window = new settings_window output scrolled_window0
978 button_export_to_postscript (choose_selection output) in
979 ignore(settingsb#connect#clicked settings_window#show) ;
980 ignore(button_export_to_postscript#connect#clicked (export_to_postscript output)) ;
981 ignore(saveb#connect#clicked (save self)) ;
982 ignore(proveitb#connect#clicked (proveit self)) ;
983 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
984 ignore(stateb#connect#clicked (state self)) ;
985 ignore(openb#connect#clicked (open_ self)) ;
986 ignore(checkb#connect#clicked (check self scratch_window)) ;
987 ignore(exactb#connect#clicked (exact self)) ;
988 ignore(applyb#connect#clicked (apply self)) ;
989 ignore(elimintrosb#connect#clicked (elimintros self)) ;
990 ignore(whdb#connect#clicked (whd self)) ;
991 ignore(reduceb#connect#clicked (reduce self)) ;
992 ignore(simplb#connect#clicked (simpl self)) ;
993 ignore(foldb#connect#clicked (fold self)) ;
994 ignore(cutb#connect#clicked (cut self)) ;
995 ignore(changeb#connect#clicked (change self)) ;
996 ignore(introsb#connect#clicked (intros self)) ;
997 Logger.log_callback :=
998 (Logger.log_to_html ~print_and_flush:(output_html outputhtml))
1003 let initialize_everything () =
1004 let module U = Unix in
1005 let output = GMathView.math_view ~width:400 ~height:280 ()
1006 and proofw = GMathView.math_view ~width:400 ~height:275 ()
1007 and label = GMisc.label ~text:"gTopLevel" () in
1008 let rendering_window =
1009 new rendering_window output proofw label
1011 rendering_window#show () ;
1016 CicCooking.init () ;
1017 ignore (GtkMain.Main.init ()) ;
1018 initialize_everything ()