paulson@11195
|
1 |
(* Title: HOL/UNITY/Reachability
|
paulson@11195
|
2 |
ID: $Id$
|
paulson@11195
|
3 |
Author: Tanja Vos, Cambridge University Computer Laboratory
|
paulson@11195
|
4 |
Copyright 2000 University of Cambridge
|
paulson@11195
|
5 |
|
paulson@11195
|
6 |
Reachability in Graphs
|
paulson@11195
|
7 |
|
paulson@11195
|
8 |
From Chandy and Misra, "Parallel Program Design" (1989), sections 6.2 and 11.3
|
paulson@11195
|
9 |
*)
|
paulson@11195
|
10 |
|
haftmann@16417
|
11 |
theory Reachability imports Detects Reach begin
|
paulson@11195
|
12 |
|
paulson@11195
|
13 |
types edge = "(vertex*vertex)"
|
paulson@11195
|
14 |
|
paulson@11195
|
15 |
record state =
|
paulson@13785
|
16 |
reach :: "vertex => bool"
|
paulson@13785
|
17 |
nmsg :: "edge => nat"
|
paulson@11195
|
18 |
|
paulson@13785
|
19 |
consts REACHABLE :: "edge set"
|
paulson@13785
|
20 |
root :: "vertex"
|
paulson@13785
|
21 |
E :: "edge set"
|
paulson@13785
|
22 |
V :: "vertex set"
|
paulson@11195
|
23 |
|
paulson@11195
|
24 |
inductive "REACHABLE"
|
paulson@13785
|
25 |
intros
|
paulson@13806
|
26 |
base: "v \<in> V ==> ((v,v) \<in> REACHABLE)"
|
paulson@13806
|
27 |
step: "((u,v) \<in> REACHABLE) & (v,w) \<in> E ==> ((u,w) \<in> REACHABLE)"
|
paulson@11195
|
28 |
|
paulson@11195
|
29 |
constdefs
|
paulson@13785
|
30 |
reachable :: "vertex => state set"
|
paulson@11195
|
31 |
"reachable p == {s. reach s p}"
|
paulson@11195
|
32 |
|
paulson@13785
|
33 |
nmsg_eq :: "nat => edge => state set"
|
paulson@11195
|
34 |
"nmsg_eq k == %e. {s. nmsg s e = k}"
|
paulson@11195
|
35 |
|
paulson@13785
|
36 |
nmsg_gt :: "nat => edge => state set"
|
paulson@11195
|
37 |
"nmsg_gt k == %e. {s. k < nmsg s e}"
|
paulson@11195
|
38 |
|
paulson@13785
|
39 |
nmsg_gte :: "nat => edge => state set"
|
paulson@13806
|
40 |
"nmsg_gte k == %e. {s. k \<le> nmsg s e}"
|
paulson@11195
|
41 |
|
paulson@13785
|
42 |
nmsg_lte :: "nat => edge => state set"
|
paulson@13806
|
43 |
"nmsg_lte k == %e. {s. nmsg s e \<le> k}"
|
paulson@11195
|
44 |
|
paulson@13785
|
45 |
final :: "state set"
|
paulson@13806
|
46 |
"final == (\<Inter>v\<in>V. reachable v <==> {s. (root, v) \<in> REACHABLE}) \<inter>
|
paulson@13806
|
47 |
(INTER E (nmsg_eq 0))"
|
paulson@11195
|
48 |
|
paulson@13785
|
49 |
axioms
|
paulson@11195
|
50 |
|
paulson@13806
|
51 |
Graph1: "root \<in> V"
|
paulson@11195
|
52 |
|
paulson@13806
|
53 |
Graph2: "(v,w) \<in> E ==> (v \<in> V) & (w \<in> V)"
|
paulson@11195
|
54 |
|
paulson@13806
|
55 |
MA1: "F \<in> Always (reachable root)"
|
paulson@11195
|
56 |
|
paulson@13806
|
57 |
MA2: "v \<in> V ==> F \<in> Always (- reachable v \<union> {s. ((root,v) \<in> REACHABLE)})"
|
paulson@11195
|
58 |
|
paulson@13806
|
59 |
MA3: "[|v \<in> V;w \<in> V|] ==> F \<in> Always (-(nmsg_gt 0 (v,w)) \<union> (reachable v))"
|
paulson@11195
|
60 |
|
paulson@13806
|
61 |
MA4: "(v,w) \<in> E ==>
|
paulson@13806
|
62 |
F \<in> Always (-(reachable v) \<union> (nmsg_gt 0 (v,w)) \<union> (reachable w))"
|
paulson@11195
|
63 |
|
paulson@13806
|
64 |
MA5: "[|v \<in> V; w \<in> V|]
|
paulson@13806
|
65 |
==> F \<in> Always (nmsg_gte 0 (v,w) \<inter> nmsg_lte (Suc 0) (v,w))"
|
paulson@11195
|
66 |
|
paulson@13806
|
67 |
MA6: "[|v \<in> V|] ==> F \<in> Stable (reachable v)"
|
paulson@11195
|
68 |
|
paulson@13806
|
69 |
MA6b: "[|v \<in> V;w \<in> W|] ==> F \<in> Stable (reachable v \<inter> nmsg_lte k (v,w))"
|
paulson@13785
|
70 |
|
paulson@13806
|
71 |
MA7: "[|v \<in> V;w \<in> V|] ==> F \<in> UNIV LeadsTo nmsg_eq 0 (v,w)"
|
paulson@13785
|
72 |
|
paulson@13785
|
73 |
|
paulson@13785
|
74 |
lemmas E_imp_in_V_L = Graph2 [THEN conjunct1, standard]
|
paulson@13785
|
75 |
lemmas E_imp_in_V_R = Graph2 [THEN conjunct2, standard]
|
paulson@13785
|
76 |
|
paulson@13785
|
77 |
lemma lemma2:
|
paulson@13806
|
78 |
"(v,w) \<in> E ==> F \<in> reachable v LeadsTo nmsg_eq 0 (v,w) \<inter> reachable v"
|
paulson@13785
|
79 |
apply (rule MA7 [THEN PSP_Stable, THEN LeadsTo_weaken_L])
|
paulson@13785
|
80 |
apply (rule_tac [3] MA6)
|
paulson@13785
|
81 |
apply (auto simp add: E_imp_in_V_L E_imp_in_V_R)
|
paulson@13785
|
82 |
done
|
paulson@13785
|
83 |
|
paulson@13806
|
84 |
lemma Induction_base: "(v,w) \<in> E ==> F \<in> reachable v LeadsTo reachable w"
|
paulson@13785
|
85 |
apply (rule MA4 [THEN Always_LeadsTo_weaken])
|
paulson@13785
|
86 |
apply (rule_tac [2] lemma2)
|
paulson@13785
|
87 |
apply (auto simp add: nmsg_eq_def nmsg_gt_def)
|
paulson@13785
|
88 |
done
|
paulson@13785
|
89 |
|
paulson@13785
|
90 |
lemma REACHABLE_LeadsTo_reachable:
|
paulson@13806
|
91 |
"(v,w) \<in> REACHABLE ==> F \<in> reachable v LeadsTo reachable w"
|
paulson@13785
|
92 |
apply (erule REACHABLE.induct)
|
paulson@13785
|
93 |
apply (rule subset_imp_LeadsTo, blast)
|
paulson@13785
|
94 |
apply (blast intro: LeadsTo_Trans Induction_base)
|
paulson@13785
|
95 |
done
|
paulson@13785
|
96 |
|
paulson@13806
|
97 |
lemma Detects_part1: "F \<in> {s. (root,v) \<in> REACHABLE} LeadsTo reachable v"
|
paulson@13785
|
98 |
apply (rule single_LeadsTo_I)
|
paulson@13785
|
99 |
apply (simp split add: split_if_asm)
|
paulson@13785
|
100 |
apply (rule MA1 [THEN Always_LeadsToI])
|
paulson@13785
|
101 |
apply (erule REACHABLE_LeadsTo_reachable [THEN LeadsTo_weaken_L], auto)
|
paulson@13785
|
102 |
done
|
paulson@13785
|
103 |
|
paulson@13785
|
104 |
|
paulson@13785
|
105 |
lemma Reachability_Detected:
|
paulson@13806
|
106 |
"v \<in> V ==> F \<in> (reachable v) Detects {s. (root,v) \<in> REACHABLE}"
|
paulson@13785
|
107 |
apply (unfold Detects_def, auto)
|
paulson@13785
|
108 |
prefer 2 apply (blast intro: MA2 [THEN Always_weaken])
|
paulson@13785
|
109 |
apply (rule Detects_part1 [THEN LeadsTo_weaken_L], blast)
|
paulson@13785
|
110 |
done
|
paulson@13785
|
111 |
|
paulson@13785
|
112 |
|
paulson@13785
|
113 |
lemma LeadsTo_Reachability:
|
paulson@13806
|
114 |
"v \<in> V ==> F \<in> UNIV LeadsTo (reachable v <==> {s. (root,v) \<in> REACHABLE})"
|
paulson@13785
|
115 |
by (erule Reachability_Detected [THEN Detects_Imp_LeadstoEQ])
|
paulson@13785
|
116 |
|
paulson@13785
|
117 |
|
paulson@13785
|
118 |
(* ------------------------------------ *)
|
paulson@13785
|
119 |
|
paulson@13785
|
120 |
(* Some lemmas about <==> *)
|
paulson@13785
|
121 |
|
paulson@13785
|
122 |
lemma Eq_lemma1:
|
paulson@13806
|
123 |
"(reachable v <==> {s. (root,v) \<in> REACHABLE}) =
|
paulson@13806
|
124 |
{s. ((s \<in> reachable v) = ((root,v) \<in> REACHABLE))}"
|
paulson@13806
|
125 |
by (unfold Equality_def, blast)
|
paulson@13785
|
126 |
|
paulson@13785
|
127 |
|
paulson@13785
|
128 |
lemma Eq_lemma2:
|
paulson@13806
|
129 |
"(reachable v <==> (if (root,v) \<in> REACHABLE then UNIV else {})) =
|
paulson@13806
|
130 |
{s. ((s \<in> reachable v) = ((root,v) \<in> REACHABLE))}"
|
paulson@13806
|
131 |
by (unfold Equality_def, auto)
|
paulson@13785
|
132 |
|
paulson@13785
|
133 |
(* ------------------------------------ *)
|
paulson@13785
|
134 |
|
paulson@13785
|
135 |
|
paulson@13785
|
136 |
(* Some lemmas about final (I don't need all of them!) *)
|
paulson@13785
|
137 |
|
paulson@13785
|
138 |
lemma final_lemma1:
|
paulson@13806
|
139 |
"(\<Inter>v \<in> V. \<Inter>w \<in> V. {s. ((s \<in> reachable v) = ((root,v) \<in> REACHABLE)) &
|
paulson@13806
|
140 |
s \<in> nmsg_eq 0 (v,w)})
|
paulson@13806
|
141 |
\<subseteq> final"
|
paulson@13785
|
142 |
apply (unfold final_def Equality_def, auto)
|
paulson@13785
|
143 |
apply (frule E_imp_in_V_R)
|
paulson@13785
|
144 |
apply (frule E_imp_in_V_L, blast)
|
paulson@13785
|
145 |
done
|
paulson@13785
|
146 |
|
paulson@13785
|
147 |
lemma final_lemma2:
|
paulson@13806
|
148 |
"E\<noteq>{}
|
paulson@13806
|
149 |
==> (\<Inter>v \<in> V. \<Inter>e \<in> E. {s. ((s \<in> reachable v) = ((root,v) \<in> REACHABLE))}
|
paulson@13806
|
150 |
\<inter> nmsg_eq 0 e) \<subseteq> final"
|
paulson@13785
|
151 |
apply (unfold final_def Equality_def)
|
paulson@13785
|
152 |
apply (auto split add: split_if_asm)
|
paulson@13785
|
153 |
apply (frule E_imp_in_V_L, blast)
|
paulson@13785
|
154 |
done
|
paulson@13785
|
155 |
|
paulson@13785
|
156 |
lemma final_lemma3:
|
paulson@13806
|
157 |
"E\<noteq>{}
|
paulson@13806
|
158 |
==> (\<Inter>v \<in> V. \<Inter>e \<in> E.
|
paulson@13806
|
159 |
(reachable v <==> {s. (root,v) \<in> REACHABLE}) \<inter> nmsg_eq 0 e)
|
paulson@13806
|
160 |
\<subseteq> final"
|
paulson@13785
|
161 |
apply (frule final_lemma2)
|
paulson@13785
|
162 |
apply (simp (no_asm_use) add: Eq_lemma2)
|
paulson@13785
|
163 |
done
|
paulson@13785
|
164 |
|
paulson@13785
|
165 |
|
paulson@13785
|
166 |
lemma final_lemma4:
|
paulson@13806
|
167 |
"E\<noteq>{}
|
paulson@13806
|
168 |
==> (\<Inter>v \<in> V. \<Inter>e \<in> E.
|
paulson@13806
|
169 |
{s. ((s \<in> reachable v) = ((root,v) \<in> REACHABLE))} \<inter> nmsg_eq 0 e)
|
paulson@13785
|
170 |
= final"
|
paulson@13785
|
171 |
apply (rule subset_antisym)
|
paulson@13785
|
172 |
apply (erule final_lemma2)
|
paulson@13785
|
173 |
apply (unfold final_def Equality_def, blast)
|
paulson@13785
|
174 |
done
|
paulson@13785
|
175 |
|
paulson@13785
|
176 |
lemma final_lemma5:
|
paulson@13806
|
177 |
"E\<noteq>{}
|
paulson@13806
|
178 |
==> (\<Inter>v \<in> V. \<Inter>e \<in> E.
|
paulson@13806
|
179 |
((reachable v) <==> {s. (root,v) \<in> REACHABLE}) \<inter> nmsg_eq 0 e)
|
paulson@13785
|
180 |
= final"
|
paulson@13785
|
181 |
apply (frule final_lemma4)
|
paulson@13785
|
182 |
apply (simp (no_asm_use) add: Eq_lemma2)
|
paulson@13785
|
183 |
done
|
paulson@13785
|
184 |
|
paulson@13785
|
185 |
|
paulson@13785
|
186 |
lemma final_lemma6:
|
paulson@13806
|
187 |
"(\<Inter>v \<in> V. \<Inter>w \<in> V.
|
paulson@13806
|
188 |
(reachable v <==> {s. (root,v) \<in> REACHABLE}) \<inter> nmsg_eq 0 (v,w))
|
paulson@13806
|
189 |
\<subseteq> final"
|
paulson@13785
|
190 |
apply (simp (no_asm) add: Eq_lemma2 Int_def)
|
paulson@13785
|
191 |
apply (rule final_lemma1)
|
paulson@13785
|
192 |
done
|
paulson@13785
|
193 |
|
paulson@13785
|
194 |
|
paulson@13785
|
195 |
lemma final_lemma7:
|
paulson@13785
|
196 |
"final =
|
paulson@13806
|
197 |
(\<Inter>v \<in> V. \<Inter>w \<in> V.
|
paulson@13806
|
198 |
((reachable v) <==> {s. (root,v) \<in> REACHABLE}) \<inter>
|
paulson@13806
|
199 |
(-{s. (v,w) \<in> E} \<union> (nmsg_eq 0 (v,w))))"
|
paulson@13785
|
200 |
apply (unfold final_def)
|
paulson@13785
|
201 |
apply (rule subset_antisym, blast)
|
paulson@13785
|
202 |
apply (auto split add: split_if_asm)
|
paulson@13785
|
203 |
apply (blast dest: E_imp_in_V_L E_imp_in_V_R)+
|
paulson@13785
|
204 |
done
|
paulson@13785
|
205 |
|
paulson@13785
|
206 |
(* ------------------------------------ *)
|
paulson@13785
|
207 |
|
paulson@13785
|
208 |
|
paulson@13785
|
209 |
(* ------------------------------------ *)
|
paulson@13785
|
210 |
|
paulson@13785
|
211 |
(* Stability theorems *)
|
paulson@13785
|
212 |
lemma not_REACHABLE_imp_Stable_not_reachable:
|
paulson@13806
|
213 |
"[| v \<in> V; (root,v) \<notin> REACHABLE |] ==> F \<in> Stable (- reachable v)"
|
paulson@13785
|
214 |
apply (drule MA2 [THEN AlwaysD], auto)
|
paulson@13785
|
215 |
done
|
paulson@13785
|
216 |
|
paulson@13785
|
217 |
lemma Stable_reachable_EQ_R:
|
paulson@13806
|
218 |
"v \<in> V ==> F \<in> Stable (reachable v <==> {s. (root,v) \<in> REACHABLE})"
|
paulson@13785
|
219 |
apply (simp (no_asm) add: Equality_def Eq_lemma2)
|
paulson@13785
|
220 |
apply (blast intro: MA6 not_REACHABLE_imp_Stable_not_reachable)
|
paulson@13785
|
221 |
done
|
paulson@13785
|
222 |
|
paulson@13785
|
223 |
|
paulson@13785
|
224 |
lemma lemma4:
|
paulson@13806
|
225 |
"((nmsg_gte 0 (v,w) \<inter> nmsg_lte (Suc 0) (v,w)) \<inter>
|
paulson@13806
|
226 |
(- nmsg_gt 0 (v,w) \<union> A))
|
paulson@13806
|
227 |
\<subseteq> A \<union> nmsg_eq 0 (v,w)"
|
paulson@13785
|
228 |
apply (unfold nmsg_gte_def nmsg_lte_def nmsg_gt_def nmsg_eq_def, auto)
|
paulson@13785
|
229 |
done
|
paulson@13785
|
230 |
|
paulson@13785
|
231 |
|
paulson@13785
|
232 |
lemma lemma5:
|
paulson@13806
|
233 |
"reachable v \<inter> nmsg_eq 0 (v,w) =
|
paulson@13806
|
234 |
((nmsg_gte 0 (v,w) \<inter> nmsg_lte (Suc 0) (v,w)) \<inter>
|
paulson@13806
|
235 |
(reachable v \<inter> nmsg_lte 0 (v,w)))"
|
paulson@13806
|
236 |
by (unfold nmsg_gte_def nmsg_lte_def nmsg_gt_def nmsg_eq_def, auto)
|
paulson@13785
|
237 |
|
paulson@13785
|
238 |
lemma lemma6:
|
paulson@13806
|
239 |
"- nmsg_gt 0 (v,w) \<union> reachable v \<subseteq> nmsg_eq 0 (v,w) \<union> reachable v"
|
paulson@13785
|
240 |
apply (unfold nmsg_gte_def nmsg_lte_def nmsg_gt_def nmsg_eq_def, auto)
|
paulson@13785
|
241 |
done
|
paulson@13785
|
242 |
|
paulson@13785
|
243 |
lemma Always_reachable_OR_nmsg_0:
|
paulson@13806
|
244 |
"[|v \<in> V; w \<in> V|] ==> F \<in> Always (reachable v \<union> nmsg_eq 0 (v,w))"
|
paulson@13785
|
245 |
apply (rule Always_Int_I [OF MA5 MA3, THEN Always_weaken])
|
paulson@13785
|
246 |
apply (rule_tac [5] lemma4, auto)
|
paulson@13785
|
247 |
done
|
paulson@13785
|
248 |
|
paulson@13785
|
249 |
lemma Stable_reachable_AND_nmsg_0:
|
paulson@13806
|
250 |
"[|v \<in> V; w \<in> V|] ==> F \<in> Stable (reachable v \<inter> nmsg_eq 0 (v,w))"
|
paulson@13785
|
251 |
apply (subst lemma5)
|
paulson@13785
|
252 |
apply (blast intro: MA5 Always_imp_Stable [THEN Stable_Int] MA6b)
|
paulson@13785
|
253 |
done
|
paulson@13785
|
254 |
|
paulson@13785
|
255 |
lemma Stable_nmsg_0_OR_reachable:
|
paulson@13806
|
256 |
"[|v \<in> V; w \<in> V|] ==> F \<in> Stable (nmsg_eq 0 (v,w) \<union> reachable v)"
|
paulson@13785
|
257 |
by (blast intro!: Always_weaken [THEN Always_imp_Stable] lemma6 MA3)
|
paulson@13785
|
258 |
|
paulson@13785
|
259 |
lemma not_REACHABLE_imp_Stable_not_reachable_AND_nmsg_0:
|
paulson@13806
|
260 |
"[| v \<in> V; w \<in> V; (root,v) \<notin> REACHABLE |]
|
paulson@13806
|
261 |
==> F \<in> Stable (- reachable v \<inter> nmsg_eq 0 (v,w))"
|
paulson@13785
|
262 |
apply (rule Stable_Int [OF MA2 [THEN Always_imp_Stable]
|
paulson@13785
|
263 |
Stable_nmsg_0_OR_reachable,
|
paulson@13785
|
264 |
THEN Stable_eq])
|
paulson@13785
|
265 |
prefer 4 apply blast
|
paulson@13785
|
266 |
apply auto
|
paulson@13785
|
267 |
done
|
paulson@13785
|
268 |
|
paulson@13785
|
269 |
lemma Stable_reachable_EQ_R_AND_nmsg_0:
|
paulson@13806
|
270 |
"[| v \<in> V; w \<in> V |]
|
paulson@13806
|
271 |
==> F \<in> Stable ((reachable v <==> {s. (root,v) \<in> REACHABLE}) \<inter>
|
paulson@13785
|
272 |
nmsg_eq 0 (v,w))"
|
paulson@13785
|
273 |
by (simp add: Equality_def Eq_lemma2 Stable_reachable_AND_nmsg_0
|
paulson@13785
|
274 |
not_REACHABLE_imp_Stable_not_reachable_AND_nmsg_0)
|
paulson@13785
|
275 |
|
paulson@13785
|
276 |
|
paulson@13785
|
277 |
|
paulson@13785
|
278 |
(* ------------------------------------ *)
|
paulson@13785
|
279 |
|
paulson@13785
|
280 |
|
paulson@13785
|
281 |
(* LeadsTo final predicate (Exercise 11.2 page 274) *)
|
paulson@13785
|
282 |
|
paulson@13806
|
283 |
lemma UNIV_lemma: "UNIV \<subseteq> (\<Inter>v \<in> V. UNIV)"
|
paulson@13785
|
284 |
by blast
|
paulson@13785
|
285 |
|
paulson@13785
|
286 |
lemmas UNIV_LeadsTo_completion =
|
paulson@13785
|
287 |
LeadsTo_weaken_L [OF Finite_stable_completion UNIV_lemma]
|
paulson@13785
|
288 |
|
paulson@13806
|
289 |
lemma LeadsTo_final_E_empty: "E={} ==> F \<in> UNIV LeadsTo final"
|
paulson@13785
|
290 |
apply (unfold final_def, simp)
|
paulson@13785
|
291 |
apply (rule UNIV_LeadsTo_completion)
|
paulson@13785
|
292 |
apply safe
|
paulson@13785
|
293 |
apply (erule LeadsTo_Reachability [simplified])
|
paulson@13785
|
294 |
apply (drule Stable_reachable_EQ_R, simp)
|
paulson@13785
|
295 |
done
|
paulson@13785
|
296 |
|
paulson@13785
|
297 |
|
paulson@13785
|
298 |
lemma Leadsto_reachability_AND_nmsg_0:
|
paulson@13806
|
299 |
"[| v \<in> V; w \<in> V |]
|
paulson@13806
|
300 |
==> F \<in> UNIV LeadsTo
|
paulson@13806
|
301 |
((reachable v <==> {s. (root,v): REACHABLE}) \<inter> nmsg_eq 0 (v,w))"
|
paulson@13785
|
302 |
apply (rule LeadsTo_Reachability [THEN LeadsTo_Trans], blast)
|
paulson@13785
|
303 |
apply (subgoal_tac
|
paulson@13806
|
304 |
"F \<in> (reachable v <==> {s. (root,v) \<in> REACHABLE}) \<inter>
|
paulson@13806
|
305 |
UNIV LeadsTo (reachable v <==> {s. (root,v) \<in> REACHABLE}) \<inter>
|
paulson@13785
|
306 |
nmsg_eq 0 (v,w) ")
|
paulson@13785
|
307 |
apply simp
|
paulson@13785
|
308 |
apply (rule PSP_Stable2)
|
paulson@13785
|
309 |
apply (rule MA7)
|
paulson@13785
|
310 |
apply (rule_tac [3] Stable_reachable_EQ_R, auto)
|
paulson@13785
|
311 |
done
|
paulson@13785
|
312 |
|
paulson@13806
|
313 |
lemma LeadsTo_final_E_NOT_empty: "E\<noteq>{} ==> F \<in> UNIV LeadsTo final"
|
paulson@13785
|
314 |
apply (rule LeadsTo_weaken_L [OF LeadsTo_weaken_R UNIV_lemma])
|
paulson@13785
|
315 |
apply (rule_tac [2] final_lemma6)
|
paulson@13785
|
316 |
apply (rule Finite_stable_completion)
|
paulson@13785
|
317 |
apply blast
|
paulson@13785
|
318 |
apply (rule UNIV_LeadsTo_completion)
|
paulson@13785
|
319 |
apply (blast intro: Stable_INT Stable_reachable_EQ_R_AND_nmsg_0
|
paulson@13785
|
320 |
Leadsto_reachability_AND_nmsg_0)+
|
paulson@13785
|
321 |
done
|
paulson@13785
|
322 |
|
paulson@13806
|
323 |
lemma LeadsTo_final: "F \<in> UNIV LeadsTo final"
|
paulson@13785
|
324 |
apply (case_tac "E={}")
|
paulson@13806
|
325 |
apply (rule_tac [2] LeadsTo_final_E_NOT_empty)
|
paulson@13785
|
326 |
apply (rule LeadsTo_final_E_empty, auto)
|
paulson@13785
|
327 |
done
|
paulson@13785
|
328 |
|
paulson@13785
|
329 |
(* ------------------------------------ *)
|
paulson@13785
|
330 |
|
paulson@13785
|
331 |
(* Stability of final (Exercise 11.2 page 274) *)
|
paulson@13785
|
332 |
|
paulson@13806
|
333 |
lemma Stable_final_E_empty: "E={} ==> F \<in> Stable final"
|
paulson@13785
|
334 |
apply (unfold final_def, simp)
|
paulson@13785
|
335 |
apply (rule Stable_INT)
|
paulson@13785
|
336 |
apply (drule Stable_reachable_EQ_R, simp)
|
paulson@13785
|
337 |
done
|
paulson@13785
|
338 |
|
paulson@13785
|
339 |
|
paulson@13806
|
340 |
lemma Stable_final_E_NOT_empty: "E\<noteq>{} ==> F \<in> Stable final"
|
paulson@13785
|
341 |
apply (subst final_lemma7)
|
paulson@13785
|
342 |
apply (rule Stable_INT)
|
paulson@13785
|
343 |
apply (rule Stable_INT)
|
paulson@13785
|
344 |
apply (simp (no_asm) add: Eq_lemma2)
|
paulson@13785
|
345 |
apply safe
|
paulson@13785
|
346 |
apply (rule Stable_eq)
|
paulson@13806
|
347 |
apply (subgoal_tac [2]
|
paulson@13806
|
348 |
"({s. (s \<in> reachable v) = ((root,v) \<in> REACHABLE) } \<inter> nmsg_eq 0 (v,w)) =
|
paulson@13806
|
349 |
({s. (s \<in> reachable v) = ( (root,v) \<in> REACHABLE) } \<inter> (- UNIV \<union> nmsg_eq 0 (v,w)))")
|
paulson@13785
|
350 |
prefer 2 apply blast
|
paulson@13785
|
351 |
prefer 2 apply blast
|
paulson@13785
|
352 |
apply (rule Stable_reachable_EQ_R_AND_nmsg_0
|
paulson@13785
|
353 |
[simplified Eq_lemma2 Collect_const])
|
paulson@13785
|
354 |
apply (blast, blast)
|
paulson@13785
|
355 |
apply (rule Stable_eq)
|
paulson@13785
|
356 |
apply (rule Stable_reachable_EQ_R [simplified Eq_lemma2 Collect_const])
|
paulson@13785
|
357 |
apply simp
|
paulson@13785
|
358 |
apply (subgoal_tac
|
paulson@13806
|
359 |
"({s. (s \<in> reachable v) = ((root,v) \<in> REACHABLE) }) =
|
paulson@13806
|
360 |
({s. (s \<in> reachable v) = ( (root,v) \<in> REACHABLE) } Int
|
paulson@13806
|
361 |
(- {} \<union> nmsg_eq 0 (v,w)))")
|
paulson@13785
|
362 |
apply blast+
|
paulson@13785
|
363 |
done
|
paulson@13785
|
364 |
|
paulson@13806
|
365 |
lemma Stable_final: "F \<in> Stable final"
|
paulson@13785
|
366 |
apply (case_tac "E={}")
|
paulson@13806
|
367 |
prefer 2 apply (blast intro: Stable_final_E_NOT_empty)
|
paulson@13785
|
368 |
apply (blast intro: Stable_final_E_empty)
|
paulson@13785
|
369 |
done
|
paulson@11195
|
370 |
|
paulson@11195
|
371 |
end
|
paulson@11195
|
372 |
|