changeset 125 | 95e7933968f8 |
parent 80 | 17305a85493d |
child 126 | a88af0e4731f |
124:71a3300d497b | 125:95e7933968f8 |
---|---|
1 theory RTree |
1 theory RTree |
2 imports "~~/src/HOL/Library/Transitive_Closure_Table" Max |
2 imports "~~/src/HOL/Library/Transitive_Closure_Table" Max |
3 (* "Lcrules" *) |
|
3 begin |
4 begin |
4 |
5 |
5 section {* A theory of relational trees *} |
6 section {* A theory of relational trees *} |
6 |
7 |
7 inductive_cases path_nilE [elim!]: "rtrancl_path r x [] y" |
8 inductive_cases path_nilE [elim!]: "rtrancl_path r x [] y" |
97 of `an edge @{text "(a, b)"} is in the sub-tree of @{text "x"}`, |
98 of `an edge @{text "(a, b)"} is in the sub-tree of @{text "x"}`, |
98 i.e., both @{text "a"} and @{text "b"} are in the sub-tree. |
99 i.e., both @{text "a"} and @{text "b"} are in the sub-tree. |
99 *} |
100 *} |
100 lemma edges_in_meaning: |
101 lemma edges_in_meaning: |
101 "edges_in r x = {(a, b) | a b. (a, b) \<in> r \<and> a \<in> subtree r x \<and> b \<in> subtree r x}" |
102 "edges_in r x = {(a, b) | a b. (a, b) \<in> r \<and> a \<in> subtree r x \<and> b \<in> subtree r x}" |
102 proof - |
103 by (auto simp:edges_in_def subtree_def) |
103 { fix a b |
|
104 assume h: "(a, b) \<in> r" "b \<in> subtree r x" |
|
105 moreover have "a \<in> subtree r x" |
|
106 proof - |
|
107 from h(2)[unfolded subtree_def] have "(b, x) \<in> r^*" by simp |
|
108 with h(1) have "(a, x) \<in> r^*" by auto |
|
109 thus ?thesis by (auto simp:subtree_def) |
|
110 qed |
|
111 ultimately have "((a, b) \<in> r \<and> a \<in> subtree r x \<and> b \<in> subtree r x)" |
|
112 by (auto) |
|
113 } thus ?thesis by (auto simp:edges_in_def) |
|
114 qed |
|
115 |
104 |
116 text {* |
105 text {* |
117 The following lemma shows the meaning of @{term "edges_in"} from the other side, |
106 The following lemma shows the meaning of @{term "edges_in"} from the other side, |
118 which says: for the edge @{text "(a,b)"} to be outside of the sub-tree of @{text "x"}, |
107 which says: for the edge @{text "(a,b)"} to be outside of the sub-tree of @{text "x"}, |
119 it is sufficient to show that @{text "b"} is. |
108 it is sufficient to show that @{text "b"} is. |
129 fixes r |
118 fixes r |
130 assumes fb: "\<forall> x \<in> Range r . finite (children r x)" |
119 assumes fb: "\<forall> x \<in> Range r . finite (children r x)" |
131 begin |
120 begin |
132 |
121 |
133 lemma finite_children: "finite (children r x)" |
122 lemma finite_children: "finite (children r x)" |
134 proof(cases "children r x = {}") |
123 using fb by (cases "children r x = {}", auto simp:children_def) |
135 case True |
|
136 thus ?thesis by auto |
|
137 next |
|
138 case False |
|
139 then obtain y where "(y, x) \<in> r" by (auto simp:children_def) |
|
140 hence "x \<in> Range r" by auto |
|
141 from fb[rule_format, OF this] |
|
142 show ?thesis . |
|
143 qed |
|
144 |
124 |
145 end |
125 end |
146 |
126 |
147 locale fsubtree = fbranch + |
127 locale fsubtree = fbranch + |
148 assumes wf: "wf r" |
128 assumes wf: "wf r" |
149 |
|
150 (* ccc *) |
|
151 |
129 |
152 subsection {* Auxiliary lemmas *} |
130 subsection {* Auxiliary lemmas *} |
153 |
131 |
154 lemma index_minimize: |
132 lemma index_minimize: |
155 assumes "P (i::nat)" |
133 assumes "P (i::nat)" |
156 obtains j where "P j" and "\<forall> k < j. \<not> P k" |
134 obtains j where "P j" and "\<forall> k < j. \<not> P k" |
157 using assms |
135 using assms |
158 proof - |
136 by (induct i rule:less_induct, auto) |
159 have "\<exists> j. P j \<and> (\<forall> k < j. \<not> P k)" |
|
160 using assms |
|
161 proof(induct i rule:less_induct) |
|
162 case (less t) |
|
163 show ?case |
|
164 proof(cases "\<forall> j < t. \<not> P j") |
|
165 case True |
|
166 with less (2) show ?thesis by blast |
|
167 next |
|
168 case False |
|
169 then obtain j where "j < t" "P j" by auto |
|
170 from less(1)[OF this] |
|
171 show ?thesis . |
|
172 qed |
|
173 qed |
|
174 with that show ?thesis by metis |
|
175 qed |
|
176 |
137 |
177 subsection {* Properties of Relational Graphs and Relational Trees *} |
138 subsection {* Properties of Relational Graphs and Relational Trees *} |
178 |
139 |
179 subsubsection {* Properties of @{text "rel_of"} and @{text "pred_of"} *} |
140 subsubsection {* Properties of @{text "rel_of"} and @{text "pred_of"} *} |
180 |
141 |
208 and "\<And>x y ys z. (x, y) \<in> r \<Longrightarrow> rpath r y ys z \<Longrightarrow> P y ys z \<Longrightarrow> P x (y # ys) z" |
169 and "\<And>x y ys z. (x, y) \<in> r \<Longrightarrow> rpath r y ys z \<Longrightarrow> P y ys z \<Longrightarrow> P x (y # ys) z" |
209 shows "P x1 x2 x3" |
170 shows "P x1 x2 x3" |
210 using assms[unfolded rpath_def] |
171 using assms[unfolded rpath_def] |
211 by (induct, auto simp:pred_of_def rpath_def) |
172 by (induct, auto simp:pred_of_def rpath_def) |
212 |
173 |
213 lemma rpathE: |
174 lemma rpathE [elim]: |
214 assumes "rpath r x xs y" |
175 assumes "rpath r x xs y" |
215 obtains (base) "y = x" "xs = []" |
176 obtains (base) "y = x" "xs = []" |
216 | (step) z zs where "(x, z) \<in> r" "rpath r z zs y" "xs = z#zs" |
177 | (step) z zs where "(x, z) \<in> r" "rpath r z zs y" "xs = z#zs" |
217 using assms |
178 using assms |
218 by (induct, auto) |
179 by (induct, auto) |
234 next |
195 next |
235 from assms(2) show "rtrancl_path (pred_of r) y ys z" |
196 from assms(2) show "rtrancl_path (pred_of r) y ys z" |
236 by (auto simp:pred_of_def rpath_def) |
197 by (auto simp:pred_of_def rpath_def) |
237 qed |
198 qed |
238 |
199 |
200 lemma rpath_stepI'[intro, simp]: |
|
201 assumes "rpath r x xs y" |
|
202 and "(y, z) \<in> r" |
|
203 shows "rpath r x (xs@[z]) z" |
|
204 using assms |
|
205 by (induct, auto) |
|
206 |
|
239 text {* Introduction rule for @{text "@"}-path *} |
207 text {* Introduction rule for @{text "@"}-path *} |
240 lemma rpath_appendI [intro]: |
208 lemma rpath_appendI [intro,simp]: |
241 assumes "rpath r x xs a" and "rpath r a ys y" |
209 assumes "rpath r x xs a" and "rpath r a ys y" |
242 shows "rpath r x (xs @ ys) y" |
210 shows "rpath r x (xs @ ys) y" |
243 using assms |
211 using assms |
244 by (unfold rpath_def, auto intro:rtrancl_path_trans) |
212 by (unfold rpath_def, auto intro:rtrancl_path_trans) |
245 |
213 |
246 text {* Elimination rule for empty path *} |
214 text {* Elimination rule for empty path *} |
247 |
215 |
248 lemma rpath_cases [cases pred:rpath]: |
216 lemma rpath_cases [cases pred:rpath,elim]: |
249 assumes "rpath r a1 a2 a3" |
217 assumes "rpath r a1 a2 a3" |
250 obtains (rbase) "a1 = a3" and "a2 = []" |
218 obtains (rbase) "a1 = a3" and "a2 = []" |
251 | (rstep) y :: "'a" and ys :: "'a list" |
219 | (rstep) y :: "'a" and ys :: "'a list" |
252 where "(a1, y) \<in> r" and "a2 = y # ys" and "rpath r y ys a3" |
220 where "(a1, y) \<in> r" and "a2 = y # ys" and "rpath r y ys a3" |
253 using assms [unfolded rpath_def] |
221 using assms [unfolded rpath_def] |
256 lemma rpath_nilE [elim!, cases pred:rpath]: |
224 lemma rpath_nilE [elim!, cases pred:rpath]: |
257 assumes "rpath r x [] y" |
225 assumes "rpath r x [] y" |
258 obtains "y = x" |
226 obtains "y = x" |
259 using assms[unfolded rpath_def] by auto |
227 using assms[unfolded rpath_def] by auto |
260 |
228 |
261 -- {* This is a auxiliary lemmas used only in the proof of @{text "rpath_nnl_lastE"} *} |
|
262 lemma rpath_nnl_last: |
|
263 assumes "rtrancl_path r x xs y" |
|
264 and "xs \<noteq> []" |
|
265 obtains xs' where "xs = xs'@[y]" |
|
266 proof - |
|
267 from append_butlast_last_id[OF `xs \<noteq> []`, symmetric] |
|
268 obtain xs' y' where eq_xs: "xs = (xs' @ y' # [])" by simp |
|
269 with assms(1) |
|
270 have "rtrancl_path r x ... y" by simp |
|
271 hence "y = y'" by (rule rtrancl_path_appendE, auto) |
|
272 with eq_xs have "xs = xs'@[y]" by simp |
|
273 from that[OF this] show ?thesis . |
|
274 qed |
|
275 |
|
276 text {* |
229 text {* |
277 Elimination rule for non-empty paths constructed with @{text "#"}. |
230 Elimination rule for non-empty paths constructed with @{text "#"}. |
278 *} |
231 *} |
279 |
232 |
280 lemma rpath_ConsE [elim!, cases pred:rpath]: |
233 lemma rpath_ConsE [elim!, cases pred:rpath]: |
285 |
238 |
286 text {* |
239 text {* |
287 Elimination rule for non-empty path, where the destination node |
240 Elimination rule for non-empty path, where the destination node |
288 @{text "y"} is shown to be at the end of the path. |
241 @{text "y"} is shown to be at the end of the path. |
289 *} |
242 *} |
290 lemma rpath_nnl_lastE: |
243 lemma rpath_nnl_lastE [elim]: |
291 assumes "rpath r x xs y" |
244 assumes "rpath r x xs y" |
292 and "xs \<noteq> []" |
245 and "xs \<noteq> []" |
293 obtains xs' where "xs = xs'@[y]" |
246 obtains xs' where "xs = xs'@[y]" |
294 using assms[unfolded rpath_def] |
247 using assms |
295 by (rule rpath_nnl_last, auto) |
248 proof(induct) |
249 case (rstep x y ys z) |
|
250 thus ?case by (cases ys, auto) |
|
251 qed auto |
|
296 |
252 |
297 text {* Other elimination rules of @{text "rpath"} *} |
253 text {* Other elimination rules of @{text "rpath"} *} |
298 |
254 |
299 lemma rpath_appendE: |
255 lemma rpath_appendE [elim]: |
300 assumes "rpath r x (xs @ [a] @ ys) y" |
256 assumes "rpath r x (xs @ [a] @ ys) y" |
301 obtains "rpath r x (xs @ [a]) a" and "rpath r a ys y" |
257 obtains "rpath r x (xs @ [a]) a" and "rpath r a ys y" |
302 using rtrancl_path_appendE[OF assms[unfolded rpath_def, simplified], folded rpath_def] |
258 using rtrancl_path_appendE[OF assms[unfolded rpath_def, simplified], folded rpath_def] |
303 by auto |
259 by auto |
304 |
260 |
305 lemma rpath_subE: |
261 lemma rpath_subE [elim]: |
306 assumes "rpath r x (xs @ [a] @ ys @ [b] @ zs) y" |
262 assumes "rpath r x (xs @ [a] @ ys @ [b] @ zs) y" |
307 obtains "rpath r x (xs @ [a]) a" and "rpath r a (ys @ [b]) b" and "rpath r b zs y" |
263 obtains "rpath r x (xs @ [a]) a" and "rpath r a (ys @ [b]) b" and "rpath r b zs y" |
308 using assms |
264 using assms |
309 by (elim rpath_appendE, auto) |
265 by (elim rpath_appendE, auto) |
310 |
266 |
311 text {* Every path has a unique end point. *} |
267 text {* Every path has a unique end point. *} |
312 lemma rpath_dest_eq: |
268 lemma rpath_dest_eq [simp]: |
313 assumes "rpath r x xs x1" |
269 assumes "rpath r x xs x1" |
314 and "rpath r x xs x2" |
270 and "rpath r x xs x2" |
315 shows "x1 = x2" |
271 shows "x1 = x2" |
316 using assms |
272 using assms |
317 by (induct, auto) |
273 by (induct, auto) |
318 |
274 |
275 lemma rpath_dest_eq_simp[simp]: |
|
276 assumes "rpath r x xs1 x1" |
|
277 and "rpath r x xs2 x2" |
|
278 and "xs1 = xs2" |
|
279 shows "x1 = x2" |
|
280 using assms |
|
281 by (induct, auto) |
|
282 |
|
319 subsubsection {* Properites of @{text "edges_on"} *} |
283 subsubsection {* Properites of @{text "edges_on"} *} |
320 |
284 |
321 lemma edges_on_unfold: |
285 lemma edge_on_headI[simp, intro]: |
286 assumes "(a, b) = (a', b')" |
|
287 shows "(a, b) \<in> edges_on (a' # b' # xs)" |
|
288 using assms |
|
289 by (unfold edges_on_def, auto) |
|
290 |
|
291 lemma edges_on_ConsI[intro]: |
|
292 assumes "(a, b) \<in> edges_on xs" |
|
293 shows "(a, b) \<in> edges_on (x#xs)" |
|
294 using assms |
|
295 apply (unfold edges_on_def, auto) |
|
296 by (meson Cons_eq_appendI) |
|
297 |
|
298 lemma edges_on_appendI1[intro]: |
|
299 assumes "(a, b) \<in> edges_on xs" |
|
300 shows "(a, b) \<in> edges_on (xs'@xs)" |
|
301 using assms |
|
302 apply (unfold edges_on_def, auto simp:append_assoc) |
|
303 by (metis append_assoc) |
|
304 |
|
305 lemma edges_on_appendI2[intro]: |
|
306 assumes "(a, b) \<in> edges_on xs" |
|
307 shows "(a, b) \<in> edges_on (xs@xs')" |
|
308 using assms |
|
309 apply (unfold edges_on_def, auto) |
|
310 by metis |
|
311 |
|
312 lemma edges_onE [elim]: |
|
313 assumes "(a, b) \<in> edges_on xs" |
|
314 obtains a' b' xs' where "(a,b) = (a', b')" "xs = a'#b'#xs'" |
|
315 | a' b' xs' where "(a,b) \<noteq> (a', b')" "xs = a'#b'#xs'" "(a,b) \<in> edges_on (b'#xs')" |
|
316 proof(cases xs) |
|
317 case Nil |
|
318 with assms show ?thesis |
|
319 by (unfold edges_on_def, auto) |
|
320 next |
|
321 case cs1: (Cons a' xsa) |
|
322 show ?thesis |
|
323 proof(cases xsa) |
|
324 case Nil |
|
325 with cs1 and assms show ?thesis |
|
326 by (unfold edges_on_def, auto) |
|
327 next |
|
328 case (Cons b' xsb) |
|
329 show ?thesis |
|
330 proof(cases "(a,b) = (a', b')") |
|
331 case True |
|
332 with cs1 Cons show ?thesis using that by metis |
|
333 next |
|
334 case False |
|
335 from assms[unfolded cs1 Cons edges_on_def] |
|
336 obtain xs1 ys1 where "a' # b' # xsb = xs1 @ [a, b] @ ys1" by auto |
|
337 moreover with False obtain c xsc where "xs1 = Cons c xsc" by (cases xs1, auto) |
|
338 ultimately have h: "b' # xsb = xsc @ [a, b] @ ys1" by auto |
|
339 show ?thesis |
|
340 apply (rule that(2)[OF False], insert cs1 Cons, simp) |
|
341 using h by auto |
|
342 qed |
|
343 qed |
|
344 qed |
|
345 |
|
346 lemma edges_on_nil [simp]: |
|
347 "edges_on [] = {}" by auto |
|
348 |
|
349 lemma edges_on_single [simp]: |
|
350 "edges_on [a] = {}" by auto |
|
351 |
|
352 lemma edges_on_unfold [simp]: |
|
322 "edges_on (a # b # xs) = {(a, b)} \<union> edges_on (b # xs)" (is "?L = ?R") |
353 "edges_on (a # b # xs) = {(a, b)} \<union> edges_on (b # xs)" (is "?L = ?R") |
323 proof - |
354 by (auto) |
324 { fix c d |
|
325 assume "(c, d) \<in> ?L" |
|
326 then obtain l1 l2 where h: "(a # b # xs) = l1 @ [c, d] @ l2" |
|
327 by (auto simp:edges_on_def) |
|
328 have "(c, d) \<in> ?R" |
|
329 proof(cases "l1") |
|
330 case Nil |
|
331 with h have "(c, d) = (a, b)" by auto |
|
332 thus ?thesis by auto |
|
333 next |
|
334 case (Cons e es) |
|
335 from h[unfolded this] have "b#xs = es@[c, d]@l2" by auto |
|
336 thus ?thesis by (auto simp:edges_on_def) |
|
337 qed |
|
338 } moreover |
|
339 { fix c d |
|
340 assume "(c, d) \<in> ?R" |
|
341 moreover have "(a, b) \<in> ?L" |
|
342 proof - |
|
343 have "(a # b # xs) = []@[a,b]@xs" by simp |
|
344 hence "\<exists> l1 l2. (a # b # xs) = l1@[a,b]@l2" by auto |
|
345 thus ?thesis by (unfold edges_on_def, simp) |
|
346 qed |
|
347 moreover { |
|
348 assume "(c, d) \<in> edges_on (b#xs)" |
|
349 then obtain l1 l2 where "b#xs = l1@[c, d]@l2" by (unfold edges_on_def, auto) |
|
350 hence "a#b#xs = (a#l1)@[c,d]@l2" by simp |
|
351 hence "\<exists> l1 l2. (a # b # xs) = l1@[c,d]@l2" by metis |
|
352 hence "(c,d) \<in> ?L" by (unfold edges_on_def, simp) |
|
353 } |
|
354 ultimately have "(c, d) \<in> ?L" by auto |
|
355 } ultimately show ?thesis by auto |
|
356 qed |
|
357 |
355 |
358 lemma edges_on_len: |
356 lemma edges_on_len: |
359 assumes "(a,b) \<in> edges_on l" |
357 assumes "x \<in> edges_on l" |
360 shows "length l \<ge> 2" |
358 shows "2 \<le> length l" using assms by (cases x, auto) |
361 using assms |
|
362 by (unfold edges_on_def, auto) |
|
363 |
359 |
364 text {* Elimination of @{text "edges_on"} for non-empty path *} |
360 text {* Elimination of @{text "edges_on"} for non-empty path *} |
365 |
361 |
366 lemma edges_on_consE [elim, cases set:edges_on]: |
362 lemma edges_on_consE [elim!, cases set:edges_on]: |
367 assumes "(a,b) \<in> edges_on (x#xs)" |
363 assumes "(a,b) \<in> edges_on (x#xs)" |
368 obtains (head) xs' where "x = a" and "xs = b#xs'" |
364 obtains (head) xs' where "x = a" and "xs = b#xs'" |
369 | (tail) "(a,b) \<in> edges_on xs" |
365 | (tail) "(a,b) \<in> edges_on xs" |
370 proof - |
366 using assms |
371 from assms obtain l1 l2 |
367 by auto |
372 where h: "(x#xs) = l1 @ [a,b] @ l2" by (unfold edges_on_def, blast) |
368 |
373 have "(\<exists> xs'. x = a \<and> xs = b#xs') \<or> ((a,b) \<in> edges_on xs)" |
|
374 proof(cases "l1") |
|
375 case Nil with h |
|
376 show ?thesis by auto |
|
377 next |
|
378 case (Cons e el) |
|
379 from h[unfolded this] |
|
380 have "xs = el @ [a,b] @ l2" by auto |
|
381 thus ?thesis |
|
382 by (unfold edges_on_def, auto) |
|
383 qed |
|
384 thus ?thesis |
|
385 proof |
|
386 assume "(\<exists>xs'. x = a \<and> xs = b # xs')" |
|
387 then obtain xs' where "x = a" "xs = b#xs'" by blast |
|
388 from that(1)[OF this] show ?thesis . |
|
389 next |
|
390 assume "(a, b) \<in> edges_on xs" |
|
391 from that(2)[OF this] show ?thesis . |
|
392 qed |
|
393 qed |
|
394 |
369 |
395 text {* |
370 text {* |
396 Every edges on the path is a graph edges: |
371 Every edges on the path is a graph edges: |
397 *} |
372 *} |
398 lemma rpath_edges_on: |
373 |
374 lemma rpath_edges_on [intro]: |
|
399 assumes "rpath r x xs y" |
375 assumes "rpath r x xs y" |
400 shows "(edges_on (x#xs)) \<subseteq> r" |
376 shows "edges_on (x#xs) \<subseteq> r" |
401 using assms |
377 using assms |
402 proof(induct arbitrary:y) |
378 by (induct arbitrary:y, auto) |
403 case (rbase x) |
|
404 thus ?case by (unfold edges_on_def, auto) |
|
405 next |
|
406 case (rstep x y ys z) |
|
407 show ?case |
|
408 proof - |
|
409 { fix a b |
|
410 assume "(a, b) \<in> edges_on (x # y # ys)" |
|
411 hence "(a, b) \<in> r" by (cases, insert rstep, auto) |
|
412 } thus ?thesis by auto |
|
413 qed |
|
414 qed |
|
415 |
379 |
416 text {* @{text "edges_on"} is mono with respect to @{text "#"}-operation: *} |
380 text {* @{text "edges_on"} is mono with respect to @{text "#"}-operation: *} |
417 lemma edges_on_Cons_mono: |
381 lemma edges_on_Cons_mono [intro,simp]: |
418 shows "edges_on xs \<subseteq> edges_on (x#xs)" |
382 shows "edges_on xs \<subseteq> edges_on (x#xs)" |
419 proof - |
383 by auto |
420 { fix a b |
384 |
421 assume "(a, b) \<in> edges_on xs" |
385 lemma edges_on_append_mono [intro,simp]: |
422 then obtain l1 l2 where "xs = l1 @ [a,b] @ l2" |
386 shows "edges_on xs \<subseteq> edges_on (xs'@xs)" |
423 by (auto simp:edges_on_def) |
387 by auto |
424 hence "x # xs = (x#l1) @ [a, b] @ l2" by auto |
388 |
425 hence "(a, b) \<in> edges_on (x#xs)" |
389 lemma edges_on_append_mono' [intro,simp]: |
426 by (unfold edges_on_def, blast) |
390 shows "edges_on xs \<subseteq> edges_on (xs@xs')" |
427 } thus ?thesis by auto |
391 by auto |
428 qed |
|
429 |
392 |
430 text {* |
393 text {* |
431 The following rule @{text "rpath_transfer"} is used to show |
394 The following rule @{text "rpath_transfer"} is used to show |
432 that one path is intact as long as all the edges on it are intact |
395 that one path is intact as long as all the edges on it are intact |
433 with the change of graph. |
396 with the change of graph. |
435 If @{text "x#xs"} is path in graph @{text "r1"} and |
398 If @{text "x#xs"} is path in graph @{text "r1"} and |
436 every edges along the path is also in @{text "r2"}, |
399 every edges along the path is also in @{text "r2"}, |
437 then @{text "x#xs"} is also a edge in graph @{text "r2"}: |
400 then @{text "x#xs"} is also a edge in graph @{text "r2"}: |
438 *} |
401 *} |
439 |
402 |
440 lemma rpath_transfer: |
403 lemma rpath_transfer[intro]: |
441 assumes "rpath r1 x xs y" |
404 assumes "rpath r1 x xs y" |
442 and "edges_on (x#xs) \<subseteq> r2" |
405 and "edges_on (x#xs) \<subseteq> r2" |
443 shows "rpath r2 x xs y" |
406 shows "rpath r2 x xs y" |
444 using assms |
407 using assms |
445 proof(induct) |
408 by (induct, auto) |
446 case (rstep x y ys z) |
409 |
447 show ?case |
410 lemma edges_on_rpathI[intro, simp]: |
448 proof(rule rstepI) |
|
449 show "(x, y) \<in> r2" |
|
450 proof - |
|
451 have "(x, y) \<in> edges_on (x # y # ys)" |
|
452 by (unfold edges_on_def, auto) |
|
453 with rstep(4) show ?thesis by auto |
|
454 qed |
|
455 next |
|
456 show "rpath r2 y ys z" |
|
457 using rstep edges_on_Cons_mono[of "y#ys" "x"] by (auto) |
|
458 qed |
|
459 qed (unfold rpath_def, auto intro!:Transitive_Closure_Table.rtrancl_path.base) |
|
460 |
|
461 lemma edges_on_rpathI: |
|
462 assumes "edges_on (a#xs@[b]) \<subseteq> r" |
411 assumes "edges_on (a#xs@[b]) \<subseteq> r" |
463 shows "rpath r a (xs@[b]) b" |
412 shows "rpath r a (xs@[b]) b" |
464 using assms |
413 using assms |
465 proof(induct xs arbitrary: a b) |
414 by (induct xs arbitrary: a b, auto) |
466 case Nil |
415 |
467 moreover have "(a, b) \<in> edges_on (a # [] @ [b])" |
416 lemma list_nnl_appendE [elim]: |
468 by (unfold edges_on_def, auto) |
417 assumes "xs \<noteq> []" |
469 ultimately have "(a, b) \<in> r" by auto |
418 obtains x xs' where "xs = xs'@[x]" |
470 thus ?case by auto |
419 by (insert assms, rule rev_exhaust, fastforce) |
471 next |
420 |
472 case (Cons x xs a b) |
421 lemma edges_on_rpathI' [intro]: |
473 from this(2) have "edges_on (x # xs @ [b]) \<subseteq> r" by (simp add:edges_on_unfold) |
422 assumes "edges_on (a#xs) \<subseteq> r" |
474 from Cons(1)[OF this] have " rpath r x (xs @ [b]) b" . |
423 and "xs \<noteq> []" |
475 moreover from Cons(2) have "(a, x) \<in> r" by (auto simp:edges_on_unfold) |
424 and "last xs = b" |
476 ultimately show ?case by (auto) |
425 shows "rpath r a xs b" |
426 proof - |
|
427 obtain xs' where "xs = xs'@[b]" |
|
428 using assms by fastforce |
|
429 with assms show ?thesis by fastforce |
|
477 qed |
430 qed |
478 |
431 |
479 text {* |
432 text {* |
480 The following lemma extracts the path from @{text "x"} to @{text "y"} |
433 The following lemma extracts the path from @{text "x"} to @{text "y"} |
481 from proposition @{text "(x, y) \<in> r^*"} |
434 from proposition @{text "(x, y) \<in> r^*"} |
482 *} |
435 *} |
483 lemma star_rpath: |
436 |
437 lemma star_rpath [elim]: |
|
484 assumes "(x, y) \<in> r^*" |
438 assumes "(x, y) \<in> r^*" |
485 obtains xs where "rpath r x xs y" |
439 obtains xs where "rpath r x xs y" |
486 proof - |
440 using assms |
487 have "\<exists> xs. rpath r x xs y" |
441 by (induct, auto) |
488 proof(unfold rpath_def, rule iffD1[OF rtranclp_eq_rtrancl_path]) |
442 |
489 from assms |
|
490 show "(pred_of r)\<^sup>*\<^sup>* x y" |
|
491 apply (fold pred_of_star) |
|
492 by (auto simp:pred_of_def) |
|
493 qed |
|
494 from that and this show ?thesis by blast |
|
495 qed |
|
496 |
443 |
497 text {* |
444 text {* |
498 The following lemma uses the path @{text "xs"} from @{text "x"} to @{text "y"} |
445 The following lemma uses the path @{text "xs"} from @{text "x"} to @{text "y"} |
499 as a witness to show @{text "(x, y) \<in> r^*"}. |
446 as a witness to show @{text "(x, y) \<in> r^*"}. |
500 *} |
447 *} |
501 lemma rpath_star: |
448 lemma rpath_star [simp]: |
502 assumes "rpath r x xs y" |
449 assumes "rpath r x xs y" |
503 shows "(x, y) \<in> r^*" |
450 shows "(x, y) \<in> r^*" |
504 proof - |
451 proof - |
505 from iffD2[OF rtranclp_eq_rtrancl_path] and assms[unfolded rpath_def] |
452 from iffD2[OF rtranclp_eq_rtrancl_path] and assms[unfolded rpath_def] |
506 have "(pred_of r)\<^sup>*\<^sup>* x y" by metis |
453 have "(pred_of r)\<^sup>*\<^sup>* x y" by metis |
507 thus ?thesis by (simp add: pred_of_star star_2_pstar) |
454 thus ?thesis by (simp add: pred_of_star star_2_pstar) |
508 qed |
455 qed |
509 |
456 |
510 lemma subtree_transfer: |
457 declare rpath_star[elim_format] |
458 |
|
459 lemma rpath_transfer' [intro]: |
|
460 assumes "rpath r1 x xs y" |
|
461 and "r1 \<subseteq> r2" |
|
462 shows "rpath r2 x xs y" |
|
463 using assms |
|
464 by (induct, auto) |
|
465 |
|
466 lemma subtree_transfer[intro]: |
|
511 assumes "a \<in> subtree r1 a'" |
467 assumes "a \<in> subtree r1 a'" |
512 and "r1 \<subseteq> r2" |
468 and "r1 \<subseteq> r2" |
513 shows "a \<in> subtree r2 a'" |
469 shows "a \<in> subtree r2 a'" |
514 proof - |
470 using assms |
515 from assms(1)[unfolded subtree_def] |
471 proof - |
516 have "(a, a') \<in> r1^*" by auto |
472 from assms(1) |
517 from star_rpath[OF this] |
473 obtain xs where h1: "rpath r1 a xs a'" by (auto simp:subtree_def) |
518 obtain xs where rp: "rpath r1 a xs a'" by blast |
474 show ?thesis |
519 hence "rpath r2 a xs a'" |
475 proof - |
520 proof(rule rpath_transfer) |
476 from rpath_star[OF h1] |
521 from rpath_edges_on[OF rp] and assms(2) |
477 have "(a, a') \<in> r1\<^sup>*" . |
522 show "edges_on (a # xs) \<subseteq> r2" by simp |
478 with assms(2) have "(a, a') \<in> r2\<^sup>*" |
479 using rtrancl_mono subsetCE by blast |
|
480 thus ?thesis by (auto simp:subtree_def) |
|
523 qed |
481 qed |
524 from rpath_star[OF this] |
482 qed |
525 show ?thesis by (auto simp:subtree_def) |
483 |
526 qed |
484 text {* |
527 |
485 @{text "subtree"} is mono with respect to the underlying graph. |
528 lemma subtree_rev_transfer: |
486 *} |
487 lemma subtree_mono[intro]: |
|
488 assumes "r1 \<subseteq> r2" |
|
489 shows "subtree r1 x \<subseteq> subtree r2 x" |
|
490 using assms by auto |
|
491 |
|
492 lemma subtree_rev_transfer[intro]: |
|
529 assumes "a \<notin> subtree r2 a'" |
493 assumes "a \<notin> subtree r2 a'" |
530 and "r1 \<subseteq> r2" |
494 and "r1 \<subseteq> r2" |
531 shows "a \<notin> subtree r1 a'" |
495 shows "a \<notin> subtree r1 a'" |
532 using assms and subtree_transfer by metis |
496 using assms and subtree_transfer by metis |
533 |
497 |
534 text {* |
498 text {* |
535 The following lemmas establishes a relation from paths in @{text "r"} |
499 The following lemmas establishes a relation from paths in @{text "r"} |
536 to @{text "r^+"} relation. |
500 to @{text "r^+"} relation. |
537 *} |
501 *} |
538 lemma rpath_plus: |
502 lemma rpath_plus[simp]: |
539 assumes "rpath r x xs y" |
503 assumes "rpath r x xs y" |
540 and "xs \<noteq> []" |
504 and "xs \<noteq> []" |
541 shows "(x, y) \<in> r^+" |
505 shows "(x, y) \<in> r^+" |
542 proof - |
506 using assms |
543 from assms(2) obtain e es where "xs = e#es" by (cases xs, auto) |
507 by (induct, simp) fastforce |
544 from assms(1)[unfolded this] |
508 |
545 show ?thesis |
509 lemma plus_rpath [elim]: |
546 proof(cases) |
|
547 case rstep |
|
548 show ?thesis |
|
549 proof - |
|
550 from rpath_star[OF rstep(2)] have "(e, y) \<in> r\<^sup>*" . |
|
551 with rstep(1) show "(x, y) \<in> r^+" by auto |
|
552 qed |
|
553 qed |
|
554 qed |
|
555 |
|
556 lemma plus_rpath: |
|
557 assumes "(x, y) \<in> r^+" |
510 assumes "(x, y) \<in> r^+" |
558 obtains xs where "rpath r x xs y" and "xs \<noteq> []" |
511 obtains xs where "rpath r x xs y" and "xs \<noteq> []" |
559 proof - |
512 proof - |
560 from assms |
513 from assms |
561 show ?thesis |
514 have "\<exists> xs. rpath r x xs y \<and> xs \<noteq> []" by (induct; auto) |
562 proof(cases rule:converse_tranclE[consumes 1]) |
515 with that show ?thesis by metis |
563 case 1 |
516 qed |
564 hence "rpath r x [y] y" by auto |
517 |
565 from that[OF this] show ?thesis by auto |
|
566 next |
|
567 case (2 z) |
|
568 from 2(2) have "(z, y) \<in> r^*" by auto |
|
569 from star_rpath[OF this] obtain xs where "rpath r z xs y" by auto |
|
570 from rstepI[OF 2(1) this] |
|
571 have "rpath r x (z # xs) y" . |
|
572 from that[OF this] show ?thesis by auto |
|
573 qed |
|
574 qed |
|
575 |
|
576 subsubsection {* Properties of @{text "subtree"} and @{term "ancestors"}*} |
518 subsubsection {* Properties of @{text "subtree"} and @{term "ancestors"}*} |
577 |
519 |
578 lemma ancestors_subtreeI: |
520 lemma ancestors_subtreeI [intro, dest]: |
579 assumes "b \<in> ancestors r a" |
521 assumes "b \<in> ancestors r a" |
580 shows "a \<in> subtree r b" |
522 shows "a \<in> subtree r b" |
581 using assms by (auto simp:subtree_def ancestors_def) |
523 using assms by (auto simp:subtree_def ancestors_def) |
582 |
524 |
583 lemma ancestors_Field: |
525 lemma ancestors_Field[elim]: |
584 assumes "b \<in> ancestors r a" |
526 assumes "b \<in> ancestors r a" |
585 obtains "a \<in> Domain r" "b \<in> Range r" |
527 obtains "a \<in> Domain r" "b \<in> Range r" |
586 using assms |
528 using assms |
587 apply (unfold ancestors_def, simp) |
529 apply (unfold ancestors_def, simp) |
588 by (metis Domain.DomainI Range.intros trancl_domain trancl_range) |
530 by (metis Domain.DomainI Range.intros trancl_domain trancl_range) |
589 |
531 |
590 lemma subtreeE: |
532 lemma subtreeE [elim]: |
591 assumes "a \<in> subtree r b" |
533 assumes "a \<in> subtree r b" |
592 obtains "a = b" |
534 obtains "a = b" |
593 | "a \<noteq> b" and "b \<in> ancestors r a" |
535 | "a \<noteq> b" and "b \<in> ancestors r a" |
594 proof - |
536 proof - |
595 from assms have "(a, b) \<in> r^*" by (auto simp:subtree_def) |
537 from assms have "(a, b) \<in> r^*" by (auto simp:subtree_def) |
597 have " a = b \<or> a \<noteq> b \<and> (a, b) \<in> r\<^sup>+" . |
539 have " a = b \<or> a \<noteq> b \<and> (a, b) \<in> r\<^sup>+" . |
598 with that[unfolded ancestors_def] show ?thesis by auto |
540 with that[unfolded ancestors_def] show ?thesis by auto |
599 qed |
541 qed |
600 |
542 |
601 |
543 |
602 lemma subtree_Field: |
544 lemma subtree_Field [simp, iff]: |
603 "subtree r x \<subseteq> Field r \<union> {x}" |
545 "subtree r x \<subseteq> Field r \<union> {x}" |
604 proof |
546 proof |
605 fix y |
547 fix y |
606 assume "y \<in> subtree r x" |
548 assume "y \<in> subtree r x" |
607 thus "y \<in> Field r \<union> {x}" |
549 thus "y \<in> Field r \<union> {x}" |
608 proof(cases rule:subtreeE) |
550 proof(cases rule:subtreeE) |
609 case 1 |
551 case 1 |
610 thus ?thesis by auto |
552 thus ?thesis by auto |
611 next |
553 next |
612 case 2 |
554 case 2 |
613 thus ?thesis apply (auto simp:ancestors_def) |
555 thus ?thesis |
614 using Field_def tranclD by fastforce |
556 by (unfold Field_def, fast) |
615 qed |
557 qed |
616 qed |
558 qed |
617 |
559 |
618 lemma subtree_ancestorsI: |
560 lemma subtree_ancestorsI: |
619 assumes "a \<in> subtree r b" |
561 assumes "a \<in> subtree r b" |
620 and "a \<noteq> b" |
562 and "a \<noteq> b" |
621 shows "b \<in> ancestors r a" |
563 shows "b \<in> ancestors r a" |
622 using assms |
564 using assms |
623 by (auto elim!:subtreeE) |
565 by auto |
624 |
|
625 text {* |
|
626 @{text "subtree"} is mono with respect to the underlying graph. |
|
627 *} |
|
628 lemma subtree_mono: |
|
629 assumes "r1 \<subseteq> r2" |
|
630 shows "subtree r1 x \<subseteq> subtree r2 x" |
|
631 proof |
|
632 fix c |
|
633 assume "c \<in> subtree r1 x" |
|
634 hence "(c, x) \<in> r1^*" by (auto simp:subtree_def) |
|
635 from star_rpath[OF this] obtain xs |
|
636 where rp:"rpath r1 c xs x" by metis |
|
637 hence "rpath r2 c xs x" |
|
638 proof(rule rpath_transfer) |
|
639 from rpath_edges_on[OF rp] have "edges_on (c # xs) \<subseteq> r1" . |
|
640 with assms show "edges_on (c # xs) \<subseteq> r2" by auto |
|
641 qed |
|
642 thus "c \<in> subtree r2 x" |
|
643 by (rule rpath_star[elim_format], auto simp:subtree_def) |
|
644 qed |
|
645 |
566 |
646 text {* |
567 text {* |
647 The following lemma characterizes the change of sub-tree of @{text "x"} |
568 The following lemma characterizes the change of sub-tree of @{text "x"} |
648 with the removal of an outside edge @{text "(a,b)"}. |
569 with the removal of an outside edge @{text "(a,b)"}. |
649 |
570 |
650 Note that, according to lemma @{thm edges_in_refutation}, the assumption |
571 Note that, according to lemma @{thm edges_in_refutation}, the assumption |
651 @{term "b \<notin> subtree r x"} amounts to saying @{text "(a, b)"} |
572 @{term "b \<notin> subtree r x"} amounts to saying @{text "(a, b)"} |
652 is outside the sub-tree of @{text "x"}. |
573 is outside the sub-tree of @{text "x"}. |
653 *} |
574 *} |
654 lemma subtree_del_outside: (* ddd *) |
575 lemma subtree_del_outside [simp,intro]: (* ddd *) |
655 assumes "b \<notin> subtree r x" |
576 assumes "b \<notin> subtree r x" |
656 shows "subtree (r - {(a, b)}) x = (subtree r x)" |
577 shows "subtree (r - {(a, b)}) x = (subtree r x)" (is "?L = ?R") |
657 proof - |
578 proof - |
658 { fix c |
579 { fix c |
659 assume "c \<in> (subtree r x)" |
580 assume "c \<in> ?R" |
660 hence "(c, x) \<in> r^*" by (auto simp:subtree_def) |
581 hence "(c, x) \<in> r^*" by (auto simp:subtree_def) |
661 hence "c \<in> subtree (r - {(a, b)}) x" |
582 hence "c \<in> ?L" |
662 proof(rule star_rpath) |
583 proof(rule star_rpath) |
663 fix xs |
584 fix xs |
664 assume rp: "rpath r c xs x" |
585 assume rp: "rpath r c xs x" |
665 show ?thesis |
586 show ?thesis |
666 proof - |
587 proof - |
667 from rp |
588 from rp |
668 have "rpath (r - {(a, b)}) c xs x" |
589 have "rpath (r - {(a, b)}) c xs x" |
669 proof(rule rpath_transfer) |
590 proof(rule rpath_transfer) |
670 from rpath_edges_on[OF rp] have "edges_on (c # xs) \<subseteq> r" . |
591 from rp have "edges_on (c # xs) \<subseteq> r" .. |
671 moreover have "(a, b) \<notin> edges_on (c#xs)" |
592 moreover have "(a, b) \<notin> edges_on (c#xs)" |
672 proof |
593 proof |
673 assume "(a, b) \<in> edges_on (c # xs)" |
594 assume "(a, b) \<in> edges_on (c # xs)" |
674 then obtain l1 l2 where h: "c#xs = l1@[a,b]@l2" by (auto simp:edges_on_def) |
595 then obtain l1 l2 where h: "c#xs = l1@[a,b]@l2" by (auto simp:edges_on_def) |
675 hence "tl (c#xs) = tl (l1@[a,b]@l2)" by simp |
596 hence "tl (c#xs) = tl (l1@[a,b]@l2)" by simp |
676 then obtain l1' where eq_xs_b: "xs = l1'@[b]@l2" by (cases l1, auto) |
597 then obtain l1' where eq_xs_b: "xs = l1'@[b]@l2" by (cases l1, auto) |
677 from rp[unfolded this] |
598 from rp[unfolded this] |
678 show False |
599 show False |
679 proof(rule rpath_appendE) |
600 by (rule rpath_appendE, insert assms(1), auto simp:subtree_def) |
680 assume "rpath r b l2 x" |
|
681 thus ?thesis |
|
682 by(rule rpath_star[elim_format], insert assms(1), auto simp:subtree_def) |
|
683 qed |
|
684 qed |
601 qed |
685 ultimately show "edges_on (c # xs) \<subseteq> r - {(a,b)}" by auto |
602 ultimately show "edges_on (c # xs) \<subseteq> (r - {(a, b)})" |
603 by (auto) |
|
686 qed |
604 qed |
687 thus ?thesis by (rule rpath_star[elim_format], auto simp:subtree_def) |
605 thus ?thesis by (auto simp:subtree_def) |
688 qed |
606 qed |
689 qed |
607 qed |
690 } moreover { |
608 } moreover { |
691 fix c |
609 fix c |
692 assume "c \<in> subtree (r - {(a, b)}) x" |
610 assume "c \<in> ?L" |
693 moreover have "... \<subseteq> (subtree r x)" by (rule subtree_mono, auto) |
611 moreover have "... \<subseteq> (subtree r x)" by auto |
694 ultimately have "c \<in> (subtree r x)" by auto |
612 ultimately have "c \<in> ?R" by auto |
695 } ultimately show ?thesis by auto |
613 } ultimately show ?thesis by auto |
696 qed |
614 qed |
697 |
615 |
698 (* ddd *) |
616 (* ddd *) |
699 lemma subset_del_subtree_outside: (* ddd *) |
617 lemma subset_del_subtree_outside [simp, intro]: (* ddd *) |
700 assumes "Range r' \<inter> subtree r x = {}" |
618 assumes "Range r' \<inter> subtree r x = {}" |
701 shows "subtree (r - r') x = (subtree r x)" |
619 shows "subtree (r - r') x = (subtree r x)" |
702 proof - |
620 proof - |
703 { fix c |
621 { fix c |
704 assume "c \<in> (subtree r x)" |
622 assume "c \<in> (subtree r x)" |
710 show ?thesis |
628 show ?thesis |
711 proof - |
629 proof - |
712 from rp |
630 from rp |
713 have "rpath (r - r') c xs x" |
631 have "rpath (r - r') c xs x" |
714 proof(rule rpath_transfer) |
632 proof(rule rpath_transfer) |
715 from rpath_edges_on[OF rp] have "edges_on (c # xs) \<subseteq> r" . |
633 from rp have "edges_on (c # xs) \<subseteq> r" .. |
716 moreover { |
634 moreover { |
717 fix a b |
635 fix a b |
718 assume h: "(a, b) \<in> r'" |
636 assume h: "(a, b) \<in> r'" |
719 have "(a, b) \<notin> edges_on (c#xs)" |
637 have "(a, b) \<notin> edges_on (c#xs)" |
720 proof |
638 proof |
729 from rpath_star[OF this] |
647 from rpath_star[OF this] |
730 have "b \<in> subtree r x" by (auto simp:subtree_def) |
648 have "b \<in> subtree r x" by (auto simp:subtree_def) |
731 with assms (1) and h show ?thesis by (auto) |
649 with assms (1) and h show ?thesis by (auto) |
732 qed |
650 qed |
733 qed |
651 qed |
734 } ultimately show "edges_on (c # xs) \<subseteq> r - r'" by auto |
652 } ultimately show "edges_on (c # xs) \<subseteq> (r - r')" by (auto) |
735 qed |
653 qed |
736 thus ?thesis by (rule rpath_star[elim_format], auto simp:subtree_def) |
654 thus ?thesis by (rule rpath_star[elim_format], auto simp:subtree_def) |
737 qed |
655 qed |
738 qed |
656 qed |
739 } moreover { |
657 } moreover { |
742 moreover have "... \<subseteq> (subtree r x)" by (rule subtree_mono, auto) |
660 moreover have "... \<subseteq> (subtree r x)" by (rule subtree_mono, auto) |
743 ultimately have "c \<in> (subtree r x)" by auto |
661 ultimately have "c \<in> (subtree r x)" by auto |
744 } ultimately show ?thesis by auto |
662 } ultimately show ?thesis by auto |
745 qed |
663 qed |
746 |
664 |
747 lemma subtree_insert_ext: |
665 lemma subtree_insert_ext [simp, intro]: |
748 assumes "b \<in> subtree r x" |
666 assumes "b \<in> subtree r x" |
749 shows "subtree (r \<union> {(a, b)}) x = (subtree r x) \<union> (subtree r a)" |
667 shows "subtree (r \<union> {(a, b)}) x = (subtree r x) \<union> (subtree r a)" |
750 using assms by (auto simp:subtree_def rtrancl_insert) |
668 using assms by (auto simp:subtree_def rtrancl_insert) |
751 |
669 |
752 lemma subtree_insert_next: |
670 lemma subtree_insert_next [simp, intro]: |
753 assumes "b \<notin> subtree r x" |
671 assumes "b \<notin> subtree r x" |
754 shows "subtree (r \<union> {(a, b)}) x = (subtree r x)" |
672 shows "subtree (r \<union> {(a, b)}) x = (subtree r x)" |
755 using assms |
673 using assms |
756 by (auto simp:subtree_def rtrancl_insert) |
674 by (auto simp:subtree_def rtrancl_insert) |
757 |
675 |
758 lemma set_add_rootI: |
676 lemma set_add_rootI[simp, intro]: |
759 assumes "root r a" |
677 assumes "root r a" |
760 and "a \<notin> Domain r1" |
678 and "a \<notin> Domain r1" |
761 shows "root (r \<union> r1) a" |
679 shows "root (r \<union> r1) a" |
680 using assms |
|
762 proof - |
681 proof - |
763 let ?r = "r \<union> r1" |
682 let ?r = "r \<union> r1" |
764 { fix a' |
683 { fix a' |
765 assume "a' \<in> ancestors ?r a" |
684 assume "a' \<in> ancestors ?r a" |
766 hence "(a, a') \<in> ?r^+" by (auto simp:ancestors_def) |
685 hence "(a, a') \<in> ?r^+" by (auto simp:ancestors_def) |
775 with assms(2) |
694 with assms(2) |
776 have False by (auto) |
695 have False by (auto) |
777 } thus ?thesis by (auto simp:root_def) |
696 } thus ?thesis by (auto simp:root_def) |
778 qed |
697 qed |
779 |
698 |
780 lemma ancestors_mono: |
699 lemma ancestors_mono [simp]: |
781 assumes "r1 \<subseteq> r2" |
700 assumes "r1 \<subseteq> r2" |
782 shows "ancestors r1 x \<subseteq> ancestors r2 x" |
701 shows "ancestors r1 x \<subseteq> ancestors r2 x" |
783 proof |
702 proof |
784 fix a |
703 fix a |
785 assume "a \<in> ancestors r1 x" |
704 assume "a \<in> ancestors r1 x" |
786 hence "(x, a) \<in> r1^+" by (auto simp:ancestors_def) |
705 hence "(x, a) \<in> r1^+" by (auto simp:ancestors_def) |
787 from plus_rpath[OF this] obtain xs where |
706 from plus_rpath[OF this] obtain xs where |
788 h: "rpath r1 x xs a" "xs \<noteq> []" . |
707 h: "rpath r1 x xs a" "xs \<noteq> []" . |
789 have "rpath r2 x xs a" |
708 have "rpath r2 x xs a" |
790 proof(rule rpath_transfer[OF h(1)]) |
709 proof(rule rpath_transfer[OF h(1)]) |
791 from rpath_edges_on[OF h(1)] and assms |
710 from h(1) have "edges_on (x # xs) \<subseteq> r1" .. |
792 show "edges_on (x # xs) \<subseteq> r2" by auto |
711 also note assms |
712 finally show "edges_on (x # xs) \<subseteq> r2" . |
|
793 qed |
713 qed |
794 from rpath_plus[OF this h(2)] |
714 from rpath_plus[OF this h(2)] |
795 show "a \<in> ancestors r2 x" by (auto simp:ancestors_def) |
715 show "a \<in> ancestors r2 x" by (auto simp:ancestors_def) |
796 qed |
716 qed |
797 |
717 |
864 with assms show ?thesis by (auto simp:ancestors_def) |
784 with assms show ?thesis by (auto simp:ancestors_def) |
865 qed |
785 qed |
866 } ultimately show ?thesis by auto |
786 } ultimately show ?thesis by auto |
867 qed |
787 qed |
868 |
788 |
869 lemma rootI: |
789 lemma rootI [intro]: |
870 assumes h: "\<And> x'. x' \<noteq> x \<Longrightarrow> x \<notin> subtree r' x'" |
790 assumes h: "\<And> x'. x' \<noteq> x \<Longrightarrow> x \<notin> subtree r' x'" |
871 and "r' \<subseteq> r" |
791 and "r' \<subseteq> r" |
872 shows "root r' x" |
792 shows "root r' x" |
873 proof - |
793 proof - |
874 from acyclic_subset[OF acl assms(2)] |
794 from acyclic_subset[OF acl assms(2)] |
885 moreover from h1 have "x \<in> subtree r' x'" by (auto simp:subtree_def) |
805 moreover from h1 have "x \<in> subtree r' x'" by (auto simp:subtree_def) |
886 ultimately have False using h by auto |
806 ultimately have False using h by auto |
887 } thus ?thesis by (auto simp:root_def) |
807 } thus ?thesis by (auto simp:root_def) |
888 qed |
808 qed |
889 |
809 |
890 lemma rpath_overlap_oneside: (* ddd *) |
810 lemma rpath_overlap_oneside [elim]: (* ddd *) |
891 assumes "rpath r x xs1 x1" |
811 assumes "rpath r x xs1 x1" |
892 and "rpath r x xs2 x2" |
812 and "rpath r x xs2 x2" |
893 and "length xs1 \<le> length xs2" |
813 and "length xs1 \<le> length xs2" |
894 obtains xs3 where "xs2 = xs1 @ xs3" |
814 obtains xs3 where "xs2 = xs1 @ xs3" |
895 proof(cases "xs1 = []") |
815 proof(cases "xs1 = []") |
914 have lt_i': "?idx < length xs2" using lt_i and assms(3) by auto |
834 have lt_i': "?idx < length xs2" using lt_i and assms(3) by auto |
915 have lt_j: "?idx < j" using h1 by (cases j, auto) |
835 have lt_j: "?idx < j" using h1 by (cases j, auto) |
916 -- {* From thesis inequalities, a number of equations concerning @{text "xs1"} |
836 -- {* From thesis inequalities, a number of equations concerning @{text "xs1"} |
917 and @{text "xs2"} are derived *} |
837 and @{text "xs2"} are derived *} |
918 have eq_take: "take ?idx xs1 = take ?idx xs2" |
838 have eq_take: "take ?idx xs1 = take ?idx xs2" |
919 using h2[rule_format, OF lt_j] and h1 by auto |
839 using h2[rule_format, OF lt_j] and h1 by linarith |
920 have eq_xs1: " xs1 = take ?idx xs1 @ xs1 ! (?idx) # drop (Suc (?idx)) xs1" |
840 have eq_xs1: " xs1 = take ?idx xs1 @ xs1 ! (?idx) # drop (Suc (?idx)) xs1" |
921 using id_take_nth_drop[OF lt_i] . |
841 using id_take_nth_drop[OF lt_i] . |
922 have eq_xs2: "xs2 = take ?idx xs2 @ xs2 ! (?idx) # drop (Suc (?idx)) xs2" |
842 have eq_xs2: "xs2 = take ?idx xs2 @ xs2 ! (?idx) # drop (Suc (?idx)) xs2" |
923 using id_take_nth_drop[OF lt_i'] . |
843 using id_take_nth_drop[OF lt_i'] . |
924 -- {* The branch point along the path is finally pinpointed *} |
844 -- {* The branch point along the path is finally pinpointed *} |
948 show ?thesis by (auto simp:pred_of_def) |
868 show ?thesis by (auto simp:pred_of_def) |
949 qed |
869 qed |
950 ultimately show ?thesis using neq_idx sgv[unfolded single_valued_def] by metis |
870 ultimately show ?thesis using neq_idx sgv[unfolded single_valued_def] by metis |
951 next |
871 next |
952 case False |
872 case False |
953 then obtain e es where eq_es: "take ?idx xs1 = es@[e]" |
873 then obtain e es where eq_es: "take ?idx xs1 = es@[e]" by fast |
954 using rev_exhaust by blast |
|
955 have "(e, xs1!?idx) \<in> r" |
874 have "(e, xs1!?idx) \<in> r" |
956 proof - |
875 proof - |
957 from eq_xs1[unfolded eq_es] |
876 from eq_xs1[unfolded eq_es] |
958 have "xs1 = es@[e, xs1!?idx]@drop (Suc ?idx) xs1" by simp |
877 have "xs1 = es@[e, xs1!?idx]@drop (Suc ?idx) xs1" by simp |
959 hence "(e, xs1!?idx) \<in> edges_on xs1" by (simp add:edges_on_def, metis) |
878 hence "(e, xs1!?idx) \<in> edges_on xs1" by (simp add:edges_on_def, metis) |
960 with rpath_edges_on[OF assms(1)] edges_on_Cons_mono[of xs1 x] |
879 with rpath_edges_on[OF assms(1)] edges_on_Cons_mono[of xs1 x] |
961 show ?thesis by auto |
880 show ?thesis by (auto) |
962 qed moreover have "(e, xs2!?idx) \<in> r" |
881 qed moreover have "(e, xs2!?idx) \<in> r" |
963 proof - |
882 proof - |
964 from eq_xs2[folded eq_take, unfolded eq_es] |
883 from eq_xs2[folded eq_take, unfolded eq_es] |
965 have "xs2 = es@[e, xs2!?idx]@drop (Suc ?idx) xs2" by simp |
884 have "xs2 = es@[e, xs2!?idx]@drop (Suc ?idx) xs2" by simp |
966 hence "(e, xs2!?idx) \<in> edges_on xs2" by (simp add:edges_on_def, metis) |
885 hence "(e, xs2!?idx) \<in> edges_on xs2" by (simp add:edges_on_def, metis) |
967 with rpath_edges_on[OF assms(2)] edges_on_Cons_mono[of xs2 x] |
886 with rpath_edges_on[OF assms(2)] edges_on_Cons_mono[of xs2 x] |
968 show ?thesis by auto |
887 show ?thesis by (auto) |
969 qed |
888 qed |
970 ultimately show ?thesis |
889 ultimately show ?thesis |
971 using sgv[unfolded single_valued_def] neq_idx by metis |
890 using sgv[unfolded single_valued_def] neq_idx by metis |
972 qed |
891 qed |
973 qed |
892 qed |
1066 from less_1 and False show "xs2 \<noteq> []" by simp |
985 from less_1 and False show "xs2 \<noteq> []" by simp |
1067 qed |
986 qed |
1068 with acl show ?thesis by (unfold acyclic_def, auto) |
987 with acl show ?thesis by (unfold acyclic_def, auto) |
1069 next |
988 next |
1070 case False |
989 case False |
1071 then obtain e es where eq_xs1: "xs1 = es@[e]" using rev_exhaust by auto |
990 then obtain e es where eq_xs1: "xs1 = es@[e]" by fast |
1072 from assms(2)[unfolded less_1 this] |
991 from assms(2)[unfolded less_1 this] |
1073 have "rpath r x (es @ [e] @ xs3) y" by simp |
992 have "rpath r x (es @ [e] @ xs3) y" by simp |
1074 thus ?thesis |
993 thus ?thesis |
1075 proof(cases rule:rpath_appendE) |
994 proof(cases rule:rpath_appendE) |
1076 case 1 |
995 case 1 |
1127 from rp1[unfolded this] have "x = z" by auto |
1046 from rp1[unfolded this] have "x = z" by auto |
1128 from rp2[folded this] rpath_star ind[unfolded indep_def] |
1047 from rp2[folded this] rpath_star ind[unfolded indep_def] |
1129 show ?thesis by metis |
1048 show ?thesis by metis |
1130 next |
1049 next |
1131 case False |
1050 case False |
1132 then obtain e es where eq_xs1: "xs1 = es@[e]" using rev_exhaust by blast |
1051 then obtain e es where eq_xs1: "xs1 = es@[e]" by fast |
1133 from rp2[unfolded h this] |
1052 from rp2[unfolded h this] |
1134 have "rpath r z (es @ [e] @ xs3) y" by simp |
1053 have "rpath r z (es @ [e] @ xs3) y" by simp |
1135 thus ?thesis |
1054 thus ?thesis |
1136 proof(cases rule:rpath_appendE) |
1055 proof(cases rule:rpath_appendE) |
1137 case 1 |
1056 case 1 |
1202 let ?r' = "r - {(a, b)}" -- {* The reduced graph is abbreviated as @{text "?r'"} *} |
1121 let ?r' = "r - {(a, b)}" -- {* The reduced graph is abbreviated as @{text "?r'"} *} |
1203 from h have "(c, x) \<in> ?r'^*" by (auto simp:subtree_def) |
1122 from h have "(c, x) \<in> ?r'^*" by (auto simp:subtree_def) |
1204 -- {* Extract from the reduced graph the path @{text "xs"} from @{text "c"} to @{text "x"}. *} |
1123 -- {* Extract from the reduced graph the path @{text "xs"} from @{text "c"} to @{text "x"}. *} |
1205 then obtain xs where rp0: "rpath ?r' c xs x" by (rule star_rpath, auto) |
1124 then obtain xs where rp0: "rpath ?r' c xs x" by (rule star_rpath, auto) |
1206 -- {* It is easy to show @{text "xs"} is also a path in the original graph *} |
1125 -- {* It is easy to show @{text "xs"} is also a path in the original graph *} |
1207 hence rp1: "rpath r c xs x" |
1126 hence rp1: "rpath r c xs x" using rpath_edges_on[OF rp0] |
1208 proof(rule rpath_transfer) |
1127 by auto |
1209 from rpath_edges_on[OF rp0] |
|
1210 show "edges_on (c # xs) \<subseteq> r" by auto |
|
1211 qed |
|
1212 -- {* @{text "xs"} is used as the witness to show that @{text "c"} |
1128 -- {* @{text "xs"} is used as the witness to show that @{text "c"} |
1213 in the sub-tree of @{text "x"} in the original graph. *} |
1129 in the sub-tree of @{text "x"} in the original graph. *} |
1214 hence "c \<in> subtree r x" |
1130 hence "c \<in> subtree r x" |
1215 by (rule rpath_star[elim_format], auto simp:subtree_def) |
1131 by (rule rpath_star[elim_format], auto simp:subtree_def) |
1216 -- {* The next step is to show that @{text "c"} can not be in the sub-tree of @{text "a"} |
1132 -- {* The next step is to show that @{text "c"} can not be in the sub-tree of @{text "a"} |
1253 -- {* It can be shown that @{term "(a,b)"} is on this fictional path. *} |
1169 -- {* It can be shown that @{term "(a,b)"} is on this fictional path. *} |
1254 have "(a, b) \<in> edges_on (c#xs)" |
1170 have "(a, b) \<in> edges_on (c#xs)" |
1255 proof(cases "xs1 = []") |
1171 proof(cases "xs1 = []") |
1256 case True |
1172 case True |
1257 from rp_c[unfolded this] have "rpath r c [] a" . |
1173 from rp_c[unfolded this] have "rpath r c [] a" . |
1258 hence eq_c: "c = a" by (rule rpath_nilE, simp) |
1174 hence eq_c: "c = a" by fast |
1259 hence "c#xs = a#xs" by simp |
1175 hence "c#xs = a#xs" by simp |
1260 from this and eq_xs have "c#xs = a # xs1 @ b # ys" by simp |
1176 from this and eq_xs have "c#xs = a # xs1 @ b # ys" by simp |
1261 from this[unfolded True] have "c#xs = []@[a,b]@ys" by simp |
1177 from this[unfolded True] have "c#xs = []@[a,b]@ys" by simp |
1262 thus ?thesis by (auto simp:edges_on_def) |
1178 thus ?thesis by (auto simp:edges_on_def) |
1263 next |
1179 next |
1267 from eq_xs[unfolded this] have "c#xs = (c#xs')@[a,b]@ys" by simp |
1183 from eq_xs[unfolded this] have "c#xs = (c#xs')@[a,b]@ys" by simp |
1268 thus ?thesis by (unfold edges_on_def, blast) |
1184 thus ?thesis by (unfold edges_on_def, blast) |
1269 qed |
1185 qed |
1270 -- {* It can also be shown that @{term "(a,b)"} is not on this fictional path. *} |
1186 -- {* It can also be shown that @{term "(a,b)"} is not on this fictional path. *} |
1271 moreover have "(a, b) \<notin> edges_on (c#xs)" |
1187 moreover have "(a, b) \<notin> edges_on (c#xs)" |
1272 using rpath_edges_on[OF rp0] by auto |
1188 using rpath_edges_on[OF rp0] by (auto) |
1273 -- {* Contradiction is thus derived. *} |
1189 -- {* Contradiction is thus derived. *} |
1274 ultimately show False by auto |
1190 ultimately show False by auto |
1275 qed |
1191 qed |
1276 qed |
1192 qed |
1277 ultimately show ?thesis by auto |
1193 ultimately show ?thesis by auto |
1347 inthe reduced graph. *} |
1263 inthe reduced graph. *} |
1348 from rpath_star[OF this] show ?thesis by (auto simp:subtree_def) |
1264 from rpath_star[OF this] show ?thesis by (auto simp:subtree_def) |
1349 qed |
1265 qed |
1350 } |
1266 } |
1351 -- {* The equality of sets is derived from the two directions just proved. *} |
1267 -- {* The equality of sets is derived from the two directions just proved. *} |
1352 ultimately show ?thesis by auto |
1268 ultimately show ?thesis by blast |
1353 qed |
1269 qed |
1354 |
1270 |
1355 lemma set_del_rootI: |
1271 lemma set_del_rootI: |
1356 assumes "r1 \<subseteq> r" |
1272 assumes "r1 \<subseteq> r" |
1357 and "a \<in> Domain r1" |
1273 and "a \<in> Domain r1" |
1459 hence "z \<in> ?L" |
1375 hence "z \<in> ?L" |
1460 by (unfold subtree_def, auto) |
1376 by (unfold subtree_def, auto) |
1461 } ultimately show ?thesis by auto |
1377 } ultimately show ?thesis by auto |
1462 qed |
1378 qed |
1463 |
1379 |
1380 lemma ancestor_children_subtreeI [intro]: |
|
1381 "x \<in> ancestors r z \<Longrightarrow> z \<in> \<Union>(subtree r ` children r x)" |
|
1382 by (unfold ancestors_def children_def, auto simp:subtree_def dest:tranclD2) |
|
1383 |
|
1384 lemma [iff]: "x \<in> subtree r x" |
|
1385 by (auto simp:subtree_def) |
|
1386 |
|
1387 lemma [intro]: "xa \<in> children r x \<Longrightarrow> z \<in> subtree r xa \<Longrightarrow> z \<in> subtree r x" |
|
1388 by (unfold children_def subtree_def, auto) |
|
1464 |
1389 |
1465 lemma subtree_children: |
1390 lemma subtree_children: |
1466 "subtree r x = {x} \<union> (\<Union> (subtree r ` (children r x)))" (is "?L = ?R") |
1391 "subtree r x = ({x} \<union> (\<Union> (subtree r ` (children r x))))" (is "?L = ?R") |
1467 proof - |
1392 by fast |
1468 { fix z |
|
1469 assume "z \<in> ?L" |
|
1470 hence "z \<in> ?R" |
|
1471 proof(cases rule:subtreeE[consumes 1]) |
|
1472 case 2 |
|
1473 hence "(z, x) \<in> r^+" by (auto simp:ancestors_def) |
|
1474 thus ?thesis |
|
1475 proof(rule tranclE) |
|
1476 assume "(z, x) \<in> r" |
|
1477 hence "z \<in> children r x" by (unfold children_def, auto) |
|
1478 moreover have "z \<in> subtree r z" by (auto simp:subtree_def) |
|
1479 ultimately show ?thesis by auto |
|
1480 next |
|
1481 fix c |
|
1482 assume h: "(z, c) \<in> r\<^sup>+" "(c, x) \<in> r" |
|
1483 hence "c \<in> children r x" by (auto simp:children_def) |
|
1484 moreover from h have "z \<in> subtree r c" by (auto simp:subtree_def) |
|
1485 ultimately show ?thesis by auto |
|
1486 qed |
|
1487 qed auto |
|
1488 } moreover { |
|
1489 fix z |
|
1490 assume h: "z \<in> ?R" |
|
1491 have "x \<in> subtree r x" by (auto simp:subtree_def) |
|
1492 moreover { |
|
1493 assume "z \<in> \<Union>(subtree r ` children r x)" |
|
1494 then obtain y where "(y, x) \<in> r" "(z, y) \<in> r^*" |
|
1495 by (auto simp:subtree_def children_def) |
|
1496 hence "(z, x) \<in> r^*" by auto |
|
1497 hence "z \<in> ?L" by (auto simp:subtree_def) |
|
1498 } ultimately have "z \<in> ?L" using h by auto |
|
1499 } ultimately show ?thesis by auto |
|
1500 qed |
|
1501 |
1393 |
1502 context fsubtree |
1394 context fsubtree |
1503 begin |
1395 begin |
1504 |
1396 |
1505 lemma finite_subtree: |
1397 lemma finite_subtree: |
1682 apply (simp add:Suc relpow_add[symmetric]) |
1574 apply (simp add:Suc relpow_add[symmetric]) |
1683 by (unfold h, simp) |
1575 by (unfold h, simp) |
1684 qed |
1576 qed |
1685 qed simp |
1577 qed simp |
1686 |
1578 |
1687 lemma compose_relpow_2: |
1579 lemma compose_relpow_2 [intro, simp]: |
1688 assumes "r1 \<subseteq> r" |
1580 assumes "r1 \<subseteq> r" |
1689 and "r2 \<subseteq> r" |
1581 and "r2 \<subseteq> r" |
1690 shows "r1 O r2 \<subseteq> r ^^ (2::nat)" |
1582 shows "r1 O r2 \<subseteq> r ^^ (2::nat)" |
1691 proof - |
1583 proof - |
1692 { fix a b |
1584 { fix a b |
1696 with assms have "(a, e) \<in> r" "(e, b) \<in> r" by auto |
1588 with assms have "(a, e) \<in> r" "(e, b) \<in> r" by auto |
1697 hence "(a, b) \<in> r ^^ (Suc (Suc 0))" by auto |
1589 hence "(a, b) \<in> r ^^ (Suc (Suc 0))" by auto |
1698 } thus ?thesis by (auto simp:numeral_2_eq_2) |
1590 } thus ?thesis by (auto simp:numeral_2_eq_2) |
1699 qed |
1591 qed |
1700 |
1592 |
1701 lemma acyclic_compose: |
1593 lemma acyclic_compose [intro, simp]: |
1702 assumes "acyclic r" |
1594 assumes "acyclic r" |
1703 and "r1 \<subseteq> r" |
1595 and "r1 \<subseteq> r" |
1704 and "r2 \<subseteq> r" |
1596 and "r2 \<subseteq> r" |
1705 shows "acyclic (r1 O r2)" |
1597 shows "acyclic (r1 O r2)" |
1706 proof - |
1598 proof - |
1722 |
1614 |
1723 lemma children_compose_unfold: |
1615 lemma children_compose_unfold: |
1724 "children (r1 O r2) x = \<Union> (children r1 ` (children r2 x))" |
1616 "children (r1 O r2) x = \<Union> (children r1 ` (children r2 x))" |
1725 by (auto simp:children_def) |
1617 by (auto simp:children_def) |
1726 |
1618 |
1727 lemma fbranch_compose: |
1619 lemma fbranch_compose [intro, simp]: |
1728 assumes "fbranch r1" |
1620 assumes "fbranch r1" |
1729 and "fbranch r2" |
1621 and "fbranch r2" |
1730 shows "fbranch (r1 O r2)" |
1622 shows "fbranch (r1 O r2)" |
1731 proof - |
1623 proof - |
1732 { fix x |
1624 { fix x |
1756 qed |
1648 qed |
1757 qed |
1649 qed |
1758 } thus ?thesis by (unfold fbranch_def, auto) |
1650 } thus ?thesis by (unfold fbranch_def, auto) |
1759 qed |
1651 qed |
1760 |
1652 |
1761 lemma finite_fbranchI: |
1653 lemma finite_fbranchI [intro]: |
1762 assumes "finite r" |
1654 assumes "finite r" |
1763 shows "fbranch r" |
1655 shows "fbranch r" |
1764 proof - |
1656 proof - |
1765 { fix x |
1657 { fix x |
1766 assume "x \<in>Range r" |
1658 assume "x \<in>Range r" |
1772 thus ?thesis by (unfold children_def, simp) |
1664 thus ?thesis by (unfold children_def, simp) |
1773 qed |
1665 qed |
1774 } thus ?thesis by (auto simp:fbranch_def) |
1666 } thus ?thesis by (auto simp:fbranch_def) |
1775 qed |
1667 qed |
1776 |
1668 |
1777 lemma subset_fbranchI: |
1669 lemma subset_fbranchI [intro]: |
1778 assumes "fbranch r1" |
1670 assumes "fbranch r1" |
1779 and "r2 \<subseteq> r1" |
1671 and "r2 \<subseteq> r1" |
1780 shows "fbranch r2" |
1672 shows "fbranch r2" |
1781 proof - |
1673 proof - |
1782 { fix x |
1674 { fix x |
1790 show "children r2 x \<subseteq> children r1 x" by (auto simp:children_def) |
1682 show "children r2 x \<subseteq> children r1 x" by (auto simp:children_def) |
1791 qed |
1683 qed |
1792 } thus ?thesis by (auto simp:fbranch_def) |
1684 } thus ?thesis by (auto simp:fbranch_def) |
1793 qed |
1685 qed |
1794 |
1686 |
1795 lemma children_subtree: |
1687 lemma children_subtree [simp, intro]: |
1796 shows "children r x \<subseteq> subtree r x" |
1688 shows "children r x \<subseteq> subtree r x" |
1797 by (auto simp:children_def subtree_def) |
1689 by (auto simp:children_def subtree_def) |
1798 |
1690 |
1799 lemma children_union_kept: |
1691 lemma children_union_kept [simp]: |
1800 assumes "x \<notin> Range r'" |
1692 assumes "x \<notin> Range r'" |
1801 shows "children (r \<union> r') x = children r x" |
1693 shows "children (r \<union> r') x = children r x" |
1802 using assms |
1694 using assms |
1803 by (auto simp:children_def) |
1695 by (auto simp:children_def) |
1804 |
1696 |
1805 lemma wf_rbase: |
1697 lemma wf_rbase [elim]: |
1806 assumes "wf r" |
1698 assumes "wf r" |
1807 obtains b where "(b, a) \<in> r^*" "\<forall> c. (c, b) \<notin> r" |
1699 obtains b where "(b, a) \<in> r^*" "\<forall> c. (c, b) \<notin> r" |
1808 proof - |
1700 proof - |
1809 from assms |
1701 from assms |
1810 have "\<exists> b. (b, a) \<in> r^* \<and> (\<forall> c. (c, b) \<notin> r)" |
1702 have "\<exists> b. (b, a) \<in> r^* \<and> (\<forall> c. (c, b) \<notin> r)" |
1826 qed |
1718 qed |
1827 qed |
1719 qed |
1828 with that show ?thesis by metis |
1720 with that show ?thesis by metis |
1829 qed |
1721 qed |
1830 |
1722 |
1831 lemma wf_base: |
1723 lemma wf_base [elim]: |
1832 assumes "wf r" |
1724 assumes "wf r" |
1833 and "a \<in> Range r" |
1725 and "a \<in> Range r" |
1834 obtains b where "(b, a) \<in> r^+" "\<forall> c. (c, b) \<notin> r" |
1726 obtains b where "(b, a) \<in> r^+" "\<forall> c. (c, b) \<notin> r" |
1835 proof - |
1727 proof - |
1836 from assms(2) obtain a' where h_a: "(a', a) \<in> r" by auto |
1728 from assms(2) obtain a' where h_a: "(a', a) \<in> r" by auto |
1841 moreover have "b \<noteq> a" using h_a h_b(2) by auto |
1733 moreover have "b \<noteq> a" using h_a h_b(2) by auto |
1842 ultimately have "(b, a) \<in> r\<^sup>+" by auto |
1734 ultimately have "(b, a) \<in> r\<^sup>+" by auto |
1843 with h_b(2) and that show ?thesis by metis |
1735 with h_b(2) and that show ?thesis by metis |
1844 qed |
1736 qed |
1845 |
1737 |
1738 (* |
|
1739 lcrules crules |
|
1740 |
|
1741 declare crules(26,43,44,45,46,47)[rule del] |
|
1742 *) |
|
1743 |
|
1744 |
|
1745 declare RTree.subtree_transfer[rule del] |
|
1746 |
|
1747 declare RTree.subtreeE[rule del] |
|
1748 |
|
1749 declare RTree.ancestors_Field[rule del] |
|
1750 |
|
1751 declare RTree.star_rpath[rule del] |
|
1752 |
|
1753 declare RTree.plus_rpath[rule del] |
|
1754 |
|
1846 end |
1755 end |