controller_itp.ml 44.8 KB
Newer Older
1 2 3
(********************************************************************)
(*                                                                  *)
(*  The Why3 Verification Platform   /   The Why3 Development Team  *)
Guillaume Melquiond's avatar
Guillaume Melquiond committed
4
(*  Copyright 2010-2018   --   Inria - CNRS - Paris-Sud University  *)
5 6 7 8 9 10 11
(*                                                                  *)
(*  This software is distributed under the terms of the GNU Lesser  *)
(*  General Public License version 2.1, with the special exception  *)
(*  on linking described in file LICENSE.                           *)
(*                                                                  *)
(********************************************************************)

12
open Format
13
open Wstdlib
Clément Fumex's avatar
Clément Fumex committed
14 15
open Session_itp

Sylvain Dailler's avatar
Sylvain Dailler committed
16 17 18 19
let debug_sched = Debug.register_info_flag "scheduler"
  ~desc:"Print@ debugging@ messages@ about@ scheduling@ of@ prover@ calls@ \
         and@ transformation@ applications."

Sylvain Dailler's avatar
Sylvain Dailler committed
20
let debug_call_prover = Debug.lookup_flag "call_prover"
21 22
let default_delay_ms = 100 (* 0.1 seconds *)

Sylvain Dailler's avatar
Sylvain Dailler committed
23

24 25
exception Noprogress

26 27 28
let () = Exn_printer.register
    (fun fmt e ->
      match e with
Sylvain Dailler's avatar
Sylvain Dailler committed
29 30
      | Noprogress ->
          Format.fprintf fmt "The transformation made no progress.\n"
31 32
      | _ -> raise e)

Clément Fumex's avatar
Clément Fumex committed
33 34
(** State of a proof *)
type proof_attempt_status =
35
  | Undone   (** prover was never called *)
36 37 38
  | Scheduled (** external proof attempt is scheduled *)
  | Running (** external proof attempt is in progress *)
  | Done of Call_provers.prover_result (** external proof done *)
39 40
  | Interrupted (** external proof has never completed *)
  | Detached (** parent goal has no task, is detached *)
41 42
  | InternalFailure of exn (** external proof aborted by internal error *)
  | Uninstalled of Whyconf.prover (** prover is uninstalled *)
43
  | UpgradeProver of Whyconf.prover (** prover is upgraded *)
Clément Fumex's avatar
Clément Fumex committed
44

MARCHE Claude's avatar
MARCHE Claude committed
45 46
let print_status fmt st =
  match st with
47
  | Undone            -> fprintf fmt "Undone"
Sylvain Dailler's avatar
Sylvain Dailler committed
48 49 50 51
  | Scheduled         -> fprintf fmt "Scheduled"
  | Running           -> fprintf fmt "Running"
  | Done r            ->
      fprintf fmt "Done(%a)" Call_provers.print_prover_result r
52 53
  | Interrupted       -> fprintf fmt "Interrupted"
  | Detached          -> fprintf fmt "Detached"
Sylvain Dailler's avatar
Sylvain Dailler committed
54 55 56 57
  | InternalFailure e ->
      fprintf fmt "InternalFailure(%a)" Exn_printer.exn_printer e
  | Uninstalled pr    ->
      fprintf fmt "Prover %a is uninstalled" Whyconf.print_prover pr
58 59
  | UpgradeProver pr    ->
      fprintf fmt "Prover upgrade to %a" Whyconf.print_prover pr
MARCHE Claude's avatar
MARCHE Claude committed
60 61

type transformation_status =
62
  | TSscheduled | TSdone of transID | TSfailed of (proofNodeID * exn)
63 64 65 66

let print_trans_status fmt st =
  match st with
  | TSscheduled -> fprintf fmt "TScheduled"
67
  | TSdone _tid -> fprintf fmt "TSdone" (* TODO print tid *)
68
  | TSfailed _e -> fprintf fmt "TSfailed"
Clément Fumex's avatar
Clément Fumex committed
69

70 71 72 73
type strategy_status = STSgoto of proofNodeID * int | STShalt

let print_strategy_status fmt st =
  match st with
Sylvain Dailler's avatar
Sylvain Dailler committed
74 75
  | STSgoto(id,n) ->
      fprintf fmt "goto step %d in proofNode %a" n print_proofNodeID id
76 77 78
  | STShalt -> fprintf fmt "halt"


79
type controller =
Sylvain Dailler's avatar
Sylvain Dailler committed
80
  { mutable controller_session: Session_itp.session;
81
    controller_config : Whyconf.config;
MARCHE Claude's avatar
MARCHE Claude committed
82
    mutable controller_env: Env.env;
Sylvain Dailler's avatar
Sylvain Dailler committed
83 84
    controller_provers:
      (Whyconf.config_prover * Driver.driver) Whyconf.Hprover.t;
85
    controller_strategies : (string * string * string * Strategy.instruction array) Hstr.t;
86
    controller_running_proof_attempts : unit Hpan.t;
87 88
  }

89 90 91 92 93
let session_max_tasks = ref 1

let set_session_max_tasks n =
  session_max_tasks := n;
  Prove_client.set_max_running_provers n
94

MARCHE Claude's avatar
MARCHE Claude committed
95 96 97
let load_drivers c =
  let env = c.controller_env in
  let config = c.controller_config in
98 99 100 101
  let provers = Whyconf.get_provers config in
  Whyconf.Mprover.iter
    (fun _ p ->
     try
102
       let d = Whyconf.load_driver (Whyconf.get_main config) env p.Whyconf.driver [] in
103 104
       Whyconf.Hprover.add c.controller_provers p.Whyconf.prover (p,d)
     with e ->
Sylvain Dailler's avatar
Sylvain Dailler committed
105
       Debug.dprintf debug_call_prover
106 107 108
         "[Controller_itp] error while loading driver for prover %a: %a@."
         Whyconf.print_prover p.Whyconf.prover
         Exn_printer.exn_printer e)
MARCHE Claude's avatar
MARCHE Claude committed
109 110 111 112 113 114 115 116 117
    provers

let create_controller config env ses =
  let c =
    {
      controller_session = ses;
      controller_config = config;
      controller_env = env;
      controller_provers = Whyconf.Hprover.create 7;
118
      controller_strategies = Hstr.create 7;
MARCHE Claude's avatar
MARCHE Claude committed
119 120 121 122
      controller_running_proof_attempts = Hpan.create 17;
    }
  in
  load_drivers c;
