]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/components/binaries/matitaprover/matitaprover.ml
Various architectural changes
[helm.git] / helm / software / components / binaries / matitaprover / matitaprover.ml
index 3736c024dbf02a4b2199f235480bccbae8e4bab4..12fb6b9aacdf51cfac6166a7acafdb560e38ff8a 100644 (file)
@@ -46,36 +46,40 @@ module type LeafComparer =
   end
 ;;
 
+let rec embed m = function
+  | Ast.Variable name ->
+     (try m, List.assoc name m
+      with Not_found -> 
+       let t = Terms.Var ~-(List.length m) in
+        (name,t)::m, t)
+  | Ast.Constant name -> m, Terms.Leaf (hash name)
+  | Ast.Function (name,args) -> 
+     let m, args = 
+       HExtlib.list_mapi_acc 
+         (fun x _ m -> embed m x) m args
+     in
+       m, Terms.Node (Terms.Leaf (hash name):: args) 
+;;
+
+let saturate bo (nlit,plit) = 
+  let vars,nlit = HExtlib.list_mapi_acc (fun x _ m -> embed m x) [] nlit in
+  let vars,plit = HExtlib.list_mapi_acc (fun x _ m -> embed m x) vars plit in
+  let _, bo = embed vars bo in
+  let bo = Terms.Node (bo :: List.map snd (List.rev vars)) in
+  bo, (nlit, plit)
+;;
+
+let embed t = snd(embed [] t);;
+
+
 module MakeBlob(C:LeafComparer) : Terms.Blob 
-  with type t = leaf and type input = Ast.term = struct
+  with type t = leaf = struct
         type t = leaf
         let eq a b = a == b
         let compare a b = C.cmp a b
         let eqP = hash "=="
         let pp (_,a) =  a 
-        type input = Ast.term
-        let rec embed m = function
-            | Ast.Variable name ->
-                (try m, List.assoc name m
-                 with Not_found -> 
-                    let t = Terms.Var ~-(List.length m) in
-                    (name,t)::m, t)
-            | Ast.Constant name -> m, Terms.Leaf (hash name)
-            | Ast.Function (name,args) -> 
-                let m, args = 
-                  HExtlib.list_mapi_acc 
-                    (fun x _ m -> embed m x) m args
-                in
-                m, Terms.Node (Terms.Leaf (hash name):: args) 
-        ;;
-        let saturate bo ty = 
-          let vars, ty = embed [] ty in
-          let _, bo = embed vars bo in
-          let bo = Terms.Node (bo :: List.map snd (List.rev vars)) in
-          bo, ty
-        ;;
-        let embed t = snd(embed [] t);;
-
+        
   end
 ;;
 
@@ -100,13 +104,14 @@ let success_msg bag l (pp : ?margin:int -> leaf Terms.clause -> string) ord =
     (times.Unix.tms_utime +. times.Unix.tms_stime) ^ " using " ^ ord);
 ;;
 
-let start_msg stats passives g_passives (pp : ?margin:int -> leaf Terms.clause -> string) oname =
+let start_msg stats hypotheses (g_t,g_ty) 
+    (pp : ?margin:int -> leaf Terms.clause -> string) oname =
   let prefix = string_of_int (Unix.getpid ()) in
   let prerr_endline s = prerr_endline (prefix ^ ": " ^ s) in
   prerr_endline "Facts:";
-  List.iter (fun x -> prerr_endline (" " ^ pp x)) passives;
+  (*List.iter (fun x -> prerr_endline (" " ^ pp x)) passives;*)
   prerr_endline "Goal:";
-  prerr_endline (" " ^ pp g_passives);
+  (*prerr_endline (" " ^ pp g_passives);*)
   prerr_endline "Order:";
   prerr_endline ("  " ^ oname);
   prerr_endline "Leaf order:";
