]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/gTopLevel/gTopLevel.ml
Experimental commit: definitions are now allowed in contexts. As a consequence,
[helm.git] / helm / gTopLevel / gTopLevel.ml
index f6556ed8c58614589af187b497486ffc8e6c4cb4..47c416d8b60b9ad472098d883f4cacf2f2026345 100644 (file)
@@ -83,12 +83,6 @@ let c2 = parseStyle "annotatedpres.xsl";;
 
 let getterURL = Configuration.getter_url;;
 let processorURL = Configuration.processor_url;;
-(*
-let processorURL = "http://phd.cs.unibo.it:8080/helm/servelt/uwobo/";;
-let getterURL = "http://phd.cs.unibo.it:8081/";;
-let processorURL = "http://localhost:8080/helm/servelt/uwobo/";;
-let getterURL = "http://localhost:8081/";;
-*)
 
 let mml_styles = [d_c ; c1 ; g ; c2 ; l];;
 let mml_args =
@@ -157,7 +151,7 @@ let mml_of_cic_object uri annobj ids_to_inner_sorts ids_to_inner_types =
 (*CSC: We save the innertypes to disk so that we can retrieve them in the  *)
 (*CSC: stylesheet. This DOES NOT work when UWOBO and/or the getter are not *)
 (*CSC: local.                                                              *)
-   Xml.pp xmlinnertypes (Some "/public/sacerdot/innertypes") ;
+   Xml.pp xmlinnertypes (Some "/public/fguidi/innertypes") ;
    let output = applyStylesheets input mml_styles mml_args in
     output
 ;;
@@ -340,13 +334,6 @@ let call_tactic_with_input tactic rendering_window () =
         output_html outputhtml
          ("<h1 color=\"red\">Exception raised during the refresh of the " ^
           "proof: " ^ Printexc.to_string e ^ "</h1>") ;
-prerr_endline "PROVA CHE FA SOLLEVARE UN'ECCEZIONE:" ; flush stderr ;
-begin
-match !ProofEngine.proof with Some (_,metasenv,bo,_) ->
-List.iter (function (i,ty) -> prerr_endline ("?" ^ string_of_int i ^ ": " ^
-CicPp.ppterm ty) ; flush stderr) metasenv ;
-prerr_endline ("PROOF: " ^ CicPp.ppterm bo) ; flush stderr ;
-end ;
         ProofEngine.proof := savedproof ;
         ProofEngine.goal := savedgoal ;
         refresh_sequent proofw ;
@@ -595,7 +582,10 @@ let save rendering_window () =
  match !ProofEngine.proof with
     None -> assert false
   | Some (uri,[],bo,ty) ->
