author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Mon, 02 Jun 2014 14:58:42 +0100 | |
changeset 39 | 7ea6b019ce24 |
parent 38 | c89013dca1aa |
child 40 | 0781a2fc93f1 |
permissions | -rw-r--r-- |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
theory Test |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
imports Precedence_ord |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
begin |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
type_synonym thread = nat -- {* Type for thread identifiers. *} |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
type_synonym priority = nat -- {* Type for priorities. *} |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
7 |
type_synonym cs = nat -- {* Type for critical sections (or resources). *} |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
datatype event = |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
Create thread priority |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
| Exit thread |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
| P thread cs |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
13 |
| V thread cs |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
| Set thread priority |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
type_synonym state = "event list" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
fun threads :: "state \<Rightarrow> thread set" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
where |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
"threads [] = {}" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
| "threads (Create th prio#s) = {th} \<union> threads s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
| "threads (Exit th # s) = (threads s) - {th}" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
| "threads (_#s) = threads s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
fun priority :: "thread \<Rightarrow> state \<Rightarrow> priority" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
where |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
27 |
"priority th [] = 0" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
| "priority th (Create th' prio#s) = (if th' = th then prio else priority th s)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
29 |
| "priority th (Set th' prio#s) = (if th' = th then prio else priority th s)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
| "priority th (_#s) = priority th s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
fun last_set :: "thread \<Rightarrow> state \<Rightarrow> nat" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
where |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
"last_set th [] = 0" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
| "last_set th ((Create th' prio)#s) = (if (th = th') then length s else last_set th s)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
| "last_set th ((Set th' prio)#s) = (if (th = th') then length s else last_set th s)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
| "last_set th (_#s) = last_set th s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
38 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
definition preced :: "thread \<Rightarrow> state \<Rightarrow> precedence" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
where "preced th s \<equiv> Prc (priority th s) (last_set th s)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
41 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
definition |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
43 |
"holds wq th cs \<equiv> th \<in> set (wq cs) \<and> th = hd (wq cs)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
44 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
definition |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
"waits wq th cs \<equiv> th \<in> set (wq cs) \<and> th \<noteq> hd (wq cs)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
48 |
datatype node = |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
Th "thread" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
| Cs "cs" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
51 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
52 |
definition |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
"RAG wq \<equiv> {(Th th, Cs cs) | th cs. waits wq th cs} \<union> {(Cs cs, Th th) | cs th. holds wq th cs}" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
54 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
55 |
definition |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
56 |
"dependants wq th \<equiv> {th' . (Th th', Th th) \<in> (RAG wq)^+}" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
57 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
58 |
record schedule_state = |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
59 |
wq_fun :: "cs \<Rightarrow> thread list" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
60 |
cprec_fun :: "thread \<Rightarrow> precedence" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
61 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
definition cpreced :: "(cs \<Rightarrow> thread list) \<Rightarrow> state \<Rightarrow> thread \<Rightarrow> precedence" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
63 |
where |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
64 |
"cpreced wq s th \<equiv> Max ({preced th s} \<union> {preced th' s | th'. th' \<in> dependants wq th})" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
65 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
66 |
abbreviation |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
67 |
"all_unlocked \<equiv> \<lambda>_::cs. ([]::thread list)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
68 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
69 |
abbreviation |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
70 |
"initial_cprec \<equiv> \<lambda>_::thread. Prc 0 0" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
71 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
72 |
abbreviation |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
73 |
"release qs \<equiv> case qs of |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
74 |
[] => [] |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
75 |
| (_ # qs) => SOME q. distinct q \<and> set q = set qs" |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
76 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
77 |
fun schs :: "state \<Rightarrow> schedule_state" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
78 |
where |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
79 |
"schs [] = (| wq_fun = \<lambda> cs. [], cprec_fun = (\<lambda>_. Prc 0 0) |)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
80 |
| "schs (Create th prio # s) = |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
81 |
(let wq = wq_fun (schs s) in |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
82 |
(|wq_fun = wq, cprec_fun = cpreced wq (Create th prio # s)|))" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
83 |
| "schs (Exit th # s) = |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
84 |
(let wq = wq_fun (schs s) in |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
85 |
(|wq_fun = wq, cprec_fun = cpreced wq (Exit th # s)|))" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
86 |
| "schs (Set th prio # s) = |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
87 |
(let wq = wq_fun (schs s) in |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
88 |
(|wq_fun = wq, cprec_fun = cpreced wq (Set th prio # s)|))" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
89 |
| "schs (P th cs # s) = |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
90 |
(let wq = wq_fun (schs s) in |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
91 |
let new_wq = wq(cs := (wq cs @ [th])) in |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
92 |
(|wq_fun = new_wq, cprec_fun = cpreced new_wq (P th cs # s)|))" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
93 |
| "schs (V th cs # s) = |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
94 |
(let wq = wq_fun (schs s) in |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
95 |
let new_wq = wq(cs := release (wq cs)) in |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
96 |
(|wq_fun = new_wq, cprec_fun = cpreced new_wq (V th cs # s)|))" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
97 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
98 |
definition wq :: "state \<Rightarrow> cs \<Rightarrow> thread list" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
99 |
where "wq s = wq_fun (schs s)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
100 |
|
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
101 |
definition cpreced2 :: "state \<Rightarrow> thread \<Rightarrow> precedence" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
102 |
where "cpreced2 s \<equiv> cprec_fun (schs s)" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
103 |
|
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
104 |
abbreviation |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
105 |
"cpreceds2 s ths \<equiv> {cpreced2 s th | th. th \<in> ths}" |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
106 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
107 |
definition |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
108 |
"holds2 s \<equiv> holds (wq_fun (schs s))" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
109 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
110 |
definition |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
111 |
"waits2 s \<equiv> waits (wq_fun (schs s))" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
112 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
113 |
definition |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
114 |
"RAG2 s \<equiv> RAG (wq_fun (schs s))" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
115 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
116 |
definition |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
117 |
"dependants2 s \<equiv> dependants (wq_fun (schs s))" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
118 |
|
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
119 |
(* ready -> is a thread that is not waiting for any resource *) |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
120 |
definition readys :: "state \<Rightarrow> thread set" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
121 |
where "readys s \<equiv> {th . th \<in> threads s \<and> (\<forall> cs. \<not> waits2 s th cs)}" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
122 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
123 |
definition runing :: "state \<Rightarrow> thread set" |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
124 |
where "runing s \<equiv> {th . th \<in> readys s \<and> cpreced2 s th = Max (cpreceds2 s (readys s))}" |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
125 |
|
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
126 |
(* all resources a thread hols in a state *) |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
127 |
definition holding :: "state \<Rightarrow> thread \<Rightarrow> cs set" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
128 |
where "holding s th \<equiv> {cs . holds2 s th cs}" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
129 |
|
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
130 |
abbreviation |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
131 |
"next_to_run ths \<equiv> hd (SOME q::thread list. distinct q \<and> set q = set ths)" |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
132 |
|
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
133 |
lemma exists_distinct: |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
134 |
obtains ys where "distinct ys" "set ys = set xs" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
135 |
by (metis List.finite_set finite_distinct_list) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
136 |
|
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
137 |
lemma next_to_run_set [simp]: |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
138 |
"wts \<noteq> [] \<Longrightarrow> next_to_run wts \<in> set wts" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
139 |
apply(rule exists_distinct[of wts]) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
140 |
by (metis (mono_tags, lifting) hd_in_set set_empty some_eq_ex) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
141 |
|
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
142 |
lemma holding_RAG: |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
143 |
"holding s th = {cs . (Cs cs, Th th) \<in> RAG2 s}" |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
144 |
unfolding holding_def RAG2_def RAG_def |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
145 |
unfolding holds2_def holds_def waits_def |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
146 |
by auto |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
147 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
148 |
inductive step :: "state \<Rightarrow> event \<Rightarrow> bool" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
149 |
where |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
150 |
step_Create: "\<lbrakk>th \<notin> threads s\<rbrakk> \<Longrightarrow> step s (Create th prio)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
151 |
| step_Exit: "\<lbrakk>th \<in> runing s; holding s th = {}\<rbrakk> \<Longrightarrow> step s (Exit th)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
152 |
| step_P: "\<lbrakk>th \<in> runing s; (Cs cs, Th th) \<notin> (RAG2 s)^+\<rbrakk> \<Longrightarrow> step s (P th cs)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
153 |
| step_V: "\<lbrakk>th \<in> runing s; holds2 s th cs\<rbrakk> \<Longrightarrow> step s (V th cs)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
154 |
| step_Set: "\<lbrakk>th \<in> runing s\<rbrakk> \<Longrightarrow> step s (Set th prio)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
155 |
|
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
156 |
(* valid states *) |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
157 |
inductive vt :: "state \<Rightarrow> bool" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
158 |
where |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
159 |
vt_nil[intro]: "vt []" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
160 |
| vt_cons[intro]: "\<lbrakk>vt s; step s e\<rbrakk> \<Longrightarrow> vt (e#s)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
161 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
162 |
lemma runing_ready: |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
163 |
shows "runing s \<subseteq> readys s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
164 |
unfolding runing_def readys_def |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
165 |
by auto |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
166 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
lemma readys_threads: |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
168 |
shows "readys s \<subseteq> threads s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
169 |
unfolding readys_def |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
170 |
by auto |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
171 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
172 |
lemma wq_distinct_step: |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
173 |
assumes "step s e" "distinct (wq s cs)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
174 |
shows "distinct (wq (e # s) cs)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
175 |
using assms |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
176 |
unfolding wq_def |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
177 |
apply(induct) |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
178 |
apply(auto simp add: RAG2_def RAG_def Let_def)[1] |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
179 |
apply(auto simp add: wq_def Let_def RAG2_def RAG_def holds_def runing_def waits2_def waits_def readys_def) |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
180 |
apply(auto split: list.split) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
181 |
apply(rule someI2) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
182 |
apply(auto) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
183 |
done |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
184 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
185 |
lemma wq_distinct: |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
186 |
assumes "vt s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
187 |
shows "distinct (wq s cs)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
188 |
using assms |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
189 |
apply(induct) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
190 |
apply(simp add: wq_def) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
191 |
apply(simp add: wq_distinct_step) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
192 |
done |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
193 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
194 |
lemma RAG_set_unchanged[simp]: |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
195 |
shows "RAG2 (Set th prio # s) = RAG2 s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
196 |
unfolding RAG2_def |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
197 |
by (simp add: Let_def) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
198 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
199 |
lemma RAG_create_unchanged[simp]: |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
200 |
"RAG2 (Create th prio # s) = RAG2 s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
201 |
unfolding RAG2_def |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
202 |
by (simp add: Let_def) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
203 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
204 |
lemma RAG_exit_unchanged[simp]: |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
205 |
shows "RAG2 (Exit th # s) = RAG2 s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
206 |
unfolding RAG2_def |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
207 |
by (simp add: Let_def) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
208 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
209 |
lemma RAG_p1: |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
210 |
assumes "wq s cs = []" |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
211 |
shows "RAG2 (P th cs # s) \<subseteq> RAG2 s \<union> {(Cs cs, Th th)}" |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
212 |
using assms |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
213 |
unfolding RAG2_def RAG_def wq_def Let_def waits_def holds_def |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
214 |
by (auto simp add: Let_def) |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
215 |
|
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
216 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
217 |
lemma RAG_p2: |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
218 |
assumes "(Cs cs, Th th) \<notin> (RAG2 s)\<^sup>+" "wq s cs \<noteq> []" |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
219 |
shows "RAG2 (P th cs # s) \<subseteq> RAG2 s \<union> {(Th th, Cs cs)}" |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
220 |
using assms |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
221 |
unfolding RAG2_def RAG_def wq_def Let_def waits_def holds_def |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
222 |
by (auto simp add: Let_def) |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
223 |
|
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
224 |
lemma [simp]: "(SOME q. distinct q \<and> q = []) = []" |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
225 |
by auto |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
226 |
|
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
227 |
lemma [simp]: "(x \<in> set (SOME q. distinct q \<and> set q = set p)) = (x \<in> set p)" |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
228 |
apply auto |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
229 |
apply (metis (mono_tags, lifting) List.finite_set finite_distinct_list some_eq_ex) |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
230 |
by (metis (mono_tags, lifting) List.finite_set finite_distinct_list some_eq_ex) |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
231 |
|
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
232 |
lemma RAG_v1: |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
233 |
assumes vt: "wq s cs = [th]" |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
234 |
shows "RAG2 (V th cs # s) \<subseteq> RAG2 s - {(Cs cs, Th th)}" |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
235 |
using assms |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
236 |
unfolding RAG2_def RAG_def waits_def holds_def wq_def |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
237 |
by (auto simp add: Let_def) |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
238 |
|
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
239 |
lemma RAG_v2: |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
240 |
assumes vt:"vt s" "wq s cs = th # wts \<and> wts \<noteq> []" |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
241 |
shows "RAG2 (V th cs # s) \<subseteq> |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
242 |
RAG2 s - {(Cs cs, Th th), (Th (next_to_run wts), Cs cs)} \<union> {(Cs cs, Th (next_to_run wts))}" |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
243 |
unfolding RAG2_def RAG_def waits_def holds_def |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
244 |
using assms wq_distinct[OF vt(1), of"cs"] |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
245 |
by (auto simp add: Let_def wq_def) |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
246 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
247 |
lemma waiting_unique: |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
248 |
assumes "vt s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
249 |
and "waits2 s th cs1" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
250 |
and "waits2 s th cs2" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
251 |
shows "cs1 = cs2" |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
252 |
using assms |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
253 |
apply(induct) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
254 |
apply(simp add: waits2_def waits_def) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
255 |
apply(erule step.cases) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
256 |
apply(auto simp add: Let_def waits2_def waits_def holds_def RAG2_def RAG_def |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
257 |
readys_def runing_def split: if_splits) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
258 |
apply (metis Nil_is_append_conv hd_append2 list.distinct(1) split_list) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
259 |
apply (metis Nil_is_append_conv hd_append2 list.distinct(1) split_list) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
260 |
apply (metis distinct.simps(2) distinct_length_2_or_more list.sel(1) wq_def wq_distinct) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
261 |
by (metis (full_types, hide_lams) distinct.simps(2) distinct_length_2_or_more list.sel(1) wq_def wq_distinct) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
262 |
|
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
263 |
|
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
264 |
lemma rtrancl_eq_trancl [simp]: |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
265 |
assumes "x \<noteq> y" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
266 |
shows "(x, y) \<in> r\<^sup>* \<longleftrightarrow> (x, y) \<in> r\<^sup>+" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
267 |
using assms by (metis rtrancl_eq_or_trancl) |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
268 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
269 |
lemma acyclic_RAG_step: |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
270 |
assumes vt: "vt s" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
271 |
and stp: "step s e" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
272 |
and ac: "acyclic (RAG2 s)" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
273 |
shows "acyclic (RAG2 (e # s))" |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
274 |
using stp vt ac |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
275 |
proof (induct) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
276 |
case (step_P th s cs) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
277 |
have ac: "acyclic (RAG2 s)" by fact |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
278 |
have ds: "(Cs cs, Th th) \<notin> (RAG2 s)\<^sup>+" by fact |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
279 |
{ assume wq_empty: "wq s cs = []" -- "case waiting queue is empty" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
280 |
then have "(Th th, Cs cs) \<notin> (RAG2 s)\<^sup>+" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
281 |
proof (rule_tac notI) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
282 |
assume "(Th th, Cs cs) \<in> (RAG2 s)\<^sup>+" |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
283 |
then obtain x where "(x, Cs cs) \<in> RAG2 s" using tranclD2 by metis |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
284 |
with wq_empty show False by (auto simp: RAG2_def RAG_def wq_def waits_def) |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
285 |
qed |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
286 |
with ac have "acyclic (RAG2 s \<union> {(Cs cs, Th th)})" by simp |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
287 |
then have "acyclic (RAG2 (P th cs # s))" using RAG_p1[OF wq_empty] |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
288 |
by (rule acyclic_subset) |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
289 |
} |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
290 |
moreover |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
291 |
{ assume wq_not_empty: "wq s cs \<noteq> []" -- "case waiting queue is not empty" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
292 |
from ac ds |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
293 |
have "acyclic (RAG2 s \<union> {(Th th, Cs cs)})" by simp |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
294 |
then have "acyclic (RAG2 (P th cs # s))" using RAG_p2[OF ds wq_not_empty] |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
295 |
by (rule acyclic_subset) |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
296 |
} |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
297 |
ultimately show "acyclic (RAG2 (P th cs # s))" by metis |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
298 |
next |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
299 |
case (step_V th s cs) -- "case for release of a lock" |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
300 |
have vt: "vt s" by fact |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
301 |
have ac: "acyclic (RAG2 s)" by fact |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
302 |
have hd: "holds2 s th cs" by fact |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
303 |
from vt have wq_distinct:"distinct (wq s cs)" by (rule wq_distinct) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
304 |
from hd have "th \<in> set (wq s cs)" "th = hd (wq s cs)" unfolding holds2_def holds_def wq_def by auto |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
305 |
then obtain wts where eq_wq: "wq s cs = th # wts" by (cases "wq s cs") (auto) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
306 |
-- "case no thread present in the waiting queue to take over" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
307 |
{ assume "wts = []" |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
308 |
with eq_wq have "wq s cs = [th]" by simp |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
309 |
then have "RAG2 (V th cs # s) \<subseteq> RAG2 s - {(Cs cs, Th th)}" by (rule RAG_v1) |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
310 |
moreover have "acyclic (RAG2 s - {(Cs cs, Th th)})" using ac by (auto intro: acyclic_subset) |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
311 |
ultimately |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
312 |
have "acyclic (RAG2 (V th cs # s))" by (auto intro: acyclic_subset) |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
313 |
} |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
314 |
moreover |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
315 |
-- "at least one thread present to take over" |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
316 |
{ def nth \<equiv> "next_to_run wts" |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
317 |
assume wq_not_empty: "wts \<noteq> []" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
318 |
have waits2_cs: "waits2 s nth cs" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
319 |
using eq_wq wq_not_empty wq_distinct |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
320 |
unfolding nth_def waits2_def waits_def wq_def[symmetric] by auto |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
321 |
have "RAG2 (V th cs # s) \<subseteq> RAG2 s - {(Cs cs, Th th), (Th nth, Cs cs)} \<union> {(Cs cs, Th nth)}" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
322 |
unfolding nth_def using vt wq_not_empty eq_wq by (rule_tac RAG_v2) (auto) |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
323 |
moreover |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
324 |
have "acyclic (RAG2 s - {(Cs cs, Th th), (Th nth, Cs cs)} \<union> {(Cs cs, Th nth)})" |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
325 |
proof - |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
326 |
have "acyclic (RAG2 s - {(Cs cs, Th th), (Th nth, Cs cs)})" using ac by (auto intro: acyclic_subset) |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
327 |
moreover |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
328 |
have "(Th nth, Cs cs) \<notin> (RAG2 s - {(Cs cs, Th th), (Th nth, Cs cs)})\<^sup>+" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
329 |
proof (rule notI) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
330 |
assume "(Th nth, Cs cs) \<in> (RAG2 s - {(Cs cs, Th th), (Th nth, Cs cs)})\<^sup>+" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
331 |
then obtain z where a: "(Th nth, z) \<in> (RAG2 s - {(Cs cs, Th th), (Th nth, Cs cs)})" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
332 |
by (metis converse_tranclE) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
333 |
then have "(Th nth, z) \<in> RAG2 s" by simp |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
334 |
then obtain cs' where b: "z = Cs cs'" "(Th nth, Cs cs') \<in> RAG2 s" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
335 |
unfolding RAG2_def RAG_def by auto |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
336 |
moreover |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
337 |
have "waits2 s nth cs'" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
338 |
using b(2) unfolding RAG2_def RAG_def waits2_def by simp |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
339 |
ultimately have "cs = cs'" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
340 |
by (rule_tac waiting_unique[OF vt waits2_cs]) |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
341 |
then show "False" using a b(1) by simp |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
342 |
qed |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
343 |
ultimately |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
344 |
show "acyclic (RAG2 s - {(Cs cs, Th th), (Th nth, Cs cs)} \<union> {(Cs cs, Th nth) })" by simp |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
345 |
qed |
38
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
346 |
ultimately have "acyclic (RAG2 (V th cs # s))" |
c89013dca1aa
finished proof of acyclity
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
347 |
by (rule_tac acyclic_subset) |
37
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
348 |
} |
c820ac0f3088
simplified RAG_acyclic proof
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
349 |
ultimately show "acyclic (RAG2 (V th cs # s))" by metis |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
350 |
qed (simp_all) |
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
351 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
352 |
|
39
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
353 |
lemma finite_RAG: |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
354 |
assumes "vt s" |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
355 |
shows "finite (RAG2 s)" |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
356 |
using assms |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
357 |
apply(induct) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
358 |
apply(simp add: RAG2_def RAG_def waits_def holds_def) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
359 |
apply(erule step.cases) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
360 |
apply(auto) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
361 |
apply(case_tac "wq sa cs = []") |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
362 |
apply(rule finite_subset) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
363 |
apply(rule RAG_p1) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
364 |
apply(simp) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
365 |
apply(simp) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
366 |
apply(rule finite_subset) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
367 |
apply(rule RAG_p2) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
368 |
apply(simp) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
369 |
apply(simp) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
370 |
apply(simp) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
371 |
apply(subgoal_tac "\<exists>wts. wq sa cs = th # wts") |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
372 |
apply(erule exE) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
373 |
apply(case_tac "wts = []") |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
374 |
apply(rule finite_subset) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
375 |
apply(rule RAG_v1) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
376 |
apply(simp) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
377 |
apply(simp) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
378 |
apply(rule finite_subset) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
379 |
apply(rule RAG_v2) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
380 |
apply(simp) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
381 |
apply(simp) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
382 |
apply(simp) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
383 |
apply(subgoal_tac "th \<in> set (wq sa cs) \<and> th = hd (wq sa cs)") |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
384 |
apply(case_tac "wq sa cs") |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
385 |
apply(auto)[2] |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
386 |
apply(auto simp add: holds2_def holds_def wq_def) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
387 |
done |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
388 |
|
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
389 |
lemma wq_threads: |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
390 |
assumes vt: "vt s" |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
391 |
and h: "th \<in> set (wq s cs)" |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
392 |
shows "th \<in> threads s" |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
393 |
using assms |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
394 |
apply(induct) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
395 |
apply(simp add: wq_def) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
396 |
apply(erule step.cases) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
397 |
apply(auto simp add: wq_def Let_def holding_def holds2_def holds_def waits2_def runing_def readys_def) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
398 |
apply(simp add: waits_def) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
399 |
apply(auto simp add: waits_def split: if_splits)[1] |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
400 |
apply(auto split: if_splits) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
401 |
apply(simp only: waits_def) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
402 |
by (metis insert_iff set_simps(2)) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
403 |
|
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
404 |
lemma max_cpreceds_readys_threads: |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
405 |
assumes vt: "vt s" |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
406 |
shows "Max (cpreceds2 s (readys s)) = Max (cpreceds2 s (threads s))" |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
407 |
apply(case_tac "threads s = {}") |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
408 |
apply(simp add: readys_def) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
409 |
using vt |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
410 |
apply(induct) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
411 |
apply(simp) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
412 |
apply(erule step.cases) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
413 |
apply(auto simp add: readys_def waits2_def waits_def Let_def holding_def runing_def holds2_def) |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
414 |
defer |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
415 |
defer |
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
416 |
oops |
36
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
417 |
|
af38526275f8
added a test theory for polishing teh proofs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
418 |
|
39
7ea6b019ce24
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
419 |
end |