Commit 2484e7b9 authored by MARCHE Claude's avatar MARCHE Claude
Browse files

improved interaction with external provers

parent fd402ea5
...@@ -19,7 +19,8 @@ transformations ...@@ -19,7 +19,8 @@ transformations
"eliminate_algebraic" "eliminate_algebraic"
"eliminate_let" "eliminate_let"
"inline_trivial" "inline_trivial"
"split_goal_pos_neg_goal" (*"split_goal_pos_neg_all"*) (* "split_goal_pos_neg_goal"*)
(*"split_goal_pos_neg_all"*)
end end
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
printer "coq" printer "coq"
filename "%f_%t_%g.v" filename "%f_%t_%g.v"
valid "Success"
unknown "Error: \\(.*\\)$" "\\1"
fail "Syntax error: \\(.*\\)$" "\\1"
prelude "(* generated by Why3's Coq driver *)" prelude "(* generated by Why3's Coq driver *)"
theory BuiltIn theory BuiltIn
......
(* Why driver for SMT syntax *) (* Why driver for SMT syntax *)
prelude "(* this is a prelude for smtlib*)" prelude ";;; this is a prelude for Z3"
printer "smtv1" printer "smtv1"
filename "%f-%t-%g.smt" filename "%f-%t-%g.smt"
...@@ -32,7 +32,7 @@ end ...@@ -32,7 +32,7 @@ end
theory int.Int theory int.Int
prelude "(* this is a prelude for Alt-Ergo arithmetic *)" prelude ";;; this is a prelude for Z3, Arithmetic"
syntax logic zero "0" syntax logic zero "0"
......
...@@ -40,14 +40,14 @@ let print_prover_answer fmt = function ...@@ -40,14 +40,14 @@ let print_prover_answer fmt = function
| Valid -> fprintf fmt "Valid" | Valid -> fprintf fmt "Valid"
| Invalid -> fprintf fmt "Invalid" | Invalid -> fprintf fmt "Invalid"
| Timeout -> fprintf fmt "Timeout" | Timeout -> fprintf fmt "Timeout"
| Unknown s -> pp_print_string fmt s | Unknown s -> fprintf fmt "Unknown: %s" s
| Failure s -> pp_print_string fmt s | Failure s -> fprintf fmt "Failure: %s" s
| HighFailure -> fprintf fmt "HighFailure" | HighFailure -> fprintf fmt "HighFailure"
let print_prover_result fmt pr = let print_prover_result fmt pr =
fprintf fmt "%a (%.2fs)" print_prover_answer pr.pr_answer pr.pr_time; fprintf fmt "%a (%.2fs)" print_prover_answer pr.pr_answer pr.pr_time;
if pr.pr_answer == HighFailure then if pr.pr_answer == HighFailure then
fprintf fmt "@\n@stdout-stderr:@\n%s@." pr.pr_output fprintf fmt "@\nstdout-stderr:@\n%s@." pr.pr_output
let rec grep out l = match l with let rec grep out l = match l with
| [] -> HighFailure | [] -> HighFailure
...@@ -72,13 +72,16 @@ let call_prover debug command regexps opt_cout buffer = ...@@ -72,13 +72,16 @@ let call_prover debug command regexps opt_cout buffer =
if debug then Format.eprintf "Call_provers: Command output:@\n%s@." out; if debug then Format.eprintf "Call_provers: Command output:@\n%s@." out;
let ans = match ret with let ans = match ret with
| Unix.WSTOPPED n -> | Unix.WSTOPPED n ->
if debug then Format.eprintf "Call_provers: stopped on signal %d" n; if debug then Format.eprintf "Call_provers: stopped on signal %d@." n;
HighFailure HighFailure
| Unix.WSIGNALED 24 (* SIGXCPU signal cf. /usr/include/bits/signum.h *) ->
if debug then Format.eprintf "Call_provers: killed by signal SIGXCPU@.";
Timeout
| Unix.WSIGNALED n -> | Unix.WSIGNALED n ->
if debug then Format.eprintf "Call_provers: killed by signal %d" n; if debug then Format.eprintf "Call_provers: killed by signal %d@." n;
HighFailure HighFailure
| Unix.WEXITED n -> | Unix.WEXITED n ->
if debug then Format.eprintf "Call_provers: exited with status %d" n; if debug then Format.eprintf "Call_provers: exited with status %d@." n;
grep out regexps grep out regexps
in in
{ pr_answer = ans; { pr_answer = ans;
......
...@@ -111,6 +111,7 @@ type proof_attempt_status = ...@@ -111,6 +111,7 @@ type proof_attempt_status =
type prover_data = type prover_data =
{ prover_name : string; { prover_name : string;
command : string;
driver : Why.Driver.driver; driver : Why.Driver.driver;
} }
...@@ -1176,6 +1177,7 @@ let root_goals () = ...@@ -1176,6 +1177,7 @@ let root_goals () =
(*
let string_from_result = function let string_from_result = function
| Why.Driver.Valid -> "Valid" | Why.Driver.Valid -> "Valid"
| Why.Driver.Invalid -> "Invalid" | Why.Driver.Invalid -> "Invalid"
...@@ -1183,6 +1185,7 @@ let string_from_result = function ...@@ -1183,6 +1185,7 @@ let string_from_result = function
| Why.Driver.Failure s -> "Failure " ^ s | Why.Driver.Failure s -> "Failure " ^ s
| Why.Driver.Timeout -> "Timeout" | Why.Driver.Timeout -> "Timeout"
| Why.Driver.HighFailure -> "HighFailure" | Why.Driver.HighFailure -> "HighFailure"
*)
exception AlreadyAttempted exception AlreadyAttempted
...@@ -1194,15 +1197,31 @@ let try_prover ~timelimit ?memlimit (g : goal) (d: prover_data) : unit -> unit = ...@@ -1194,15 +1197,31 @@ let try_prover ~timelimit ?memlimit (g : goal) (d: prover_data) : unit -> unit =
match memlimit with None -> () match memlimit with None -> ()
| Some _ -> Format.eprintf "Db.try_prover warning: memlimit is ignored@." | Some _ -> Format.eprintf "Db.try_prover warning: memlimit is ignored@."
end; end;
Format.eprintf "Task : %a@." Why.Pretty.print_task g.task;
let [task] = Why.Driver.apply_transforms d.driver g.task in
Format.eprintf "Task for prover: %a@." (Why.Driver.print_task d.driver) task;
(*
let callback = Why.Driver.call_prover_ext ~debug:true ~timeout:timelimit d.driver g.task let callback = Why.Driver.call_prover_ext ~debug:true ~timeout:timelimit d.driver g.task
in in
*)
let callback =
let dest =
Why.Driver.file_of_task d.driver "" "" task
in
let print_task fmt =
Format.fprintf fmt "@[%a@]@?" (Why.Driver.print_task d.driver) task
in
let regexps = Why.Driver.get_regexps d.driver in
Why.Call_provers.call_on_formatter ~debug:true ~suffix:dest
~command:d.command ~timelimit ~memlimit:0 ~regexps print_task
in
fun () -> fun () ->
let r = callback () in let r = callback () in
Format.eprintf "prover returned %s in %f seconds@." Format.eprintf "prover result: %a@." Why.Call_provers.print_prover_result r;
(string_from_result r.Why.Call_provers.pr_answer) (*
r.Why.Call_provers.pr_time;
Format.eprintf "stdout: %s@." r.Why.Call_provers.pr_stdout; Format.eprintf "stdout: %s@." r.Why.Call_provers.pr_stdout;
Format.eprintf "stderr: %s@." r.Why.Call_provers.pr_stderr; Format.eprintf "stderr: %s@." r.Why.Call_provers.pr_stderr;
*)
(* TODO : update attempt depending on r = Valid *) (* TODO : update attempt depending on r = Valid *)
() ()
......
...@@ -64,6 +64,7 @@ type proof_attempt_status = ...@@ -64,6 +64,7 @@ type proof_attempt_status =
type prover_data = type prover_data =
{ prover_name : string; { prover_name : string;
command : string;
driver : Why.Driver.driver; driver : Why.Driver.driver;
} }
......
...@@ -71,6 +71,7 @@ let provers_data = ...@@ -71,6 +71,7 @@ let provers_data =
let name = conf.Whyconf.name in let name = conf.Whyconf.name in
printf " %s, " name; printf " %s, " name;
{ Db.prover_name = name; { Db.prover_name = name;
Db.command = conf.Whyconf.command;
Db.driver = get_driver id; } :: acc Db.driver = get_driver id; } :: acc
) config.provers [] ) config.provers []
in in
......
...@@ -148,6 +148,8 @@ let rec print_fmla drv fmt f = match f.f_node with ...@@ -148,6 +148,8 @@ let rec print_fmla drv fmt f = match f.f_node with
and print_expr drv fmt = e_apply (print_term drv fmt) (print_fmla drv fmt) and print_expr drv fmt = e_apply (print_term drv fmt) (print_fmla drv fmt)
and print_triggers drv fmt tl = and print_triggers drv fmt tl =
let tl = List.map (List.filter (function Term _ -> true | Fmla _ -> false)) tl in
let tl = List.filter (function [] -> false | _::_ -> true) tl in
if tl = [] then () else fprintf fmt "@ [%a]" if tl = [] then () else fprintf fmt "@ [%a]"
(print_list alt (print_list comma (print_expr drv))) tl (print_list alt (print_list comma (print_expr drv))) tl
......
...@@ -319,7 +319,7 @@ let print_pkind fmt = function ...@@ -319,7 +319,7 @@ let print_pkind fmt = function
let print_proof fmt = function let print_proof fmt = function
| Paxiom -> () | Paxiom -> ()
| Plemma | Pgoal -> fprintf fmt "Admitted.@\n" | Plemma | Pgoal -> fprintf fmt "Qed.@\n"
let print_decl drv fmt d = match d.d_node with let print_decl drv fmt d = match d.d_node with
| Dtype tl -> print_list nothing (print_type_decl drv) fmt tl | Dtype tl -> print_list nothing (print_type_decl drv) fmt tl
......
...@@ -9,7 +9,7 @@ driver = "drivers/alt_ergo.drv" ...@@ -9,7 +9,7 @@ driver = "drivers/alt_ergo.drv"
[prover coq] [prover coq]
name = "Coq" name = "Coq"
command = "coqc %f" command = "coqc %f && echo Success"
driver = "drivers/coq.drv" driver = "drivers/coq.drv"
[prover cvc3] [prover cvc3]
...@@ -18,7 +18,7 @@ command = "cvc3 -lang smt" ...@@ -18,7 +18,7 @@ command = "cvc3 -lang smt"
driver = "drivers/cvc3.drv" driver = "drivers/cvc3.drv"
[prover z3] [prover z3]
name = "Z3" name = "Z3 en mieux"
command = "z3 -smt -in" command = "why-cpulimit %t z3 -smt %f"
driver = "drivers/z3.drv" driver = "drivers/z3.drv"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment