forked from cubicle-model-checker/cubicle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsafety.ml
50 lines (42 loc) · 1.84 KB
/
safety.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
(**************************************************************************)
(* *)
(* 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 Ast
exception Unsafe of Node.t
(*************************************************)
(* Safety check : n /\ init must be inconsistent *)
(*************************************************)
let cdnf_asafe ua =
List.exists (
List.for_all (fun a ->
Cube.inconsistent_2arrays ua a))
(* fast check for inconsistence *)
let obviously_safe { t_init_instances = init_inst; } n =
let nb_procs = Node.dim n in
let { init_cdnf_a } = Hashtbl.find init_inst nb_procs in
cdnf_asafe (Node.array n) init_cdnf_a
let check s n =
(*Debug.unsafe s;*)
try
if not (obviously_safe s n) then
begin
Prover.unsafe s n;
if not quiet then eprintf "\nUnsafe trace: @[%a@]@."
Node.print_history n;
raise (Unsafe n)
end
with
| Smt.Unsat _ -> ()