-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbrab.ml
65 lines (58 loc) · 2.56 KB
/
brab.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(**************************************************************************)
(* *)
(* Cubicle *)
(* *)
(* Copyright (C) 2011-2014 *)
(* *)
(* Sylvain Conchon and Alain Mebsout *)
(* Universite Paris-Sud 11 *)
(* *)
(* *)
(* This file is distributed under the terms of the Apache Software *)
(* License version 2.0 *)
(* *)
(**************************************************************************)
open Format
open Options
open Types
open Ast
module BWD = Bwd.Selected
module Oracle = Approx.SelectedOracle
(* FIXME Bug when search is parallel *)
let rec search_and_backtrack candidates system =
let res = BWD.search ~candidates system in
match res with
| Bwd.Safe _ -> res
| Bwd.Unsafe (faulty, candidates) ->
let o = Node.origin faulty in
if o.kind = Orig then res
else
(* Bad candidate, we backtrack while keeping interresting candidates *)
begin
assert (o.kind = Approx);
if not quiet then eprintf "The candidate %d = %a is BAD\n@."
o.tag Node.print o;
Stats.restart ();
let candidates =
Approx.remove_bad_candidates system faulty candidates
in
(* Restarting *)
search_and_backtrack candidates system
end
(** intercepts SIGINT [Ctrl-C] to display progress before exit *)
let reinstall_sigint () =
Sys.set_signal Sys.sigint
(Sys.Signal_handle
(fun _ ->
eprintf "@{<n>@}@."; (* Remove colors *)
Stats.print_report ~safe:false [] [];
eprintf "\n\n@{<b>@{<fg_red>ABORT !@}@} Received SIGINT@.";
exit 1))
(**************************************************************)
(* Backward reachability with approximations and backtracking *)
(**************************************************************)
let brab system =
Oracle.init system;
if only_forward then exit 0;
reinstall_sigint ();
search_and_backtrack [] system