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 (* CSC: quick fix: a function from [uri#xpointer(path)] to [uri#path] *)
38 let wrong_xpointer_format_from_wrong_xpointer_format' uri =
40 let index_sharp = String.index uri '#' in
41 let index_rest = index_sharp + 10 in
42 let baseuri = String.sub uri 0 index_sharp in
43 let rest = String.sub uri index_rest (String.length uri - index_rest - 1) in
48 (* GLOBAL CONSTANTS *)
50 let helmns = Gdome.domString "http://www.cs.unibo.it/helm";;
54 " <body bgColor=\"white\">"
63 let prooffile = "/home/tassi/miohelm/tmp/currentproof";;
65 let prooffile = "/public/sacerdot/currentproof";;
66 let prooffiletype = "/public/sacerdot/currentprooftype";;
67 (*CSC: the getter should handle the innertypes, not the FS *)
69 let innertypesfile = "/home/tassi/miohelm/tmp/innertypes";;
71 let innertypesfile = "/public/sacerdot/innertypes";;
72 let constanttypefile = "/public/sacerdot/constanttype";;
74 (* GLOBAL REFERENCES (USED BY CALLBACKS) *)
76 let htmlheader_and_content = ref htmlheader;;
78 let current_cic_infos = ref None;;
79 let current_goal_infos = ref None;;
80 let current_scratch_infos = ref None;;
82 (* COMMAND LINE OPTIONS *)
88 "-nodb", Arg.Clear usedb, "disable use of MathQL DB"
91 Arg.parse argspec ignore ""
96 let cic_textual_parser_uri_of_uri uri' =
98 if String.sub uri' (String.length uri' - 4) 4 = ".con" then
99 CicTextualParser0.ConUri (UriManager.uri_of_string uri')
101 if String.sub uri' (String.length uri' - 4) 4 = ".var" then
102 CicTextualParser0.VarUri (UriManager.uri_of_string uri')
106 let uri'',typeno = CicTextualLexer.indtyuri_of_uri uri' in
107 CicTextualParser0.IndTyUri (uri'',typeno)
110 (* Constructor of an Inductive Type *)
111 let uri'',typeno,consno =
112 CicTextualLexer.indconuri_of_uri uri'
114 CicTextualParser0.IndConUri (uri'',typeno,consno)
118 let term_of_uri uri =
119 let module C = Cic in
120 let module CTP = CicTextualParser0 in
121 match (cic_textual_parser_uri_of_uri uri) with
122 CTP.ConUri uri -> C.Const (uri,[])
123 | CTP.VarUri uri -> C.Var (uri,[])
124 | CTP.IndTyUri (uri,tyno) -> C.MutInd (uri,tyno,[])
125 | CTP.IndConUri (uri,tyno,consno) -> C.MutConstruct (uri,tyno,consno,[])
128 let domImpl = Gdome.domImplementation ();;
130 let parseStyle name =
132 domImpl#createDocumentFromURI
134 ~uri:("http://phd.cs.unibo.it:8081/getxslt?uri=" ^ name) ?mode:None
136 ~uri:("styles/" ^ name) ()
138 Gdome_xslt.processStylesheet style
141 let d_c = parseStyle "drop_coercions.xsl";;
142 let tc1 = parseStyle "objtheorycontent.xsl";;
143 let hc2 = parseStyle "content_to_html.xsl";;
144 let l = parseStyle "link.xsl";;
146 let c1 = parseStyle "rootcontent.xsl";;
147 let g = parseStyle "genmmlid.xsl";;
148 let c2 = parseStyle "annotatedpres.xsl";;
151 let getterURL = Configuration.getter_url;;
152 let processorURL = Configuration.processor_url;;
154 let mml_styles = [d_c ; c1 ; g ; c2 ; l];;
156 ["processorURL", "'" ^ processorURL ^ "'" ;
157 "getterURL", "'" ^ getterURL ^ "'" ;
158 "draw_graphURL", "'http%3A//phd.cs.unibo.it%3A8083/'" ;
159 "uri_set_queueURL", "'http%3A//phd.cs.unibo.it%3A8084/'" ;
160 "UNICODEvsSYMBOL", "'symbol'" ;
161 "doctype-public", "'-//W3C//DTD%20XHTML%201.0%20Transitional//EN'" ;
162 "encoding", "'iso-8859-1'" ;
163 "media-type", "'text/html'" ;
164 "keys", "'d_c%2CC1%2CG%2CC2%2CL'" ;
165 "interfaceURL", "'http%3A//phd.cs.unibo.it/helm/html/cic/index.html'" ;
166 "naturalLanguage", "'yes'" ;
167 "annotations", "'no'" ;
168 "explodeall", "'true()'" ;
169 "topurl", "'http://phd.cs.unibo.it/helm'" ;
170 "CICURI", "'cic:/Coq/Init/Datatypes/bool_ind.con'" ]
173 let sequent_styles = [d_c ; c1 ; g ; c2 ; l];;
175 ["processorURL", "'" ^ processorURL ^ "'" ;
176 "getterURL", "'" ^ getterURL ^ "'" ;
177 "draw_graphURL", "'http%3A//phd.cs.unibo.it%3A8083/'" ;
178 "uri_set_queueURL", "'http%3A//phd.cs.unibo.it%3A8084/'" ;
179 "UNICODEvsSYMBOL", "'symbol'" ;
180 "doctype-public", "'-//W3C//DTD%20XHTML%201.0%20Transitional//EN'" ;
181 "encoding", "'iso-8859-1'" ;
182 "media-type", "'text/html'" ;
183 "keys", "'d_c%2CC1%2CG%2CC2%2CL'" ;
184 "interfaceURL", "'http%3A//phd.cs.unibo.it/helm/html/cic/index.html'" ;
185 "naturalLanguage", "'no'" ;
186 "annotations", "'no'" ;
187 "explodeall", "'true()'" ;
188 "topurl", "'http://phd.cs.unibo.it/helm'" ;
189 "CICURI", "'cic:/Coq/Init/Datatypes/bool_ind.con'" ]
192 let parse_file filename =
193 let inch = open_in filename in
194 let rec read_lines () =
196 let line = input_line inch in
204 let applyStylesheets input styles args =
205 List.fold_left (fun i style -> Gdome_xslt.applyStylesheet i style args)
209 let mml_of_cic_object uri annobj ids_to_inner_sorts ids_to_inner_types =
210 (*CSC: ????????????????? *)
212 Cic2Xml.print_object uri ~ids_to_inner_sorts annobj
215 Cic2Xml.print_inner_types uri ~ids_to_inner_sorts
220 None -> Xml2Gdome.document_of_xml domImpl xml
222 Xml.pp xml (Some constanttypefile) ;
223 Xml2Gdome.document_of_xml domImpl bodyxml'
225 (*CSC: We save the innertypes to disk so that we can retrieve them in the *)
226 (*CSC: stylesheet. This DOES NOT work when UWOBO and/or the getter are not *)
228 Xml.pp xmlinnertypes (Some innertypesfile) ;
229 let output = applyStylesheets input mml_styles mml_args in
236 exception RefreshSequentException of exn;;
237 exception RefreshProofException of exn;;
239 let refresh_proof (output : GMathView.math_view) =
241 let uri,currentproof =
242 match !ProofEngine.proof with
244 | Some (uri,metasenv,bo,ty) ->
245 (*CSC: Wrong: [] is just plainly wrong *)
246 uri,(Cic.CurrentProof (UriManager.name_of_uri uri, metasenv, bo, ty, []))
249 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
250 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
252 Cic2acic.acic_object_of_cic_object currentproof
255 mml_of_cic_object uri acic ids_to_inner_sorts ids_to_inner_types
257 output#load_tree mml ;
259 Some (ids_to_terms,ids_to_father_ids,ids_to_conjectures,ids_to_hypotheses)
262 match !ProofEngine.proof with
264 | Some (uri,metasenv,bo,ty) ->
265 prerr_endline ("Offending proof: " ^ CicPp.ppobj (Cic.CurrentProof ("questa",metasenv,bo,ty,[]))) ; flush stderr ;
266 raise (RefreshProofException e)
269 let refresh_sequent (proofw : GMathView.math_view) =
271 match !ProofEngine.goal with
272 None -> proofw#unload
275 match !ProofEngine.proof with
277 | Some (_,metasenv,_,_) -> metasenv
279 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
280 let sequent_gdome,ids_to_terms,ids_to_father_ids,ids_to_hypotheses =
281 SequentPp.XmlPp.print_sequent metasenv currentsequent
284 Xml2Gdome.document_of_xml domImpl sequent_gdome
287 applyStylesheets sequent_doc sequent_styles sequent_args
289 proofw#load_tree ~dom:sequent_mml ;
290 current_goal_infos :=
291 Some (ids_to_terms,ids_to_father_ids,ids_to_hypotheses)
295 match !ProofEngine.goal with
300 match !ProofEngine.proof with
302 | Some (_,metasenv,_,_) -> metasenv
304 let currentsequent = List.find (function (m,_,_) -> m=metano) metasenv in
305 prerr_endline ("Offending sequent: " ^ SequentPp.TextualPp.print_sequent currentsequent) ; flush stderr ;
306 raise (RefreshSequentException e)
310 ignore(domImpl#saveDocumentToFile ~doc:sequent_doc
311 ~name:"/home/galata/miohelm/guruguru1" ~indent:true ()) ;
314 let mml_of_cic_term metano term =
316 match !ProofEngine.proof with
318 | Some (_,metasenv,_,_) -> metasenv
321 match !ProofEngine.goal with
324 let (_,canonical_context,_) =
325 List.find (function (m,_,_) -> m=metano) metasenv
329 let sequent_gdome,ids_to_terms,ids_to_father_ids,ids_to_hypotheses =
330 SequentPp.XmlPp.print_sequent metasenv (metano,context,term)
333 Xml2Gdome.document_of_xml domImpl sequent_gdome
336 applyStylesheets sequent_doc sequent_styles sequent_args ;
338 current_scratch_infos :=
339 Some (term,ids_to_terms,ids_to_father_ids,ids_to_hypotheses) ;
343 let output_html outputhtml msg =
344 htmlheader_and_content := !htmlheader_and_content ^ msg ;
345 outputhtml#source (!htmlheader_and_content ^ htmlfooter) ;
346 outputhtml#set_topline (-1)
349 (***********************)
351 (***********************)
353 let call_tactic tactic rendering_window () =
354 let proofw = (rendering_window#proofw : GMathView.math_view) in
355 let output = (rendering_window#output : GMathView.math_view) in
356 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
357 let savedproof = !ProofEngine.proof in
358 let savedgoal = !ProofEngine.goal in
362 refresh_sequent proofw ;
365 RefreshSequentException e ->
366 output_html outputhtml
367 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
368 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
369 ProofEngine.proof := savedproof ;
370 ProofEngine.goal := savedgoal ;
371 refresh_sequent proofw
372 | RefreshProofException e ->
373 output_html outputhtml
374 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
375 "proof: " ^ Printexc.to_string e ^ "</h1>") ;
376 ProofEngine.proof := savedproof ;
377 ProofEngine.goal := savedgoal ;
378 refresh_sequent proofw ;
381 output_html outputhtml
382 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
383 ProofEngine.proof := savedproof ;
384 ProofEngine.goal := savedgoal ;
388 let call_tactic_with_input tactic rendering_window () =
389 let proofw = (rendering_window#proofw : GMathView.math_view) in
390 let output = (rendering_window#output : GMathView.math_view) in
391 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
392 let inputt = (rendering_window#inputt : GEdit.text) in
393 let savedproof = !ProofEngine.proof in
394 let savedgoal = !ProofEngine.goal in
395 (*CSC: Gran cut&paste da sotto... *)
396 let inputlen = inputt#length in
397 let input = inputt#get_chars 0 inputlen ^ "\n" in
398 let lexbuf = Lexing.from_string input in
400 match !ProofEngine.proof with
402 | Some (curi,_,_,_) -> curi
404 let uri,metasenv,bo,ty =
405 match !ProofEngine.proof with
407 | Some (uri,metasenv,bo,ty) -> uri,metasenv,bo,ty
414 (match !ProofEngine.goal with
417 let (_,canonical_context,_) =
418 List.find (function (m,_,_) -> m=metano) metasenv
426 CicTextualParserContext.main
427 curi context metasenv CicTextualLexer.token lexbuf
430 | Some (metasenv',expr) ->
431 ProofEngine.proof := Some (uri,metasenv',bo,ty) ;
433 refresh_sequent proofw ;
437 CicTextualParser0.Eof ->
438 inputt#delete_text 0 inputlen
439 | RefreshSequentException e ->
440 output_html outputhtml
441 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
442 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
443 ProofEngine.proof := savedproof ;
444 ProofEngine.goal := savedgoal ;
445 refresh_sequent proofw
446 | RefreshProofException e ->
447 output_html outputhtml
448 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
449 "proof: " ^ Printexc.to_string e ^ "</h1>") ;
450 ProofEngine.proof := savedproof ;
451 ProofEngine.goal := savedgoal ;
452 refresh_sequent proofw ;
455 output_html outputhtml
456 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
457 ProofEngine.proof := savedproof ;
458 ProofEngine.goal := savedgoal ;
461 let call_tactic_with_goal_input tactic rendering_window () =
462 let module L = LogicalOperations in
463 let module G = Gdome in
464 let proofw = (rendering_window#proofw : GMathView.math_view) in
465 let output = (rendering_window#output : GMathView.math_view) in
466 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
467 let savedproof = !ProofEngine.proof in
468 let savedgoal = !ProofEngine.goal in
469 match proofw#get_selection with
472 ((node : Gdome.element)#getAttributeNS
474 ~localName:(G.domString "xref"))#to_string
476 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
480 match !current_goal_infos with
481 Some (ids_to_terms, ids_to_father_ids,_) ->
483 tactic (Hashtbl.find ids_to_terms id) ;
484 refresh_sequent rendering_window#proofw ;
485 refresh_proof rendering_window#output
486 | None -> assert false (* "ERROR: No current term!!!" *)
488 RefreshSequentException e ->
489 output_html outputhtml
490 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
491 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
492 ProofEngine.proof := savedproof ;
493 ProofEngine.goal := savedgoal ;
494 refresh_sequent proofw
495 | RefreshProofException e ->
496 output_html outputhtml
497 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
498 "proof: " ^ Printexc.to_string e ^ "</h1>") ;
499 ProofEngine.proof := savedproof ;
500 ProofEngine.goal := savedgoal ;
501 refresh_sequent proofw ;
504 output_html outputhtml
505 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
506 ProofEngine.proof := savedproof ;
507 ProofEngine.goal := savedgoal ;
510 output_html outputhtml
511 ("<h1 color=\"red\">No term selected</h1>")
514 let call_tactic_with_input_and_goal_input tactic rendering_window () =
515 let module L = LogicalOperations in
516 let module G = Gdome in
517 let proofw = (rendering_window#proofw : GMathView.math_view) in
518 let output = (rendering_window#output : GMathView.math_view) in
519 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
520 let inputt = (rendering_window#inputt : GEdit.text) in
521 let savedproof = !ProofEngine.proof in
522 let savedgoal = !ProofEngine.goal in
523 match proofw#get_selection with
526 ((node : Gdome.element)#getAttributeNS
528 ~localName:(G.domString "xref"))#to_string
530 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
534 match !current_goal_infos with
535 Some (ids_to_terms, ids_to_father_ids,_) ->
537 (* Let's parse the input *)
538 let inputlen = inputt#length in
539 let input = inputt#get_chars 0 inputlen ^ "\n" in
540 let lexbuf = Lexing.from_string input in
542 match !ProofEngine.proof with
544 | Some (curi,_,_,_) -> curi
546 let uri,metasenv,bo,ty =
547 match !ProofEngine.proof with
549 | Some (uri,metasenv,bo,ty) -> uri,metasenv,bo,ty
556 (match !ProofEngine.goal with
559 let (_,canonical_context,_) =
560 List.find (function (m,_,_) -> m=metano) metasenv
569 CicTextualParserContext.main curi context metasenv
570 CicTextualLexer.token lexbuf
573 | Some (metasenv',expr) ->
574 ProofEngine.proof := Some (uri,metasenv',bo,ty) ;
575 tactic ~goal_input:(Hashtbl.find ids_to_terms id)
577 refresh_sequent proofw ;
581 CicTextualParser0.Eof ->
582 inputt#delete_text 0 inputlen
584 | None -> assert false (* "ERROR: No current term!!!" *)
586 RefreshSequentException e ->
587 output_html outputhtml
588 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
589 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
590 ProofEngine.proof := savedproof ;
591 ProofEngine.goal := savedgoal ;
592 refresh_sequent proofw
593 | RefreshProofException e ->
594 output_html outputhtml
595 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
596 "proof: " ^ Printexc.to_string e ^ "</h1>") ;
597 ProofEngine.proof := savedproof ;
598 ProofEngine.goal := savedgoal ;
599 refresh_sequent proofw ;
602 output_html outputhtml
603 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
604 ProofEngine.proof := savedproof ;
605 ProofEngine.goal := savedgoal ;
608 output_html outputhtml
609 ("<h1 color=\"red\">No term selected</h1>")
612 let call_tactic_with_goal_input_in_scratch tactic scratch_window () =
613 let module L = LogicalOperations in
614 let module G = Gdome in
615 let mmlwidget = (scratch_window#mmlwidget : GMathView.math_view) in
616 let outputhtml = (scratch_window#outputhtml : GHtml.xmhtml) in
617 let savedproof = !ProofEngine.proof in
618 let savedgoal = !ProofEngine.goal in
619 match mmlwidget#get_selection with
622 ((node : Gdome.element)#getAttributeNS
624 ~localName:(G.domString "xref"))#to_string
626 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
630 match !current_scratch_infos with
631 (* term is the whole goal in the scratch_area *)
632 Some (term,ids_to_terms, ids_to_father_ids,_) ->
634 let expr = tactic term (Hashtbl.find ids_to_terms id) in
635 let mml = mml_of_cic_term 111 expr in
636 scratch_window#show () ;
637 scratch_window#mmlwidget#load_tree ~dom:mml
638 | None -> assert false (* "ERROR: No current term!!!" *)
641 output_html outputhtml
642 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
645 output_html outputhtml
646 ("<h1 color=\"red\">No term selected</h1>")
649 let call_tactic_with_hypothesis_input tactic rendering_window () =
650 let module L = LogicalOperations in
651 let module G = Gdome in
652 let proofw = (rendering_window#proofw : GMathView.math_view) in
653 let output = (rendering_window#output : GMathView.math_view) in
654 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
655 let savedproof = !ProofEngine.proof in
656 let savedgoal = !ProofEngine.goal in
657 match proofw#get_selection with
660 ((node : Gdome.element)#getAttributeNS
662 ~localName:(G.domString "xref"))#to_string
664 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
668 match !current_goal_infos with
669 Some (_,_,ids_to_hypotheses) ->
671 tactic (Hashtbl.find ids_to_hypotheses id) ;
672 refresh_sequent rendering_window#proofw ;
673 refresh_proof rendering_window#output
674 | None -> assert false (* "ERROR: No current term!!!" *)
676 RefreshSequentException e ->
677 output_html outputhtml
678 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
679 "sequent: " ^ Printexc.to_string e ^ "</h1>") ;
680 ProofEngine.proof := savedproof ;
681 ProofEngine.goal := savedgoal ;
682 refresh_sequent proofw
683 | RefreshProofException e ->
684 output_html outputhtml
685 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
686 "proof: " ^ Printexc.to_string e ^ "</h1>") ;
687 ProofEngine.proof := savedproof ;
688 ProofEngine.goal := savedgoal ;
689 refresh_sequent proofw ;
692 output_html outputhtml
693 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
694 ProofEngine.proof := savedproof ;
695 ProofEngine.goal := savedgoal ;
698 output_html outputhtml
699 ("<h1 color=\"red\">No term selected</h1>")
703 let intros rendering_window = call_tactic ProofEngine.intros rendering_window;;
704 let exact rendering_window =
705 call_tactic_with_input ProofEngine.exact rendering_window
707 let apply rendering_window =
708 call_tactic_with_input ProofEngine.apply rendering_window
710 let elimintrossimpl rendering_window =
711 call_tactic_with_input ProofEngine.elim_intros_simpl rendering_window
713 let elimtype rendering_window =
714 call_tactic_with_input ProofEngine.elim_type rendering_window
716 let whd rendering_window =
717 call_tactic_with_goal_input ProofEngine.whd rendering_window
719 let reduce rendering_window =
720 call_tactic_with_goal_input ProofEngine.reduce rendering_window
722 let simpl rendering_window =
723 call_tactic_with_goal_input ProofEngine.simpl rendering_window
725 let fold rendering_window =
726 call_tactic_with_input ProofEngine.fold rendering_window
728 let cut rendering_window =
729 call_tactic_with_input ProofEngine.cut rendering_window
731 let change rendering_window =
732 call_tactic_with_input_and_goal_input ProofEngine.change rendering_window
734 let letin rendering_window =
735 call_tactic_with_input ProofEngine.letin rendering_window
737 let ring rendering_window = call_tactic ProofEngine.ring rendering_window;;
738 let clearbody rendering_window =
739 call_tactic_with_hypothesis_input ProofEngine.clearbody rendering_window
741 let clear rendering_window =
742 call_tactic_with_hypothesis_input ProofEngine.clear rendering_window
744 let fourier rendering_window =
745 call_tactic ProofEngine.fourier rendering_window
747 let rewritesimpl rendering_window =
748 call_tactic_with_input ProofEngine.rewrite_simpl rendering_window
753 let whd_in_scratch scratch_window =
754 call_tactic_with_goal_input_in_scratch ProofEngine.whd_in_scratch
757 let reduce_in_scratch scratch_window =
758 call_tactic_with_goal_input_in_scratch ProofEngine.reduce_in_scratch
761 let simpl_in_scratch scratch_window =
762 call_tactic_with_goal_input_in_scratch ProofEngine.simpl_in_scratch
768 (**********************)
770 (**********************)
772 exception OpenConjecturesStillThere;;
773 exception WrongProof;;
775 let qed rendering_window () =
776 match !ProofEngine.proof with
778 | Some (uri,[],bo,ty) ->
780 CicReduction.are_convertible []
781 (CicTypeChecker.type_of_aux' [] [] bo) ty
784 (*CSC: Wrong: [] is just plainly wrong *)
785 let proof = Cic.Constant (UriManager.name_of_uri uri,Some bo,ty,[]) in
787 (acic,ids_to_terms,ids_to_father_ids,ids_to_inner_sorts,
788 ids_to_inner_types,ids_to_conjectures,ids_to_hypotheses)
790 Cic2acic.acic_object_of_cic_object proof
793 mml_of_cic_object uri acic ids_to_inner_sorts ids_to_inner_types
795 (rendering_window#output : GMathView.math_view)#load_tree mml ;
798 (ids_to_terms,ids_to_father_ids,ids_to_conjectures,
803 | _ -> raise OpenConjecturesStillThere
807 let dtdname = "http://www.cs.unibo.it/helm/dtd/cic.dtd";;
808 let dtdname = "/home/tassi/miohelm/helm/dtd/cic.dtd";;
810 let dtdname = "/projects/helm/V7_mowgli/dtd/cic.dtd";;
812 let save rendering_window () =
813 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
814 match !ProofEngine.proof with
816 | Some (uri, metasenv, bo, ty) ->
818 (*CSC: Wrong: [] is just plainly wrong *)
819 Cic.CurrentProof (UriManager.name_of_uri uri,metasenv,bo,ty,[])
821 let (acurrentproof,_,_,ids_to_inner_sorts,_,_,_) =
822 Cic2acic.acic_object_of_cic_object currentproof
825 match Cic2Xml.print_object uri ~ids_to_inner_sorts acurrentproof with
826 xml,Some bodyxml -> xml,bodyxml
827 | _,None -> assert false
829 Xml.pp ~quiet:true xml (Some prooffiletype) ;
830 output_html outputhtml
831 ("<h1 color=\"Green\">Current proof type saved to " ^
832 prooffiletype ^ "</h1>") ;
833 Xml.pp ~quiet:true bodyxml (Some prooffile) ;
834 output_html outputhtml
835 ("<h1 color=\"Green\">Current proof body saved to " ^
839 (* Used to typecheck the loaded proofs *)
840 let typecheck_loaded_proof metasenv bo ty =
841 let module T = CicTypeChecker in
844 (fun metasenv ((_,context,ty) as conj) ->
845 ignore (T.type_of_aux' metasenv context ty) ;
848 ignore (T.type_of_aux' metasenv [] ty) ;
849 ignore (T.type_of_aux' metasenv [] bo)
852 (*CSC: ancora da implementare *)
853 let load rendering_window () =
854 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
855 let output = (rendering_window#output : GMathView.math_view) in
856 let proofw = (rendering_window#proofw : GMathView.math_view) in
858 let uri = UriManager.uri_of_string "cic:/dummy.con" in
859 match CicParser.obj_of_xml prooffiletype (Some prooffile) with
860 Cic.CurrentProof (_,metasenv,bo,ty,_) ->
861 typecheck_loaded_proof metasenv bo ty ;
863 Some (uri, metasenv, bo, ty) ;
867 | (metano,_,_)::_ -> Some metano
869 refresh_proof output ;
870 refresh_sequent proofw ;
871 output_html outputhtml
872 ("<h1 color=\"Green\">Current proof type loaded from " ^
873 prooffiletype ^ "</h1>") ;
874 output_html outputhtml
875 ("<h1 color=\"Green\">Current proof body loaded from " ^
879 RefreshSequentException e ->
880 output_html outputhtml
881 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
882 "sequent: " ^ Printexc.to_string e ^ "</h1>")
883 | RefreshProofException e ->
884 output_html outputhtml
885 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
886 "proof: " ^ Printexc.to_string e ^ "</h1>")
888 output_html outputhtml
889 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
892 let proveit rendering_window () =
893 let module L = LogicalOperations in
894 let module G = Gdome in
895 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
896 match rendering_window#output#get_selection with
899 ((node : Gdome.element)#getAttributeNS
901 ((element : G.element)#getAttributeNS
904 ~localName:(G.domString "xref"))#to_string
906 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
910 match !current_cic_infos with
911 Some (ids_to_terms, ids_to_father_ids, _, _) ->
913 L.to_sequent id ids_to_terms ids_to_father_ids ;
914 refresh_proof rendering_window#output ;
915 refresh_sequent rendering_window#proofw
916 | None -> assert false (* "ERROR: No current term!!!" *)
918 RefreshSequentException e ->
919 output_html outputhtml
920 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
921 "sequent: " ^ Printexc.to_string e ^ "</h1>")
922 | RefreshProofException e ->
923 output_html outputhtml
924 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
925 "proof: " ^ Printexc.to_string e ^ "</h1>")
927 output_html outputhtml
928 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
930 | None -> assert false (* "ERROR: No selection!!!" *)
933 let focus rendering_window () =
934 let module L = LogicalOperations in
935 let module G = Gdome in
936 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
937 match rendering_window#output#get_selection with
940 ((node : Gdome.element)#getAttributeNS
942 ((element : G.element)#getAttributeNS
945 ~localName:(G.domString "xref"))#to_string
947 if xpath = "" then assert false (* "ERROR: No xref found!!!" *)
951 match !current_cic_infos with
952 Some (ids_to_terms, ids_to_father_ids, _, _) ->
954 L.focus id ids_to_terms ids_to_father_ids ;
955 refresh_sequent rendering_window#proofw
956 | None -> assert false (* "ERROR: No current term!!!" *)
958 RefreshSequentException e ->
959 output_html outputhtml
960 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
961 "sequent: " ^ Printexc.to_string e ^ "</h1>")
962 | RefreshProofException e ->
963 output_html outputhtml
964 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
965 "proof: " ^ Printexc.to_string e ^ "</h1>")
967 output_html outputhtml
968 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
970 | None -> assert false (* "ERROR: No selection!!!" *)
973 exception NoPrevGoal;;
974 exception NoNextGoal;;
976 let prevgoal metasenv metano =
980 | [(m,_,_)] -> raise NoPrevGoal
981 | (n,_,_)::(m,_,_)::_ when m=metano -> n
987 let nextgoal metasenv metano =
991 | [(m,_,_)] when m = metano -> raise NoNextGoal
992 | (m,_,_)::(n,_,_)::_ when m=metano -> n
998 let prev_or_next_goal select_goal rendering_window () =
999 let module L = LogicalOperations in
1000 let module G = Gdome in
1001 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
1003 match !ProofEngine.proof with
1004 None -> assert false
1005 | Some (_,metasenv,_,_) -> metasenv
1008 match !ProofEngine.goal with
1009 None -> assert false
1013 ProofEngine.goal := Some (select_goal metasenv metano) ;
1014 refresh_sequent rendering_window#proofw
1016 RefreshSequentException e ->
1017 output_html outputhtml
1018 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1019 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1021 output_html outputhtml
1022 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
1025 exception NotADefinition;;
1027 let open_ rendering_window () =
1028 let inputt = (rendering_window#inputt : GEdit.text) in
1029 let oldinputt = (rendering_window#oldinputt : GEdit.text) in
1030 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
1031 let output = (rendering_window#output : GMathView.math_view) in
1032 let proofw = (rendering_window#proofw : GMathView.math_view) in
1033 let inputlen = inputt#length in
1034 let input = inputt#get_chars 0 inputlen in
1036 let uri = UriManager.uri_of_string ("cic:" ^ input) in
1037 CicTypeChecker.typecheck uri ;
1038 let metasenv,bo,ty =
1039 match CicEnvironment.get_cooked_obj uri with
1040 Cic.Constant (_,Some bo,ty,_) -> [],bo,ty
1041 | Cic.CurrentProof (_,metasenv,bo,ty,_) -> metasenv,bo,ty
1044 | Cic.InductiveDefinition _ -> raise NotADefinition
1046 ProofEngine.proof :=
1047 Some (uri, metasenv, bo, ty) ;
1048 ProofEngine.goal := None ;
1049 refresh_sequent proofw ;
1050 refresh_proof output ;
1051 inputt#delete_text 0 inputlen ;
1052 ignore(oldinputt#insert_text input oldinputt#length)
1054 RefreshSequentException e ->
1055 output_html outputhtml
1056 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1057 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1058 | RefreshProofException e ->
1059 output_html outputhtml
1060 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1061 "proof: " ^ Printexc.to_string e ^ "</h1>")
1063 output_html outputhtml
1064 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1067 let state rendering_window () =
1068 let inputt = (rendering_window#inputt : GEdit.text) in
1069 let oldinputt = (rendering_window#oldinputt : GEdit.text) in
1070 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
1071 let output = (rendering_window#output : GMathView.math_view) in
1072 let proofw = (rendering_window#proofw : GMathView.math_view) in
1073 let inputlen = inputt#length in
1074 let input = inputt#get_chars 0 inputlen ^ "\n" in
1075 (* Do something interesting *)
1076 let lexbuf = Lexing.from_string input in
1079 (* Execute the actions *)
1080 match CicTextualParser.main CicTextualLexer.token lexbuf with
1083 let _ = CicTypeChecker.type_of_aux' [] [] expr in
1084 ProofEngine.proof :=
1085 Some (UriManager.uri_of_string "cic:/dummy.con",
1086 [1,[],expr], Cic.Meta (1,[]), expr) ;
1087 ProofEngine.goal := Some 1 ;
1088 refresh_sequent proofw ;
1089 refresh_proof output ;
1092 CicTextualParser0.Eof ->
1093 inputt#delete_text 0 inputlen ;
1094 ignore(oldinputt#insert_text input oldinputt#length)
1095 | RefreshSequentException e ->
1096 output_html outputhtml
1097 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1098 "sequent: " ^ Printexc.to_string e ^ "</h1>")
1099 | RefreshProofException e ->
1100 output_html outputhtml
1101 ("<h1 color=\"red\">Exception raised during the refresh of the " ^
1102 "proof: " ^ Printexc.to_string e ^ "</h1>")
1104 output_html outputhtml
1105 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1108 let check rendering_window scratch_window () =
1109 let inputt = (rendering_window#inputt : GEdit.text) in
1110 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
1111 let output = (rendering_window#output : GMathView.math_view) in
1112 let proofw = (rendering_window#proofw : GMathView.math_view) in
1113 let inputlen = inputt#length in
1114 let input = inputt#get_chars 0 inputlen ^ "\n" in
1116 match !ProofEngine.proof with
1117 None -> UriManager.uri_of_string "cic:/dummy.con", []
1118 | Some (curi,metasenv,_,_) -> curi,metasenv
1120 let context,names_context =
1122 match !ProofEngine.goal with
1125 let (_,canonical_context,_) =
1126 List.find (function (m,_,_) -> m=metano) metasenv
1133 Some (n,_) -> Some n
1137 let lexbuf = Lexing.from_string input in
1140 (* Execute the actions *)
1142 CicTextualParserContext.main curi names_context metasenv
1143 CicTextualLexer.token lexbuf
1146 | Some (metasenv',expr) ->
1148 let ty = CicTypeChecker.type_of_aux' metasenv' context expr in
1149 let mml = mml_of_cic_term 111 (Cic.Cast (expr,ty)) in
1150 prerr_endline ("### " ^ CicPp.ppterm expr ^ " ==> " ^ CicPp.ppterm ty) ;
1151 scratch_window#show () ;
1152 scratch_window#mmlwidget#load_tree ~dom:mml
1155 print_endline ("? " ^ CicPp.ppterm expr) ;
1159 CicTextualParser0.Eof -> ()
1161 output_html outputhtml
1162 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
1165 exception NoObjectsLocated;;
1167 let user_uri_choice uris =
1170 [] -> raise NoObjectsLocated
1174 GToolbox.question_box ~title:"Ambiguous result."
1175 ~buttons:uris ~default:1
1176 "Ambiguous result. Please, choose one."
1178 List.nth uris (choice-1)
1180 String.sub uri 4 (String.length uri - 4)
1183 (* CSC: IMPERATIVE AND NOT VERY CLEAN, TO GET THE LAST ISSUED QUERY *)
1184 let get_last_query =
1185 let query = ref "" in
1186 MQueryGenerator.set_confirm_query
1187 (function q -> query := MQueryUtil.text_of_query q ; true) ;
1188 function result -> !query ^ " <h1>Result:</h1> " ^ MQueryUtil.text_of_result result "<br>"
1191 let locate rendering_window () =
1192 let inputt = (rendering_window#inputt : GEdit.text) in
1193 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
1194 let inputlen = inputt#length in
1195 let input = inputt#get_chars 0 inputlen in
1197 match Str.split (Str.regexp "[ \t]+") input with
1200 inputt#delete_text 0 inputlen ;
1201 let result = MQueryGenerator.locate head in
1204 (function uri,_ -> wrong_xpointer_format_from_wrong_xpointer_format' uri)
1206 let html = (" <h1>Locate Query: </h1><pre>" ^ get_last_query result ^ "</pre>") in
1207 output_html outputhtml html ;
1208 let uri' = user_uri_choice uris in
1209 ignore ((inputt#insert_text uri') ~pos:0)
1212 output_html outputhtml
1213 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
1216 let searchPattern rendering_window () =
1217 let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
1218 let inputt = (rendering_window#inputt : GEdit.text) in
1219 let inputlen = inputt#length in
1220 let input = inputt#get_chars 0 inputlen in
1221 let level = int_of_string input in
1223 match !ProofEngine.proof with
1224 None -> assert false
1225 | Some (_,metasenv,_,_) -> metasenv
1228 match !ProofEngine.goal with
1231 let (_, ey ,ty) = List.find (function (m,_,_) -> m=metano) metasenv in
1232 let result = MQueryGenerator.searchPattern metasenv ey ty level in
1235 (function uri,_ -> wrong_xpointer_format_from_wrong_xpointer_format' uri)
1238 " <h1>Backward Query: </h1>" ^
1239 " <h2>Levels: </h2> " ^
1240 MQueryGenerator.string_of_levels
1241 (MQueryGenerator.levels_of_term metasenv ey ty) "<br>" ^
1242 " <pre>" ^ get_last_query result ^ "</pre>"
1244 output_html outputhtml html ;
1246 let rec filter_out =
1250 let tl',exc = filter_out tl in
1252 if ProofEngine.can_apply (term_of_uri uri) then
1259 "<h1 color=\"red\"> ^ Exception raised trying to apply " ^
1260 uri ^ ": " ^ Printexc.to_string e ^ " </h1>" ^ exc
1267 " <h1>Objects that can actually be applied: </h1> " ^
1268 String.concat "<br>" uris' ^ exc ^
1269 " <h1>Number of false matches: " ^
1270 string_of_int (List.length uris - List.length uris') ^ "</h1>"
1272 output_html outputhtml html' ;
1273 let uri' = user_uri_choice uris' in
1274 inputt#delete_text 0 inputlen ;
1275 ignore ((inputt#insert_text uri') ~pos:0)
1278 output_html outputhtml
1279 ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
1282 let choose_selection
1283 (mmlwidget : GMathView.math_view) (element : Gdome.element option)
1285 let module G = Gdome in
1286 let rec aux element =
1287 if element#hasAttributeNS
1288 ~namespaceURI:helmns
1289 ~localName:(G.domString "xref")
1291 mmlwidget#set_selection (Some element)
1293 match element#get_parentNode with
1294 None -> assert false
1295 (*CSC: OCAML DIVERGES!
1296 | Some p -> aux (new G.element_of_node p)
1298 | Some p -> aux (new Gdome.element_of_node p)
1302 | None -> mmlwidget#set_selection None
1305 (* STUFF TO BUILD THE GTK INTERFACE *)
1307 (* Stuff for the widget settings *)
1309 let export_to_postscript (output : GMathView.math_view) () =
1310 output#export_to_postscript ~filename:"output.ps" ();
1313 let activate_t1 (output : GMathView.math_view) button_set_anti_aliasing
1314 button_set_kerning button_set_transparency button_export_to_postscript
1317 let is_set = button_t1#active in
1318 output#set_font_manager_type
1319 (if is_set then `font_manager_t1 else `font_manager_gtk) ;
1322 button_set_anti_aliasing#misc#set_sensitive true ;
1323 button_set_kerning#misc#set_sensitive true ;
1324 button_set_transparency#misc#set_sensitive true ;
1325 button_export_to_postscript#misc#set_sensitive true ;
1329 button_set_anti_aliasing#misc#set_sensitive false ;
1330 button_set_kerning#misc#set_sensitive false ;
1331 button_set_transparency#misc#set_sensitive false ;
1332 button_export_to_postscript#misc#set_sensitive false ;
1336 let set_anti_aliasing output button_set_anti_aliasing () =
1337 output#set_anti_aliasing button_set_anti_aliasing#active
1340 let set_kerning output button_set_kerning () =
1341 output#set_kerning button_set_kerning#active
1344 let set_transparency output button_set_transparency () =
1345 output#set_transparency button_set_transparency#active
1348 let changefont output font_size_spinb () =
1349 output#set_font_size font_size_spinb#value_as_int
1352 let set_log_verbosity output log_verbosity_spinb () =
1353 output#set_log_verbosity log_verbosity_spinb#value_as_int
1356 class settings_window (output : GMathView.math_view) sw
1357 button_export_to_postscript selection_changed_callback
1359 let settings_window = GWindow.window ~title:"GtkMathView settings" () in
1361 GPack.vbox ~packing:settings_window#add () in
1364 ~rows:1 ~columns:3 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
1365 ~border_width:5 ~packing:vbox#add () in
1367 GButton.toggle_button ~label:"activate t1 fonts"
1368 ~packing:(table#attach ~left:0 ~top:0) () in
1369 let button_set_anti_aliasing =
1370 GButton.toggle_button ~label:"set_anti_aliasing"
1371 ~packing:(table#attach ~left:0 ~top:1) () in
1372 let button_set_kerning =
1373 GButton.toggle_button ~label:"set_kerning"
1374 ~packing:(table#attach ~left:1 ~top:1) () in
1375 let button_set_transparency =
1376 GButton.toggle_button ~label:"set_transparency"
1377 ~packing:(table#attach ~left:2 ~top:1) () in
1380 ~rows:2 ~columns:2 ~homogeneous:false ~row_spacings:5 ~col_spacings:5
1381 ~border_width:5 ~packing:vbox#add () in
1382 let font_size_label =
1383 GMisc.label ~text:"font size:"
1384 ~packing:(table#attach ~left:0 ~top:0 ~expand:`NONE) () in
1385 let font_size_spinb =
1387 GData.adjustment ~value:14.0 ~lower:5.0 ~upper:50.0 ~step_incr:1.0 ()
1390 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:0 ~fill:`NONE) () in
1391 let log_verbosity_label =
1392 GMisc.label ~text:"log verbosity:"
1393 ~packing:(table#attach ~left:0 ~top:1) () in
1394 let log_verbosity_spinb =
1396 GData.adjustment ~value:0.0 ~lower:0.0 ~upper:3.0 ~step_incr:1.0 ()
1399 ~adjustment:sadj ~packing:(table#attach ~left:1 ~top:1) () in
1401 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1403 GButton.button ~label:"Close"
1404 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1406 method show = settings_window#show
1408 button_set_anti_aliasing#misc#set_sensitive false ;
1409 button_set_kerning#misc#set_sensitive false ;
1410 button_set_transparency#misc#set_sensitive false ;
1411 (* Signals connection *)
1412 ignore(button_t1#connect#clicked
1413 (activate_t1 output button_set_anti_aliasing button_set_kerning
1414 button_set_transparency button_export_to_postscript button_t1)) ;
1415 ignore(font_size_spinb#connect#changed (changefont output font_size_spinb)) ;
1416 ignore(button_set_anti_aliasing#connect#toggled
1417 (set_anti_aliasing output button_set_anti_aliasing));
1418 ignore(button_set_kerning#connect#toggled
1419 (set_kerning output button_set_kerning)) ;
1420 ignore(button_set_transparency#connect#toggled
1421 (set_transparency output button_set_transparency)) ;
1422 ignore(log_verbosity_spinb#connect#changed
1423 (set_log_verbosity output log_verbosity_spinb)) ;
1424 ignore(closeb#connect#clicked settings_window#misc#hide)
1427 (* Scratch window *)
1429 class scratch_window outputhtml =
1431 GWindow.window ~title:"MathML viewer" ~border_width:2 () in
1433 GPack.vbox ~packing:window#add () in
1435 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1437 GButton.button ~label:"Whd"
1438 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1440 GButton.button ~label:"Reduce"
1441 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1443 GButton.button ~label:"Simpl"
1444 ~packing:(hbox#pack ~expand:false ~fill:false ~padding:5) () in
1445 let scrolled_window =
1446 GBin.scrolled_window ~border_width:10
1447 ~packing:(vbox#pack ~expand:true ~padding:5) () in
1450 ~packing:(scrolled_window#add) ~width:400 ~height:280 () in
1452 method outputhtml = outputhtml
1453 method mmlwidget = mmlwidget
1454 method show () = window#misc#hide () ; window#show ()
1456 ignore(mmlwidget#connect#selection_changed (choose_selection mmlwidget)) ;
1457 ignore(window#event#connect#delete (fun _ -> window#misc#hide () ; true )) ;
1458 ignore(whdb#connect#clicked (whd_in_scratch self)) ;
1459 ignore(reduceb#connect#clicked (reduce_in_scratch self)) ;
1460 ignore(simplb#connect#clicked (simpl_in_scratch self))
1465 class rendering_window output proofw (label : GMisc.label) =
1467 GWindow.window ~title:"MathML viewer" ~border_width:2 () in
1469 GPack.hbox ~packing:window#add () in
1471 GPack.vbox ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1472 let _ = vbox#pack ~expand:false ~fill:false ~padding:5 label#coerce in
1473 let scrolled_window0 =
1474 GBin.scrolled_window ~border_width:10
1475 ~packing:(vbox#pack ~expand:true ~padding:5) () in
1476 let _ = scrolled_window0#add output#coerce in
1478 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1480 GButton.button ~label:"Settings"
1481 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1482 let button_export_to_postscript =
1483 GButton.button ~label:"export_to_postscript"
1484 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1486 GButton.button ~label:"Qed"
1487 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1489 GButton.button ~label:"Save"
1490 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1492 GButton.button ~label:"Load"
1493 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1495 GButton.button ~label:"Close"
1496 ~packing:(hbox1#pack ~expand:false ~fill:false ~padding:5) () in
1498 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1500 GButton.button ~label:"Prove It"
1501 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1503 GButton.button ~label:"Focus"
1504 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1506 GButton.button ~label:"<"
1507 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1509 GButton.button ~label:">"
1510 ~packing:(hbox2#pack ~expand:false ~fill:false ~padding:5) () in
1511 let oldinputt = GEdit.text ~editable:false ~width:400 ~height:180
1512 ~packing:(vbox#pack ~padding:5) () in
1514 GPack.hbox ~packing:(vbox#pack ~expand:false ~fill:false ~padding:5) () in
1516 GButton.button ~label:"State"
1517 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1519 GButton.button ~label:"Open"
1520 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1522 GButton.button ~label:"Check"
1523 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1525 GButton.button ~label:"Locate"
1526 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1527 let searchpatternb =
1528 GButton.button ~label:"SearchPattern"
1529 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1530 let inputt = GEdit.text ~editable:true ~width:400 ~height: 100
1531 ~packing:(vbox#pack ~padding:5) () in
1533 GPack.vbox ~packing:(hbox0#pack ~expand:false ~fill:false ~padding:5) () in
1534 let scrolled_window1 =
1535 GBin.scrolled_window ~border_width:10
1536 ~packing:(vbox1#pack ~expand:true ~padding:5) () in
1537 let _ = scrolled_window1#add proofw#coerce in
1539 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
1541 GButton.button ~label:"Exact"
1542 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1544 GButton.button ~label:"Intros"
1545 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1547 GButton.button ~label:"Apply"
1548 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1549 let elimintrossimplb =
1550 GButton.button ~label:"ElimIntrosSimpl"
1551 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1553 GButton.button ~label:"ElimType"
1554 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1556 GButton.button ~label:"Whd"
1557 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1559 GButton.button ~label:"Reduce"
1560 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1562 GButton.button ~label:"Simpl"
1563 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1565 GButton.button ~label:"Fold"
1566 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1568 GButton.button ~label:"Cut"
1569 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1571 GButton.button ~label:"Change"
1572 ~packing:(hbox3#pack ~expand:false ~fill:false ~padding:5) () in
1574 GPack.hbox ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5) () in
1576 GButton.button ~label:"Let ... In"
1577 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1579 GButton.button ~label:"Ring"
1580 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1582 GButton.button ~label:"ClearBody"
1583 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1585 GButton.button ~label:"Clear"
1586 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1588 GButton.button ~label:"Fourier"
1589 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1591 GButton.button ~label:"RewriteSimpl ->"
1592 ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
1595 ~source:"<html><body bgColor=\"white\"></body></html>"
1596 ~width:400 ~height: 200
1597 ~packing:(vbox1#pack ~expand:false ~fill:false ~padding:5)
1599 let scratch_window = new scratch_window outputhtml in
1601 method outputhtml = outputhtml
1602 method oldinputt = oldinputt
1603 method inputt = inputt
1604 method output = (output : GMathView.math_view)
1605 method proofw = (proofw : GMathView.math_view)
1606 method show = window#show
1608 button_export_to_postscript#misc#set_sensitive false ;
1610 (* signal handlers here *)
1611 ignore(output#connect#selection_changed
1612 (function elem -> proofw#unload ; choose_selection output elem)) ;
1613 ignore(proofw#connect#selection_changed (choose_selection proofw)) ;
1614 ignore(closeb#connect#clicked (fun _ -> GMain.Main.quit ())) ;
1615 let settings_window = new settings_window output scrolled_window0
1616 button_export_to_postscript (choose_selection output) in
1617 ignore(settingsb#connect#clicked settings_window#show) ;
1618 ignore(button_export_to_postscript#connect#clicked (export_to_postscript output)) ;
1619 ignore(qedb#connect#clicked (qed self)) ;
1620 ignore(saveb#connect#clicked (save self)) ;
1621 ignore(loadb#connect#clicked (load self)) ;
1622 ignore(proveitb#connect#clicked (proveit self)) ;
1623 ignore(focusb#connect#clicked (focus self)) ;
1624 ignore(prevgoalb#connect#clicked (prev_or_next_goal prevgoal self)) ;
1625 ignore(nextgoalb#connect#clicked (prev_or_next_goal nextgoal self)) ;
1626 ignore(window#event#connect#delete (fun _ -> GMain.Main.quit () ; true )) ;
1627 ignore(stateb#connect#clicked (state self)) ;
1628 ignore(openb#connect#clicked (open_ self)) ;
1629 ignore(checkb#connect#clicked (check self scratch_window)) ;
1630 ignore(locateb#connect#clicked (locate self)) ;
1631 ignore(searchpatternb#connect#clicked (searchPattern self)) ;
1632 ignore(exactb#connect#clicked (exact self)) ;
1633 ignore(applyb#connect#clicked (apply self)) ;
1634 ignore(elimintrossimplb#connect#clicked (elimintrossimpl self)) ;
1635 ignore(elimtypeb#connect#clicked (elimtype self)) ;
1636 ignore(whdb#connect#clicked (whd self)) ;
1637 ignore(reduceb#connect#clicked (reduce self)) ;
1638 ignore(simplb#connect#clicked (simpl self)) ;
1639 ignore(foldb#connect#clicked (fold self)) ;
1640 ignore(cutb#connect#clicked (cut self)) ;
1641 ignore(changeb#connect#clicked (change self)) ;
1642 ignore(letinb#connect#clicked (letin self)) ;
1643 ignore(ringb#connect#clicked (ring self)) ;
1644 ignore(clearbodyb#connect#clicked (clearbody self)) ;
1645 ignore(clearb#connect#clicked (clear self)) ;
1646 ignore(fourierb#connect#clicked (fourier self)) ;
1647 ignore(rewritesimplb#connect#clicked (rewritesimpl self)) ;
1648 ignore(introsb#connect#clicked (intros self)) ;
1649 Logger.log_callback :=
1650 (Logger.log_to_html ~print_and_flush:(output_html outputhtml))
1655 let rendering_window = ref None;;
1657 let initialize_everything () =
1658 let module U = Unix in
1659 let output = GMathView.math_view ~width:350 ~height:280 ()
1660 and proofw = GMathView.math_view ~width:400 ~height:275 ()
1661 and label = GMisc.label ~text:"gTopLevel" () in
1662 let rendering_window' =
1663 new rendering_window output proofw label
1665 rendering_window := Some rendering_window' ;
1666 rendering_window'#show () ;
1674 Mqint.init "dbname=helm" ;
1676 Mqint.init "host=mowgli.cs.unibo.it dbname=helm_mowgli user=helm" ;
1677 CicTextualParser0.set_locate_object
1679 let result = MQueryGenerator.locate id in
1683 wrong_xpointer_format_from_wrong_xpointer_format' uri
1686 (" <h1>Locate Query: </h1><pre>" ^ get_last_query result ^ "</pre>")
1689 match !rendering_window with
1690 None -> assert false
1691 | Some rw -> output_html rw#outputhtml html ;
1697 (GToolbox.input_string ~title:"Unknown input"
1698 ("No URI matching \"" ^ id ^ "\" found. Please enter its URI"))
1701 | Some uri -> Some ("cic:" ^ uri)
1706 GToolbox.question_box ~title:"Ambiguous input."
1707 ~buttons:uris ~default:1 "Ambiguous input. Please, choose one."
1710 Some (List.nth uris (choice - 1))
1712 (* No choice from the user *)
1716 Some uri' -> Some (cic_textual_parser_uri_of_uri uri')
1720 ignore (GtkMain.Main.init ()) ;
1721 initialize_everything () ;
1722 if !usedb then Mqint.close ();