-     if CicReduction.are_convertible (CicTypeChecker.type_of_aux' [] [] bo) ty then
+     if
+      CicReduction.are_convertible []
+       (CicTypeChecker.type_of_aux' [] [] bo) ty
+     then
       begin
        (*CSC: Wrong: [] is just plainly wrong *)
        let proof = Cic.Definition (UriManager.name_of_uri uri,bo,ty,[]) in
@@ -642,9 +632,17 @@ let proveit rendering_window () =
               refresh_sequent rendering_window#proofw
           | None -> assert false (* "ERROR: No current term!!!" *)
         with
-         e ->
-          output_html outputhtml
-           ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
+           RefreshSequentException e ->
+            output_html outputhtml
+             ("<h1 color=\"red\">Exception raised during the refresh of the " ^
+              "sequent: " ^ Printexc.to_string e ^ "</h1>")
+         | RefreshProofException e ->
+            output_html outputhtml
+             ("<h1 color=\"red\">Exception raised during the refresh of the " ^
+              "proof: " ^ Printexc.to_string e ^ "</h1>")
+         | e ->
+            output_html outputhtml
+             ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
        end
   | None -> assert false (* "ERROR: No selection!!!" *)
 ;;
@@ -673,14 +671,22 @@ let open_ rendering_window () =
       ProofEngine.proof :=
        Some (uri, metasenv, bo, ty) ;
       ProofEngine.goal := None ;
-      inputt#delete_text 0 inputlen ;
-      ignore(oldinputt#insert_text input oldinputt#length) ;
       refresh_sequent proofw ;
       refresh_proof output ;
+      inputt#delete_text 0 inputlen ;
+      ignore(oldinputt#insert_text input oldinputt#length)
    with
-    e ->
-     output_html outputhtml
-      ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
+      RefreshSequentException e ->
+       output_html outputhtml
+        ("<h1 color=\"red\">Exception raised during the refresh of the " ^
+         "sequent: " ^ Printexc.to_string e ^ "</h1>")
+    | RefreshProofException e ->
+       output_html outputhtml
+        ("<h1 color=\"red\">Exception raised during the refresh of the " ^
+         "proof: " ^ Printexc.to_string e ^ "</h1>")
+    | e ->
+       output_html outputhtml
+        ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
 ;;
 
 let state rendering_window () =
@@ -699,23 +705,26 @@ let state rendering_window () =
       match CicTextualParser.main CicTextualLexer.token lexbuf with
          None -> ()
        | Some expr ->
-          try
-           let _  = CicTypeChecker.type_of_aux' [] [] expr in
-            ProofEngine.proof :=
-             Some (UriManager.uri_of_string "cic:/dummy.con",
-                    [1,expr], Cic.Meta 1, expr) ;
-            ProofEngine.goal := Some (1,([],expr)) ;
-            refresh_sequent proofw ;
-            refresh_proof output ;
-          with
-           e ->
-            print_endline ("? " ^ CicPp.ppterm expr) ;
-            raise e
+          let _  = CicTypeChecker.type_of_aux' [] [] expr in
+           ProofEngine.proof :=
+            Some (UriManager.uri_of_string "cic:/dummy.con",
+                   [1,expr], Cic.Meta 1, expr) ;
+           ProofEngine.goal := Some (1,([],expr)) ;
+           refresh_sequent proofw ;
+           refresh_proof output ;
      done
     with
        CicTextualParser0.Eof ->
         inputt#delete_text 0 inputlen ;
         ignore(oldinputt#insert_text input oldinputt#length)
+     | RefreshSequentException e ->
+        output_html outputhtml
+         ("<h1 color=\"red\">Exception raised during the refresh of the " ^
+          "sequent: " ^ Printexc.to_string e ^ "</h1>")
+     | RefreshProofException e ->
+        output_html outputhtml
+         ("<h1 color=\"red\">Exception raised during the refresh of the " ^
+          "proof: " ^ Printexc.to_string e ^ "</h1>")
      | e ->
         output_html outputhtml
          ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
@@ -723,7 +732,6 @@ let state rendering_window () =
 
 let check rendering_window scratch_window () =
  let inputt = (rendering_window#inputt : GEdit.text) in
- let oldinputt = (rendering_window#oldinputt : GEdit.text) in
  let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
  let output = (rendering_window#output : GMathView.math_view) in
  let proofw = (rendering_window#proofw : GMathView.math_view) in
@@ -769,14 +777,35 @@ let check rendering_window scratch_window () =
             raise e
      done
     with
-       CicTextualParser0.Eof ->
-        inputt#delete_text 0 inputlen ;
-        ignore(oldinputt#insert_text input oldinputt#length)
+       CicTextualParser0.Eof -> ()
      | e ->
        output_html outputhtml
         ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>") ;
 ;;
 
+let locate rendering_window () =
+ let inputt = (rendering_window#inputt : GEdit.text) in
+ let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
+  let inputlen = inputt#length in
+  let input = inputt#get_chars 0 inputlen in
+   try   
+    output_html outputhtml (Mquery.locate input) ;
+    inputt#delete_text 0 inputlen 
+   with
+    e -> 
+     output_html outputhtml
+      ("<h1 color=\"red\">" ^ Printexc.to_string e ^ "</h1>")
+;;
+
+let backward rendering_window () =
+   let outputhtml = (rendering_window#outputhtml : GHtml.xmhtml) in
+   let result =
+      match !ProofEngine.goal with
+         | None -> ""
+         | Some (_, (_, t)) -> (Mquery.backward t)
+      in 
+   output_html outputhtml result
+      
 let choose_selection
      (mmlwidget : GMathView.math_view) (element : Gdome.element option)
 =
@@ -1004,6 +1033,12 @@ class rendering_window output proofw (label : GMisc.label) =
  let checkb =
   GButton.button ~label:"Check"
    ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
+ let locateb =
+  GButton.button ~label:"Locate"
+   ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
+ let backwardb =
+  GButton.button ~label:"Backward"
+   ~packing:(hbox4#pack ~expand:false ~fill:false ~padding:5) () in
  let inputt = GEdit.text ~editable:true ~width:400 ~height: 100
    ~packing:(vbox#pack ~padding:5) () in
  let vbox1 =
@@ -1079,6 +1114,8 @@ object(self)
   ignore(stateb#connect#clicked (state self)) ;
   ignore(openb#connect#clicked (open_ self)) ;
   ignore(checkb#connect#clicked (check self scratch_window)) ;
+  ignore(locateb#connect#clicked (locate self)) ;
+  ignore(backwardb#connect#clicked (backward self)) ;
   ignore(exactb#connect#clicked (exact self)) ;
   ignore(applyb#connect#clicked (apply self)) ;
   ignore(elimintrosb#connect#clicked (elimintros self)) ;