]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/gTopLevel/topLevel/topLevel.ml
*** empty log message ***
[helm.git] / helm / gTopLevel / topLevel / topLevel.ml
index d53ea70eaf5096cb4a015266a0d58fa958bca7c9..745be0767a6b137a7937447e20b2757a5e929316 100644 (file)
@@ -1,4 +1,4 @@
-let connection_param = "host=mowgli.cs.unibo.it dbname=helm user=helm"
+let connection_param = "host=mowgli.cs.unibo.it dbname=helm_mowgli_new_schema user=helm"
 
 let show_queries = ref false
 
@@ -25,13 +25,13 @@ let get_terms () =
    let lexbuf = Lexing.from_channel stdin in
    try
       while true do
-         match CicTextualParserContext.main  
-           (UriManager.uri_of_string "cic:/dummy") [] []
-           CicTextualLexer.token lexbuf
-           with
-            | None           -> ()
-            | Some (_, expr) -> terms := expr :: ! terms
-      done;
+       let dom,mk_term =
+        CicTextualParserContext.main [] [] CicTextualLexer.token lexbuf
+       in
+        match dom with
+          [] -> terms := (snd (mk_term (function _ -> None))) :: !terms
+        | _ -> assert false
+      done ;
       ! terms
    with
       CicTextualParser0.Eof -> ! terms
@@ -39,10 +39,9 @@ let get_terms () =
 let pp_type_of uri = 
    let u = UriManager.uri_of_string uri in  
    let s = match (CicEnvironment.get_obj u) with
-      | Cic.Definition (_, _, ty, _) -> CicPp.ppterm ty
-      | Cic.Axiom (_, ty, _)         -> CicPp.ppterm ty
-      | Cic.Variable (_, _, ty)      -> CicPp.ppterm ty
-      | _                            -> "Current proof or inductive definition."      
+      | Cic.Constant (_, _, ty, _) -> CicPp.ppterm ty
+      | Cic.Variable (_, _, ty, _) -> CicPp.ppterm ty
+      | _                          -> "Current proof or inductive definition."      
 (*
       | Cic.CurrentProof (_,conjs,te,ty) ->
       | C.InductiveDefinition _ ->
@@ -74,18 +73,6 @@ let rec display = function
       print_string ("? " ^ CicPp.ppterm term ^ nl);
       flush stdout
 
-let levels l =
-   let module Gen = MQueryGenerator in
-   let rec levels_aux = function
-      | []           -> ()
-      | term :: tail -> 
-         levels_aux tail;
-         print_string ("? " ^ CicPp.ppterm term ^ nl);
-         print_string (Gen.string_of_levels (Gen.levels_of_term [] [] term) nl);
-         flush stdout
-   in
-   levels_aux l
-
 let execute ich =
    let module Util = MQueryUtil in
    let module Gen = MQueryGenerator in
@@ -121,7 +108,10 @@ let mbackward n m l =
            if Mqint.get_stat () then 
               print_string ("? " ^ CicPp.ppterm term ^ nl);
            let t0 = Sys.time () in
-            let r = Gen.backward [] [] term level in
+           let list_of_must,can = MQueryLevels.out_restr [] [] term in
+           let len = List.length list_of_must in
+           let must = if level < len then List.nth list_of_must level else can in
+           let r = Gen.searchPattern [] [] term must can in
            let t1 = Sys.time () -. t0 in
            let info = Gen.get_query_info () in
            let num = List.nth info 0 in
@@ -157,7 +147,6 @@ let prerr_help () =
    prerr_endline "-t  -typeof URI         outputs the CIC type of the given HELM object";
    prerr_endline "-x  -execute            issues a query given in the input file";
    prerr_endline "-d  -disply             outputs the CIC terms given in the input file";
-   prerr_endline "-l  -levels             outputs the cut levels of the CIC terms given in the input file";
    prerr_endline "-L  -locate ALIAS       issues the \"Locate\" query for the given alias";
    prerr_endline "-B  -backward LEVEL     issues the \"Backward\" query for the given level on all CIC terms";
    prerr_endline "                        in the input file";
@@ -173,7 +162,6 @@ let parse_args () =
       | ("-h"|"-help") :: rem -> prerr_help ()
       | ("-d"|"-display") :: rem -> display (get_terms ())
       | ("-t"|"-typeof") :: arg :: rem -> pp_type_of arg; parse rem
-      | ("-l"|"-levels") :: rem -> levels (get_terms ())
       | ("-x"|"-execute") :: rem -> execute stdin; parse rem
       | ("-q"|"-show-queries") :: rem -> show_queries := true; parse rem
       | ("-s"|"-stat") :: rem -> Mqint.set_stat true; parse rem
@@ -193,7 +181,6 @@ let parse_args () =
 
 let _ =
    let module Gen = MQueryGenerator in
-   CicCooking.init () ; 
    Logger.log_callback :=
       (Logger.log_to_html
       ~print_and_flush:(function s -> print_string s ; flush stdout)) ;