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
;;
(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:";
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)::_) ->
;;
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
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
(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
;;
| Ast.NotEq (a,b) -> false, Ast.Function ("==",[Ast.Constant "_"; a; b])
;;
-let trans_formulae = function
- | Ast.Disjunction _ -> assert false
- | Ast.Atom a -> trans_atom a
+let rec trans_formulae (nlit,plit) = function
+ | Ast.Disjunction (a,b) ->
+ trans_formulae (trans_formulae (nlit,plit) b) a
+ | Ast.Atom a ->
+ let is_positive,lit = trans_atom a in
+ if is_positive then (nlit,lit::plit) else (lit::nlit,plit)
| Ast.NegAtom _ -> assert false
;;
+let trans_formulae = trans_formulae ([],[]);;
+
(* HELPERS *)
let resolve ~tptppath s =
| Ast.Comment _ :: tl -> aux p n tl
| Ast.AnnotatedFormula (name,
(Ast.Axiom | Ast.Hypothesis|Ast.Negated_conjecture), f,_,_) :: tl->
- let is_positive, f = trans_formulae f in
- if is_positive then aux (p@[Ast.Constant name,f]) n tl
- else aux p (n@[Ast.Constant name,f]) tl
+ let (nlit,plit) = trans_formulae f in
+ if plit = [] then aux p (n@[Ast.Constant name,(nlit,plit)]) tl
+ else aux (p@[Ast.Constant name,(nlit,plit)]) n tl
| _ -> prerr_endline "bad syntax"; assert false
in
aux [] [] statements