5111
|
1 |
(* Title: HOL/UNITY/Traces
|
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1998 University of Cambridge
|
4776
|
5 |
|
5111
|
6 |
Deadlock examples from section 5.6 of
|
|
7 |
Misra, "A Logic for Concurrent Programming", 1994
|
|
8 |
*)
|
4776
|
9 |
|
|
10 |
(*Trivial, two-process case*)
|
5069
|
11 |
Goalw [constrains_def, stable_def]
|
5111
|
12 |
"[| constrains Acts (A Int B) A; constrains Acts (B Int A) B |] \
|
4776
|
13 |
\ ==> stable Acts (A Int B)";
|
|
14 |
by (Blast_tac 1);
|
|
15 |
result();
|
|
16 |
|
|
17 |
|
5069
|
18 |
Goal "{i. i < Suc n} = insert n {i. i < n}";
|
4776
|
19 |
by (blast_tac (claset() addSEs [less_SucE] addIs [less_SucI]) 1);
|
|
20 |
qed "Collect_less_Suc_insert";
|
|
21 |
|
|
22 |
|
5069
|
23 |
Goal "{i. i <= Suc n} = insert (Suc n) {i. i <= n}";
|
4776
|
24 |
by (blast_tac (claset() addSEs [le_SucE] addIs [le_SucI]) 1);
|
|
25 |
qed "Collect_le_Suc_insert";
|
|
26 |
|
|
27 |
|
|
28 |
(*a simplification step*)
|
5069
|
29 |
Goal "(INT i:{i. i <= n}. A(Suc i) Int A i) = \
|
4776
|
30 |
\ (INT i:{i. i <= Suc n}. A i)";
|
|
31 |
by (induct_tac "n" 1);
|
|
32 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [Collect_le_Suc_insert])));
|
|
33 |
by (blast_tac (claset() addEs [le_SucE] addSEs [equalityE]) 1);
|
|
34 |
qed "Collect_le_Int_equals";
|
|
35 |
|
|
36 |
|
|
37 |
(*Dual of the required property. Converse inclusion fails.*)
|
5069
|
38 |
Goal "(UN i:{i. i < n}. A i) Int Compl (A n) <= \
|
4776
|
39 |
\ (UN i:{i. i < n}. (A i) Int Compl (A(Suc i)))";
|
|
40 |
by (induct_tac "n" 1);
|
|
41 |
by (Asm_simp_tac 1);
|
|
42 |
by (simp_tac (simpset() addsimps [Collect_less_Suc_insert]) 1);
|
|
43 |
by (Blast_tac 1);
|
|
44 |
qed "UN_Int_Compl_subset";
|
|
45 |
|
|
46 |
|
|
47 |
(*Converse inclusion fails.*)
|
5069
|
48 |
Goal "(INT i:{i. i < n}. Compl(A i) Un A (Suc i)) <= \
|
4776
|
49 |
\ (INT i:{i. i < n}. Compl(A i)) Un A n";
|
|
50 |
by (induct_tac "n" 1);
|
|
51 |
by (Asm_simp_tac 1);
|
|
52 |
by (asm_simp_tac (simpset() addsimps [Collect_less_Suc_insert]) 1);
|
|
53 |
by (Blast_tac 1);
|
|
54 |
qed "INT_Un_Compl_subset";
|
|
55 |
|
|
56 |
|
|
57 |
(*Specialized rewriting*)
|
5069
|
58 |
Goal "A 0 Int (Compl (A n) Int \
|
4776
|
59 |
\ (INT i:{i. i < n}. Compl(A i) Un A (Suc i))) = {}";
|
|
60 |
by (blast_tac (claset() addIs [gr0I]
|
|
61 |
addDs [impOfSubs INT_Un_Compl_subset]) 1);
|
|
62 |
val lemma = result();
|
|
63 |
|
|
64 |
(*Reverse direction makes it harder to invoke the ind hyp*)
|
5069
|
65 |
Goal "(INT i:{i. i <= n}. A i) = \
|
4776
|
66 |
\ A 0 Int (INT i:{i. i < n}. Compl(A i) Un A(Suc i))";
|
|
67 |
by (induct_tac "n" 1);
|
|
68 |
by (Asm_simp_tac 1);
|
|
69 |
by (asm_simp_tac
|
|
70 |
(simpset() addsimps (Int_ac @
|
|
71 |
[Int_Un_distrib, Int_Un_distrib2, lemma,
|
|
72 |
Collect_less_Suc_insert, Collect_le_Suc_insert])) 1);
|
|
73 |
qed "INT_le_equals_Int";
|
|
74 |
|
5069
|
75 |
Goal "(INT i:{i. i <= Suc n}. A i) = \
|
4776
|
76 |
\ A 0 Int (INT i:{i. i <= n}. Compl(A i) Un A(Suc i))";
|
|
77 |
by (simp_tac (simpset() addsimps [le_eq_less_Suc RS sym,
|
|
78 |
INT_le_equals_Int]) 1);
|
|
79 |
qed "INT_le_Suc_equals_Int";
|
|
80 |
|
|
81 |
|
|
82 |
(*The final deadlock example*)
|
|
83 |
val [zeroprem, allprem] = goalw thy [stable_def]
|
|
84 |
"[| constrains Acts (A 0 Int A (Suc n)) (A 0); \
|
|
85 |
\ ALL i:{i. i <= n}. constrains Acts (A(Suc i) Int A i) \
|
|
86 |
\ (Compl(A i) Un A(Suc i)) |] \
|
|
87 |
\ ==> stable Acts (INT i:{i. i <= Suc n}. A i)";
|
|
88 |
|
|
89 |
by (rtac ([zeroprem, allprem RS ball_constrains_INT] MRS
|
|
90 |
constrains_Int RS constrains_weaken) 1);
|
|
91 |
by (simp_tac (simpset() addsimps [Collect_le_Int_equals,
|
|
92 |
Int_assoc, INT_absorb]) 1);
|
|
93 |
by (simp_tac (simpset() addsimps ([INT_le_Suc_equals_Int])) 1);
|
|
94 |
result();
|
|
95 |
|