-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmutexAbstractN.mlw
89 lines (58 loc) · 1.67 KB
/
mutexAbstractN.mlw
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
(* Abstract spec of mutual exclusion problem,
arbitrary number of concurrent processes
*)
module MutexAbstractN
use bool.Bool
use map.Map
use map.Const
type proc
type state = Init | CS | Done
(* System configurations
*)
type world = { pc_n : map proc state }
(* Inductive invariant
*)
predicate atMostOneCS (w:world) = forall p q :proc.
w.pc_n[p] = CS -> w.pc_n[q] = CS -> p = q
predicate inv (w:world) = atMostOneCS w
(* System INIT
*)
predicate initWorld_p (w:world) = w.pc_n = const Init
let ghost predicate initWorld (w:world) = initWorld_p w
(* System Actions
*)
(* Enter CS if no other process has
*)
predicate i_enbld (w:world) (p:proc) =
w.pc_n[p] = Init /\ forall p' :proc. w.pc_n[p'] <> CS
let ghost function i (w:world) (p:proc) : world
requires { i_enbld w p }
ensures { inv w -> inv result }
= { pc_n = (w.pc_n)[p<-CS] }
(* Exit CS
*)
predicate cs_enbld (w:world) (p:proc) =
w.pc_n[p] = CS
let ghost function cs (w:world) (p:proc) : world
requires { cs_enbld w p }
ensures { inv w -> inv result }
= { pc_n = w.pc_n[p<-Done] }
(* Transition relation
*)
inductive stepind world world =
| i : forall w :world, p :proc.
i_enbld w p -> stepind w (i w p)
| cs : forall w :world, p :proc.
cs_enbld w p -> stepind w (cs w p)
let ghost predicate step (w1:world) (w2:world) = stepind w1 w2
(* Proof of inductiveness
*)
clone export inductiveness.Inductiveness with
type world,
predicate inv,
val step,
val initWorld
(* Safety Property
*)
goal oneCS : forall w :world. reachable w -> atMostOneCS w
end