author | paulson |
Thu, 26 Aug 1999 11:33:24 +0200 | |
changeset 7359 | 98a2afab3f86 |
parent 7127 | 48e235179ffb |
child 8334 | 7896bcbd8641 |
permissions | -rw-r--r-- |
5232 | 1 |
(* Title: HOL/UNITY/Deadlock |
5111 | 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] |
7127
48e235179ffb
added parentheses to cope with a possible reduction of the precedence of unary
paulson
parents:
6536
diff
changeset
|
12 |
"[| F : (A Int B) co A; F : (B Int A) co B |] ==> F : stable (A Int B)"; |
4776 | 13 |
by (Blast_tac 1); |
14 |
result(); |
|
15 |
||
16 |
||
17 |
(*a simplification step*) |
|
7127
48e235179ffb
added parentheses to cope with a possible reduction of the precedence of unary
paulson
parents:
6536
diff
changeset
|
18 |
Goal "(INT i: atMost n. A(Suc i) Int A i) = (INT i: atMost (Suc n). A i)"; |
4776 | 19 |
by (induct_tac "n" 1); |
5648 | 20 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [atMost_Suc]))); |
4776 | 21 |
by (blast_tac (claset() addEs [le_SucE] addSEs [equalityE]) 1); |
22 |
qed "Collect_le_Int_equals"; |
|
23 |
||
24 |
||
25 |
(*Dual of the required property. Converse inclusion fails.*) |
|
7127
48e235179ffb
added parentheses to cope with a possible reduction of the precedence of unary
paulson
parents:
6536
diff
changeset
|
26 |
Goal "(UN i: lessThan n. A i) Int (- A n) <= \ |
48e235179ffb
added parentheses to cope with a possible reduction of the precedence of unary
paulson
parents:
6536
diff
changeset
|
27 |
\ (UN i: lessThan n. (A i) Int (- A (Suc i)))"; |
4776 | 28 |
by (induct_tac "n" 1); |
29 |
by (Asm_simp_tac 1); |
|
5648 | 30 |
by (simp_tac (simpset() addsimps [lessThan_Suc]) 1); |
4776 | 31 |
by (Blast_tac 1); |
32 |
qed "UN_Int_Compl_subset"; |
|
33 |
||
34 |
||
35 |
(*Converse inclusion fails.*) |
|
5648 | 36 |
Goal "(INT i: lessThan n. -A i Un A (Suc i)) <= \ |
37 |
\ (INT i: lessThan n. -A i) Un A n"; |
|
4776 | 38 |
by (induct_tac "n" 1); |
39 |
by (Asm_simp_tac 1); |
|
5648 | 40 |
by (asm_simp_tac (simpset() addsimps [lessThan_Suc]) 1); |
4776 | 41 |
by (Blast_tac 1); |
42 |
qed "INT_Un_Compl_subset"; |
|
43 |
||
44 |
||
45 |
(*Specialized rewriting*) |
|
5648 | 46 |
Goal "A 0 Int (-(A n) Int (INT i: lessThan n. -A i Un A (Suc i))) = {}"; |
4776 | 47 |
by (blast_tac (claset() addIs [gr0I] |
48 |
addDs [impOfSubs INT_Un_Compl_subset]) 1); |
|
49 |
val lemma = result(); |
|
50 |
||
51 |
(*Reverse direction makes it harder to invoke the ind hyp*) |
|
5648 | 52 |
Goal "(INT i: atMost n. A i) = \ |
53 |
\ A 0 Int (INT i: lessThan n. -A i Un A(Suc i))"; |
|
4776 | 54 |
by (induct_tac "n" 1); |
55 |
by (Asm_simp_tac 1); |
|
56 |
by (asm_simp_tac |
|
7127
48e235179ffb
added parentheses to cope with a possible reduction of the precedence of unary
paulson
parents:
6536
diff
changeset
|
57 |
(simpset() addsimps Int_ac @ [Int_Un_distrib, Int_Un_distrib2, lemma, |
48e235179ffb
added parentheses to cope with a possible reduction of the precedence of unary
paulson
parents:
6536
diff
changeset
|
58 |
lessThan_Suc, atMost_Suc]) 1); |
4776 | 59 |
qed "INT_le_equals_Int"; |
60 |
||
5648 | 61 |
Goal "(INT i: atMost (Suc n). A i) = \ |
7127
48e235179ffb
added parentheses to cope with a possible reduction of the precedence of unary
paulson
parents:
6536
diff
changeset
|
62 |
\ A 0 Int (INT i: atMost n. -A i Un A(Suc i))"; |
5648 | 63 |
by (simp_tac (simpset() addsimps [lessThan_Suc_atMost, INT_le_equals_Int]) 1); |
4776 | 64 |
qed "INT_le_Suc_equals_Int"; |
65 |
||
66 |
||
67 |
(*The final deadlock example*) |
|
68 |
val [zeroprem, allprem] = goalw thy [stable_def] |
|
6536 | 69 |
"[| F : (A 0 Int A (Suc n)) co (A 0); \ |
70 |
\ ALL i: atMost n. F : (A(Suc i) Int A i) co \ |
|
71 |
\ (-A i Un A(Suc i)) |] \ |
|
5648 | 72 |
\ ==> F : stable (INT i: atMost (Suc n). A i)"; |
4776 | 73 |
by (rtac ([zeroprem, allprem RS ball_constrains_INT] MRS |
7127
48e235179ffb
added parentheses to cope with a possible reduction of the precedence of unary
paulson
parents:
6536
diff
changeset
|
74 |
constrains_Int RS constrains_weaken) 1); |
4776 | 75 |
by (simp_tac (simpset() addsimps [Collect_le_Int_equals, |
76 |
Int_assoc, INT_absorb]) 1); |
|
5536 | 77 |
by (simp_tac (simpset() addsimps [INT_le_Suc_equals_Int]) 1); |
4776 | 78 |
result(); |
79 |