@@ -120,18 +125,17 @@ let start_msg stats passives g_passives (pp : ?margin:int -> leaf Terms.clause -
 
 let report_error s =  prerr_endline (string_of_int (Unix.getpid())^": "^s);;
 
-module Main(P : Paramod.Paramod with type t = leaf) = struct
+module Main(O : Orderings.Blob with type t = leaf) = struct
+ module P = Paramod.Paramod(O)
+ module Utils = FoUtils.Utils(O)
 
- let run ~useage ~printmsg stats goal hypotheses pp_clause name = 
-   let bag = Terms.empty_bag, 0 in
-   let bag, g_passives = P.mk_goal bag goal in
-   let bag, passives = 
-     HExtlib.list_mapi_acc (fun x _ b -> P.mk_passive b x) bag hypotheses 
-   in
-   if printmsg then start_msg stats passives g_passives pp_clause name;
+ let run ~useage ~printmsg stats (g_t,g_ty) hypotheses pp_clause name = 
+   let g_t,g_ty = saturate g_t g_ty in
+   let hypotheses = List.map (fun (t,(nlit,plit)) -> saturate t (nlit,plit)) hypotheses in
+   if printmsg then start_msg stats hypotheses (g_t,g_ty) pp_clause name;
    match
      P.paramod ~useage
-      ~max_steps:max_int bag ~g_passives:[g_passives] ~passives 
+      ~max_steps:max_int (g_t,g_ty) ~print_problem:printmsg hypotheses
    with
    | P.Error s -> report_error s; 3
    | P.Unsatisfiable ((bag,_,l)::_) -> 
@@ -143,7 +147,7 @@ module Main(P : Paramod.Paramod with type t = leaf) = struct
  ;;
 end
 
- let compute_stats goal hypotheses =
+(* let compute_stats goal hypotheses =
    let module C = 
      struct type t = leaf let cmp (a,_) (b,_) = Pervasives.compare a b end 
    in
@@ -179,14 +183,14 @@ end
              in if res = 0 then Pervasives.compare (HExtlib.list_index ((=) n1) oplist) (HExtlib.list_index ((=) n2) oplist)
                 else res)
      data
- ;;
+ ;;*)
 
 let worker order ~useage ~printmsg goal hypotheses =
-   let stats = compute_stats goal hypotheses in
+   (*let stats = compute_stats goal hypotheses in*)
    let module C = 
      struct
       let cmp =
-        let raw = List.map snd stats in
+        (*let raw = List.map snd stats in
         let rec pos x = function
           | ((y,_)::tl) when y = x -> 0
           | _::tl -> 1 + pos x tl
@@ -201,25 +205,26 @@ let worker order ~useage ~printmsg goal hypotheses =
               (pos a stats)
               (pos b stats))
         else
-          (prerr_endline "CLASH, statistics insufficient";
-            fun (a,_) (b,_) -> Pervasives.compare a b)
+          (prerr_endline "CLASH, statistics insufficient";*)
+            fun (a,_) (b,_) -> Pervasives.compare a b(* ) *)
       ;;
      end
    in
    let module B = MakeBlob(C) in
    let module Pp = Pp.Pp(B) in
+   let stats = [] in
    match order with
    | `NRKBO ->
        let module O = Orderings.NRKBO(B) in
-       let module Main = Main(Paramod.Paramod(O)) in
+       let module Main = Main(O) in
        Main.run ~useage ~printmsg stats goal hypotheses Pp.pp_clause O.name
    | `KBO ->
        let module O = Orderings.KBO(B) in
-       let module Main = Main(Paramod.Paramod(O)) in
+       let module Main = Main(O) in
        Main.run ~useage ~printmsg stats goal hypotheses Pp.pp_clause O.name
    | `LPO ->
        let module O = Orderings.LPO(B) in
-       let module Main = Main(Paramod.Paramod(O)) in
+       let module Main = Main(O) in
        Main.run ~useage ~printmsg stats goal hypotheses Pp.pp_clause O.name
 ;;