2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
12 (* $Id: orderings.ml 9869 2009-06-11 22:52:38Z denes $ *)
14 module OT = struct type t = string let compare = Pervasives.compare end
15 module HC = Map.Make(OT)
17 type leaf = int * string
19 let cache = ref HC.empty
25 cache := HC.add s (!num,s) !cache;
33 let problem_file = ref "no-file-given";;
34 let tptppath = ref "/";;
35 let seconds = ref 300;;
38 print_endline ("% SZS status Timeout for " ^
39 Filename.basename !problem_file)
44 Sys.signal 24 (Sys.Signal_handle (fun _ -> fail_msg (); exit 1)) in
46 Sys.signal Sys.sigalrm
47 (Sys.Signal_handle (fun _ -> fail_msg (); exit 1)) in
49 "--tptppath", Arg.String (fun p -> tptppath := p),
50 ("[path] TPTP lib root, default " ^ !tptppath);
51 "--timeout", Arg.Int (fun p -> seconds := p),
52 ("[seconds] timeout, default " ^ string_of_int !seconds);
53 ] (fun x -> problem_file := x) "
54 Matitaprover is the first order automatic prover that equips the
55 Matita interactive theorem prover (http://matita.cs.unibo.it).
57 Developed by A.Asperti, M.Denes and E.Tassi, released under GPL-2.1
59 If --tptppath is given, instead of the problem file you can just give the
60 problem name with the .p suffix (e.g. BOO001-1.p)
62 If --tptppath is not given, included files (i.e. axiom sets) are searched
63 in the current directory only.
65 usage: matitaprover [options] problemfile";
66 let hypotheses, goals = Tptp_cnf.parse ~tptppath:!tptppath !problem_file in
67 let goal = match goals with [x] -> x | _ -> assert false in
68 let leaf_compare = ref (fun ((a,_) : leaf) ((b,_) : leaf) -> Pervasives.compare a b) in
69 let module B : Terms.Blob
70 with type t = leaf and type input = Ast.term = struct
73 let compare a b = !leaf_compare a b
77 let rec embed m = function
78 | Ast.Variable name ->
79 (try m, List.assoc name m
81 let t = Terms.Var ~-(List.length m) in
83 | Ast.Constant name -> m, Terms.Leaf (hash name)
84 | Ast.Function (name,args) ->
87 (fun x _ m -> embed m x) m args
89 m, Terms.Node (Terms.Leaf (hash name):: args)
92 let vars, ty = embed [] ty in
93 let _, bo = embed vars bo in
94 let bo = Terms.Node (bo :: List.map snd (List.rev vars)) in
97 let embed t = snd(embed [] t);;
101 let module Pp = Pp.Pp(B) in
102 let module P = Paramod.Paramod(B) in
103 let success_msg bag l (pp : ?margin:int -> B.t Terms.unit_clause -> string)=
104 print_endline ("% SZS status Unsatisfiable for " ^
105 Filename.basename !problem_file);
106 print_endline ("% SZS output start CNFRefutation for " ^
107 Filename.basename !problem_file);
110 print_endline (pp ~margin:max_int
111 (fst(Terms.M.find x bag)))) l;
112 print_endline ("% SZS output end CNFRefutation for " ^
113 Filename.basename !problem_file)
115 let bag = Terms.M.empty, 0 in
116 let bag, g_passives = P.mk_goal bag goal in
118 HExtlib.list_mapi_acc (fun x _ b -> P.mk_passive b x) bag hypotheses
120 prerr_endline "Order";
122 (fun _ (w,x) -> prerr_endline (" " ^ x ^ " is " ^ string_of_int w)) !cache;
123 prerr_endline "Facts";
124 List.iter (fun x -> prerr_endline (" " ^ Pp.pp_unit_clause x)) passives;
125 prerr_endline "Goal";
126 prerr_endline (" " ^ Pp.pp_unit_clause g_passives);
127 let _ = Unix.alarm !seconds in
130 ~timeout:(Unix.gettimeofday () +. float_of_int (!seconds / 2) )
131 ~max_steps:max_int bag ~g_passives:[g_passives] ~passives
134 leaf_compare := (fun (_,a) (_,b) -> Pervasives.compare a b);
137 ~timeout:(Unix.gettimeofday () +. float_of_int (!seconds / 2) )
138 ~max_steps:max_int bag ~g_passives:[g_passives] ~passives
141 | (bag,_,l)::_ -> success_msg bag l Pp.pp_unit_clause)
142 | (bag,_,l)::_ -> success_msg bag l Pp.pp_unit_clause