Commit d4c3cfbf authored by David Hauzar's avatar David Hauzar

Store steplimit in session file.

parent b5883169
......@@ -93,6 +93,7 @@ let add_proofs_attempts g =
~obsolete:true
~archived:false
~timelimit:5
~steplimit:(-1)
~memlimit:1000
~edit:None
g p.Whyconf.prover Session.Scheduled
......@@ -106,5 +107,3 @@ let () =
(* save the session on disk *)
let () = Session.save_session config env_session.Session.session
......@@ -1016,7 +1016,7 @@ let prover_on_selected_goals pr =
M.run_prover
(env_session()) sched
~context_unproved_goals_only:!context_unproved_goals_only
~cntexample ~timelimit ~memlimit
~cntexample ~timelimit ~steplimit:(-1) ~memlimit
pr a
with e ->
eprintf "@[Exception raised while running a prover:@ %a@.@]"
......@@ -1541,11 +1541,11 @@ let test_strategy () =
Whyconf.filter_one_prover config fp
in
[|
Strategy.Icall_prover(altergo.Whyconf.prover,1,1000);
Strategy.Icall_prover(cvc4.Whyconf.prover,1,1000);
Strategy.Icall_prover(altergo.Whyconf.prover,1,-1,1000);
Strategy.Icall_prover(cvc4.Whyconf.prover,1,0,1000);
Strategy.Itransform(split_transformation,0); (* goto 0 on success *)
Strategy.Icall_prover(altergo.Whyconf.prover,10,4000);
Strategy.Icall_prover(cvc4.Whyconf.prover,10,4000);
Strategy.Icall_prover(altergo.Whyconf.prover,10,-1,4000);
Strategy.Icall_prover(cvc4.Whyconf.prover,10,-1,4000);
|]
(*
......
......@@ -158,6 +158,7 @@ and 'a proof_attempt =
proof_parent : 'a goal;
mutable proof_state : proof_attempt_status;
mutable proof_timelimit : int;
mutable proof_steplimit : int;
mutable proof_memlimit : int;
mutable proof_obsolete : bool;
mutable proof_archived : bool;
......@@ -490,10 +491,10 @@ let get_used_provers_with_stats session =
(fun pa ->
(* record mostly used pa.proof_timelimit pa.proof_memlimit *)
let prover = pa.proof_prover in
let timelimits,memlimits =
let timelimits,steplimits,memlimits =
try PHprover.find prover_table prover
with Not_found ->
let x = (Hashtbl.create 5,Hashtbl.create 5) in
let x = (Hashtbl.create 5,Hashtbl.create 5,Hashtbl.create 5) in
PHprover.add prover_table prover x;
x
in
......@@ -501,11 +502,16 @@ let get_used_provers_with_stats session =
try Hashtbl.find timelimits pa.proof_timelimit
with Not_found -> 0
in
let sf =
try Hashtbl.find steplimits pa.proof_steplimit
with Not_found -> 0
in
let mf =
try Hashtbl.find memlimits pa.proof_timelimit
with Not_found -> 0
in
Hashtbl.replace timelimits pa.proof_timelimit (tf+1);
Hashtbl.replace steplimits pa.proof_steplimit (sf+1);
Hashtbl.replace memlimits pa.proof_memlimit (mf+1))
session;
prover_table
......@@ -578,11 +584,12 @@ let save_int_def name def fmt n =
let opt_string = opt save_string
let save_proof_attempt fmt ((id,tl,ml),a) =
let save_proof_attempt fmt ((id,tl,sl,ml),a) =
fprintf fmt
"@\n@[<h><proof@ prover=\"%i\"%a%a%a%a%a>"
"@\n@[<h><proof@ prover=\"%i\"%a%a%a%a%a%a>"
id
(save_int_def "timelimit" tl) a.proof_timelimit
(save_int_def "steplimit" sl) a.proof_steplimit
(save_int_def "memlimit" ml) a.proof_memlimit
(opt_string "edited") a.proof_edited_as
(save_bool_def "obsolete" false) a.proof_obsolete
......@@ -603,7 +610,7 @@ module Compr = Compress.Compress_z
type save_ctxt = {
prover_ids : int PHprover.t;
provers : (int * int * int) Mprover.t;
provers : (int * int * int * int) Mprover.t;
ch_shapes : Compr.out_channel;
}
......@@ -633,7 +640,7 @@ let rec save_goal ctxt fmt g =
let l = PHprover.fold
(fun _ a acc -> (Mprover.find a.proof_prover ctxt.provers, a) :: acc)
g.goal_external_proofs [] in
let l = List.sort (fun ((i1,_,_),_) ((i2,_,_),_) -> compare i1 i2) l in
let l = List.sort (fun ((i1,_,_,_),_) ((i2,_,_,_),_) -> compare i1 i2) l in
List.iter (save_proof_attempt fmt) l;
let l = PHstr.fold (fun _ t acc -> t :: acc) g.goal_transformations [] in
let l = List.sort (fun t1 t2 -> compare t1.transf_name t2.transf_name) l in
......@@ -746,13 +753,19 @@ let save_file ctxt fmt _ f =
List.iter (save_theory ctxt fmt) f.file_theories;
fprintf fmt "@]@\n</file>"
let get_prover_to_save prover_ids p (timelimits,memlimits) provers =
let get_prover_to_save prover_ids p (timelimits,steplimits,memlimits) provers =
let mostfrequent_timelimit,_ =
Hashtbl.fold
(fun t f ((_,f') as t') -> if f > f' then (t,f) else t')
timelimits
(0,0)
in
let mostfrequent_steplimit,_ =
Hashtbl.fold
(fun s f ((_,f') as s') -> if f > f' then (s,f) else s')
steplimits
(0,0)
in
let mostfrequent_memlimit,_ =
Hashtbl.fold
(fun m f ((_,f') as m') -> if f > f' then (m,f) else m')
......@@ -778,17 +791,17 @@ let get_prover_to_save prover_ids p (timelimits,memlimits) provers =
PHprover.add prover_ids p !id;
!id
in
Mprover.add p (id,mostfrequent_timelimit,mostfrequent_memlimit) provers
Mprover.add p (id,mostfrequent_timelimit,mostfrequent_steplimit,mostfrequent_memlimit) provers
let save_prover fmt id (p,mostfrequent_timelimit,mostfrequent_memlimit) =
let save_prover fmt id (p,mostfrequent_timelimit,mostfrequent_steplimit,mostfrequent_memlimit) =
fprintf fmt "@\n@[<h><prover@ id=\"%i\"@ name=\"%a\"@ \
version=\"%a\"%a@ timelimit=\"%d\"@ memlimit=\"%d\"/>@]"
version=\"%a\"%a@ timelimit=\"%d\"@ steplimit=\"%d\"@ memlimit=\"%d\"/>@]"
id save_string p.C.prover_name save_string p.C.prover_version
(fun fmt s -> if s <> "" then fprintf fmt "@ alternative=\"%a\""
save_string s)
p.C.prover_altern
mostfrequent_timelimit mostfrequent_memlimit
mostfrequent_timelimit mostfrequent_steplimit mostfrequent_memlimit
let save fname shfname _config session =
let ch = open_out fname in
......@@ -811,8 +824,8 @@ let save fname shfname _config session =
in
let provers_to_save =
Mprover.fold
(fun p (id,mostfrequent_timelimit,mostfrequent_memlimit) acc ->
Mint.add id (p,mostfrequent_timelimit,mostfrequent_memlimit) acc)
(fun p (id,mostfrequent_timelimit,mostfrequent_steplimit,mostfrequent_memlimit) acc ->
Mint.add id (p,mostfrequent_timelimit,mostfrequent_steplimit,mostfrequent_memlimit) acc)
provers Mint.empty
in
Mint.iter (save_prover fmt) provers_to_save;
......@@ -936,7 +949,7 @@ type 'a keygen = ?parent:'a -> unit -> 'a
let add_external_proof
?(notify=notify)
~(keygen:'a keygen) ~obsolete
~archived ~timelimit ~memlimit ~edit (g:'a goal) p result =
~archived ~timelimit ~steplimit ~memlimit ~edit (g:'a goal) p result =
assert (edit <> Some "");
let key = keygen ~parent:g.goal_key () in
let a = { proof_prover = p;
......@@ -946,6 +959,7 @@ let add_external_proof
proof_archived = archived;
proof_state = result;
proof_timelimit = timelimit;
proof_steplimit = steplimit;
proof_memlimit = memlimit;
proof_edited_as = edit;
}
......@@ -1231,7 +1245,7 @@ let load_ident elt =
Ident.id_register preid
type 'key load_ctxt = {
old_provers : (Whyconf.prover * int * int) Mint.t ;
old_provers : (Whyconf.prover * int * int * int) Mint.t ;
keygen : 'key keygen;
}
......@@ -1265,7 +1279,7 @@ and load_proof_or_transf ctxt mg a =
let prover = string_attribute "prover" a in
try
let prover = int_of_string prover in
let (p,timelimit,memlimit) =Mint.find prover ctxt.old_provers in
let (p,timelimit,steplimit,memlimit) =Mint.find prover ctxt.old_provers in
let res = match a.Xml.elements with
| [r] -> load_result r
| [] -> Interrupted
......@@ -1278,6 +1292,7 @@ and load_proof_or_transf ctxt mg a =
let obsolete = bool_attribute "obsolete" a false in
let archived = bool_attribute "archived" a false in
let timelimit = int_attribute_def "timelimit" a timelimit in
let steplimit = int_attribute_def "steplimit" a steplimit in
let memlimit = int_attribute_def "memlimit" a memlimit in
(*
if timelimit < 0 then begin
......@@ -1289,7 +1304,7 @@ and load_proof_or_transf ctxt mg a =
*)
let (_ : 'a proof_attempt) =
add_external_proof ~keygen:ctxt.keygen ~archived ~obsolete
~timelimit ~memlimit ~edit mg p res
~timelimit ~steplimit ~memlimit ~edit mg p res
in
()
with Failure _ | Not_found ->
......@@ -1476,11 +1491,12 @@ let load_file ~keygen session old_provers f =
let version = string_attribute "version" f in
let altern = string_attribute_def "alternative" f "" in
let timelimit = int_attribute_def "timelimit" f 5 in
let steplimit = int_attribute_def "steplimit" f 1 in
let memlimit = int_attribute_def "memlimit" f 1000 in
let p = {C.prover_name = name;
prover_version = version;
prover_altern = altern} in
Mint.add id (p,timelimit,memlimit) old_provers
Mint.add id (p,timelimit,steplimit,memlimit) old_provers
with Failure _ ->
Warning.emit "[Warning] Session.load_file: unexpected non-numeric prover id '%s'@." id;
old_provers
......@@ -1500,7 +1516,7 @@ let load_session ~keygen session xml =
List.fold_left (load_file ~keygen session) Mint.empty xml.Xml.elements
in
Mint.iter
(fun id (p,_,_) ->
(fun id (p,_,_,_) ->
Debug.dprintf debug "prover %d: %a@." id Whyconf.print_prover p;
PHprover.replace session.session_prover_ids p id)
old_provers;
......@@ -1909,7 +1925,7 @@ let ft_of_pa a =
But since it will be perhaps removed...
*)
let copy_external_proof
?notify ~keygen ?obsolete ?archived ?timelimit ?memlimit ?edit
?notify ~keygen ?obsolete ?archived ?timelimit ?steplimit ?memlimit ?edit
?goal ?prover ?attempt_status ?env_session ?session a =
let session = match env_session with
| Some eS -> Some eS.session
......@@ -1917,6 +1933,7 @@ let copy_external_proof
let obsolete = Opt.get_def a.proof_obsolete obsolete in
let archived = Opt.get_def a.proof_archived archived in
let timelimit = Opt.get_def a.proof_timelimit timelimit in
let steplimit = Opt.get_def a.proof_steplimit steplimit in
let memlimit = Opt.get_def a.proof_memlimit memlimit in
let pas = Opt.get_def a.proof_state attempt_status in
let ngoal = Opt.get_def a.proof_parent goal in
......@@ -1964,7 +1981,7 @@ let copy_external_proof
Some (dst_file)
in
add_external_proof ?notify ~keygen
~obsolete ~archived ~timelimit ~memlimit ~edit ngoal nprover pas
~obsolete ~archived ~timelimit ~steplimit ~memlimit ~edit ngoal nprover pas
exception UnloadableProver of Whyconf.prover
......@@ -2021,10 +2038,10 @@ let print_attempt_status fmt = function
| InternalFailure _ -> pp_print_string fmt "Failure"
let print_external_proof fmt p =
fprintf fmt "%a - %a (%i, %i)%s%s%s"
fprintf fmt "%a - %a (%i, %i, %i)%s%s%s"
Whyconf.print_prover p.proof_prover
print_attempt_status p.proof_state
p.proof_timelimit p.proof_memlimit
p.proof_timelimit p.proof_steplimit p.proof_memlimit
(if p.proof_obsolete then " obsolete" else "")
(if p.proof_archived then " archived" else "")
(if p.proof_edited_as <> None then " edited" else "")
......@@ -2060,6 +2077,7 @@ let merge_proof ~keygen obsolete to_goal _ from_proof =
~obsolete
~archived:from_proof.proof_archived
~timelimit:from_proof.proof_timelimit
~steplimit:from_proof.proof_steplimit
~memlimit:from_proof.proof_memlimit
~edit:from_proof.proof_edited_as
to_goal
......
......@@ -96,6 +96,7 @@ and 'a proof_attempt = private
proof_parent : 'a goal;
mutable proof_state : proof_attempt_status;
mutable proof_timelimit : int;
mutable proof_steplimit : int;
mutable proof_memlimit : int;
mutable proof_obsolete : bool;
mutable proof_archived : bool;
......@@ -346,6 +347,7 @@ val add_external_proof :
obsolete:bool ->
archived:bool ->
timelimit:int ->
steplimit:int ->
memlimit:int ->
edit:string option ->
'key goal ->
......@@ -388,6 +390,7 @@ val copy_external_proof :
?obsolete:bool ->
?archived:bool ->
?timelimit:int ->
?steplimit:int ->
?memlimit:int ->
?edit:string option ->
?goal:'key goal ->
......
......@@ -545,7 +545,7 @@ let run_external_proof eS eT ?(cntexample=false) ?callback a =
in
run_external_proof_v2 ~use_steps:false eS eT a ~cntexample callback
let prover_on_goal eS eT ?callback ?(cntexample=false) ~timelimit ~memlimit p g =
let prover_on_goal eS eT ?callback ?(cntexample=false) ~timelimit ~steplimit ~memlimit p g =
let a =
try
let a = PHprover.find g.goal_external_proofs p in
......@@ -554,7 +554,7 @@ let prover_on_goal eS eT ?callback ?(cntexample=false) ~timelimit ~memlimit p g
a
with Not_found ->
let ep = add_external_proof ~keygen:O.create ~obsolete:false
~archived:false ~timelimit ~memlimit
~archived:false ~timelimit ~steplimit ~memlimit
~edit:None g p Interrupted in
O.init ep.proof_key (Proof_attempt ep);
ep
......@@ -562,39 +562,39 @@ let prover_on_goal eS eT ?callback ?(cntexample=false) ~timelimit ~memlimit p g
run_external_proof eS eT ~cntexample ?callback a
let prover_on_goal_or_children eS eT
~context_unproved_goals_only ~cntexample ~timelimit ~memlimit p g =
~context_unproved_goals_only ~cntexample ~timelimit ~steplimit ~memlimit p g =
goal_iter_leaf_goal ~unproved_only:context_unproved_goals_only
(prover_on_goal eS eT ~cntexample ~timelimit ~memlimit p) g
(prover_on_goal eS eT ~cntexample ~timelimit ~steplimit ~memlimit p) g
let run_prover eS eT ~context_unproved_goals_only ~cntexample ~timelimit ~memlimit pr a =
let run_prover eS eT ~context_unproved_goals_only ~cntexample ~timelimit ~steplimit ~memlimit pr a =
match a with
| Goal g ->
prover_on_goal_or_children eS eT
~context_unproved_goals_only ~cntexample ~timelimit ~memlimit pr g
~context_unproved_goals_only ~cntexample ~timelimit ~steplimit ~memlimit pr g
| Theory th ->
List.iter
(prover_on_goal_or_children eS eT
~context_unproved_goals_only ~cntexample ~timelimit ~memlimit pr)
~context_unproved_goals_only ~cntexample ~timelimit ~steplimit ~memlimit pr)
th.theory_goals
| File file ->
List.iter
(fun th ->
List.iter
(prover_on_goal_or_children eS eT
~context_unproved_goals_only ~cntexample ~timelimit ~memlimit pr)
~context_unproved_goals_only ~cntexample ~timelimit ~steplimit ~memlimit pr)
th.theory_goals)
file.file_theories
| Proof_attempt a ->
prover_on_goal_or_children eS eT
~context_unproved_goals_only ~cntexample ~timelimit ~memlimit pr a.proof_parent
~context_unproved_goals_only ~cntexample ~timelimit ~steplimit ~memlimit pr a.proof_parent
| Transf tr ->
List.iter
(prover_on_goal_or_children eS eT
~context_unproved_goals_only ~cntexample ~timelimit ~memlimit pr)
~context_unproved_goals_only ~cntexample ~timelimit ~steplimit ~memlimit pr)
tr.transf_goals
| Metas m ->
prover_on_goal_or_children eS eT
~context_unproved_goals_only ~cntexample ~timelimit ~memlimit pr m.metas_goal
~context_unproved_goals_only ~cntexample ~timelimit ~steplimit ~memlimit pr m.metas_goal
......@@ -741,16 +741,17 @@ let replay eS eT ~obsolete_only ~context_unproved_goals_only a =
(* play all *)
(***********************************)
let rec play_on_goal_and_children eS eT ~timelimit ~memlimit todo l g =
let timelimit, memlimit, auto_proved =
PHprover.fold (fun _ pa (timelimit, memlimit, _ as acc) ->
let rec play_on_goal_and_children eS eT ~timelimit ~steplimit ~memlimit todo l g =
let timelimit, steplimit, memlimit, auto_proved =
PHprover.fold (fun _ pa (timelimit, steplimit, memlimit, _ as acc) ->
match pa.proof_edited_as, pa.proof_state with
| None, Done { Call_provers.pr_answer = Call_provers.Valid } ->
max timelimit pa.proof_timelimit,
max steplimit pa.proof_steplimit,
max memlimit pa.proof_memlimit,
true
| _ -> acc)
g.goal_external_proofs (timelimit, memlimit, false) in
g.goal_external_proofs (timelimit, steplimit, memlimit, false) in
let callback _key status =
if not (running status) then Todo._done todo () in
if auto_proved then begin
......@@ -760,21 +761,21 @@ let rec play_on_goal_and_children eS eT ~timelimit ~memlimit todo l g =
(* eprintf "todo increased to %d@." todo.Todo.todo; *)
(* eprintf "prover %a on goal %s@." *)
(* Whyconf.print_prover p g.goal_name.Ident.id_string; *)
prover_on_goal eS eT ~callback ~timelimit ~memlimit p g)
prover_on_goal eS eT ~callback ~timelimit ~steplimit ~memlimit p g)
l
end;
iter_goal
(fun _ -> ())
(iter_transf
(play_on_goal_and_children eS eT ~timelimit ~memlimit todo l)
(play_on_goal_and_children eS eT ~timelimit ~steplimit ~memlimit todo l)
)
(iter_metas
(play_on_goal_and_children eS eT ~timelimit ~memlimit todo l)
(play_on_goal_and_children eS eT ~timelimit ~steplimit ~memlimit todo l)
)
g
let play_all eS eT ~callback ~timelimit ~memlimit l =
let play_all eS eT ~callback ~timelimit ~steplimit ~memlimit l =
let todo = Todo.create () (fun () _ -> ()) callback in
Todo.start todo;
PHstr.iter
......@@ -782,7 +783,7 @@ let play_all eS eT ~callback ~timelimit ~memlimit l =
List.iter
(fun th ->
List.iter
(play_on_goal_and_children eS eT ~timelimit ~memlimit todo l)
(play_on_goal_and_children eS eT ~timelimit ~steplimit ~memlimit todo l)
th.theory_goals)
file.file_theories)
eS.session.session_files;
......@@ -939,7 +940,7 @@ let convert_unknown_prover =
Todo._done todo ()
else
match Array.get strat pc with
| Icall_prover(p,timelimit,memlimit) ->
| Icall_prover(p,timelimit,steplimit,memlimit) ->
let callback _pa res =
match res with
| Scheduled | Running ->
......@@ -956,7 +957,7 @@ let convert_unknown_prover =
(* should not happen *)
assert false
in
prover_on_goal es sched ~callback ~timelimit ~memlimit p g
prover_on_goal es sched ~callback ~timelimit ~steplimit ~memlimit p g
| Itransform(trname,pcsuccess) ->
let callback ntr =
match ntr with
......
......@@ -133,7 +133,7 @@ module Make(O: OBSERVER) : sig
O.key env_session -> t ->
context_unproved_goals_only:bool ->
cntexample : bool ->
timelimit:int -> memlimit:int ->
timelimit:int -> steplimit:int -> memlimit:int ->
Whyconf.prover -> O.key any -> unit
(** [run_prover es sched p a] runs prover [p] on all goals under [a]
the proof attempts are only scheduled for running, and they
......@@ -188,7 +188,7 @@ module Make(O: OBSERVER) : sig
O.key env_session -> t ->
?callback:(O.key proof_attempt -> proof_attempt_status -> unit) ->
?cntexample : bool ->
timelimit:int -> memlimit:int ->
timelimit:int -> steplimit:int -> memlimit:int ->
Whyconf.prover -> O.key goal -> unit
(** [prover_on_goal es sched ?cntexample ?timelimit p g] same as
{!redo_external_proof} but creates or reuses existing proof_attempt
......@@ -298,7 +298,7 @@ module Make(O: OBSERVER) : sig
val play_all :
O.key env_session -> t -> callback:(unit-> unit) ->
timelimit:int -> memlimit:int -> Whyconf.prover list -> unit
timelimit:int -> steplimit:int -> memlimit:int -> Whyconf.prover list -> unit
(** [play_all es sched l] runs every prover of list [l] on all
goals and sub-goals of the session, with the given time limit.
[callback] is called when all tasks are finished.
......
......@@ -12,7 +12,7 @@
(** {2 User-defined strategies} *)
type instruction =
| Icall_prover of Whyconf.prover * int * int (** timelimit, memlimit *)
| Icall_prover of Whyconf.prover * int * int * int (** timelimit, steplimi, memlimit *)
| Itransform of string * int (** successor state on success *)
| Igoto of int (** goto state *)
......
......@@ -27,10 +27,8 @@
*)
type instruction =
| Icall_prover of Whyconf.prover * int * int (** timelimit, memlimit *)
| Icall_prover of Whyconf.prover * int * int * int (** timelimit, steplimi, memlimit *)
| Itransform of string * int (** successor state on success *)
| Igoto of int (** goto state *)
type t = instruction array
......@@ -120,13 +120,15 @@ rule scan code = parse
| goto space+ (ident as id)
{ add_instr code (Igoto (find_label code id));
scan code lexbuf }
| call space+ (ident as p) space+ (integer as t) space+ (integer as m)
| call space+ (ident as p) space+ (integer as t) space+ (integer as s) space+ (integer as m)
{ let p = prover code p in
let t = integer "timelimit" t in
if t <= 0 then error "timelimit %d is invalid" t;
let s = integer "steplimit" s in
if s <= 0 then error "steplimit %d is invalid" s;
let m = integer "memlimit" m in
if m <= 0 then error "memlimit %d is invalid" m;
add_instr code (Icall_prover (p.Whyconf.prover, t, m));
add_instr code (Icall_prover (p.Whyconf.prover, t, s, m));
scan code lexbuf }
| transform space+ (ident as t) space+ (ident as l)
{ transform code t;
......
......@@ -397,7 +397,7 @@ let run_as_bench env_session =
eprintf " done.@.";
exit 0
in
M.play_all env_session sched ~callback ~timelimit:2 ~memlimit:0 provers;
M.play_all env_session sched ~callback ~timelimit:2 ~steplimit:(-1) ~memlimit:0 provers;
main_loop ();
eprintf "main replayer (in bench mode) exited unexpectedly@.";
exit 1
......
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