Commit 057b8d9f authored by MARCHE Claude's avatar MARCHE Claude
Browse files

[run strategy] allow the user to provide callbacks

parent 853deb85
...@@ -926,10 +926,10 @@ let convert_unknown_prover = ...@@ -926,10 +926,10 @@ let convert_unknown_prover =
open Strategy open Strategy
let rec exec_strategy es sched pc strat g = let rec exec_strategy ~todo es sched pc strat g =
if pc < 0 || pc >= Array.length strat then if pc < 0 || pc >= Array.length strat then
(* halt the strategy *) (* halt the strategy *)
() Todo._done todo ()
else else
match Array.get strat pc with match Array.get strat pc with
| Icall_prover(p,timelimit,memlimit) -> | Icall_prover(p,timelimit,memlimit) ->
...@@ -940,10 +940,10 @@ let convert_unknown_prover = ...@@ -940,10 +940,10 @@ let convert_unknown_prover =
() ()
| Done { Call_provers.pr_answer = Call_provers.Valid } -> | Done { Call_provers.pr_answer = Call_provers.Valid } ->
(* proof succeeded, nothing more to do *) (* proof succeeded, nothing more to do *)
() Todo._done todo ()
| Interrupted | InternalFailure _ | Done _ -> | Interrupted | InternalFailure _ | Done _ ->
(* proof did not succeed, goto to next step *) (* proof did not succeed, goto to next step *)
let callback () = exec_strategy es sched (pc+1) strat g in let callback () = exec_strategy ~todo es sched (pc+1) strat g in
schedule_delayed_action sched callback schedule_delayed_action sched callback
| Unedited | JustEdited -> | Unedited | JustEdited ->
(* should not happen *) (* should not happen *)
...@@ -954,25 +954,34 @@ let convert_unknown_prover = ...@@ -954,25 +954,34 @@ let convert_unknown_prover =
let callback ntr = let callback ntr =
match ntr with match ntr with
| None -> (* transformation failed *) | None -> (* transformation failed *)
let callback () = exec_strategy es sched (pc+1) strat g in let callback () = exec_strategy ~todo es sched (pc+1) strat g in
schedule_delayed_action sched callback schedule_delayed_action sched callback
| Some tr -> | Some tr ->
List.iter List.iter
(fun g -> (fun g ->
Todo.start todo;
let callback () = let callback () =
exec_strategy es sched pcsuccess strat g exec_strategy ~todo es sched pcsuccess strat g
in in
schedule_delayed_action sched callback schedule_delayed_action sched callback
) )
tr.transf_goals tr.transf_goals;
Todo._done todo ()
in in
transform_goal es sched ~callback trname g transform_goal es sched ~callback trname g
| Igoto pc -> | Igoto pc ->
exec_strategy es sched pc strat g exec_strategy ~todo es sched pc strat g
let run_strategy_on_goal es sched strat g = let run_strategy_on_goal
let callback () = exec_strategy es sched 0 strat g in ?(intermediate_callback=fun () -> ())
?(final_callback=fun () -> ())
es sched strat g =
let todo =
Todo.create () (fun () -> intermediate_callback) final_callback
in
Todo.start todo;
let callback () = exec_strategy ~todo es sched 0 strat g in
schedule_delayed_action sched callback schedule_delayed_action sched callback
......
...@@ -296,6 +296,8 @@ module Make(O: OBSERVER) : sig ...@@ -296,6 +296,8 @@ module Make(O: OBSERVER) : sig
(** Same as {!Session_tools.convert_unknown_prover} *) (** Same as {!Session_tools.convert_unknown_prover} *)
val run_strategy_on_goal: val run_strategy_on_goal:
?intermediate_callback: (unit -> unit) ->
?final_callback: (unit -> unit) ->
O.key Session.env_session -> t -> O.key Session.env_session -> t ->
Strategy.t -> O.key Session.goal -> unit Strategy.t -> O.key Session.goal -> unit
......
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