author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Thu, 09 Jun 2016 23:01:36 +0100 | |
changeset 127 | 38c6acf03f68 |
parent 57 | f1b39d77db00 |
permissions | -rw-r--r-- |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1 |
section {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
2 |
This file contains lemmas used to guide the recalculation of current precedence |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
3 |
after every system call (or system operation) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
4 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
5 |
theory CpsG |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
6 |
imports PrioG Max RTree |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
7 |
begin |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
8 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
9 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
10 |
definition "wRAG (s::state) = {(Th th, Cs cs) | th cs. waiting s th cs}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
11 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
12 |
definition "hRAG (s::state) = {(Cs cs, Th th) | th cs. holding s th cs}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
13 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
14 |
definition "tRAG s = wRAG s O hRAG s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
15 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
16 |
definition "pairself f = (\<lambda>(a, b). (f a, f b))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
17 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
18 |
definition "rel_map f r = (pairself f ` r)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
19 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
20 |
fun the_thread :: "node \<Rightarrow> thread" where |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
21 |
"the_thread (Th th) = th" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
22 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
23 |
definition "tG s = rel_map the_thread (tRAG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
24 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
25 |
locale pip = |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
26 |
fixes s |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
27 |
assumes vt: "vt s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
28 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
29 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
30 |
lemma RAG_split: "RAG s = (wRAG s \<union> hRAG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
31 |
by (unfold s_RAG_abv wRAG_def hRAG_def s_waiting_abv |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
32 |
s_holding_abv cs_RAG_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
33 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
34 |
lemma relpow_mult: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
35 |
"((r::'a rel) ^^ m) ^^ n = r ^^ (m*n)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
36 |
proof(induct n arbitrary:m) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
37 |
case (Suc k m) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
38 |
thus ?case (is "?L = ?R") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
39 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
40 |
have h: "(m * k + m) = (m + m * k)" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
41 |
show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
42 |
apply (simp add:Suc relpow_add[symmetric]) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
43 |
by (unfold h, simp) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
44 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
45 |
qed simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
46 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
47 |
lemma compose_relpow_2: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
48 |
assumes "r1 \<subseteq> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
49 |
and "r2 \<subseteq> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
50 |
shows "r1 O r2 \<subseteq> r ^^ (2::nat)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
51 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
52 |
{ fix a b |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
53 |
assume "(a, b) \<in> r1 O r2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
54 |
then obtain e where "(a, e) \<in> r1" "(e, b) \<in> r2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
55 |
by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
56 |
with assms have "(a, e) \<in> r" "(e, b) \<in> r" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
57 |
hence "(a, b) \<in> r ^^ (Suc (Suc 0))" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
58 |
} thus ?thesis by (auto simp:numeral_2_eq_2) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
59 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
60 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
61 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
62 |
lemma acyclic_compose: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
63 |
assumes "acyclic r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
64 |
and "r1 \<subseteq> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
65 |
and "r2 \<subseteq> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
66 |
shows "acyclic (r1 O r2)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
67 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
68 |
{ fix a |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
69 |
assume "(a, a) \<in> (r1 O r2)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
70 |
from trancl_mono[OF this compose_relpow_2[OF assms(2, 3)]] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
71 |
have "(a, a) \<in> (r ^^ 2) ^+" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
72 |
from trancl_power[THEN iffD1, OF this] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
73 |
obtain n where h: "(a, a) \<in> (r ^^ 2) ^^ n" "n > 0" by blast |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
74 |
from this(1)[unfolded relpow_mult] have h2: "(a, a) \<in> r ^^ (2 * n)" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
75 |
have "(a, a) \<in> r^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
76 |
proof(cases rule:trancl_power[THEN iffD2]) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
77 |
from h(2) h2 show "\<exists>n>0. (a, a) \<in> r ^^ n" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
78 |
by (rule_tac x = "2*n" in exI, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
79 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
80 |
with assms have "False" by (auto simp:acyclic_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
81 |
} thus ?thesis by (auto simp:acyclic_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
82 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
83 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
84 |
lemma range_tRAG: "Range (tRAG s) \<subseteq> {Th th | th. True}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
85 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
86 |
have "Range (wRAG s O hRAG s) \<subseteq> {Th th |th. True}" (is "?L \<subseteq> ?R") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
87 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
88 |
have "?L \<subseteq> Range (hRAG s)" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
89 |
also have "... \<subseteq> ?R" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
90 |
by (unfold hRAG_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
91 |
finally show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
92 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
93 |
thus ?thesis by (simp add:tRAG_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
94 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
95 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
96 |
lemma domain_tRAG: "Domain (tRAG s) \<subseteq> {Th th | th. True}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
97 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
98 |
have "Domain (wRAG s O hRAG s) \<subseteq> {Th th |th. True}" (is "?L \<subseteq> ?R") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
99 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
100 |
have "?L \<subseteq> Domain (wRAG s)" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
101 |
also have "... \<subseteq> ?R" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
102 |
by (unfold wRAG_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
103 |
finally show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
104 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
105 |
thus ?thesis by (simp add:tRAG_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
106 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
107 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
108 |
lemma rel_mapE: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
109 |
assumes "(a, b) \<in> rel_map f r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
110 |
obtains c d |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
111 |
where "(c, d) \<in> r" "(a, b) = (f c, f d)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
112 |
using assms |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
113 |
by (unfold rel_map_def pairself_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
114 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
115 |
lemma rel_mapI: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
116 |
assumes "(a, b) \<in> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
117 |
and "c = f a" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
118 |
and "d = f b" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
119 |
shows "(c, d) \<in> rel_map f r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
120 |
using assms |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
121 |
by (unfold rel_map_def pairself_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
122 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
123 |
lemma map_appendE: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
124 |
assumes "map f zs = xs @ ys" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
125 |
obtains xs' ys' |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
126 |
where "zs = xs' @ ys'" "xs = map f xs'" "ys = map f ys'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
127 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
128 |
have "\<exists> xs' ys'. zs = xs' @ ys' \<and> xs = map f xs' \<and> ys = map f ys'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
129 |
using assms |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
130 |
proof(induct xs arbitrary:zs ys) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
131 |
case (Nil zs ys) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
132 |
thus ?case by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
133 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
134 |
case (Cons x xs zs ys) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
135 |
note h = this |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
136 |
show ?case |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
137 |
proof(cases zs) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
138 |
case (Cons e es) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
139 |
with h have eq_x: "map f es = xs @ ys" "x = f e" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
140 |
from h(1)[OF this(1)] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
141 |
obtain xs' ys' where "es = xs' @ ys'" "xs = map f xs'" "ys = map f ys'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
142 |
by blast |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
143 |
with Cons eq_x |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
144 |
have "zs = (e#xs') @ ys' \<and> x # xs = map f (e#xs') \<and> ys = map f ys'" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
145 |
thus ?thesis by metis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
146 |
qed (insert h, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
147 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
148 |
thus ?thesis by (auto intro!:that) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
149 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
150 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
151 |
lemma rel_map_mono: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
152 |
assumes "r1 \<subseteq> r2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
153 |
shows "rel_map f r1 \<subseteq> rel_map f r2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
154 |
using assms |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
155 |
by (auto simp:rel_map_def pairself_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
156 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
157 |
lemma rel_map_compose [simp]: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
158 |
shows "rel_map f1 (rel_map f2 r) = rel_map (f1 o f2) r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
159 |
by (auto simp:rel_map_def pairself_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
160 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
161 |
lemma edges_on_map: "edges_on (map f xs) = rel_map f (edges_on xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
162 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
163 |
{ fix a b |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
164 |
assume "(a, b) \<in> edges_on (map f xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
165 |
then obtain l1 l2 where eq_map: "map f xs = l1 @ [a, b] @ l2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
166 |
by (unfold edges_on_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
167 |
hence "(a, b) \<in> rel_map f (edges_on xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
168 |
by (auto elim!:map_appendE intro!:rel_mapI simp:edges_on_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
169 |
} moreover { |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
170 |
fix a b |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
171 |
assume "(a, b) \<in> rel_map f (edges_on xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
172 |
then obtain c d where |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
173 |
h: "(c, d) \<in> edges_on xs" "(a, b) = (f c, f d)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
174 |
by (elim rel_mapE, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
175 |
then obtain l1 l2 where |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
176 |
eq_xs: "xs = l1 @ [c, d] @ l2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
177 |
by (auto simp:edges_on_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
178 |
hence eq_map: "map f xs = map f l1 @ [f c, f d] @ map f l2" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
179 |
have "(a, b) \<in> edges_on (map f xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
180 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
181 |
from h(2) have "[f c, f d] = [a, b]" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
182 |
from eq_map[unfolded this] show ?thesis by (auto simp:edges_on_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
183 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
184 |
} ultimately show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
185 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
186 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
187 |
lemma plus_rpath: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
188 |
assumes "(a, b) \<in> r^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
189 |
obtains xs where "rpath r a xs b" "xs \<noteq> []" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
190 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
191 |
from assms obtain m where h: "(a, m) \<in> r" "(m, b) \<in> r^*" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
192 |
by (auto dest!:tranclD) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
193 |
from star_rpath[OF this(2)] obtain xs where "rpath r m xs b" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
194 |
from rstepI[OF h(1) this] have "rpath r a (m # xs) b" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
195 |
from that[OF this] show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
196 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
197 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
198 |
lemma edges_on_unfold: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
199 |
"edges_on (a # b # xs) = {(a, b)} \<union> edges_on (b # xs)" (is "?L = ?R") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
200 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
201 |
{ fix c d |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
202 |
assume "(c, d) \<in> ?L" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
203 |
then obtain l1 l2 where h: "(a # b # xs) = l1 @ [c, d] @ l2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
204 |
by (auto simp:edges_on_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
205 |
have "(c, d) \<in> ?R" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
206 |
proof(cases "l1") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
207 |
case Nil |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
208 |
with h have "(c, d) = (a, b)" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
209 |
thus ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
210 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
211 |
case (Cons e es) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
212 |
from h[unfolded this] have "b#xs = es@[c, d]@l2" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
213 |
thus ?thesis by (auto simp:edges_on_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
214 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
215 |
} moreover |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
216 |
{ fix c d |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
217 |
assume "(c, d) \<in> ?R" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
218 |
moreover have "(a, b) \<in> ?L" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
219 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
220 |
have "(a # b # xs) = []@[a,b]@xs" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
221 |
hence "\<exists> l1 l2. (a # b # xs) = l1@[a,b]@l2" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
222 |
thus ?thesis by (unfold edges_on_def, simp) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
223 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
224 |
moreover { |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
225 |
assume "(c, d) \<in> edges_on (b#xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
226 |
then obtain l1 l2 where "b#xs = l1@[c, d]@l2" by (unfold edges_on_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
227 |
hence "a#b#xs = (a#l1)@[c,d]@l2" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
228 |
hence "\<exists> l1 l2. (a # b # xs) = l1@[c,d]@l2" by metis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
229 |
hence "(c,d) \<in> ?L" by (unfold edges_on_def, simp) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
230 |
} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
231 |
ultimately have "(c, d) \<in> ?L" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
232 |
} ultimately show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
233 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
234 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
235 |
lemma edges_on_rpathI: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
236 |
assumes "edges_on (a#xs@[b]) \<subseteq> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
237 |
shows "rpath r a (xs@[b]) b" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
238 |
using assms |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
239 |
proof(induct xs arbitrary: a b) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
240 |
case Nil |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
241 |
moreover have "(a, b) \<in> edges_on (a # [] @ [b])" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
242 |
by (unfold edges_on_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
243 |
ultimately have "(a, b) \<in> r" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
244 |
thus ?case by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
245 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
246 |
case (Cons x xs a b) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
247 |
from this(2) have "edges_on (x # xs @ [b]) \<subseteq> r" by (simp add:edges_on_unfold) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
248 |
from Cons(1)[OF this] have " rpath r x (xs @ [b]) b" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
249 |
moreover from Cons(2) have "(a, x) \<in> r" by (auto simp:edges_on_unfold) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
250 |
ultimately show ?case by (auto intro!:rstepI) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
251 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
252 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
253 |
lemma image_id: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
254 |
assumes "\<And> x. x \<in> A \<Longrightarrow> f x = x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
255 |
shows "f ` A = A" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
256 |
using assms by (auto simp:image_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
257 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
258 |
lemma rel_map_inv_id: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
259 |
assumes "inj_on f ((Domain r) \<union> (Range r))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
260 |
shows "(rel_map (inv_into ((Domain r) \<union> (Range r)) f \<circ> f) r) = r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
261 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
262 |
let ?f = "(inv_into (Domain r \<union> Range r) f \<circ> f)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
263 |
{ |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
264 |
fix a b |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
265 |
assume h0: "(a, b) \<in> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
266 |
have "pairself ?f (a, b) = (a, b)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
267 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
268 |
from assms h0 have "?f a = a" by (auto intro:inv_into_f_f) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
269 |
moreover have "?f b = b" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
270 |
by (insert h0, simp, intro inv_into_f_f[OF assms], auto intro!:RangeI) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
271 |
ultimately show ?thesis by (auto simp:pairself_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
272 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
273 |
} thus ?thesis by (unfold rel_map_def, intro image_id, case_tac x, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
274 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
275 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
276 |
lemma rel_map_acyclic: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
277 |
assumes "acyclic r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
278 |
and "inj_on f ((Domain r) \<union> (Range r))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
279 |
shows "acyclic (rel_map f r)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
280 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
281 |
let ?D = "Domain r \<union> Range r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
282 |
{ fix a |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
283 |
assume "(a, a) \<in> (rel_map f r)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
284 |
from plus_rpath[OF this] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
285 |
obtain xs where rp: "rpath (rel_map f r) a xs a" "xs \<noteq> []" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
286 |
from rpath_nnl_lastE[OF this] obtain xs' where eq_xs: "xs = xs'@[a]" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
287 |
from rpath_edges_on[OF rp(1)] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
288 |
have h: "edges_on (a # xs) \<subseteq> rel_map f r" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
289 |
from edges_on_map[of "inv_into ?D f" "a#xs"] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
290 |
have "edges_on (map (inv_into ?D f) (a # xs)) = rel_map (inv_into ?D f) (edges_on (a # xs))" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
291 |
with rel_map_mono[OF h, of "inv_into ?D f"] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
292 |
have "edges_on (map (inv_into ?D f) (a # xs)) \<subseteq> rel_map ((inv_into ?D f) o f) r" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
293 |
from this[unfolded eq_xs] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
294 |
have subr: "edges_on (map (inv_into ?D f) (a # xs' @ [a])) \<subseteq> rel_map (inv_into ?D f \<circ> f) r" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
295 |
have "(map (inv_into ?D f) (a # xs' @ [a])) = (inv_into ?D f a) # map (inv_into ?D f) xs' @ [inv_into ?D f a]" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
296 |
by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
297 |
from edges_on_rpathI[OF subr[unfolded this]] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
298 |
have "rpath (rel_map (inv_into ?D f \<circ> f) r) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
299 |
(inv_into ?D f a) (map (inv_into ?D f) xs' @ [inv_into ?D f a]) (inv_into ?D f a)" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
300 |
hence "(inv_into ?D f a, inv_into ?D f a) \<in> (rel_map (inv_into ?D f \<circ> f) r)^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
301 |
by (rule rpath_plus, simp) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
302 |
moreover have "(rel_map (inv_into ?D f \<circ> f) r) = r" by (rule rel_map_inv_id[OF assms(2)]) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
303 |
moreover note assms(1) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
304 |
ultimately have False by (unfold acyclic_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
305 |
} thus ?thesis by (auto simp:acyclic_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
306 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
307 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
308 |
context pip |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
309 |
begin |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
310 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
311 |
interpretation rtree_RAG: rtree "RAG s" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
312 |
proof |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
313 |
show "single_valued (RAG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
314 |
by (unfold single_valued_def, auto intro: unique_RAG[OF vt]) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
315 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
316 |
show "acyclic (RAG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
317 |
by (rule acyclic_RAG[OF vt]) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
318 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
319 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
320 |
lemma sgv_wRAG: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
321 |
shows "single_valued (wRAG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
322 |
using waiting_unique[OF vt] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
323 |
by (unfold single_valued_def wRAG_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
324 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
325 |
lemma sgv_hRAG: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
326 |
shows "single_valued (hRAG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
327 |
using held_unique |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
328 |
by (unfold single_valued_def hRAG_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
329 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
330 |
lemma sgv_tRAG: shows "single_valued (tRAG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
331 |
by (unfold tRAG_def, rule Relation.single_valued_relcomp, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
332 |
insert sgv_hRAG sgv_wRAG, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
333 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
334 |
lemma acyclic_hRAG: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
335 |
shows "acyclic (hRAG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
336 |
by (rule acyclic_subset[OF acyclic_RAG[OF vt]], insert RAG_split, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
337 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
338 |
lemma acyclic_wRAG: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
339 |
shows "acyclic (wRAG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
340 |
by (rule acyclic_subset[OF acyclic_RAG[OF vt]], insert RAG_split, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
341 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
342 |
lemma acyclic_tRAG: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
343 |
shows "acyclic (tRAG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
344 |
by (unfold tRAG_def, rule acyclic_compose[OF acyclic_RAG[OF vt]], |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
345 |
unfold RAG_split, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
346 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
347 |
lemma acyclic_tG: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
348 |
shows "acyclic (tG s)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
349 |
proof(unfold tG_def, rule rel_map_acyclic[OF acyclic_tRAG]) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
350 |
show "inj_on the_thread (Domain (tRAG s) \<union> Range (tRAG s))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
351 |
proof(rule subset_inj_on) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
352 |
show " inj_on the_thread {Th th |th. True}" by (unfold inj_on_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
353 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
354 |
from domain_tRAG range_tRAG |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
355 |
show " Domain (tRAG s) \<union> Range (tRAG s) \<subseteq> {Th th |th. True}" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
356 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
357 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
358 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
359 |
end |