123 124
  c

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145

(* Cannot remove a proof_attempt that was scheduled but did not finish yet.
   It can be interrupted though. *)
let removable_proof_attempt c pa =
  try let () = Hpan.find c.controller_running_proof_attempts pa in false
  with Not_found -> true

let any_removable c any =
  match any with
  | APa pa -> removable_proof_attempt c pa
  | _ -> true

(* Check whether the subtree [n] contains an unremovable proof_attempt
   (ie: scheduled or running) *)
let check_removable c (n: any) =
  fold_all_any c.controller_session (fun acc any -> acc && any_removable c any) true n


let remove_subtree ~(notification:notifier) ~(removed:notifier) c (n: any) =
  if check_removable c n then
    Session_itp.remove_subtree ~notification ~removed c.controller_session n
146

147 148 149
(* Get children of any without proofattempts *)
let get_undetached_children_no_pa s any : any list =
  match any with
150
  | AFile f -> List.map (fun th -> ATh th) (file_theories f)
151 152 153
  | ATh th  -> List.map (fun g -> APn g) (theory_goals th)
  | ATn tn  -> List.map (fun pn -> APn pn) (get_sub_tasks s tn)
  | APn pn  -> List.map (fun tn -> ATn tn) (get_transformations s pn)
Sylvain Dailler's avatar
Sylvain Dailler committed
154
  | APa _ -> []
155

156 157


158 159 160 161 162 163 164 165 166 167
(* printing *)

module PSession = struct

  type any =
    | Session
    | File of file
    | Theory of theory
    | Goal of proofNodeID
    | Transf of transID
168
    | ProofAttempt of proof_attempt_node
169 170 171 172 173 174 175 176 177 178

  type 'a t = { tcont : controller;
                tkind : any }

  let decomp x =
    let s = x.tcont.controller_session in
    let n y acc = { x with tkind = y } :: acc in
    match x.tkind with
    | Session -> "", Hstr.fold (fun _ f -> n (File f)) (get_files s) []
    | File f ->
179
       (file_name f),
180
       List.fold_right (fun th -> n (Theory th)) (file_theories f) []
181 182 183
    | Theory th ->
       let id = theory_name th in
       let name = id.Ident.id_string in
184
       let name = if th_proved s th then name^"!" else name^"?" in
185
       name,
Sylvain Dailler's avatar
Sylvain Dailler committed
186 187 188
       List.fold_right
         (fun g -> n (Goal g))
         (theory_goals th)
MARCHE Claude's avatar
MARCHE Claude committed
189
         []
190 191 192
    | Goal id ->
       let gid = get_proof_name s id in
       let name = gid.Ident.id_string in
193
       let name = if pn_proved s id then name^"!" else name^"?" in
194 195 196 197 198 199 200
       let pas = get_proof_attempts s id in
       let trs = get_transformations s id in
       name,
       List.fold_right (fun g -> n (Transf g)) trs
                       (List.fold_right (fun g -> n (ProofAttempt g)) pas [])
    | ProofAttempt pa ->
       Pp.sprintf_wnl "%a%s%s"
Sylvain Dailler's avatar
Sylvain Dailler committed
201 202 203 204 205
          Whyconf.print_prover pa.prover
          (match pa.Session_itp.proof_state with
          | Some { Call_provers.pr_answer = Call_provers.Valid} -> ""
          | _ -> "?")
          (if pa.proof_obsolete then "O" else ""), []
206 207
    | Transf id ->
       let name = get_transf_name s id in
208
       let name = if tn_proved s id then name^"!" else name^"?" in
209 210
       let sts = get_sub_tasks s id in
       name,
MARCHE Claude's avatar
MARCHE Claude committed
211
       List.fold_right (fun g -> n (Goal g)) sts []
212 213 214 215 216 217 218 219 220 221 222 223

end

module P = Print_tree.PMake(PSession)

let print_session fmt c =
  P.print fmt { PSession.tcont = c; PSession.tkind = PSession.Session }

(*********)



224 225 226 227 228 229

(** reload files, associating old proof attempts and transformations
    to the new goals.  old theories and old goals for which we cannot
    find a corresponding new theory resp. old goal are kept, with
    tasks associated to them *)

230
let reload_files (c : controller) ~use_shapes =
231
  let old_ses = c.controller_session in
MARCHE Claude's avatar
MARCHE Claude committed
232
  c.controller_env <- Env.create_env (Env.get_loadpath c.controller_env);
MARCHE Claude's avatar
MARCHE Claude committed
233 234
  Whyconf.Hprover.reset c.controller_provers;
  load_drivers c;
235
  c.controller_session <- empty_session ~from:old_ses (get_dir old_ses);
236 237 238 239 240 241 242 243 244
  merge_files ~use_shapes c.controller_env c.controller_session old_ses

exception Errors_list of exn list

let reload_files (c: controller) ~use_shapes =
  let errors, b1, b2 = reload_files c ~use_shapes in
  match errors with
  | [] -> b1, b2
  | _ -> raise (Errors_list errors)
245 246

let add_file c ?format fname =
247 248 249
  let file_is_detached,theories,errors =
    try false,(Session_itp.read_file c.controller_env ?format fname), None
    with e -> true,[], Some e
250
  in
251
  let (_ : file) = add_file_section c.controller_session fname ~file_is_detached theories format in
252
  errors
253

254 255 256 257 258
let add_file c ?format fname =
  let errors = add_file c ?format fname in
  match errors with
  | None -> ()
  | Some error -> raise (Errors_list [error])
259 260

module type Scheduler = sig
261
  val blocking: bool
262
  val multiplier: int
263 264 265 266
  val timeout: ms:int -> (unit -> bool) -> unit
  val idle: prio:int -> (unit -> bool) -> unit
end

267 268
module Make(S : Scheduler) = struct

MARCHE Claude's avatar
MARCHE Claude committed
269 270
let scheduled_proof_attempts = Queue.create ()

271 272 273 274 275 276
let prover_tasks_in_progress = Hashtbl.create 17

