2 let trans_atom = function
3 | Ast.True | Ast.False | Ast.Predicate _ | Ast.Proposition _ -> assert false
4 | Ast.Eq (a,b) -> true, Ast.Function ("==",[Ast.Constant "_"; a; b])
5 | Ast.NotEq (a,b) -> false, Ast.Function ("==",[Ast.Constant "_"; a; b])
8 let trans_formulae = function
9 | Ast.Disjunction _ -> assert false
10 | Ast.Atom a -> trans_atom a
11 | Ast.NegAtom _ -> assert false
16 let resolve ~tptppath s =
18 if HExtlib.is_regular s then s else
19 if tptppath = "/" then s else
20 if Filename.check_suffix s ".p" then
21 (assert (String.length s > 5);
22 let prefix = String.sub s 0 3 in
23 tptppath ^ "/Problems/" ^ prefix ^ "/" ^ s)
24 else tptppath ^ "/" ^ s
26 if HExtlib.is_regular resolved_name then
30 prerr_endline ("Unable to find " ^ s ^ " (" ^ resolved_name ^ ")");
36 let parse ~tptppath filename =
37 let rec aux = function
39 | (Ast.Inclusion (file,_)) :: tl ->
40 let file = resolve ~tptppath file in
41 let lexbuf = Lexing.from_channel (open_in file) in
42 let statements = Parser.main Lexer.yylex lexbuf in
44 | hd::tl -> hd :: aux tl
46 let statements = aux [Ast.Inclusion (filename,[])] in
47 let positives, negatives =
48 let rec aux p n = function
50 | Ast.Comment _ :: tl -> aux p n tl
51 | Ast.AnnotatedFormula (name,
52 (Ast.Axiom | Ast.Hypothesis|Ast.Negated_conjecture), f,_,_) :: tl->
53 let is_positive, f = trans_formulae f in
54 if is_positive then aux (p@[Ast.Constant name,f]) n tl
55 else aux p (n@[Ast.Constant name,f]) tl
56 | _ -> prerr_endline "bad syntax"; assert false