(* We need to separate tasks that are edited from proofattempt in progress
   because we are not using why3server for the edited proofs and timeout_handler
   rely on a loop on why3server's results. *)
let prover_tasks_edited = Queue.create ()
MARCHE Claude's avatar
MARCHE Claude committed
277 278 279

let timeout_handler_running = ref false

280

MARCHE Claude's avatar
MARCHE Claude committed
281
let number_of_running_provers = ref 0
282

283 284 285 286
let observer = ref (fun _ _ _ -> ())

let register_observer = (:=) observer

287
module Hprover = Whyconf.Hprover
MARCHE Claude's avatar
MARCHE Claude committed
288

289 290 291 292 293 294 295 296 297 298 299 300 301
(* calling provers, with limits adaptation

 *)


(* to avoid corner cases when prover results are obtained very closely
   to the time or mem limits, we adapt these limits when we replay a
   proof *)

let adapt_limits ~interactive ~use_steps limits a =
  let t, m, s =
    let timelimit = limits.Call_provers.limit_time in
    let memlimit = limits.Call_provers.limit_mem in
302
    let steplimit = limits.Call_provers.limit_steps in
303 304 305 306 307 308 309 310
    match a.proof_state with
    | Some { Call_provers.pr_answer = r;
             Call_provers.pr_time = t;
             Call_provers.pr_steps = s } ->
       (* increased time limit is 1 + twice the previous running time,
       but enforced to remain inside the interval [l,2l] where l is
       the previous time limit *)
       let t = truncate (1.0 +. 2.0 *. t) in
311
       let increased_time = if interactive then 0
312 313 314 315 316
                            else max timelimit (min t (2 * timelimit)) in
       (* increased mem limit is just 1.5 times the previous mem limit *)
       let increased_mem = if interactive then 0 else 3 * memlimit / 2 in
       begin
         match r with
317 318
         | Call_provers.OutOfMemory -> increased_time, memlimit, steplimit
         | Call_provers.Timeout -> timelimit, increased_mem, steplimit
319 320
         | Call_provers.Valid ->
            let steplimit =
321 322 323 324 325 326 327 328 329
              if use_steps && not a.proof_obsolete then
                (* We need to allow at least one more step than what was used to
                   prove the same statement. Otherwise, the prover run out of
                   steps: this happens with cvc4 on some very fast proofs
                   (steps = 28).
                *)
                s + 1
              else
                0
330 331 332 333
            in
            increased_time, increased_mem, steplimit
         | Call_provers.Unknown _
         | Call_provers.StepLimitExceeded
334
         | Call_provers.Invalid -> increased_time, increased_mem, steplimit
335 336 337
         | Call_provers.Failure _
         | Call_provers.HighFailure ->
            (* correct ? failures are supposed to appear quickly anyway... *)
338
            timelimit, memlimit, steplimit
339 340
       end
    | None when interactive -> 0, 0, 0
341
    | None -> timelimit, memlimit, steplimit
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
  in
  { Call_provers.limit_time = t; limit_mem = m; limit_steps = s }

let group_answer a =
  match a with
  | Call_provers.OutOfMemory
  | Call_provers.Unknown _
  | Call_provers.Timeout -> Call_provers.Timeout
  | _ -> a

let fuzzy_proof_time nres ores =
  let ansold = ores.Call_provers.pr_answer in
  let told = ores.Call_provers.pr_time in
  let ansnew = nres.Call_provers.pr_answer in
  let tnew = nres.Call_provers.pr_time in
  if group_answer ansold = group_answer ansnew &&
       tnew >= told *. 0.9 -. 0.1 && tnew <= told *. 1.1 +. 0.1
  then { nres with Call_provers.pr_time = told }
  else nres


363
let build_prover_call ?proof_script c id pr limit callback ores =
364
  let (config_pr,driver) = Hprover.find c.controller_provers pr in
365
  let with_steps = Call_provers.(limit.limit_steps <> empty_limit.limit_steps) in
366
  let command =
367
    Whyconf.get_complete_command config_pr ~with_steps in
368
  try
369
    let task = Session_itp.get_task c.controller_session id in
370 371 372
    Debug.dprintf debug_sched "[build_prover_call] Script file = %a@."
                  (Pp.print_option Pp.string) proof_script;
    let inplace = config_pr.Whyconf.in_place in
373
    let interactive = config_pr.Whyconf.interactive in
374 375
    try
      let call =
376
        Driver.prove_task ?old:proof_script ~inplace ~command
377
                          ~limit ~interactive driver task
378 379 380 381 382
      in
      let pa = (c.controller_session,id,pr,callback,false,call,ores) in
      Hashtbl.replace prover_tasks_in_progress call pa
    with Sys_error _ as e ->
      callback (InternalFailure e)
383 384
  with Not_found (* goal has no task, it is detached *) ->
       callback Detached
MARCHE Claude's avatar
MARCHE Claude committed
385

386 387
let update_observer () =
  let scheduled = Queue.length scheduled_proof_attempts in
388
  let waiting_or_running = Hashtbl.length prover_tasks_in_progress in
389 390 391
  let running = !number_of_running_provers in
  !observer scheduled (waiting_or_running - running) running

MARCHE Claude's avatar
MARCHE Claude committed
392 393
let timeout_handler () =
  (* examine all the prover tasks in progress *)
394 395 396
  (* When no tasks are there, probably no tasks were scheduled and the server
     was not launched so getting results could fail. *)
  if Hashtbl.length prover_tasks_in_progress != 0 then begin
397
    let results = Call_provers.get_new_results ~blocking:S.blocking in
398 399 400 401
    List.iter (fun (call, prover_update) ->
      match Hashtbl.find prover_tasks_in_progress call with
      | (ses,id,pr,callback,started,call,ores) ->
        begin match prover_update with
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424
        | Call_provers.NoUpdates -> ()
        | Call_provers.ProverStarted ->
            assert (not started);
            callback Running;
            incr number_of_running_provers;
            Hashtbl.replace prover_tasks_in_progress call
              (ses,id,pr,callback,true,call,ores)
        | Call_provers.ProverFinished res ->
            Hashtbl.remove prover_tasks_in_progress call;
            if started then decr number_of_running_provers;
            let res = Opt.fold fuzzy_proof_time res ores in
            (* inform the callback *)
            callback (Done res)
        | Call_provers.ProverInterrupted ->
            Hashtbl.remove prover_tasks_in_progress call;
            if started then decr number_of_running_provers;
            (* inform the callback *)
            callback (Interrupted)
        | Call_provers.InternalFailure exn ->
            Hashtbl.remove prover_tasks_in_progress call;
            if started then decr number_of_running_provers;
            (* inform the callback *)
            callback (InternalFailure (exn))
425 426 427 428 429 430
        end
      | exception Not_found -> ()
        (* We probably received ProverStarted after ProverFinished,
           because what is sent to and received from the server is
           not ordered. *)
    ) results;
431 432
  end;

433 434 435 436 437 438 439
  (* When blocking is activated, we are in script mode and we don't want editors
     to be launched so we don't need to go in this loop. *)
  if not S.blocking then begin
    (* Check for editor calls which are not finished *)
    let q = Queue.create () in
    while not (Queue.is_empty prover_tasks_edited) do
      (* call is an EditorCall *)
440
      let (callback,call,ores) as c =
441 442 443 444
        Queue.pop prover_tasks_edited in
      let prover_update = Call_provers.query_call call in
      match prover_update with
      | Call_provers.NoUpdates -> Queue.add c q
445
      | Call_provers.ProverFinished res ->
446 447
          (* res is meaningless for edition, we returned the old result *)
          (* inform the callback *)
448
          callback (match ores with None -> Done res | Some r -> Done r)
449 450 451 452
      | _ -> assert (false) (* An edition can only return Noupdates or finished *)
    done;
    Queue.transfer q prover_tasks_edited;
  end;
453 454

  (* if the number of prover tasks is less than S.multiplier times the maximum
MARCHE Claude's avatar
MARCHE Claude committed
455 456
     number of running provers, then we heuristically decide to add
     more tasks *)
457 458
  begin
    try
459
      for _i = Hashtbl.length prover_tasks_in_progress
460
          to S.multiplier * !session_max_tasks do
461
        let (c,id,pr,limit,proof_script,callback,ores) =
462
          Queue.pop scheduled_proof_attempts in
463
        try
464
          build_prover_call ?proof_script c id pr limit callback ores
465 466 467 468 469
        with e when not (Debug.test_flag Debug.stack_trace) ->
          callback (InternalFailure e)
      done
  with Queue.Empty -> ()
  end;
470
  update_observer ();
471
  true
MARCHE Claude's avatar
MARCHE Claude committed
472

473
let interrupt () =
474 475 476 477 478 479 480
  (* Interrupt provers *)
  Hashtbl.iter (fun _k e ->
    let (_, _, _, callback, _, _, _) = e in callback Interrupted)
    prover_tasks_in_progress;
  Hashtbl.clear prover_tasks_in_progress;
  (* Do not interrupt editors
  while not (Queue.is_empty prover_tasks_edited) do
481
    let (_ses,_id,_pr,callback,_started,_call,_ores) =
482
      Queue.pop prover_tasks_edited in
483 484
    callback Interrupted
  done;
485
  *)
486 487
  number_of_running_provers := 0;
  while not (Queue.is_empty scheduled_proof_attempts) do
488
    let (_c,_id,_pr,_limit,_proof_script,callback,_ores) =
489
      Queue.pop scheduled_proof_attempts in
490 491 492 493
    callback Interrupted
  done;
  !observer 0 0 0

MARCHE Claude's avatar
MARCHE Claude committed
494 495 496 497
let run_timeout_handler () =
  if not !timeout_handler_running then
    begin
      timeout_handler_running := true;
498
      S.timeout ~ms:default_delay_ms timeout_handler;
MARCHE Claude's avatar
MARCHE Claude committed
499 500
    end

501
let schedule_proof_attempt c id pr ?save_to ~limit ~callback ~notification =
502 503
  let ses = c.controller_session in
  let callback panid s =
504 505
    begin
      match s with
506
      | UpgradeProver _ -> ()
507 508 509 510 511 512 513 514
      | Scheduled ->
         Hpan.add c.controller_running_proof_attempts panid ();
         update_goal_node notification ses id
      | Running -> update_goal_node notification ses id
      | Done res ->
         Hpan.remove c.controller_running_proof_attempts panid;
         update_proof_attempt ~obsolete:false notification ses id pr res;
         update_goal_node notification ses id
515 516
      | Interrupted
      | InternalFailure _ ->
517 518 519 520 521
         Hpan.remove c.controller_running_proof_attempts panid;
         (* what to do ?
         update_proof_attempt ~obsolete:false notification ses id pr res;
          *)
         update_goal_node notification ses id
522 523
      | Detached -> assert false
      | Uninstalled _ -> assert false
524
      | Undone -> assert false
525
    end;
526 527 528
    callback panid s
  in
  let adaptlimit,ores,proof_script =
529
    try
530
      let h = get_proof_attempt_ids ses id in
531
      let pa = Hprover.find h pr in
532
      let a = get_proof_attempt_node ses pa in
533 534 535 536 537
      let old_res = a.proof_state in
      let config_pr,_ = Hprover.find c.controller_provers pr in
      let interactive = config_pr.Whyconf.interactive in
      let use_steps = Call_provers.(limit.limit_steps <> empty_limit.limit_steps) in
      let limit = adapt_limits ~interactive ~use_steps limit a in
538 539 540
      let script =
        if save_to = None then
          Opt.map (fun s ->
541 542
                            Debug.dprintf debug_sched "Script file = %s@." s;
                            Filename.concat (get_dir ses) s) a.proof_script
543 544
        else
          save_to
545 546
      in
      limit, old_res, script
547
    with Not_found | Session_itp.BadID -> limit,None,save_to
548
  in
549
  let panid = graft_proof_attempt ~limit ses id pr in
550
  Queue.add (c,id,pr,adaptlimit,proof_script,callback panid,ores)
551
            scheduled_proof_attempts;
552
  callback panid Scheduled;
MARCHE Claude's avatar
MARCHE Claude committed
553
  run_timeout_handler ()
Clément Fumex's avatar
Clément Fumex committed
554

555

556 557


558 559
(*** { 2 edition of proof scripts} *)

Sylvain Dailler's avatar
Sylvain Dailler committed
560 561 562
(* create the path to a file for saving the external proof script *)
let create_file_rel_path c pr pn =
  let session = c.controller_session in
563
  let driver = snd (Hprover.find c.controller_provers pr) in
564
  let task = Session_itp.get_task session pn in
Sylvain Dailler's avatar
Sylvain Dailler committed
565 566 567 568
  let session_dir = Session_itp.get_dir session in
  let th = get_encapsulating_theory session (APn pn) in
  let th_name = (Session_itp.theory_name th).Ident.id_string in
  let f = get_encapsulating_file session (ATh th) in
569
  let fn = Filename.chop_extension (Filename.basename (file_name f)) in
Sylvain Dailler's avatar
Sylvain Dailler committed
570 571 572 573 574 575
  let file = Driver.file_of_task driver fn th_name task in
  let file = Filename.concat session_dir file in
  let file = Sysutil.uniquify file in
  let file = Sysutil.relativize_filename session_dir file in
  file

576
let prepare_edition c ?file pn pr ~notification =
Sylvain Dailler's avatar
Sylvain Dailler committed
577
  let session = c.controller_session in
578 579 580
  let proof_attempts_id = get_proof_attempt_ids session pn in
  let panid =
    try
581 582 583 584 585 586 587 588 589 590 591 592 593 594
      let panid = Hprover.find proof_attempts_id pr in
      (* if no proof script yet, we need to add one
         it happens e.g when editing a file for an automatic prover
       *)
      let pa = get_proof_attempt_node session panid in
      match pa.proof_script with
      | None ->
         let file = match file with
           | Some f -> f
           | None -> create_file_rel_path c pr pn
         in
         set_proof_script pa file;
         panid
      | Some _ -> panid
595
    with Not_found ->
596 597 598 599
      let file = match file with
        | Some f -> f
        | None -> create_file_rel_path c pr pn
      in
600 601
      let limit = Call_provers.empty_limit in
      graft_proof_attempt session pn pr ~file ~limit
Sylvain Dailler's avatar
Sylvain Dailler committed
602
  in
603
  update_goal_node notification session pn;
604 605
  let pa = get_proof_attempt_node session panid in
  let file = Opt.get pa.proof_script in
606
  let old_res = pa.proof_state in
607
  let session_dir = Session_itp.get_dir session in
Sylvain Dailler's avatar
Sylvain Dailler committed
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
  let file = Filename.concat session_dir file in
  let old =
    if Sys.file_exists file
    then
      begin
        let backup = file ^ ".bak" in
        if Sys.file_exists backup
        then Sys.remove backup;
        Sys.rename file backup;
        Some(open_in backup)
      end
    else None
  in
  let ch = open_out file in
  let fmt = formatter_of_out_channel ch in
623
  let task = Session_itp.get_task session pn in
624
  let driver = snd (Hprover.find c.controller_provers pr) in
625
  Driver.print_task ?old driver fmt task;
Sylvain Dailler's avatar
Sylvain Dailler committed
626 627
  Opt.iter close_in old;
  close_out ch;
628
  panid,file,old_res
Sylvain Dailler's avatar
Sylvain Dailler committed
629 630 631

exception Editor_not_found

632
let schedule_edition c id pr ~callback ~notification =
Sylvain Dailler's avatar
Sylvain Dailler committed
633 634 635 636
  Debug.dprintf debug_sched "[Sched] Scheduling an edition@.";
  let config = c.controller_config in
  let session = c.controller_session in
  let prover_conf = Whyconf.get_prover_config config pr in
637
  (* Make sure editor exists. Fails otherwise *)
Sylvain Dailler's avatar
Sylvain Dailler committed
638 639
  let editor =
    match prover_conf.Whyconf.editor with
640
    | "" -> Whyconf.(default_editor (get_main config))
Sylvain Dailler's avatar
Sylvain Dailler committed
641
    | s ->
642 643 644 645 646
       try
         let ed = Whyconf.editor_by_id config s in
         String.concat " " (ed.Whyconf.editor_command ::
                              ed.Whyconf.editor_options)
       with Not_found -> raise Editor_not_found
Sylvain Dailler's avatar
Sylvain Dailler committed
647
  in
648
  let panid,file,old_res = prepare_edition c id pr ~notification in
649
  (* Notification node *)
650 651 652
  let callback panid s =
    begin
      match s with
653
      | UpgradeProver _ -> ()
654
      | Running -> ()
655 656
      | Done res ->
         (* set obsolete to true since we do not know if the manual
657
            proof was completed or not *)
658 659 660 661 662
         Debug.dprintf debug_sched
                       "Setting status of %a under parent %a to obsolete@."
                       print_proofAttemptID panid print_proofNodeID id;
         update_proof_attempt ~obsolete:true notification session id pr res;
         update_goal_node notification session id
663 664 665 666
      | Interrupted
      | InternalFailure _ ->
         update_goal_node notification session id
      | Undone | Detached | Uninstalled _ | Scheduled -> assert false
667 668
    end;
    callback panid s
669
  in
Sylvain Dailler's avatar
Sylvain Dailler committed
670
  Debug.dprintf debug_sched "[Editing] goal %s with command '%s' on file %s@."
671 672
                (Session_itp.get_proof_name session id).Ident.id_string
                editor file;
673 674
  let call = Call_provers.call_editor ~command:editor file in
  callback panid Running;
675
  Queue.add (callback panid,call,old_res) prover_tasks_edited;
676
  run_timeout_handler ()
677

678 679
exception TransAlreadyExists of string * string

680 681
(*** { 2 transformations} *)

682 683 684 685 686 687 688 689 690
let schedule_transformation c id name args ~callback ~notification =
  let callback s =
    begin match s with
          | TSdone tid -> update_trans_node notification c.controller_session tid
          | TSscheduled
          | TSfailed _ -> ()
    end;
    callback s
  in
691
  let apply_trans () =
692 693
    begin
      try
694 695 696
        let subtasks =
          apply_trans_to_goal ~allow_no_effect:false
                              c.controller_session c.controller_env name args id
697
        in
698 699 700 701 702 703
        let tid = graft_transf c.controller_session id name args subtasks in
        callback (TSdone tid)
      with
      | Exit ->
         (* if result is same as input task, consider it as a failure *)
         callback (TSfailed (id, Noprogress))
704
      | e when not (Debug.test_flag Debug.stack_trace) ->
705
          (* "@[Exception raised in Session_itp.apply_trans_to_goal %s:@ %a@.@]"
706
          name Exn_printer.exn_printer e; TODO *)
707
        callback (TSfailed (id, e))
708 709
    end;
    false
710
  in
711 712
  if Session_itp.check_if_already_exists c.controller_session id name args then
    raise (TransAlreadyExists (name, List.fold_left (fun acc s -> s ^ " " ^ acc) "" args));
713 714
  S.idle ~prio:0 apply_trans;
  callback TSscheduled
Clément Fumex's avatar
Clément Fumex committed
715

716 717 718

open Strategy

Sylvain Dailler's avatar
Sylvain Dailler committed
719
let run_strategy_on_goal
720
    c id strat ~callback_pa ~callback_tr ~callback ~notification =
721 722 723 724 725 726
  let rec exec_strategy pc strat g =
    if pc < 0 || pc >= Array.length strat then
      callback STShalt
    else
      match Array.get strat pc with
      | Icall_prover(p,timelimit,memlimit) ->
MARCHE Claude's avatar
MARCHE Claude committed
727 728
         let callback panid res =
           callback_pa panid res;
729
           match res with
730
           | UpgradeProver _ | Scheduled | Running -> (* nothing to do yet *) ()
731 732 733
           | Done { Call_provers.pr_answer = Call_provers.Valid } ->
              (* proof succeeded, nothing more to do *)
              callback STShalt
734 735
           | Interrupted | InternalFailure _ ->
              callback STShalt
736 737 738 739 740
           | Done _ ->
              (* proof did not succeed, goto to next step *)
              callback (STSgoto (g,pc+1));
              let run_next () = exec_strategy (pc+1) strat g; false in
              S.idle ~prio:0 run_next
741
           | Undone | Detached | Uninstalled _ ->
742 743 744 745 746 747
                         (* should not happen *)
                         assert false
         in
         let limit = { Call_provers.empty_limit with
                       Call_provers.limit_time = timelimit;
                       limit_mem  = memlimit} in
748
         schedule_proof_attempt c g p ?save_to:None ~limit ~callback ~notification
749 750
      | Itransform(trname,pcsuccess) ->
         let callback ntr =
751
           callback_tr trname [] ntr;
752
           match ntr with
753
           | TSfailed _e -> (* transformation failed *)
754 755 756 757 758 759 760 761 762 763 764 765
              callback (STSgoto (g,pc+1));
              let run_next () = exec_strategy (pc+1) strat g; false in
              S.idle ~prio:0 run_next
           | TSscheduled -> ()
           | TSdone tid ->
              List.iter
                (fun g ->
                 callback (STSgoto (g,pcsuccess));
                 let run_next () =
                   exec_strategy pcsuccess strat g; false
                 in
                 S.idle ~prio:0 run_next)
MARCHE Claude's avatar
MARCHE Claude committed
766
                (get_sub_tasks c.controller_session tid)
767
         in
768
         schedule_transformation c g trname [] ~callback ~notification
769 770 771 772 773 774
      | Igoto pc ->
         callback (STSgoto (g,pc));
         exec_strategy pc strat g
  in
  exec_strategy 0 strat id

Sylvain Dailler's avatar
Sylvain Dailler committed
775 776
let schedule_pa_with_same_arguments
    c (pa: proof_attempt_node) (pn: proofNodeID) ~callback ~notification =
Sylvain Dailler's avatar
Sylvain Dailler committed
777 778 779 780
  let prover = pa.prover in
  let limit = pa.limit in
  schedule_proof_attempt c pn prover ~limit ~callback ~notification

Sylvain Dailler's avatar
Sylvain Dailler committed
781 782
let schedule_tr_with_same_arguments
    c (tr: transID) (pn: proofNodeID) ~callback ~notification =
Sylvain Dailler's avatar
Sylvain Dailler committed
783 784 785
  let s = c.controller_session in
  let args = get_transf_args s tr in
  let name = get_transf_name s tr in
786
  let callback = callback name args in
787

Sylvain Dailler's avatar
Sylvain Dailler committed
788 789
  schedule_transformation c pn name args ~callback ~notification

MARCHE Claude's avatar
MARCHE Claude committed
790 791 792 793 794
let proof_is_complete pa =
  match pa.Session_itp.proof_state with
  | None -> false
  | Some pr ->
     not pa.Session_itp.proof_obsolete &&
795
       Call_provers.(pr.pr_answer = Valid)
MARCHE Claude's avatar
MARCHE Claude committed
796

797

Sylvain Dailler's avatar
Sylvain Dailler committed
798
let clean c ~removed nid =
799

800
  (* clean should not change proved status *)
801 802 803
  let notification any =
    Format.eprintf "Cleaning error: cleaning attempts to change status of node %a@." fprintf_any any
  in
804
  let s = c.controller_session in
805
  (* This function is applied on leafs first for the case of removes *)
806
  let clean_aux () any =
807 808 809 810 811 812
    let do_remove =
      Session_itp.is_detached s any ||
      match any with
      | APa pa ->
         let pa = Session_itp.get_proof_attempt_node s pa in
         pn_proved s pa.parent && not (proof_is_complete pa)
813
      | ATn tn ->
814 815 816 817 818 819
         let pn = get_trans_parent s tn in
         pn_proved s pn && not (tn_proved s tn)
      | _ -> false
    in
    if do_remove then
      remove_subtree ~notification ~removed c any
820 821 822 823 824 825 826
  in

  match nid with
  | Some nid ->
      Session_itp.fold_all_any s clean_aux () nid
  | None ->
      Session_itp.fold_all_session s clean_aux ()
827

828 829
(* This function folds on any subelements of given node and tries to mark all
   proof attempts it encounters *)
830
let mark_as_obsolete ~notification c any =
831
  let s = c.controller_session in
832
  (* Case for proof attempt only *)
833
  let mark_as_obsolete_pa n =
834 835
    let parent = get_proof_attempt_parent s n in
    Session_itp.mark_obsolete s n;
836
    notification (APa n);
837
    update_goal_node notification s parent
838
  in
839 840 841 842 843 844 845 846 847 848
  match any with
  | Some any ->
      fold_all_any s
        (fun () any -> match any with
        | APa n -> mark_as_obsolete_pa n
        | _ -> ()) () any
  | None ->
      session_iter_proof_attempt
        (fun pa _pan ->
          mark_as_obsolete_pa pa) s
849

Sylvain Dailler's avatar
Sylvain Dailler committed
850 851 852
exception BadCopyPaste

(* Reproduce the transformation made on node on an other one *)
853
let rec copy_rec ~notification ~callback_pa ~callback_tr c from_any to_any =
Sylvain Dailler's avatar
Sylvain Dailler committed
854
  let s = c.controller_session in
855 856
  match from_any, to_any with
(*
Sylvain Dailler's avatar
Sylvain Dailler committed
857 858 859 860
    | AFile _, AFile _ ->
        raise BadCopyPaste
    | ATh _from_th, ATh _to_th ->
        raise BadCopyPaste
861
 *)
Sylvain Dailler's avatar
Sylvain Dailler committed
862 863
    | APn from_pn, APn to_pn ->
      let from_pa_list = get_proof_attempts s from_pn in
864
      List.iter (fun x -> schedule_pa_with_same_arguments ?save_to:None c x to_pn
Sylvain Dailler's avatar
Sylvain Dailler committed
865 866
          ~callback:callback_pa ~notification) from_pa_list;
      let from_tr_list = get_transformations s from_pn in
867
      let callback x tr args st = callback_tr tr args st;
Sylvain Dailler's avatar
Sylvain Dailler committed
868
        match st with
Sylvain Dailler's avatar
Sylvain Dailler committed
869
        | TSdone tid ->
870
          copy_rec c (ATn x) (ATn tid) ~notification ~callback_pa ~callback_tr
Sylvain Dailler's avatar
Sylvain Dailler committed
871 872 873 874 875 876 877
        | _ -> ()
      in
      List.iter (fun x -> schedule_tr_with_same_arguments c x to_pn
          ~callback:(callback x) ~notification) from_tr_list
    | ATn from_tn, ATn to_tn ->
        let from_tn_list = get_sub_tasks s from_tn in
        let to_tn_list = get_sub_tasks s to_tn in
878 879 880 881 882 883 884 885
        let rec iter_copy l1 l2 =
          match l1,l2 with
          | x::r1, y::r2 ->
             copy_rec c (APn x) (APn y)
                      ~notification ~callback_pa ~callback_tr;
             iter_copy r1 r2
          | _ -> ()
        in iter_copy from_tn_list to_tn_list
Sylvain Dailler's avatar
Sylvain Dailler committed
886 887 888
    | _ -> raise BadCopyPaste


889 890
let copy_paste ~notification ~callback_pa ~callback_tr c from_any to_any =
  let s = c.controller_session in
891 892
  if is_below s to_any from_any then
    raise BadCopyPaste;
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908
  match from_any, to_any with
  | APn _, APn _ ->
     copy_rec ~notification ~callback_pa ~callback_tr c from_any to_any
  | ATn from_tn, APn to_pn ->
     let callback tr args st =
       callback_tr tr args st;
       match st with
       | TSdone tid ->
          copy_rec c (ATn from_tn) (ATn tid) ~notification ~callback_pa ~callback_tr
       | _ -> ()
     in
     schedule_tr_with_same_arguments c from_tn to_pn ~callback ~notification
  | _ -> raise BadCopyPaste



MARCHE Claude's avatar
MARCHE Claude committed
909 910 911 912 913 914 915 916





(***************** {2 replay} ****************)


917
let debug_replay = Debug.register_flag "replay" ~desc:"Debug@ info@ for@ replay"
MARCHE Claude's avatar
MARCHE Claude committed
918

919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959
let find_prover notification c goal_id pr =
  if Hprover.mem c.controller_provers pr then Some pr else
   match Whyconf.get_prover_upgrade_policy c.controller_config pr with
   | exception Not_found -> None
   | Whyconf.CPU_keep -> None
   | Whyconf.CPU_upgrade new_pr ->
      (* does a proof using new_pr already exists ? *)
      if Hprover.mem (get_proof_attempt_ids c.controller_session goal_id) new_pr
      then (* yes, then we do nothing *)
        None
      else
        begin
          (* we modify the prover in-place *)
          Session_itp.change_prover notification c.controller_session goal_id pr new_pr;
          Some new_pr
        end
   | Whyconf.CPU_duplicate _new_pr ->
      assert false (* TODO *)
(*
      (* does a proof using new_p already exists ? *)
      if Hprover.mem (goal_external_proofs parid) new_pr
      then (* yes, then we do nothing *)
        None
      else
        begin
          (* we duplicate the proof_attempt *)
          let new_a = copy_external_proof
                        ~notify ~keygen:O.create ~prover:new_p ~env_session:eS a
          in
          Some new_pr
        end
*)

let replay_proof_attempt c pr limit (parid: proofNodeID) id ~callback ~notification =
  (* The replay can be done on a different machine so we need
     to check more things before giving the attempt to the scheduler *)
  match find_prover notification c parid pr with
  | None -> callback id (Uninstalled pr)
  | Some pr' ->
     try
       if pr' <> pr then callback id (UpgradeProver pr');
960
       let _ = get_task c.controller_session parid in
961
       schedule_proof_attempt ?save_to:None c parid pr' ~limit ~callback ~notification
962 963 964 965 966
     with Not_found ->
       callback id Detached



967 968 969 970
type report =
  | Result of Call_provers.prover_result * Call_provers.prover_result
  (** Result(new_result,old_result) *)
  | CallFailed of exn
971
  | Replay_interrupted
972 973 974 975 976 977 978 979 980 981 982
  | Prover_not_installed
  | Edited_file_absent of string
  | No_former_result of Call_provers.prover_result

(* TODO find a better way to print it *)
let print_report fmt (r: report) =
  match r with
  | Result (new_r, old_r) ->
    Format.fprintf fmt "new_result = %a, old_result = %a@."
      Call_provers.print_prover_result new_r
      Call_provers.print_prover_result old_r
983 984 985 986
  | CallFailed e ->
    Format.fprintf fmt "Callfailed %a@." Exn_printer.exn_printer e
  | Replay_interrupted ->
    Format.fprintf fmt "Interrupted@."
987 988 989 990 991 992 993 994 995
  | Prover_not_installed ->
    Format.fprintf fmt "Prover not installed@."
  | Edited_file_absent _ ->
    Format.fprintf fmt "No edited file@."
  | No_former_result new_r ->
    Format.fprintf fmt "new_result = %a, no former result@."
      Call_provers.print_prover_result new_r

(* TODO to be removed when we have a better way to print *)
996
let replay_print fmt (lr: (proofNodeID * Whyconf.prover * Call_provers.resource_limit * report) list) =
997 998
  let pp_elem fmt (id, pr, rl, report) =
    fprintf fmt "ProofNodeID: %d, Prover: %a, Timelimit?: %d, Result: %a@."
Sylvain Dailler's avatar
Sylvain Dailler committed
999 1000
      (Obj.magic id) Whyconf.print_prover pr
      rl.Call_provers.limit_time print_report report
1001
  in
1002
  Format.fprintf fmt "%a@." (Pp.print_list Pp.newline pp_elem) lr
1003

1004
let replay ~valid_only ~obsolete_only ?(use_steps=false) ?(filter=fun _ -> true)
Sylvain Dailler's avatar
Sylvain Dailler committed
1005
           c ~callback ~notification ~final_callback ~any =
1006

1007 1008 1009 1010 1011 1012
  let session = c.controller_session in
  let count = ref 0 in
  let report = ref [] in
  let found_upgraded_prover = ref false in

  let craft_report s id pr limits pa =
1013
    match s with
1014 1015
    | UpgradeProver _ -> found_upgraded_prover := true
    | Scheduled | Running -> ()
1016
    | Undone | Interrupted ->
1017
       decr count;
1018
       report := (id, pr, limits, Replay_interrupted ) :: !report
1019
    | Done new_r ->
1020
       decr count;
1021
        (match pa.Session_itp.proof_state with
1022 1023
        | None -> (report := (id, pr, limits, No_former_result new_r) :: !report)
        | Some old_r -> report := (id, pr, limits, Result (new_r, old_r)) :: !report)
1024
    | InternalFailure e ->
1025
       decr count;
1026
       report := (id, pr, limits, CallFailed (e)) :: !report
1027 1028
    | Uninstalled _ ->
       decr count;
1029
       report := (id, pr, limits, Prover_not_installed) :: !report;
1030
    | Detached -> decr count
1031
  in
1032

1033
  let need_replay id pa =
1034 1035
    filter pa &&
      (pa.proof_obsolete || not obsolete_only) &&
1036 1037 1038 1039
        (* When on a single proofattempt node, we want to always replay even non
           valid proofattempts.
        *)
        (any = Some (APa id) || not valid_only ||
1040 1041 1042
           match pa.Session_itp.proof_state with
           | None -> false
           | Some pr -> Call_provers.(pr.pr_answer = Valid))
1043 1044
  in

1045 1046 1047

  (* TODO count the number of node in a more efficient way *)
  (* Counting the number of proof_attempt to print report only once *)
Sylvain Dailler's avatar
Sylvain Dailler committed
1048 1049 1050
  (match any with
  | None ->
      Session_itp.session_iter_proof_attempt
1051
        (fun paid pa -> if need_replay paid pa then incr count) session
Sylvain Dailler's avatar
Sylvain Dailler committed
1052 1053
  | Some nid ->
      Session_itp.any_iter_proof_attempt session
1054
        (fun paid pa -> if need_replay paid pa then incr count) nid);
1055 1056

  (* Replaying function *)
1057
  let replay_pa id pa =
1058 1059 1060 1061
    let is_need_replay = need_replay id pa in
    Debug.dprintf debug_replay "Need_replay is set to %b for prover %a@."
      is_need_replay Whyconf.print_prover pa.prover;
    if is_need_replay then
1062 1063 1064
      begin
        let parid = pa.parent in
        let pr = pa.prover in
1065 1066 1067 1068
        (* TODO: if pr is not installed, lookup for a replacement policy
         OR: delegate this work to the replay_proof_attempt function *)
        (* If use_steps, we give only steps as a limit
         TODO: steps should not be used if prover was replaced above *)
1069 1070 1071 1072 1073 1074
        let limit =
          if use_steps then
            Call_provers.{empty_limit with limit_steps = pa.limit.limit_steps}
          else
            Call_provers.{ pa.limit with limit_steps = empty_limit.limit_steps }
        in
1075
        replay_proof_attempt c pr limit parid id
1076
                             ~callback:(fun id s ->
1077
                                        craft_report s parid pr limit pa;
1078
                                        callback id s;
1079 1080
                                        if !count = 0 then
                                          final_callback !found_upgraded_prover !report)
1081 1082
                             ~notification
      end in
1083

1084
  if !count = 0 then final_callback !found_upgraded_prover !report else
1085
  (* Calling replay on all the proof_attempts of the session *)
Sylvain Dailler's avatar
Sylvain Dailler committed
1086 1087 1088
  match any with
  | None -> Session_itp.session_iter_proof_attempt replay_pa session
  | Some nid -> Session_itp.any_iter_proof_attempt session replay_pa nid
1089

MARCHE Claude's avatar
MARCHE Claude committed
1090 1091 1092 1093 1094 1095 1096 1097 1098



(*************** bisect **********)



let debug = Debug.register_flag ~desc:"Task bisection" "bisect"

1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113
let create_rem_list =
  let b = Buffer.create 17 in
  fun rem ->
  Buffer.clear b;
  let add pr id =
    if Buffer.length b > 0 then Buffer.add_char b ',';
    Buffer.add_string b (Pp.string_of pr id)
  in
  let remove_ts ts = add Pretty.print_ts ts in
  let remove_ls ls = add Pretty.print_ls ls in
  let remove_pr pr = add Pretty.print_pr pr in
  Ty.Sts.iter remove_ts rem.Eliminate_definition.rem_ts;
  Term.Sls.iter remove_ls rem.Eliminate_definition.rem_ls;
  Decl.Spr.iter remove_pr rem.Eliminate_definition.rem_pr;
  Buffer.contents b
MARCHE Claude's avatar
MARCHE Claude committed
1114 1115


1116
let bisect_proof_attempt ~callback_tr ~callback_pa ~notification ~removed c pa_id =
MARCHE Claude's avatar
MARCHE Claude committed
1117 1118
  let ses = c.controller_session in
  let pa = get_proof_attempt_node ses pa_id in
MARCHE Claude's avatar
MARCHE Claude committed
1119 1120
  if not (proof_is_complete pa) then
    invalid_arg "bisect: proof attempt should be valid";
MARCHE Claude's avatar
MARCHE Claude committed
1121 1122 1123 1124 1125 1126
  let goal_id = pa.parent in
  let prover = pa.prover in
  let limit = { pa.limit with
                Call_provers.limit_steps =
                  Call_provers.empty_limit.Call_provers.limit_steps }
  in
1127
  let timelimit = ref limit.Call_provers.limit_time in
MARCHE Claude's avatar
MARCHE Claude committed