author | Christian Urban <urbanc@in.tum.de> |
Fri, 23 Jun 2017 00:27:16 +0100 | |
changeset 178 | da27bece9575 |
parent 138 | 20c1d3a14143 |
child 197 | ca4ddf26a7c7 |
permissions | -rw-r--r-- |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1 |
theory RTree |
131
6a7a8c51d42f
unified Rtree.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
2 |
imports "~~/src/HOL/Library/Transitive_Closure_Table" |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
3 |
begin |
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 |
section {* A theory of relational trees *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
6 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
7 |
inductive_cases path_nilE [elim!]: "rtrancl_path r x [] y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
8 |
inductive_cases path_consE [elim!]: "rtrancl_path r x (z#zs) y" |
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 |
subsection {* Definitions *} |
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 |
text {* |
58 | 13 |
In this theory, we are going to give a notion of of `Relational Graph` and |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
14 |
its derived notion `Relational Tree`. Given a binary relation @{text "r"}, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
15 |
the `Relational Graph of @{text "r"}` is the graph, the edges of which |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
16 |
are those in @{text "r"}. In this way, any binary relation can be viewed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
17 |
as a `Relational Graph`. Note, this notion of graph includes infinite graphs. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
18 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
19 |
A `Relation Graph` @{text "r"} is said to be a `Relational Tree` if it is both |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
20 |
{\em single valued} and {\em acyclic}. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
21 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
22 |
|
131
6a7a8c51d42f
unified Rtree.
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
127
diff
changeset
|
23 |
|
134
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
24 |
locale forest = |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
25 |
fixes r |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
26 |
assumes sgv: "single_valued r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
27 |
assumes acl: "acyclic r" |
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 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
30 |
The following two auxiliary functions @{text "rel_of"} and @{text "pred_of"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
31 |
transfer between the predicate and set representation of binary relations. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
32 |
*} |
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 |
definition "rel_of r = {(x, y) | x y. r x y}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
35 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
36 |
definition "pred_of r = (\<lambda> x y. (x, y) \<in> r)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
37 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
38 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
39 |
|
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
40 |
To reason about {\em Relational Graph}, a notion of path is needed, |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
41 |
which is given by the following @{text "rpath"} (short for |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
42 |
`relational path`). The path @{text "xs"} in proposition @{text |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
43 |
"rpath r x xs y"} is a path leading from @{text "x"} to @{text "y"}, |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
44 |
which serves as a witness of the fact @{text "(x, y) \<in> r^*"}. |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
45 |
|
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
46 |
@{text "rpath"} is simply a wrapper of the @{text "rtrancl_path"} |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
47 |
defined in the imported theory @{text "Transitive_Closure_Table"}, |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
48 |
which defines a notion of path for the predicate form of binary |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
49 |
relations. *} |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
50 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
51 |
definition "rpath r x xs y = rtrancl_path (pred_of r) x xs y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
52 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
53 |
text {* |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
54 |
|
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
55 |
Given a path @{text "ps"}, @{text "edges_on ps"} is the set of edges |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
56 |
along the path, which is defined as follows: *} |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
57 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
58 |
definition "edges_on ps = {(a,b) | a b. \<exists> xs ys. ps = xs@[a,b]@ys}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
59 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
60 |
text {* |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
61 |
|
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
62 |
The following @{text "indep"} defines a notion of independence. |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
63 |
Two nodes @{text "x"} and @{text "y"} are said to be independent |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
64 |
(expressed as @{text "indep x y"}), if neither one is reachable |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
65 |
from the other in relational graph @{text "r"}. *} |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
66 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
67 |
definition "indep r x y = (((x, y) \<notin> r^*) \<and> ((y, x) \<notin> r^*))" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
68 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
69 |
text {* |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
70 |
|
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
71 |
In relational tree @{text "r"}, the sub tree of node @{text "x"} is |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
72 |
written @{text "subtree r x"}, which is defined to be the set of |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
73 |
nodes (including itself) which can reach @{text "x"} by following |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
74 |
some path in @{text "r"}: *} |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
75 |
|
137
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
76 |
definition "subtree r x = {y . (y, x) \<in> r^*}" |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
77 |
|
137
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
78 |
definition "ancestors r x = {y. (x, y) \<in> r^+}" |
58 | 79 |
|
138
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
80 |
(* tmp *) |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
81 |
definition |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
82 |
"nancestors r x \<equiv> ancestors r x \<union> {x}" |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
83 |
|
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
84 |
lemma nancestors_def2: |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
85 |
"nancestors r x \<equiv> {y. (x, y) \<in> r\<^sup>*}" |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
86 |
unfolding nancestors_def |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
87 |
apply(auto) |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
88 |
by (smt Collect_cong ancestors_def insert_compr mem_Collect_eq rtrancl_eq_or_trancl) |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
89 |
|
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
90 |
lemma nancestors2: |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
91 |
"y \<in> ancestors r x \<Longrightarrow> y \<in> nancestors r x" |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
92 |
apply(auto simp add: nancestors_def) |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
93 |
done |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
94 |
|
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
95 |
lemma nancestors3: |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
96 |
"\<lbrakk>y \<in> nancestors r x; x \<noteq> y\<rbrakk> \<Longrightarrow> y \<in> ancestors r x" |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
97 |
apply(auto simp add: nancestors_def) |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
98 |
done |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
99 |
(* end tmp *) |
20c1d3a14143
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
137
diff
changeset
|
100 |
|
58 | 101 |
definition "root r x = (ancestors r x = {})" |
102 |
||
137
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
103 |
lemma root_indep: |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
104 |
assumes "root r x" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
105 |
and "root r y" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
106 |
and "y \<noteq> x" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
107 |
shows "indep r x y" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
108 |
proof - |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
109 |
{ assume "(x, y) \<in> r^*" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
110 |
hence False using assms |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
111 |
by (unfold root_def ancestors_def, auto dest:tranclD rtranclD) |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
112 |
} moreover { |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
113 |
assume "(y, x) \<in> r^*" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
114 |
hence False using assms |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
115 |
by (unfold root_def ancestors_def, auto dest:tranclD rtranclD) |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
116 |
} ultimately show ?thesis by (auto simp:indep_def) |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
117 |
qed |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
118 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
119 |
text {* |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
120 |
|
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
121 |
The following @{text "edge_in r x"} is the set of edges contained in |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
122 |
the sub-tree of @{text "x"}, with @{text "r"} as the underlying |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
123 |
graph. *} |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
124 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
125 |
definition "edges_in r x = {(a, b) | a b. (a, b) \<in> r \<and> b \<in> subtree r x}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
126 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
127 |
text {* |
126
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
128 |
|
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
129 |
The following lemma @{text "edges_in_meaning"} shows the intuitive |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
130 |
meaning of `an edge @{text "(a, b)"} is in the sub-tree of @{text |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
131 |
"x"}`, i.e., both @{text "a"} and @{text "b"} are in the sub-tree. |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
132 |
*} |
a88af0e4731f
minor update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
125
diff
changeset
|
133 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
134 |
lemma edges_in_meaning: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
135 |
"edges_in r x = {(a, b) | a b. (a, b) \<in> r \<and> a \<in> subtree r x \<and> b \<in> subtree r x}" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
136 |
by (auto simp:edges_in_def subtree_def) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
137 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
138 |
text {* |
58 | 139 |
The following lemma shows the meaning of @{term "edges_in"} from the other side, |
140 |
which says: for the edge @{text "(a,b)"} to be outside of the sub-tree of @{text "x"}, |
|
141 |
it is sufficient to show that @{text "b"} is. |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
142 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
143 |
lemma edges_in_refutation: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
144 |
assumes "b \<notin> subtree r x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
145 |
shows "(a, b) \<notin> edges_in r x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
146 |
using assms by (unfold edges_in_def subtree_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
147 |
|
137
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
148 |
definition "children r x = {y. (y, x) \<in> r}" |
58 | 149 |
|
134
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
150 |
locale fforest = forest + |
133
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
151 |
assumes fb: "finite (children r x)" |
132
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
152 |
assumes wf: "wf r" |
62 | 153 |
begin |
154 |
||
155 |
lemma finite_children: "finite (children r x)" |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
156 |
using fb by (cases "children r x = {}", auto simp:children_def) |
62 | 157 |
|
158 |
end |
|
58 | 159 |
|
160 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
161 |
subsection {* Auxiliary lemmas *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
162 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
163 |
lemma index_minimize: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
164 |
assumes "P (i::nat)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
165 |
obtains j where "P j" and "\<forall> k < j. \<not> P k" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
166 |
using assms |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
167 |
by (induct i rule:less_induct, auto) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
168 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
169 |
subsection {* Properties of Relational Graphs and Relational Trees *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
170 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
171 |
subsubsection {* Properties of @{text "rel_of"} and @{text "pred_of"} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
172 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
173 |
text {* The following lemmas establish bijectivity of the two functions *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
174 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
175 |
lemma pred_rel_eq: "pred_of (rel_of r) = r" by (auto simp:rel_of_def pred_of_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
176 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
177 |
lemma rel_pred_eq: "rel_of (pred_of r) = r" by (auto simp:rel_of_def pred_of_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
178 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
179 |
lemma rel_of_star: "rel_of (r^**) = (rel_of r)^*" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
180 |
by (unfold rel_of_def rtranclp_rtrancl_eq, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
181 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
182 |
lemma pred_of_star: "pred_of (r^*) = (pred_of r)^**" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
183 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
184 |
{ fix x y |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
185 |
have "pred_of (r^*) x y = (pred_of r)^** x y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
186 |
by (unfold pred_of_def rtranclp_rtrancl_eq, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
187 |
} thus ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
188 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
189 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
190 |
lemma star_2_pstar: "(x, y) \<in> r^* = (pred_of (r^*)) x y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
191 |
by (simp add: pred_of_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
192 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
193 |
subsubsection {* Properties of @{text "rpath"} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
194 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
195 |
text {* Induction rule for @{text "rpath"}: *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
196 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
197 |
lemma rpath_induct [consumes 1, case_names rbase rstep, induct pred: rpath]: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
198 |
assumes "rpath r x1 x2 x3" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
199 |
and "\<And>x. P x [] x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
200 |
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" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
201 |
shows "P x1 x2 x3" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
202 |
using assms[unfolded rpath_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
203 |
by (induct, auto simp:pred_of_def rpath_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
204 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
205 |
lemma rpathE [elim]: |
58 | 206 |
assumes "rpath r x xs y" |
207 |
obtains (base) "y = x" "xs = []" |
|
208 |
| (step) z zs where "(x, z) \<in> r" "rpath r z zs y" "xs = z#zs" |
|
209 |
using assms |
|
210 |
by (induct, auto) |
|
211 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
212 |
text {* Introduction rule for empty path *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
213 |
lemma rbaseI [intro!]: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
214 |
assumes "x = y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
215 |
shows "rpath r x [] y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
216 |
by (unfold rpath_def assms, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
217 |
rule Transitive_Closure_Table.rtrancl_path.base) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
218 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
219 |
text {* Introduction rule for non-empty path *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
220 |
lemma rstepI [intro!]: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
221 |
assumes "(x, y) \<in> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
222 |
and "rpath r y ys z" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
223 |
shows "rpath r x (y#ys) z" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
224 |
proof(unfold rpath_def, rule Transitive_Closure_Table.rtrancl_path.step) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
225 |
from assms(1) show "pred_of r x y" by (auto simp:pred_of_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
226 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
227 |
from assms(2) show "rtrancl_path (pred_of r) y ys z" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
228 |
by (auto simp:pred_of_def rpath_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
229 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
230 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
231 |
lemma rpath_stepI'[intro, simp]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
232 |
assumes "rpath r x xs y" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
233 |
and "(y, z) \<in> r" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
234 |
shows "rpath r x (xs@[z]) z" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
235 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
236 |
by (induct, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
237 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
238 |
text {* Introduction rule for @{text "@"}-path *} |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
239 |
lemma rpath_appendI [intro,simp]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
240 |
assumes "rpath r x xs a" and "rpath r a ys y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
241 |
shows "rpath r x (xs @ ys) y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
242 |
using assms |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
243 |
by (unfold rpath_def, auto intro:rtrancl_path_trans) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
244 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
245 |
text {* Elimination rule for empty path *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
246 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
247 |
lemma rpath_cases [cases pred:rpath,elim]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
248 |
assumes "rpath r a1 a2 a3" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
249 |
obtains (rbase) "a1 = a3" and "a2 = []" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
250 |
| (rstep) y :: "'a" and ys :: "'a list" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
251 |
where "(a1, y) \<in> r" and "a2 = y # ys" and "rpath r y ys a3" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
252 |
using assms [unfolded rpath_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
253 |
by (cases, auto simp:rpath_def pred_of_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
254 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
255 |
lemma rpath_nilE [elim!, cases pred:rpath]: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
256 |
assumes "rpath r x [] y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
257 |
obtains "y = x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
258 |
using assms[unfolded rpath_def] by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
259 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
260 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
261 |
Elimination rule for non-empty paths constructed with @{text "#"}. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
262 |
*} |
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 |
lemma rpath_ConsE [elim!, cases pred:rpath]: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
265 |
assumes "rpath r x (y # ys) x2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
266 |
obtains (rstep) "(x, y) \<in> r" and "rpath r y ys x2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
267 |
using assms[unfolded rpath_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
268 |
by (cases, auto simp:rpath_def pred_of_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
269 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
270 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
271 |
Elimination rule for non-empty path, where the destination node |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
272 |
@{text "y"} is shown to be at the end of the path. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
273 |
*} |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
274 |
lemma rpath_nnl_lastE [elim]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
275 |
assumes "rpath r x xs y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
276 |
and "xs \<noteq> []" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
277 |
obtains xs' where "xs = xs'@[y]" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
278 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
279 |
proof(induct) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
280 |
case (rstep x y ys z) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
281 |
thus ?case by (cases ys, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
282 |
qed auto |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
283 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
284 |
text {* Other elimination rules of @{text "rpath"} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
285 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
286 |
lemma rpath_appendE [elim]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
287 |
assumes "rpath r x (xs @ [a] @ ys) y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
288 |
obtains "rpath r x (xs @ [a]) a" and "rpath r a ys y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
289 |
using rtrancl_path_appendE[OF assms[unfolded rpath_def, simplified], folded rpath_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
290 |
by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
291 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
292 |
lemma rpath_subE [elim]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
293 |
assumes "rpath r x (xs @ [a] @ ys @ [b] @ zs) y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
294 |
obtains "rpath r x (xs @ [a]) a" and "rpath r a (ys @ [b]) b" and "rpath r b zs y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
295 |
using assms |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
296 |
by (elim rpath_appendE, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
297 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
298 |
text {* Every path has a unique end point. *} |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
299 |
lemma rpath_dest_eq [simp]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
300 |
assumes "rpath r x xs x1" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
301 |
and "rpath r x xs x2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
302 |
shows "x1 = x2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
303 |
using assms |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
304 |
by (induct, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
305 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
306 |
lemma rpath_dest_eq_simp[simp]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
307 |
assumes "rpath r x xs1 x1" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
308 |
and "rpath r x xs2 x2" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
309 |
and "xs1 = xs2" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
310 |
shows "x1 = x2" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
311 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
312 |
by (induct, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
313 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
314 |
subsubsection {* Properites of @{text "edges_on"} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
315 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
316 |
lemma edge_on_headI[simp, intro]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
317 |
assumes "(a, b) = (a', b')" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
318 |
shows "(a, b) \<in> edges_on (a' # b' # xs)" |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
319 |
using assms |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
320 |
by (unfold edges_on_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
321 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
322 |
lemma edges_on_ConsI[intro]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
323 |
assumes "(a, b) \<in> edges_on xs" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
324 |
shows "(a, b) \<in> edges_on (x#xs)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
325 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
326 |
apply (unfold edges_on_def, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
327 |
by (meson Cons_eq_appendI) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
328 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
329 |
lemma edges_on_appendI1[intro]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
330 |
assumes "(a, b) \<in> edges_on xs" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
331 |
shows "(a, b) \<in> edges_on (xs'@xs)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
332 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
333 |
apply (unfold edges_on_def, auto simp:append_assoc) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
334 |
by (metis append_assoc) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
335 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
336 |
lemma edges_on_appendI2[intro]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
337 |
assumes "(a, b) \<in> edges_on xs" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
338 |
shows "(a, b) \<in> edges_on (xs@xs')" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
339 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
340 |
apply (unfold edges_on_def, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
341 |
by metis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
342 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
343 |
lemma edges_onE [elim]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
344 |
assumes "(a, b) \<in> edges_on xs" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
345 |
obtains a' b' xs' where "(a,b) = (a', b')" "xs = a'#b'#xs'" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
346 |
| a' b' xs' where "(a,b) \<noteq> (a', b')" "xs = a'#b'#xs'" "(a,b) \<in> edges_on (b'#xs')" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
347 |
proof(cases xs) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
348 |
case Nil |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
349 |
with assms show ?thesis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
350 |
by (unfold edges_on_def, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
351 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
352 |
case cs1: (Cons a' xsa) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
353 |
show ?thesis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
354 |
proof(cases xsa) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
355 |
case Nil |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
356 |
with cs1 and assms show ?thesis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
357 |
by (unfold edges_on_def, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
358 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
359 |
case (Cons b' xsb) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
360 |
show ?thesis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
361 |
proof(cases "(a,b) = (a', b')") |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
362 |
case True |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
363 |
with cs1 Cons show ?thesis using that by metis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
364 |
next |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
365 |
case False |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
366 |
from assms[unfolded cs1 Cons edges_on_def] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
367 |
obtain xs1 ys1 where "a' # b' # xsb = xs1 @ [a, b] @ ys1" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
368 |
moreover with False obtain c xsc where "xs1 = Cons c xsc" by (cases xs1, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
369 |
ultimately have h: "b' # xsb = xsc @ [a, b] @ ys1" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
370 |
show ?thesis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
371 |
apply (rule that(2)[OF False], insert cs1 Cons, simp) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
372 |
using h by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
373 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
374 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
375 |
qed |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
376 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
377 |
lemma edges_on_nil [simp]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
378 |
"edges_on [] = {}" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
379 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
380 |
lemma edges_on_single [simp]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
381 |
"edges_on [a] = {}" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
382 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
383 |
lemma edges_on_unfold [simp]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
384 |
"edges_on (a # b # xs) = {(a, b)} \<union> edges_on (b # xs)" (is "?L = ?R") |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
385 |
by (auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
386 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
387 |
lemma edges_on_len: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
388 |
assumes "x \<in> edges_on l" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
389 |
shows "2 \<le> length l" using assms by (cases x, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
390 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
391 |
text {* Elimination of @{text "edges_on"} for non-empty path *} |
58 | 392 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
393 |
lemma edges_on_consE [elim!, cases set:edges_on]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
394 |
assumes "(a,b) \<in> edges_on (x#xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
395 |
obtains (head) xs' where "x = a" and "xs = b#xs'" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
396 |
| (tail) "(a,b) \<in> edges_on xs" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
397 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
398 |
by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
399 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
400 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
401 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
402 |
Every edges on the path is a graph edges: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
403 |
*} |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
404 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
405 |
lemma rpath_edges_on [intro]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
406 |
assumes "rpath r x xs y" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
407 |
shows "edges_on (x#xs) \<subseteq> r" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
408 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
409 |
by (induct arbitrary:y, auto) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
410 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
411 |
text {* @{text "edges_on"} is mono with respect to @{text "#"}-operation: *} |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
412 |
lemma edges_on_Cons_mono [intro,simp]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
413 |
shows "edges_on xs \<subseteq> edges_on (x#xs)" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
414 |
by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
415 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
416 |
lemma edges_on_append_mono [intro,simp]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
417 |
shows "edges_on xs \<subseteq> edges_on (xs'@xs)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
418 |
by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
419 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
420 |
lemma edges_on_append_mono' [intro,simp]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
421 |
shows "edges_on xs \<subseteq> edges_on (xs@xs')" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
422 |
by auto |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
423 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
424 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
425 |
The following rule @{text "rpath_transfer"} is used to show |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
426 |
that one path is intact as long as all the edges on it are intact |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
427 |
with the change of graph. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
428 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
429 |
If @{text "x#xs"} is path in graph @{text "r1"} and |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
430 |
every edges along the path is also in @{text "r2"}, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
431 |
then @{text "x#xs"} is also a edge in graph @{text "r2"}: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
432 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
433 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
434 |
lemma rpath_transfer[intro]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
435 |
assumes "rpath r1 x xs y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
436 |
and "edges_on (x#xs) \<subseteq> r2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
437 |
shows "rpath r2 x xs y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
438 |
using assms |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
439 |
by (induct, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
440 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
441 |
lemma edges_on_rpathI[intro, simp]: |
58 | 442 |
assumes "edges_on (a#xs@[b]) \<subseteq> r" |
443 |
shows "rpath r a (xs@[b]) b" |
|
444 |
using assms |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
445 |
by (induct xs arbitrary: a b, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
446 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
447 |
lemma list_nnl_appendE [elim]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
448 |
assumes "xs \<noteq> []" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
449 |
obtains x xs' where "xs = xs'@[x]" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
450 |
by (insert assms, rule rev_exhaust, fastforce) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
451 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
452 |
lemma edges_on_rpathI' [intro]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
453 |
assumes "edges_on (a#xs) \<subseteq> r" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
454 |
and "xs \<noteq> []" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
455 |
and "last xs = b" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
456 |
shows "rpath r a xs b" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
457 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
458 |
obtain xs' where "xs = xs'@[b]" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
459 |
using assms by fastforce |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
460 |
with assms show ?thesis by fastforce |
58 | 461 |
qed |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
462 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
463 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
464 |
The following lemma extracts the path from @{text "x"} to @{text "y"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
465 |
from proposition @{text "(x, y) \<in> r^*"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
466 |
*} |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
467 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
468 |
lemma star_rpath [elim]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
469 |
assumes "(x, y) \<in> r^*" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
470 |
obtains xs where "rpath r x xs y" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
471 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
472 |
by (induct, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
473 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
474 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
475 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
476 |
The following lemma uses the path @{text "xs"} from @{text "x"} to @{text "y"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
477 |
as a witness to show @{text "(x, y) \<in> r^*"}. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
478 |
*} |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
479 |
lemma rpath_star [simp]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
480 |
assumes "rpath r x xs y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
481 |
shows "(x, y) \<in> r^*" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
482 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
483 |
from iffD2[OF rtranclp_eq_rtrancl_path] and assms[unfolded rpath_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
484 |
have "(pred_of r)\<^sup>*\<^sup>* x y" by metis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
485 |
thus ?thesis by (simp add: pred_of_star star_2_pstar) |
60 | 486 |
qed |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
487 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
488 |
declare rpath_star[elim_format] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
489 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
490 |
lemma rpath_transfer' [intro]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
491 |
assumes "rpath r1 x xs y" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
492 |
and "r1 \<subseteq> r2" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
493 |
shows "rpath r2 x xs y" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
494 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
495 |
by (induct, auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
496 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
497 |
lemma subtree_transfer[intro]: |
58 | 498 |
assumes "a \<in> subtree r1 a'" |
499 |
and "r1 \<subseteq> r2" |
|
500 |
shows "a \<in> subtree r2 a'" |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
501 |
using assms |
58 | 502 |
proof - |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
503 |
from assms(1) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
504 |
obtain xs where h1: "rpath r1 a xs a'" by (auto simp:subtree_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
505 |
show ?thesis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
506 |
proof - |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
507 |
from rpath_star[OF h1] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
508 |
have "(a, a') \<in> r1\<^sup>*" . |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
509 |
with assms(2) have "(a, a') \<in> r2\<^sup>*" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
510 |
using rtrancl_mono subsetCE by blast |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
511 |
thus ?thesis by (auto simp:subtree_def) |
58 | 512 |
qed |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
513 |
qed |
58 | 514 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
515 |
text {* |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
516 |
@{text "subtree"} is mono with respect to the underlying graph. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
517 |
*} |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
518 |
lemma subtree_mono[intro]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
519 |
assumes "r1 \<subseteq> r2" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
520 |
shows "subtree r1 x \<subseteq> subtree r2 x" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
521 |
using assms by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
522 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
523 |
lemma subtree_rev_transfer[intro]: |
58 | 524 |
assumes "a \<notin> subtree r2 a'" |
525 |
and "r1 \<subseteq> r2" |
|
526 |
shows "a \<notin> subtree r1 a'" |
|
527 |
using assms and subtree_transfer by metis |
|
528 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
529 |
text {* |
58 | 530 |
The following lemmas establishes a relation from paths in @{text "r"} |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
531 |
to @{text "r^+"} relation. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
532 |
*} |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
533 |
lemma rpath_plus[simp]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
534 |
assumes "rpath r x xs y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
535 |
and "xs \<noteq> []" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
536 |
shows "(x, y) \<in> r^+" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
537 |
using assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
538 |
by (induct, simp) fastforce |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
539 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
540 |
lemma plus_rpath [elim]: |
58 | 541 |
assumes "(x, y) \<in> r^+" |
542 |
obtains xs where "rpath r x xs y" and "xs \<noteq> []" |
|
543 |
proof - |
|
544 |
from assms |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
545 |
have "\<exists> xs. rpath r x xs y \<and> xs \<noteq> []" by (induct; auto) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
546 |
with that show ?thesis by metis |
58 | 547 |
qed |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
548 |
|
58 | 549 |
subsubsection {* Properties of @{text "subtree"} and @{term "ancestors"}*} |
550 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
551 |
lemma ancestors_subtreeI [intro, dest]: |
58 | 552 |
assumes "b \<in> ancestors r a" |
553 |
shows "a \<in> subtree r b" |
|
554 |
using assms by (auto simp:subtree_def ancestors_def) |
|
555 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
556 |
lemma ancestors_Field[elim]: |
60 | 557 |
assumes "b \<in> ancestors r a" |
558 |
obtains "a \<in> Domain r" "b \<in> Range r" |
|
559 |
using assms |
|
560 |
apply (unfold ancestors_def, simp) |
|
561 |
by (metis Domain.DomainI Range.intros trancl_domain trancl_range) |
|
562 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
563 |
lemma subtreeE [elim]: |
58 | 564 |
assumes "a \<in> subtree r b" |
565 |
obtains "a = b" |
|
566 |
| "a \<noteq> b" and "b \<in> ancestors r a" |
|
567 |
proof - |
|
568 |
from assms have "(a, b) \<in> r^*" by (auto simp:subtree_def) |
|
569 |
from rtranclD[OF this] |
|
570 |
have " a = b \<or> a \<noteq> b \<and> (a, b) \<in> r\<^sup>+" . |
|
571 |
with that[unfolded ancestors_def] show ?thesis by auto |
|
572 |
qed |
|
573 |
||
63 | 574 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
575 |
lemma subtree_Field [simp, iff]: |
63 | 576 |
"subtree r x \<subseteq> Field r \<union> {x}" |
577 |
proof |
|
578 |
fix y |
|
579 |
assume "y \<in> subtree r x" |
|
580 |
thus "y \<in> Field r \<union> {x}" |
|
581 |
proof(cases rule:subtreeE) |
|
582 |
case 1 |
|
583 |
thus ?thesis by auto |
|
584 |
next |
|
585 |
case 2 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
586 |
thus ?thesis |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
587 |
by (unfold Field_def, fast) |
63 | 588 |
qed |
589 |
qed |
|
590 |
||
58 | 591 |
lemma subtree_ancestorsI: |
592 |
assumes "a \<in> subtree r b" |
|
593 |
and "a \<noteq> b" |
|
594 |
shows "b \<in> ancestors r a" |
|
595 |
using assms |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
596 |
by auto |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
597 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
598 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
599 |
The following lemma characterizes the change of sub-tree of @{text "x"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
600 |
with the removal of an outside edge @{text "(a,b)"}. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
601 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
602 |
Note that, according to lemma @{thm edges_in_refutation}, the assumption |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
603 |
@{term "b \<notin> subtree r x"} amounts to saying @{text "(a, b)"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
604 |
is outside the sub-tree of @{text "x"}. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
605 |
*} |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
606 |
lemma subtree_del_outside [simp,intro]: (* ddd *) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
607 |
assumes "b \<notin> subtree r x" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
608 |
shows "subtree (r - {(a, b)}) x = (subtree r x)" (is "?L = ?R") |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
609 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
610 |
{ fix c |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
611 |
assume "c \<in> ?R" |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
612 |
hence "(c, x) \<in> r^*" by (auto simp:subtree_def) |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
613 |
hence "c \<in> ?L" |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
614 |
proof(rule star_rpath) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
615 |
fix xs |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
616 |
assume rp: "rpath r c xs x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
617 |
show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
618 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
619 |
from rp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
620 |
have "rpath (r - {(a, b)}) c xs x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
621 |
proof(rule rpath_transfer) |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
622 |
from rp have "edges_on (c # xs) \<subseteq> r" .. |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
623 |
moreover have "(a, b) \<notin> edges_on (c#xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
624 |
proof |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
625 |
assume "(a, b) \<in> edges_on (c # xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
626 |
then obtain l1 l2 where h: "c#xs = l1@[a,b]@l2" by (auto simp:edges_on_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
627 |
hence "tl (c#xs) = tl (l1@[a,b]@l2)" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
628 |
then obtain l1' where eq_xs_b: "xs = l1'@[b]@l2" by (cases l1, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
629 |
from rp[unfolded this] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
630 |
show False |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
631 |
by (rule rpath_appendE, insert assms(1), auto simp:subtree_def) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
632 |
qed |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
633 |
ultimately show "edges_on (c # xs) \<subseteq> (r - {(a, b)})" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
634 |
by (auto) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
635 |
qed |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
636 |
thus ?thesis by (auto simp:subtree_def) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
637 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
638 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
639 |
} moreover { |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
640 |
fix c |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
641 |
assume "c \<in> ?L" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
642 |
moreover have "... \<subseteq> (subtree r x)" by auto |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
643 |
ultimately have "c \<in> ?R" by auto |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
644 |
} ultimately show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
645 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
646 |
|
58 | 647 |
(* ddd *) |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
648 |
lemma subset_del_subtree_outside [simp, intro]: (* ddd *) |
58 | 649 |
assumes "Range r' \<inter> subtree r x = {}" |
650 |
shows "subtree (r - r') x = (subtree r x)" |
|
651 |
proof - |
|
652 |
{ fix c |
|
653 |
assume "c \<in> (subtree r x)" |
|
654 |
hence "(c, x) \<in> r^*" by (auto simp:subtree_def) |
|
655 |
hence "c \<in> subtree (r - r') x" |
|
656 |
proof(rule star_rpath) |
|
657 |
fix xs |
|
658 |
assume rp: "rpath r c xs x" |
|
659 |
show ?thesis |
|
660 |
proof - |
|
661 |
from rp |
|
662 |
have "rpath (r - r') c xs x" |
|
663 |
proof(rule rpath_transfer) |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
664 |
from rp have "edges_on (c # xs) \<subseteq> r" .. |
58 | 665 |
moreover { |
666 |
fix a b |
|
667 |
assume h: "(a, b) \<in> r'" |
|
668 |
have "(a, b) \<notin> edges_on (c#xs)" |
|
669 |
proof |
|
670 |
assume "(a, b) \<in> edges_on (c # xs)" |
|
671 |
then obtain l1 l2 where "c#xs = (l1@[a])@[b]@l2" by (auto simp:edges_on_def) |
|
672 |
hence "tl (c#xs) = tl (l1@[a,b]@l2)" by simp |
|
673 |
then obtain l1' where eq_xs_b: "xs = l1'@[b]@l2" by (cases l1, auto) |
|
674 |
from rp[unfolded this] |
|
675 |
show False |
|
676 |
proof(rule rpath_appendE) |
|
677 |
assume "rpath r b l2 x" |
|
678 |
from rpath_star[OF this] |
|
679 |
have "b \<in> subtree r x" by (auto simp:subtree_def) |
|
680 |
with assms (1) and h show ?thesis by (auto) |
|
681 |
qed |
|
682 |
qed |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
683 |
} ultimately show "edges_on (c # xs) \<subseteq> (r - r')" by (auto) |
58 | 684 |
qed |
685 |
thus ?thesis by (rule rpath_star[elim_format], auto simp:subtree_def) |
|
686 |
qed |
|
687 |
qed |
|
688 |
} moreover { |
|
689 |
fix c |
|
690 |
assume "c \<in> subtree (r - r') x" |
|
691 |
moreover have "... \<subseteq> (subtree r x)" by (rule subtree_mono, auto) |
|
692 |
ultimately have "c \<in> (subtree r x)" by auto |
|
693 |
} ultimately show ?thesis by auto |
|
694 |
qed |
|
695 |
||
178 | 696 |
lemma subset_insert_subtree_outside [simp, intro]: (* ddd *) |
697 |
assumes "Range r' \<inter> subtree r x = {}" |
|
698 |
shows "subtree (r \<union> r') x = (subtree r x)" (is "?L = ?R") |
|
699 |
proof - |
|
700 |
{ have "?L \<subseteq> ?R" |
|
701 |
proof |
|
702 |
fix y |
|
703 |
assume "y \<in> ?L" |
|
704 |
from this[unfolded subtree_def] have "(y, x) \<in> ( (r \<union> r')^*)" by simp |
|
705 |
thus "y \<in> ?R" |
|
706 |
proof(induct rule:converse_rtrancl_induct) |
|
707 |
case (base) |
|
708 |
show ?case unfolding subtree_def by auto |
|
709 |
next |
|
710 |
case (step x y) |
|
711 |
moreover have "(x, y) \<in> r" |
|
712 |
proof - |
|
713 |
{ assume "(x, y) \<in> r'" |
|
714 |
with assms step(3) |
|
715 |
have False by auto |
|
716 |
} with step(1) show ?thesis by auto |
|
717 |
qed |
|
718 |
ultimately show ?case unfolding subtree_def by auto |
|
719 |
qed |
|
720 |
qed |
|
721 |
} moreover have "?R \<subseteq> ?L" by auto |
|
722 |
ultimately show ?thesis by auto |
|
723 |
qed |
|
724 |
||
725 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
726 |
lemma subtree_insert_ext [simp, intro]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
727 |
assumes "b \<in> subtree r x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
728 |
shows "subtree (r \<union> {(a, b)}) x = (subtree r x) \<union> (subtree r a)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
729 |
using assms by (auto simp:subtree_def rtrancl_insert) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
730 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
731 |
lemma subtree_insert_next [simp, intro]: |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
732 |
assumes "b \<notin> subtree r x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
733 |
shows "subtree (r \<union> {(a, b)}) x = (subtree r x)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
734 |
using assms |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
735 |
by (auto simp:subtree_def rtrancl_insert) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
736 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
737 |
lemma set_add_rootI[simp, intro]: |
58 | 738 |
assumes "root r a" |
739 |
and "a \<notin> Domain r1" |
|
740 |
shows "root (r \<union> r1) a" |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
741 |
using assms |
58 | 742 |
proof - |
743 |
let ?r = "r \<union> r1" |
|
744 |
{ fix a' |
|
745 |
assume "a' \<in> ancestors ?r a" |
|
746 |
hence "(a, a') \<in> ?r^+" by (auto simp:ancestors_def) |
|
747 |
from tranclD[OF this] obtain z where "(a, z) \<in> ?r" by auto |
|
748 |
moreover have "(a, z) \<notin> r" |
|
749 |
proof |
|
750 |
assume "(a, z) \<in> r" |
|
751 |
with assms(1) show False |
|
752 |
by (auto simp:root_def ancestors_def) |
|
753 |
qed |
|
754 |
ultimately have "(a, z) \<in> r1" by auto |
|
755 |
with assms(2) |
|
756 |
have False by (auto) |
|
757 |
} thus ?thesis by (auto simp:root_def) |
|
758 |
qed |
|
759 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
760 |
lemma ancestors_mono [simp]: |
58 | 761 |
assumes "r1 \<subseteq> r2" |
762 |
shows "ancestors r1 x \<subseteq> ancestors r2 x" |
|
763 |
proof |
|
764 |
fix a |
|
765 |
assume "a \<in> ancestors r1 x" |
|
766 |
hence "(x, a) \<in> r1^+" by (auto simp:ancestors_def) |
|
767 |
from plus_rpath[OF this] obtain xs where |
|
768 |
h: "rpath r1 x xs a" "xs \<noteq> []" . |
|
769 |
have "rpath r2 x xs a" |
|
770 |
proof(rule rpath_transfer[OF h(1)]) |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
771 |
from h(1) have "edges_on (x # xs) \<subseteq> r1" .. |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
772 |
also note assms |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
773 |
finally show "edges_on (x # xs) \<subseteq> r2" . |
58 | 774 |
qed |
775 |
from rpath_plus[OF this h(2)] |
|
776 |
show "a \<in> ancestors r2 x" by (auto simp:ancestors_def) |
|
777 |
qed |
|
778 |
||
779 |
lemma subtree_refute: |
|
780 |
assumes "x \<notin> ancestors r y" |
|
781 |
and "x \<noteq> y" |
|
782 |
shows "y \<notin> subtree r x" |
|
783 |
proof |
|
784 |
assume "y \<in> subtree r x" |
|
785 |
thus False |
|
786 |
by(elim subtreeE, insert assms, auto) |
|
787 |
qed |
|
788 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
789 |
subsubsection {* Properties about relational trees *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
790 |
|
134
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
791 |
context forest |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
792 |
begin |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
793 |
|
58 | 794 |
lemma ancestors_headE: |
795 |
assumes "c \<in> ancestors r a" |
|
796 |
assumes "(a, b) \<in> r" |
|
797 |
obtains "b = c" |
|
798 |
| "c \<in> ancestors r b" |
|
799 |
proof - |
|
800 |
from assms(1) |
|
801 |
have "(a, c) \<in> r^+" by (auto simp:ancestors_def) |
|
802 |
hence "b = c \<or> c \<in> ancestors r b" |
|
803 |
proof(cases rule:converse_tranclE[consumes 1]) |
|
804 |
case 1 |
|
805 |
with assms(2) and sgv have "b = c" by (auto simp:single_valued_def) |
|
806 |
thus ?thesis by auto |
|
807 |
next |
|
808 |
case (2 y) |
|
809 |
from 2(1) and assms(2) and sgv have "y = b" by (auto simp:single_valued_def) |
|
810 |
from 2(2)[unfolded this] have "c \<in> ancestors r b" by (auto simp:ancestors_def) |
|
811 |
thus ?thesis by auto |
|
812 |
qed |
|
813 |
with that show ?thesis by metis |
|
814 |
qed |
|
815 |
||
816 |
lemma ancestors_accum: |
|
817 |
assumes "(a, b) \<in> r" |
|
818 |
shows "ancestors r a = ancestors r b \<union> {b}" |
|
819 |
proof - |
|
820 |
{ fix c |
|
821 |
assume "c \<in> ancestors r a" |
|
822 |
hence "(a, c) \<in> r^+" by (auto simp:ancestors_def) |
|
823 |
hence "c \<in> ancestors r b \<union> {b}" |
|
824 |
proof(cases rule:converse_tranclE[consumes 1]) |
|
825 |
case 1 |
|
826 |
with sgv assms have "c = b" by (unfold single_valued_def, auto) |
|
827 |
thus ?thesis by auto |
|
828 |
next |
|
829 |
case (2 c') |
|
830 |
with sgv assms have "c' = b" by (unfold single_valued_def, auto) |
|
831 |
from 2(2)[unfolded this] |
|
832 |
show ?thesis by (auto simp:ancestors_def) |
|
833 |
qed |
|
834 |
} moreover { |
|
835 |
fix c |
|
836 |
assume "c \<in> ancestors r b \<union> {b}" |
|
837 |
hence "c = b \<or> c \<in> ancestors r b" by auto |
|
838 |
hence "c \<in> ancestors r a" |
|
839 |
proof |
|
840 |
assume "c = b" |
|
841 |
from assms[folded this] |
|
842 |
show ?thesis by (auto simp:ancestors_def) |
|
843 |
next |
|
844 |
assume "c \<in> ancestors r b" |
|
845 |
with assms show ?thesis by (auto simp:ancestors_def) |
|
846 |
qed |
|
847 |
} ultimately show ?thesis by auto |
|
848 |
qed |
|
849 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
850 |
lemma rootI [intro]: |
58 | 851 |
assumes h: "\<And> x'. x' \<noteq> x \<Longrightarrow> x \<notin> subtree r' x'" |
852 |
and "r' \<subseteq> r" |
|
853 |
shows "root r' x" |
|
854 |
proof - |
|
855 |
from acyclic_subset[OF acl assms(2)] |
|
856 |
have acl': "acyclic r'" . |
|
857 |
{ fix x' |
|
858 |
assume "x' \<in> ancestors r' x" |
|
859 |
hence h1: "(x, x') \<in> r'^+" by (auto simp:ancestors_def) |
|
860 |
have "x' \<noteq> x" |
|
861 |
proof |
|
862 |
assume eq_x: "x' = x" |
|
863 |
from h1[unfolded this] and acl' |
|
864 |
show False by (auto simp:acyclic_def) |
|
865 |
qed |
|
866 |
moreover from h1 have "x \<in> subtree r' x'" by (auto simp:subtree_def) |
|
867 |
ultimately have False using h by auto |
|
868 |
} thus ?thesis by (auto simp:root_def) |
|
869 |
qed |
|
870 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
871 |
lemma rpath_overlap_oneside [elim]: (* ddd *) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
872 |
assumes "rpath r x xs1 x1" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
873 |
and "rpath r x xs2 x2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
874 |
and "length xs1 \<le> length xs2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
875 |
obtains xs3 where "xs2 = xs1 @ xs3" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
876 |
proof(cases "xs1 = []") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
877 |
case True |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
878 |
with that show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
879 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
880 |
case False |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
881 |
have "\<forall> i \<le> length xs1. take i xs1 = take i xs2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
882 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
883 |
{ assume "\<not> (\<forall> i \<le> length xs1. take i xs1 = take i xs2)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
884 |
then obtain i where "i \<le> length xs1 \<and> take i xs1 \<noteq> take i xs2" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
885 |
from this(1) have "False" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
886 |
proof(rule index_minimize) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
887 |
fix j |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
888 |
assume h1: "j \<le> length xs1 \<and> take j xs1 \<noteq> take j xs2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
889 |
and h2: " \<forall>k<j. \<not> (k \<le> length xs1 \<and> take k xs1 \<noteq> take k xs2)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
890 |
-- {* @{text "j - 1"} is the branch point between @{text "xs1"} and @{text "xs2"} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
891 |
let ?idx = "j - 1" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
892 |
-- {* A number of inequalities concerning @{text "j - 1"} are derived first *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
893 |
have lt_i: "?idx < length xs1" using False h1 |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
894 |
by (metis Suc_diff_1 le_neq_implies_less length_greater_0_conv lessI less_imp_diff_less) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
895 |
have lt_i': "?idx < length xs2" using lt_i and assms(3) by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
896 |
have lt_j: "?idx < j" using h1 by (cases j, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
897 |
-- {* From thesis inequalities, a number of equations concerning @{text "xs1"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
898 |
and @{text "xs2"} are derived *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
899 |
have eq_take: "take ?idx xs1 = take ?idx xs2" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
900 |
using h2[rule_format, OF lt_j] and h1 by linarith |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
901 |
have eq_xs1: " xs1 = take ?idx xs1 @ xs1 ! (?idx) # drop (Suc (?idx)) xs1" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
902 |
using id_take_nth_drop[OF lt_i] . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
903 |
have eq_xs2: "xs2 = take ?idx xs2 @ xs2 ! (?idx) # drop (Suc (?idx)) xs2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
904 |
using id_take_nth_drop[OF lt_i'] . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
905 |
-- {* The branch point along the path is finally pinpointed *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
906 |
have neq_idx: "xs1!?idx \<noteq> xs2!?idx" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
907 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
908 |
have "take j xs1 = take ?idx xs1 @ [xs1 ! ?idx]" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
909 |
using eq_xs1 Suc_diff_1 lt_i lt_j take_Suc_conv_app_nth by fastforce |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
910 |
moreover have eq_tk2: "take j xs2 = take ?idx xs2 @ [xs2 ! ?idx]" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
911 |
using Suc_diff_1 lt_i' lt_j take_Suc_conv_app_nth by fastforce |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
912 |
ultimately show ?thesis using eq_take h1 by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
913 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
914 |
show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
915 |
proof(cases " take (j - 1) xs1 = []") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
916 |
case True |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
917 |
have "(x, xs1!?idx) \<in> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
918 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
919 |
from eq_xs1[unfolded True, simplified, symmetric] assms(1) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
920 |
have "rpath r x ( xs1 ! ?idx # drop (Suc ?idx) xs1) x1" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
921 |
from this[unfolded rpath_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
922 |
show ?thesis by (auto simp:pred_of_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
923 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
924 |
moreover have "(x, xs2!?idx) \<in> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
925 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
926 |
from eq_xs2[folded eq_take, unfolded True, simplified, symmetric] assms(2) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
927 |
have "rpath r x ( xs2 ! ?idx # drop (Suc ?idx) xs2) x2" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
928 |
from this[unfolded rpath_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
929 |
show ?thesis by (auto simp:pred_of_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
930 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
931 |
ultimately show ?thesis using neq_idx sgv[unfolded single_valued_def] by metis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
932 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
933 |
case False |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
934 |
then obtain e es where eq_es: "take ?idx xs1 = es@[e]" by fast |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
935 |
have "(e, xs1!?idx) \<in> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
936 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
937 |
from eq_xs1[unfolded eq_es] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
938 |
have "xs1 = es@[e, xs1!?idx]@drop (Suc ?idx) xs1" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
939 |
hence "(e, xs1!?idx) \<in> edges_on xs1" by (simp add:edges_on_def, metis) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
940 |
with rpath_edges_on[OF assms(1)] edges_on_Cons_mono[of xs1 x] |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
941 |
show ?thesis by (auto) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
942 |
qed moreover have "(e, xs2!?idx) \<in> r" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
943 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
944 |
from eq_xs2[folded eq_take, unfolded eq_es] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
945 |
have "xs2 = es@[e, xs2!?idx]@drop (Suc ?idx) xs2" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
946 |
hence "(e, xs2!?idx) \<in> edges_on xs2" by (simp add:edges_on_def, metis) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
947 |
with rpath_edges_on[OF assms(2)] edges_on_Cons_mono[of xs2 x] |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
948 |
show ?thesis by (auto) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
949 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
950 |
ultimately show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
951 |
using sgv[unfolded single_valued_def] neq_idx by metis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
952 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
953 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
954 |
} thus ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
955 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
956 |
from this[rule_format, of "length xs1"] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
957 |
have "take (length xs1) xs1 = take (length xs1) xs2" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
958 |
moreover have "xs2 = take (length xs1) xs2 @ drop (length xs1) xs2" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
959 |
ultimately have "xs2 = xs1 @ drop (length xs1) xs2" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
960 |
from that[OF this] show ?thesis . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
961 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
962 |
|
80
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
963 |
lemma rpath_overlap_oneside': |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
964 |
assumes "rpath r x xs1 x1" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
965 |
and "rpath r x xs2 x2" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
966 |
and "length xs1 \<le> length xs2" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
967 |
obtains xs3 where |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
968 |
"xs2 = xs1 @ xs3" "rpath r x xs1 x1" "rpath r x1 xs3 x2" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
969 |
proof - |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
970 |
from rpath_overlap_oneside[OF assms] |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
971 |
obtain xs3 where eq_xs: "xs2 = xs1 @ xs3" by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
972 |
show ?thesis |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
973 |
proof(cases "xs1 = []") |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
974 |
case True |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
975 |
from rpath_nilE[OF assms(1)[unfolded this]] |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
976 |
have eq_x1: "x1 = x" . |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
977 |
have "xs2 = xs3" using True eq_xs by simp |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
978 |
from that[OF eq_xs assms(1) assms(2)[folded eq_x1, unfolded this]] |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
979 |
show ?thesis . |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
980 |
next |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
981 |
case False |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
982 |
from rpath_nnl_lastE[OF assms(1) False] |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
983 |
obtain xs' where eq_xs1: "xs1 = xs'@[x1]" by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
984 |
from assms(2)[unfolded eq_xs this] |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
985 |
have "rpath r x (xs' @ [x1] @ xs3) x2" by simp |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
986 |
from rpath_appendE[OF this] |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
987 |
have "rpath r x (xs' @ [x1]) x1" "rpath r x1 xs3 x2" by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
988 |
from that [OF eq_xs this(1)[folded eq_xs1] this(2)] |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
989 |
show ?thesis . |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
990 |
qed |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
991 |
qed |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
992 |
|
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
993 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
994 |
lemma rpath_overlap [consumes 2, cases pred:rpath]: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
995 |
assumes "rpath r x xs1 x1" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
996 |
and "rpath r x xs2 x2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
997 |
obtains (less_1) xs3 where "xs2 = xs1 @ xs3" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
998 |
| (less_2) xs3 where "xs1 = xs2 @ xs3" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
999 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1000 |
have "length xs1 \<le> length xs2 \<or> length xs2 \<le> length xs1" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1001 |
with assms rpath_overlap_oneside that show ?thesis by metis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1002 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1003 |
|
80
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1004 |
lemma rpath_overlap' [consumes 2, cases pred:rpath]: |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1005 |
assumes "rpath r x xs1 x1" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1006 |
and "rpath r x xs2 x2" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1007 |
obtains (less_1) xs3 where "xs2 = xs1 @ xs3" "rpath r x xs1 x1" "rpath r x1 xs3 x2" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1008 |
| (less_2) xs3 where "xs1 = xs2 @ xs3" "rpath r x xs2 x2" "rpath r x2 xs3 x1" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1009 |
proof - |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1010 |
have "length xs1 \<le> length xs2 \<or> length xs2 \<le> length xs1" by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1011 |
with assms rpath_overlap_oneside' that show ?thesis by metis |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1012 |
qed |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1013 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1014 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1015 |
As a corollary of @{thm "rpath_overlap_oneside"}, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1016 |
the following two lemmas gives one important property of relation tree, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1017 |
i.e. there is at most one path between any two nodes. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1018 |
Similar to the proof of @{thm rpath_overlap}, we starts with |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1019 |
the one side version first. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1020 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1021 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1022 |
lemma rpath_unique_oneside: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1023 |
assumes "rpath r x xs1 y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1024 |
and "rpath r x xs2 y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1025 |
and "length xs1 \<le> length xs2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1026 |
shows "xs1 = xs2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1027 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1028 |
from rpath_overlap_oneside[OF assms] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1029 |
obtain xs3 where less_1: "xs2 = xs1 @ xs3" by blast |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1030 |
show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1031 |
proof(cases "xs3 = []") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1032 |
case True |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1033 |
from less_1[unfolded this] show ?thesis by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1034 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1035 |
case False |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1036 |
note FalseH = this |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1037 |
show ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1038 |
proof(cases "xs1 = []") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1039 |
case True |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1040 |
have "(x, x) \<in> r^+" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1041 |
proof(rule rpath_plus) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1042 |
from assms(1)[unfolded True] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1043 |
have "y = x" by (cases rule:rpath_nilE, simp) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1044 |
from assms(2)[unfolded this] show "rpath r x xs2 x" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1045 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1046 |
from less_1 and False show "xs2 \<noteq> []" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1047 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1048 |
with acl show ?thesis by (unfold acyclic_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1049 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1050 |
case False |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1051 |
then obtain e es where eq_xs1: "xs1 = es@[e]" by fast |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1052 |
from assms(2)[unfolded less_1 this] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1053 |
have "rpath r x (es @ [e] @ xs3) y" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1054 |
thus ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1055 |
proof(cases rule:rpath_appendE) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1056 |
case 1 |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1057 |
from rpath_dest_eq [OF 1(1)[folded eq_xs1] assms(1)] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1058 |
have "e = y" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1059 |
from rpath_plus [OF 1(2)[unfolded this] FalseH] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1060 |
have "(y, y) \<in> r^+" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1061 |
with acl show ?thesis by (unfold acyclic_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1062 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1063 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1064 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1065 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1066 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1067 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1068 |
The following is the full version of path uniqueness. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1069 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1070 |
lemma rpath_unique: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1071 |
assumes "rpath r x xs1 y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1072 |
and "rpath r x xs2 y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1073 |
shows "xs1 = xs2" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1074 |
proof(cases "length xs1 \<le> length xs2") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1075 |
case True |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1076 |
from rpath_unique_oneside[OF assms this] show ?thesis . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1077 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1078 |
case False |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1079 |
hence "length xs2 \<le> length xs1" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1080 |
from rpath_unique_oneside[OF assms(2,1) this] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1081 |
show ?thesis by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1082 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1083 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1084 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1085 |
The following lemma shows that the `independence` relation is symmetric. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1086 |
It is an obvious auxiliary lemma which will be used later. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1087 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1088 |
lemma sym_indep: "indep r x y \<Longrightarrow> indep r y x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1089 |
by (unfold indep_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1090 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1091 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1092 |
This is another `obvious` lemma about trees, which says trees rooted at |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1093 |
independent nodes are disjoint. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1094 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1095 |
lemma subtree_disjoint: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1096 |
assumes "indep r x y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1097 |
shows "subtree r x \<inter> subtree r y = {}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1098 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1099 |
{ fix z x y xs1 xs2 xs3 |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1100 |
assume ind: "indep r x y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1101 |
and rp1: "rpath r z xs1 x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1102 |
and rp2: "rpath r z xs2 y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1103 |
and h: "xs2 = xs1 @ xs3" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1104 |
have False |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1105 |
proof(cases "xs1 = []") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1106 |
case True |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1107 |
from rp1[unfolded this] have "x = z" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1108 |
from rp2[folded this] rpath_star ind[unfolded indep_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1109 |
show ?thesis by metis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1110 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1111 |
case False |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1112 |
then obtain e es where eq_xs1: "xs1 = es@[e]" by fast |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1113 |
from rp2[unfolded h this] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1114 |
have "rpath r z (es @ [e] @ xs3) y" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1115 |
thus ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1116 |
proof(cases rule:rpath_appendE) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1117 |
case 1 |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1118 |
have "e = x" using 1(1)[folded eq_xs1] rp1 rpath_dest_eq by metis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1119 |
from rpath_star[OF 1(2)[unfolded this]] ind[unfolded indep_def] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1120 |
show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1121 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1122 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1123 |
} note my_rule = this |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1124 |
{ fix z |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1125 |
assume h: "z \<in> subtree r x" "z \<in> subtree r y" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1126 |
from h(1) have "(z, x) \<in> r^*" by (unfold subtree_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1127 |
then obtain xs1 where rp1: "rpath r z xs1 x" using star_rpath by metis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1128 |
from h(2) have "(z, y) \<in> r^*" by (unfold subtree_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1129 |
then obtain xs2 where rp2: "rpath r z xs2 y" using star_rpath by metis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1130 |
from rp1 rp2 |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1131 |
have False |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1132 |
by (cases, insert my_rule[OF sym_indep[OF assms(1)] rp2 rp1] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1133 |
my_rule[OF assms(1) rp1 rp2], auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1134 |
} thus ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1135 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1136 |
|
137
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1137 |
lemma root_unique: |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1138 |
assumes "x \<in> subtree r y" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1139 |
and "x \<in> subtree r z" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1140 |
and "root r y" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1141 |
and "root r z" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1142 |
shows "y = z" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1143 |
proof - |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1144 |
{ assume "y \<noteq> z" |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1145 |
from root_indep[OF assms(4,3) this] |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1146 |
have "indep r z y" . |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1147 |
from subtree_disjoint[OF this] and assms |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1148 |
have False by auto |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1149 |
} thus ?thesis by auto |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1150 |
qed |
785c0f6b8184
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
136
diff
changeset
|
1151 |
|
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1152 |
text {* |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1153 |
The following lemma @{text "subtree_del"} characterizes the change of sub-tree of |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1154 |
@{text "x"} with the removal of an inside edge @{text "(a, b)"}. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1155 |
Note that, the case for the removal of an outside edge has already been dealt with |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1156 |
in lemma @{text "subtree_del_outside"}). |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1157 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1158 |
This lemma is underpinned by the following two `obvious` facts: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1159 |
\begin{enumearte} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1160 |
\item |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1161 |
In graph @{text "r"}, for an inside edge @{text "(a,b) \<in> edges_in r x"}, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1162 |
every node @{text "c"} in the sub-tree of @{text "a"} has a path |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1163 |
which goes first from @{text "c"} to @{text "a"}, then through edge @{text "(a, b)"}, and |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1164 |
finally reaches @{text "x"}. By the uniqueness of path in a tree, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1165 |
all paths from sub-tree of @{text "a"} to @{text "x"} are such constructed, therefore |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1166 |
must go through @{text "(a, b)"}. The consequence is: with the removal of @{text "(a,b)"}, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1167 |
all such paths will be broken. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1168 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1169 |
\item |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1170 |
On the other hand, all paths not originate from within the sub-tree of @{text "a"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1171 |
will not be affected by the removal of edge @{text "(a, b)"}. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1172 |
The reason is simple: if the path is affected by the removal, it must |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1173 |
contain @{text "(a, b)"}, then it must originate from within the sub-tree of @{text "a"}. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1174 |
\end{enumearte} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1175 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1176 |
|
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1177 |
lemma subtree_del_inside: (* ddd *) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1178 |
assumes "(a,b) \<in> edges_in r x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1179 |
shows "subtree (r - {(a, b)}) x = (subtree r x) - subtree r a" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1180 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1181 |
from assms have asm: "b \<in> subtree r x" "(a, b) \<in> r" by (auto simp:edges_in_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1182 |
-- {* The proof follows a common pattern to prove the equality of sets. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1183 |
{ -- {* The `left to right` direction. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1184 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1185 |
fix c |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1186 |
-- {* Assuming @{text "c"} is inside the sub-tree of @{text "x"} in the reduced graph *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1187 |
assume h: "c \<in> subtree (r - {(a, b)}) x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1188 |
-- {* We are going to show that @{text "c"} can not be in the sub-tree of @{text "a"} in |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1189 |
the original graph. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1190 |
-- {* In other words, all nodes inside the sub-tree of @{text "a"} in the original |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1191 |
graph will be removed from the sub-tree of @{text "x"} in the reduced graph. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1192 |
-- {* The reason, as analyzed before, is that all paths from within the |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1193 |
sub-tree of @{text "a"} are broken with the removal of edge @{text "(a,b)"}. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1194 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1195 |
have "c \<in> (subtree r x) - subtree r a" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1196 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1197 |
let ?r' = "r - {(a, b)}" -- {* The reduced graph is abbreviated as @{text "?r'"} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1198 |
from h have "(c, x) \<in> ?r'^*" by (auto simp:subtree_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1199 |
-- {* Extract from the reduced graph the path @{text "xs"} from @{text "c"} to @{text "x"}. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1200 |
then obtain xs where rp0: "rpath ?r' c xs x" by (rule star_rpath, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1201 |
-- {* It is easy to show @{text "xs"} is also a path in the original graph *} |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1202 |
hence rp1: "rpath r c xs x" using rpath_edges_on[OF rp0] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1203 |
by auto |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1204 |
-- {* @{text "xs"} is used as the witness to show that @{text "c"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1205 |
in the sub-tree of @{text "x"} in the original graph. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1206 |
hence "c \<in> subtree r x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1207 |
by (rule rpath_star[elim_format], auto simp:subtree_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1208 |
-- {* The next step is to show that @{text "c"} can not be in the sub-tree of @{text "a"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1209 |
in the original graph. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1210 |
-- {* We need to use the fact that all paths originate from within sub-tree of @{text "a"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1211 |
are broken. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1212 |
moreover have "c \<notin> subtree r a" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1213 |
proof |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1214 |
-- {* Proof by contradiction, suppose otherwise *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1215 |
assume otherwise: "c \<in> subtree r a" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1216 |
-- {* Then there is a path in original graph leading from @{text "c"} to @{text "a"} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1217 |
obtain xs1 where rp_c: "rpath r c xs1 a" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1218 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1219 |
from otherwise have "(c, a) \<in> r^*" by (auto simp:subtree_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1220 |
thus ?thesis by (rule star_rpath, auto intro!:that) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1221 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1222 |
-- {* Starting from this path, we are going to construct a fictional |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1223 |
path from @{text "c"} to @{text "x"}, which, as explained before, |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1224 |
is broken, so that contradiction can be derived. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1225 |
-- {* First, there is a path from @{text "b"} to @{text "x"} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1226 |
obtain ys where rp_b: "rpath r b ys x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1227 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1228 |
from asm have "(b, x) \<in> r^*" by (auto simp:subtree_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1229 |
thus ?thesis by (rule star_rpath, auto intro!:that) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1230 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1231 |
-- {* The paths @{text "xs1"} and @{text "ys"} can be |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1232 |
tied together using @{text "(a,b)"} to form a path |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1233 |
from @{text "c"} to @{text "x"}: *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1234 |
have "rpath r c (xs1 @ b # ys) x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1235 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1236 |
from rstepI[OF asm(2) rp_b] have "rpath r a (b # ys) x" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1237 |
from rpath_appendI[OF rp_c this] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1238 |
show ?thesis . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1239 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1240 |
-- {* By the uniqueness of path between two nodes of a tree, we have: *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1241 |
from rpath_unique[OF rp1 this] have eq_xs: "xs = xs1 @ b # ys" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1242 |
-- {* Contradiction can be derived from from this fictional path . *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1243 |
show False |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1244 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1245 |
-- {* It can be shown that @{term "(a,b)"} is on this fictional path. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1246 |
have "(a, b) \<in> edges_on (c#xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1247 |
proof(cases "xs1 = []") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1248 |
case True |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1249 |
from rp_c[unfolded this] have "rpath r c [] a" . |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1250 |
hence eq_c: "c = a" by fast |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1251 |
hence "c#xs = a#xs" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1252 |
from this and eq_xs have "c#xs = a # xs1 @ b # ys" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1253 |
from this[unfolded True] have "c#xs = []@[a,b]@ys" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1254 |
thus ?thesis by (auto simp:edges_on_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1255 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1256 |
case False |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1257 |
from rpath_nnl_lastE[OF rp_c this] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1258 |
obtain xs' where "xs1 = xs'@[a]" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1259 |
from eq_xs[unfolded this] have "c#xs = (c#xs')@[a,b]@ys" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1260 |
thus ?thesis by (unfold edges_on_def, blast) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1261 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1262 |
-- {* It can also be shown that @{term "(a,b)"} is not on this fictional path. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1263 |
moreover have "(a, b) \<notin> edges_on (c#xs)" |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1264 |
using rpath_edges_on[OF rp0] by (auto) |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1265 |
-- {* Contradiction is thus derived. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1266 |
ultimately show False by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1267 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1268 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1269 |
ultimately show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1270 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1271 |
} moreover { |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1272 |
-- {* The `right to left` direction. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1273 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1274 |
fix c |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1275 |
-- {* Assuming that @{text "c"} is in the sub-tree of @{text "x"}, but |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1276 |
outside of the sub-tree of @{text "a"} in the original graph, *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1277 |
assume h: "c \<in> (subtree r x) - subtree r a" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1278 |
-- {* we need to show that in the reduced graph, @{text "c"} is still in |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1279 |
the sub-tree of @{text "x"}. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1280 |
have "c \<in> subtree (r - {(a, b)}) x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1281 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1282 |
-- {* The proof goes by showing that the path from @{text "c"} to @{text "x"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1283 |
in the original graph is not affected by the removal of @{text "(a,b)"}. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1284 |
*} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1285 |
from h have "(c, x) \<in> r^*" by (unfold subtree_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1286 |
-- {* Extract the path @{text "xs"} from @{text "c"} to @{text "x"} in the original graph. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1287 |
from star_rpath[OF this] obtain xs where rp: "rpath r c xs x" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1288 |
-- {* Show that it is also a path in the reduced graph. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1289 |
hence "rpath (r - {(a, b)}) c xs x" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1290 |
-- {* The proof goes by using rule @{thm rpath_transfer} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1291 |
proof(rule rpath_transfer) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1292 |
-- {* We need to show all edges on the path are still in the reduced graph. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1293 |
show "edges_on (c # xs) \<subseteq> r - {(a, b)}" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1294 |
proof - |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1295 |
-- {* It is easy to show that all the edges are in the original graph. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1296 |
from rpath_edges_on [OF rp] have " edges_on (c # xs) \<subseteq> r" . |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1297 |
-- {* The essential part is to show that @{text "(a, b)"} is not on the path. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1298 |
moreover have "(a,b) \<notin> edges_on (c#xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1299 |
proof |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1300 |
-- {* Proof by contradiction, suppose otherwise: *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1301 |
assume otherwise: "(a, b) \<in> edges_on (c#xs)" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1302 |
-- {* Then @{text "(a, b)"} is in the middle of the path. |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1303 |
with @{text "l1"} and @{text "l2"} be the nodes in |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1304 |
the front and rear respectively. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1305 |
then obtain l1 l2 where eq_xs: |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1306 |
"c#xs = l1 @ [a, b] @ l2" by (unfold edges_on_def, blast) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1307 |
-- {* From this, it can be shown that @{text "c"} is |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1308 |
in the sub-tree of @{text "a"} *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1309 |
have "c \<in> subtree r a" |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1310 |
proof(cases "l1 = []") |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1311 |
case True |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1312 |
-- {* If @{text "l1"} is null, it can be derived that @{text "c = a"}. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1313 |
with eq_xs have "c = a" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1314 |
-- {* So, @{text "c"} is obviously in the sub-tree of @{text "a"}. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1315 |
thus ?thesis by (unfold subtree_def, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1316 |
next |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1317 |
case False |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1318 |
-- {* When @{text "l1"} is not null, it must have a tail @{text "es"}: *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1319 |
then obtain e es where "l1 = e#es" by (cases l1, auto) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1320 |
-- {* The relation of this tail with @{text "xs"} is derived: *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1321 |
with eq_xs have "xs = es@[a,b]@l2" by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1322 |
-- {* From this, a path from @{text "c"} to @{text "a"} is made visible: *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1323 |
from rp[unfolded this] have "rpath r c (es @ [a] @ (b#l2)) x" by simp |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1324 |
thus ?thesis |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1325 |
proof(cases rule:rpath_appendE) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1326 |
-- {* The path from @{text "c"} to @{text "a"} is extraced |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1327 |
using @{thm "rpath_appendE"}: *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1328 |
case 1 |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1329 |
from rpath_star[OF this(1)] |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1330 |
-- {* The extracted path servers as a witness that @{text "c"} is |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1331 |
in the sub-tree of @{text "a"}: *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1332 |
show ?thesis by (simp add:subtree_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1333 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1334 |
qed with h show False by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1335 |
qed ultimately show ?thesis by auto |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1336 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1337 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1338 |
-- {* From , it is shown that @{text "c"} is in the sub-tree of @{text "x"} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1339 |
inthe reduced graph. *} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1340 |
from rpath_star[OF this] show ?thesis by (auto simp:subtree_def) |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1341 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1342 |
} |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1343 |
-- {* The equality of sets is derived from the two directions just proved. *} |
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1344 |
ultimately show ?thesis by blast |
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1345 |
qed |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1346 |
|
58 | 1347 |
lemma set_del_rootI: |
1348 |
assumes "r1 \<subseteq> r" |
|
1349 |
and "a \<in> Domain r1" |
|
1350 |
shows "root (r - r1) a" |
|
1351 |
proof - |
|
1352 |
let ?r = "r - r1" |
|
1353 |
{ fix a' |
|
1354 |
assume neq: "a' \<noteq> a" |
|
1355 |
have "a \<notin> subtree ?r a'" |
|
1356 |
proof |
|
1357 |
assume "a \<in> subtree ?r a'" |
|
1358 |
hence "(a, a') \<in> ?r^*" by (auto simp:subtree_def) |
|
1359 |
from star_rpath[OF this] obtain xs |
|
1360 |
where rp: "rpath ?r a xs a'" by auto |
|
1361 |
from rpathE[OF this] and neq |
|
1362 |
obtain z zs where h: "(a, z) \<in> ?r" "rpath ?r z zs a'" "xs = z#zs" by auto |
|
1363 |
from assms(2) obtain z' where z'_in: "(a, z') \<in> r1" by (auto simp:DomainE) |
|
1364 |
with assms(1) have "(a, z') \<in> r" by auto |
|
1365 |
moreover from h(1) have "(a, z) \<in> r" by simp |
|
1366 |
ultimately have "z' = z" using sgv by (auto simp:single_valued_def) |
|
1367 |
from z'_in[unfolded this] and h(1) show False by auto |
|
1368 |
qed |
|
1369 |
} thus ?thesis by (intro rootI, auto) |
|
1370 |
qed |
|
1371 |
||
1372 |
lemma edge_del_no_rootI: |
|
1373 |
assumes "(a, b) \<in> r" |
|
1374 |
shows "root (r - {(a, b)}) a" |
|
1375 |
by (rule set_del_rootI, insert assms, auto) |
|
1376 |
||
1377 |
lemma ancestors_children_unique: |
|
1378 |
assumes "z1 \<in> ancestors r x \<inter> children r y" |
|
1379 |
and "z2 \<in> ancestors r x \<inter> children r y" |
|
1380 |
shows "z1 = z2" |
|
1381 |
proof - |
|
1382 |
from assms have h: |
|
1383 |
"(x, z1) \<in> r^+" "(z1, y) \<in> r" |
|
1384 |
"(x, z2) \<in> r^+" "(z2, y) \<in> r" |
|
1385 |
by (auto simp:ancestors_def children_def) |
|
1386 |
||
1387 |
-- {* From this, a path containing @{text "z1"} is obtained. *} |
|
1388 |
from plus_rpath[OF h(1)] obtain xs1 |
|
1389 |
where h1: "rpath r x xs1 z1" "xs1 \<noteq> []" by auto |
|
1390 |
from rpath_nnl_lastE[OF this] obtain xs1' where eq_xs1: "xs1 = xs1' @ [z1]" |
|
1391 |
by auto |
|
1392 |
from h(2) have h2: "rpath r z1 [y] y" by auto |
|
1393 |
from rpath_appendI[OF h1(1) h2, unfolded eq_xs1] |
|
1394 |
have rp1: "rpath r x (xs1' @ [z1, y]) y" by simp |
|
1395 |
||
1396 |
-- {* Then, another path containing @{text "z2"} is obtained. *} |
|
1397 |
from plus_rpath[OF h(3)] obtain xs2 |
|
1398 |
where h3: "rpath r x xs2 z2" "xs2 \<noteq> []" by auto |
|
1399 |
from rpath_nnl_lastE[OF this] obtain xs2' where eq_xs2: "xs2 = xs2' @ [z2]" |
|
1400 |
by auto |
|
1401 |
from h(4) have h4: "rpath r z2 [y] y" by auto |
|
1402 |
from rpath_appendI[OF h3(1) h4, unfolded eq_xs2] |
|
1403 |
have "rpath r x (xs2' @ [z2, y]) y" by simp |
|
1404 |
||
1405 |
-- {* Finally @{text "z1 = z2"} is proved by uniqueness of path. *} |
|
1406 |
from rpath_unique[OF rp1 this] |
|
1407 |
have "xs1' @ [z1, y] = xs2' @ [z2, y]" . |
|
1408 |
thus ?thesis by auto |
|
1409 |
qed |
|
1410 |
||
1411 |
lemma ancestors_childrenE: |
|
1412 |
assumes "y \<in> ancestors r x" |
|
1413 |
obtains "x \<in> children r y" |
|
1414 |
| z where "z \<in> ancestors r x \<inter> children r y" |
|
1415 |
proof - |
|
1416 |
from assms(1) have "(x, y) \<in> r^+" by (auto simp:ancestors_def) |
|
1417 |
from tranclD2[OF this] obtain z where |
|
1418 |
h: "(x, z) \<in> r\<^sup>*" "(z, y) \<in> r" by auto |
|
1419 |
from h(1) |
|
1420 |
show ?thesis |
|
1421 |
proof(cases rule:rtranclE) |
|
1422 |
case base |
|
1423 |
from h(2)[folded this] have "x \<in> children r y" |
|
1424 |
by (auto simp:children_def) |
|
1425 |
thus ?thesis by (intro that, auto) |
|
1426 |
next |
|
1427 |
case (step u) |
|
1428 |
hence "z \<in> ancestors r x" by (auto simp:ancestors_def) |
|
1429 |
moreover from h(2) have "z \<in> children r y" |
|
1430 |
by (auto simp:children_def) |
|
1431 |
ultimately show ?thesis by (intro that, auto) |
|
1432 |
qed |
|
1433 |
qed |
|
1434 |
||
134
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1435 |
end (* of forest *) |
58 | 1436 |
|
80
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1437 |
lemma subtree_trancl: |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1438 |
"subtree r x = {x} \<union> {y. (y, x) \<in> r^+}" (is "?L = ?R") |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1439 |
proof - |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1440 |
{ fix z |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1441 |
assume "z \<in> ?L" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1442 |
hence "z \<in> ?R" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1443 |
proof(cases rule:subtreeE) |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1444 |
case 2 |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1445 |
thus ?thesis |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1446 |
by (unfold ancestors_def, auto) |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1447 |
qed auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1448 |
} moreover |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1449 |
{ fix z |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1450 |
assume "z \<in> ?R" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1451 |
hence "z \<in> ?L" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1452 |
by (unfold subtree_def, auto) |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1453 |
} ultimately show ?thesis by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1454 |
qed |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1455 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1456 |
lemma ancestor_children_subtreeI [intro]: |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1457 |
"x \<in> ancestors r z \<Longrightarrow> z \<in> \<Union>(subtree r ` children r x)" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1458 |
by (unfold ancestors_def children_def, auto simp:subtree_def dest:tranclD2) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1459 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1460 |
lemma [iff]: "x \<in> subtree r x" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1461 |
by (auto simp:subtree_def) |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1462 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1463 |
lemma [intro]: "xa \<in> children r x \<Longrightarrow> z \<in> subtree r xa \<Longrightarrow> z \<in> subtree r x" |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1464 |
by (unfold children_def subtree_def, auto) |
58 | 1465 |
|
1466 |
lemma subtree_children: |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1467 |
"subtree r x = ({x} \<union> (\<Union> (subtree r ` (children r x))))" (is "?L = ?R") |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1468 |
by fast |
58 | 1469 |
|
134
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1470 |
context fforest |
58 | 1471 |
begin |
1472 |
||
1473 |
lemma finite_subtree: |
|
1474 |
shows "finite (subtree r x)" |
|
1475 |
proof(induct rule:wf_induct[OF wf]) |
|
1476 |
case (1 x) |
|
1477 |
have "finite (\<Union>(subtree r ` children r x))" |
|
1478 |
proof(rule finite_Union) |
|
1479 |
show "finite (subtree r ` children r x)" |
|
1480 |
proof(cases "children r x = {}") |
|
1481 |
case True |
|
1482 |
thus ?thesis by auto |
|
1483 |
next |
|
1484 |
case False |
|
1485 |
hence "x \<in> Range r" by (auto simp:children_def) |
|
133
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1486 |
from fb |
58 | 1487 |
have "finite (children r x)" . |
1488 |
thus ?thesis by (rule finite_imageI) |
|
1489 |
qed |
|
1490 |
next |
|
1491 |
fix M |
|
1492 |
assume "M \<in> subtree r ` children r x" |
|
1493 |
then obtain y where h: "y \<in> children r x" "M = subtree r y" by auto |
|
1494 |
hence "(y, x) \<in> r" by (auto simp:children_def) |
|
1495 |
from 1[rule_format, OF this, folded h(2)] |
|
1496 |
show "finite M" . |
|
1497 |
qed |
|
1498 |
thus ?case |
|
1499 |
by (unfold subtree_children finite_Un, auto) |
|
1500 |
qed |
|
1501 |
||
57
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1502 |
end |
f1b39d77db00
Added generic theory "RTree.thy"
xingyuan zhang <xingyuanzhang@126.com>
parents:
diff
changeset
|
1503 |
|
58 | 1504 |
definition "pairself f = (\<lambda>(a, b). (f a, f b))" |
1505 |
||
1506 |
definition "rel_map f r = (pairself f ` r)" |
|
1507 |
||
1508 |
lemma rel_mapE: |
|
1509 |
assumes "(a, b) \<in> rel_map f r" |
|
1510 |
obtains c d |
|
1511 |
where "(c, d) \<in> r" "(a, b) = (f c, f d)" |
|
1512 |
using assms |
|
1513 |
by (unfold rel_map_def pairself_def, auto) |
|
1514 |
||
1515 |
lemma rel_mapI: |
|
1516 |
assumes "(a, b) \<in> r" |
|
1517 |
and "c = f a" |
|
1518 |
and "d = f b" |
|
1519 |
shows "(c, d) \<in> rel_map f r" |
|
1520 |
using assms |
|
1521 |
by (unfold rel_map_def pairself_def, auto) |
|
1522 |
||
1523 |
lemma map_appendE: |
|
1524 |
assumes "map f zs = xs @ ys" |
|
1525 |
obtains xs' ys' |
|
1526 |
where "zs = xs' @ ys'" "xs = map f xs'" "ys = map f ys'" |
|
1527 |
proof - |
|
1528 |
have "\<exists> xs' ys'. zs = xs' @ ys' \<and> xs = map f xs' \<and> ys = map f ys'" |
|
1529 |
using assms |
|
1530 |
proof(induct xs arbitrary:zs ys) |
|
1531 |
case (Nil zs ys) |
|
1532 |
thus ?case by auto |
|
1533 |
next |
|
1534 |
case (Cons x xs zs ys) |
|
1535 |
note h = this |
|
1536 |
show ?case |
|
1537 |
proof(cases zs) |
|
1538 |
case (Cons e es) |
|
1539 |
with h have eq_x: "map f es = xs @ ys" "x = f e" by auto |
|
1540 |
from h(1)[OF this(1)] |
|
1541 |
obtain xs' ys' where "es = xs' @ ys'" "xs = map f xs'" "ys = map f ys'" |
|
1542 |
by blast |
|
1543 |
with Cons eq_x |
|
1544 |
have "zs = (e#xs') @ ys' \<and> x # xs = map f (e#xs') \<and> ys = map f ys'" by auto |
|
1545 |
thus ?thesis by metis |
|
1546 |
qed (insert h, auto) |
|
1547 |
qed |
|
1548 |
thus ?thesis by (auto intro!:that) |
|
1549 |
qed |
|
1550 |
||
1551 |
lemma rel_map_mono: |
|
1552 |
assumes "r1 \<subseteq> r2" |
|
1553 |
shows "rel_map f r1 \<subseteq> rel_map f r2" |
|
1554 |
using assms |
|
1555 |
by (auto simp:rel_map_def pairself_def) |
|
1556 |
||
1557 |
lemma rel_map_compose [simp]: |
|
1558 |
shows "rel_map f1 (rel_map f2 r) = rel_map (f1 o f2) r" |
|
1559 |
by (auto simp:rel_map_def pairself_def) |
|
1560 |
||
1561 |
lemma edges_on_map: "edges_on (map f xs) = rel_map f (edges_on xs)" |
|
1562 |
proof - |
|
1563 |
{ fix a b |
|
1564 |
assume "(a, b) \<in> edges_on (map f xs)" |
|
1565 |
then obtain l1 l2 where eq_map: "map f xs = l1 @ [a, b] @ l2" |
|
1566 |
by (unfold edges_on_def, auto) |
|
1567 |
hence "(a, b) \<in> rel_map f (edges_on xs)" |
|
1568 |
by (auto elim!:map_appendE intro!:rel_mapI simp:edges_on_def) |
|
1569 |
} moreover { |
|
1570 |
fix a b |
|
1571 |
assume "(a, b) \<in> rel_map f (edges_on xs)" |
|
1572 |
then obtain c d where |
|
1573 |
h: "(c, d) \<in> edges_on xs" "(a, b) = (f c, f d)" |
|
1574 |
by (elim rel_mapE, auto) |
|
1575 |
then obtain l1 l2 where |
|
1576 |
eq_xs: "xs = l1 @ [c, d] @ l2" |
|
1577 |
by (auto simp:edges_on_def) |
|
1578 |
hence eq_map: "map f xs = map f l1 @ [f c, f d] @ map f l2" by auto |
|
1579 |
have "(a, b) \<in> edges_on (map f xs)" |
|
1580 |
proof - |
|
1581 |
from h(2) have "[f c, f d] = [a, b]" by simp |
|
1582 |
from eq_map[unfolded this] show ?thesis by (auto simp:edges_on_def) |
|
1583 |
qed |
|
1584 |
} ultimately show ?thesis by auto |
|
1585 |
qed |
|
1586 |
||
1587 |
lemma image_id: |
|
1588 |
assumes "\<And> x. x \<in> A \<Longrightarrow> f x = x" |
|
1589 |
shows "f ` A = A" |
|
1590 |
using assms by (auto simp:image_def) |
|
1591 |
||
1592 |
lemma rel_map_inv_id: |
|
1593 |
assumes "inj_on f ((Domain r) \<union> (Range r))" |
|
1594 |
shows "(rel_map (inv_into ((Domain r) \<union> (Range r)) f \<circ> f) r) = r" |
|
1595 |
proof - |
|
1596 |
let ?f = "(inv_into (Domain r \<union> Range r) f \<circ> f)" |
|
1597 |
{ |
|
1598 |
fix a b |
|
1599 |
assume h0: "(a, b) \<in> r" |
|
1600 |
have "pairself ?f (a, b) = (a, b)" |
|
1601 |
proof - |
|
1602 |
from assms h0 have "?f a = a" by (auto intro:inv_into_f_f) |
|
1603 |
moreover have "?f b = b" |
|
1604 |
by (insert h0, simp, intro inv_into_f_f[OF assms], auto intro!:RangeI) |
|
1605 |
ultimately show ?thesis by (auto simp:pairself_def) |
|
1606 |
qed |
|
1607 |
} thus ?thesis by (unfold rel_map_def, intro image_id, case_tac x, auto) |
|
1608 |
qed |
|
1609 |
||
1610 |
lemma rel_map_acyclic: |
|
1611 |
assumes "acyclic r" |
|
1612 |
and "inj_on f ((Domain r) \<union> (Range r))" |
|
1613 |
shows "acyclic (rel_map f r)" |
|
1614 |
proof - |
|
1615 |
let ?D = "Domain r \<union> Range r" |
|
1616 |
{ fix a |
|
1617 |
assume "(a, a) \<in> (rel_map f r)^+" |
|
1618 |
from plus_rpath[OF this] |
|
1619 |
obtain xs where rp: "rpath (rel_map f r) a xs a" "xs \<noteq> []" by auto |
|
1620 |
from rpath_nnl_lastE[OF this] obtain xs' where eq_xs: "xs = xs'@[a]" by auto |
|
1621 |
from rpath_edges_on[OF rp(1)] |
|
1622 |
have h: "edges_on (a # xs) \<subseteq> rel_map f r" . |
|
1623 |
from edges_on_map[of "inv_into ?D f" "a#xs"] |
|
1624 |
have "edges_on (map (inv_into ?D f) (a # xs)) = rel_map (inv_into ?D f) (edges_on (a # xs))" . |
|
1625 |
with rel_map_mono[OF h, of "inv_into ?D f"] |
|
1626 |
have "edges_on (map (inv_into ?D f) (a # xs)) \<subseteq> rel_map ((inv_into ?D f) o f) r" by simp |
|
1627 |
from this[unfolded eq_xs] |
|
1628 |
have subr: "edges_on (map (inv_into ?D f) (a # xs' @ [a])) \<subseteq> rel_map (inv_into ?D f \<circ> f) r" . |
|
1629 |
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]" |
|
1630 |
by simp |
|
1631 |
from edges_on_rpathI[OF subr[unfolded this]] |
|
1632 |
have "rpath (rel_map (inv_into ?D f \<circ> f) r) |
|
1633 |
(inv_into ?D f a) (map (inv_into ?D f) xs' @ [inv_into ?D f a]) (inv_into ?D f a)" . |
|
1634 |
hence "(inv_into ?D f a, inv_into ?D f a) \<in> (rel_map (inv_into ?D f \<circ> f) r)^+" |
|
1635 |
by (rule rpath_plus, simp) |
|
1636 |
moreover have "(rel_map (inv_into ?D f \<circ> f) r) = r" by (rule rel_map_inv_id[OF assms(2)]) |
|
1637 |
moreover note assms(1) |
|
1638 |
ultimately have False by (unfold acyclic_def, auto) |
|
1639 |
} thus ?thesis by (auto simp:acyclic_def) |
|
1640 |
qed |
|
1641 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1642 |
lemma compose_relpow_2 [intro, simp]: |
58 | 1643 |
assumes "r1 \<subseteq> r" |
1644 |
and "r2 \<subseteq> r" |
|
1645 |
shows "r1 O r2 \<subseteq> r ^^ (2::nat)" |
|
1646 |
proof - |
|
1647 |
{ fix a b |
|
1648 |
assume "(a, b) \<in> r1 O r2" |
|
1649 |
then obtain e where "(a, e) \<in> r1" "(e, b) \<in> r2" |
|
1650 |
by auto |
|
1651 |
with assms have "(a, e) \<in> r" "(e, b) \<in> r" by auto |
|
1652 |
hence "(a, b) \<in> r ^^ (Suc (Suc 0))" by auto |
|
1653 |
} thus ?thesis by (auto simp:numeral_2_eq_2) |
|
1654 |
qed |
|
1655 |
||
134
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1656 |
lemma relpow_mult: |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1657 |
"((r::'a rel) ^^ m) ^^ n = r ^^ (m*n)" |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1658 |
proof(induct n arbitrary:m) |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1659 |
case (Suc k m) |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1660 |
thus ?case |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1661 |
proof - |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1662 |
have h: "(m * k + m) = (m + m * k)" by auto |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1663 |
show ?thesis |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1664 |
apply (simp add:Suc relpow_add[symmetric]) |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1665 |
by (unfold h, simp) |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1666 |
qed |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1667 |
qed simp |
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1668 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1669 |
lemma acyclic_compose [intro, simp]: |
58 | 1670 |
assumes "acyclic r" |
1671 |
and "r1 \<subseteq> r" |
|
1672 |
and "r2 \<subseteq> r" |
|
1673 |
shows "acyclic (r1 O r2)" |
|
1674 |
proof - |
|
1675 |
{ fix a |
|
1676 |
assume "(a, a) \<in> (r1 O r2)^+" |
|
1677 |
from trancl_mono[OF this compose_relpow_2[OF assms(2, 3)]] |
|
1678 |
have "(a, a) \<in> (r ^^ 2) ^+" . |
|
1679 |
from trancl_power[THEN iffD1, OF this] |
|
1680 |
obtain n where h: "(a, a) \<in> (r ^^ 2) ^^ n" "n > 0" by blast |
|
1681 |
from this(1)[unfolded relpow_mult] have h2: "(a, a) \<in> r ^^ (2 * n)" . |
|
1682 |
have "(a, a) \<in> r^+" |
|
1683 |
proof(cases rule:trancl_power[THEN iffD2]) |
|
1684 |
from h(2) h2 show "\<exists>n>0. (a, a) \<in> r ^^ n" |
|
1685 |
by (rule_tac x = "2*n" in exI, auto) |
|
1686 |
qed |
|
1687 |
with assms have "False" by (auto simp:acyclic_def) |
|
1688 |
} thus ?thesis by (auto simp:acyclic_def) |
|
1689 |
qed |
|
1690 |
||
1691 |
lemma children_compose_unfold: |
|
1692 |
"children (r1 O r2) x = \<Union> (children r1 ` (children r2 x))" |
|
1693 |
by (auto simp:children_def) |
|
1694 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1695 |
lemma fbranch_compose [intro, simp]: |
132
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1696 |
assumes "\<forall> x \<in> Range r1 . finite (children r1 x)" |
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1697 |
and "\<forall> x \<in> Range r2 . finite (children r2 x)" |
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1698 |
shows "\<forall> x \<in> Range (r1 O r2) . finite (children (r1 O r2) x)" |
58 | 1699 |
proof - |
1700 |
{ fix x |
|
1701 |
assume "x\<in>Range (r1 O r2)" |
|
1702 |
then obtain y z where h: "(y, z) \<in> r1" "(z, x) \<in> r2" by auto |
|
1703 |
have "finite (children (r1 O r2) x)" |
|
1704 |
proof(unfold children_compose_unfold, rule finite_Union) |
|
1705 |
show "finite (children r1 ` children r2 x)" |
|
1706 |
proof(rule finite_imageI) |
|
1707 |
from h(2) have "x \<in> Range r2" by auto |
|
134
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1708 |
from assms(2)[unfolded fforest_def] this |
132
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1709 |
show "finite (children r2 x)" by auto |
58 | 1710 |
qed |
1711 |
next |
|
1712 |
fix M |
|
1713 |
assume "M \<in> children r1 ` children r2 x" |
|
1714 |
then obtain y where h1: "y \<in> children r2 x" "M = children r1 y" by auto |
|
1715 |
show "finite M" |
|
1716 |
proof(cases "children r1 y = {}") |
|
1717 |
case True |
|
1718 |
with h1(2) show ?thesis by auto |
|
1719 |
next |
|
1720 |
case False |
|
1721 |
hence "y \<in> Range r1" by (unfold children_def, auto) |
|
134
8a13b37b4d95
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
133
diff
changeset
|
1722 |
from assms(1)[unfolded fforest_def] this h1(2) |
132
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1723 |
show ?thesis by auto |
58 | 1724 |
qed |
1725 |
qed |
|
132
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1726 |
} thus ?thesis using assms by auto |
58 | 1727 |
qed |
1728 |
||
133
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1729 |
lemma fbranch_compose1 [intro, simp]: |
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1730 |
assumes "\<forall>x. finite (children r1 x)" |
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1731 |
and "\<forall>x. finite (children r2 x)" |
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1732 |
shows "\<forall>x. finite (children (r1 O r2) x)" |
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1733 |
by (metis (no_types, lifting) Collect_empty_eq Range.intros assms(1) |
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1734 |
assms(2) children_def fbranch_compose finite.emptyI) |
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1735 |
|
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1736 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1737 |
lemma finite_fbranchI [intro]: |
58 | 1738 |
assumes "finite r" |
132
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1739 |
shows "\<forall> x \<in> Range r . finite (children r x)" |
58 | 1740 |
proof - |
1741 |
{ fix x |
|
1742 |
assume "x \<in>Range r" |
|
1743 |
have "finite (children r x)" |
|
1744 |
proof - |
|
1745 |
have "{y. (y, x) \<in> r} \<subseteq> Domain r" by (auto) |
|
1746 |
from rev_finite_subset[OF finite_Domain[OF assms] this] |
|
1747 |
have "finite {y. (y, x) \<in> r}" . |
|
1748 |
thus ?thesis by (unfold children_def, simp) |
|
1749 |
qed |
|
132
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1750 |
} thus ?thesis by auto |
58 | 1751 |
qed |
1752 |
||
133
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1753 |
lemma finite_fbranchI1 [intro]: |
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1754 |
assumes "finite r" |
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1755 |
shows "\<forall> x . finite (children r x)" |
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1756 |
by (metis (no_types, lifting) Collect_empty_eq Range.intros assms |
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1757 |
children_def finite.emptyI finite_fbranchI) |
4b717aa162fa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
132
diff
changeset
|
1758 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1759 |
lemma subset_fbranchI [intro]: |
132
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1760 |
assumes "\<forall> x \<in> Range r1 . finite (children r1 x)" |
58 | 1761 |
and "r2 \<subseteq> r1" |
132
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1762 |
shows "\<forall> x \<in> Range r2 . finite (children r2 x)" |
58 | 1763 |
proof - |
1764 |
{ fix x |
|
1765 |
assume "x \<in>Range r2" |
|
1766 |
with assms(2) have "x \<in> Range r1" by auto |
|
132
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1767 |
from assms(1)[rule_format, OF this] |
58 | 1768 |
have "finite (children r1 x)" . |
1769 |
hence "finite (children r2 x)" |
|
1770 |
proof(rule rev_finite_subset) |
|
1771 |
from assms(2) |
|
1772 |
show "children r2 x \<subseteq> children r1 x" by (auto simp:children_def) |
|
1773 |
qed |
|
132
d9974794436a
added version with fgraphs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1774 |
} thus ?thesis by auto |
58 | 1775 |
qed |
1776 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1777 |
lemma children_subtree [simp, intro]: |
58 | 1778 |
shows "children r x \<subseteq> subtree r x" |
1779 |
by (auto simp:children_def subtree_def) |
|
1780 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1781 |
lemma children_union_kept [simp]: |
58 | 1782 |
assumes "x \<notin> Range r'" |
1783 |
shows "children (r \<union> r') x = children r x" |
|
1784 |
using assms |
|
1785 |
by (auto simp:children_def) |
|
1786 |
||
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1787 |
lemma wf_rbase [elim]: |
80
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1788 |
assumes "wf r" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1789 |
obtains b where "(b, a) \<in> r^*" "\<forall> c. (c, b) \<notin> r" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1790 |
proof - |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1791 |
from assms |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1792 |
have "\<exists> b. (b, a) \<in> r^* \<and> (\<forall> c. (c, b) \<notin> r)" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1793 |
proof(induct) |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1794 |
case (less x) |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1795 |
thus ?case |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1796 |
proof(cases "\<exists> z. (z, x) \<in> r") |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1797 |
case False |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1798 |
moreover have "(x, x) \<in> r^*" by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1799 |
ultimately show ?thesis by metis |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1800 |
next |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1801 |
case True |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1802 |
then obtain z where h_z: "(z, x) \<in> r" by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1803 |
from less[OF this] |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1804 |
obtain b where "(b, z) \<in> r^*" "(\<forall>c. (c, b) \<notin> r)" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1805 |
by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1806 |
moreover from this(1) h_z have "(b, x) \<in> r^*" by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1807 |
ultimately show ?thesis by metis |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1808 |
qed |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1809 |
qed |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1810 |
with that show ?thesis by metis |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1811 |
qed |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1812 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1813 |
lemma wf_base [elim]: |
80
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1814 |
assumes "wf r" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1815 |
and "a \<in> Range r" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1816 |
obtains b where "(b, a) \<in> r^+" "\<forall> c. (c, b) \<notin> r" |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1817 |
proof - |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1818 |
from assms(2) obtain a' where h_a: "(a', a) \<in> r" by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1819 |
from wf_rbase[OF assms(1), of a] |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1820 |
obtain b where h_b: "(b, a) \<in> r\<^sup>*" "\<forall>c. (c, b) \<notin> r" by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1821 |
from rtranclD[OF this(1)] |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1822 |
have "b = a \<or> b \<noteq> a \<and> (b, a) \<in> r\<^sup>+" by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1823 |
moreover have "b \<noteq> a" using h_a h_b(2) by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1824 |
ultimately have "(b, a) \<in> r\<^sup>+" by auto |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1825 |
with h_b(2) and that show ?thesis by metis |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1826 |
qed |
17305a85493d
CpsG.thy retrofiting almost completed. An important mile stone.
zhangx
parents:
64
diff
changeset
|
1827 |
|
125
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1828 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1829 |
declare RTree.subtree_transfer[rule del] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1830 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1831 |
declare RTree.subtreeE[rule del] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1832 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1833 |
declare RTree.ancestors_Field[rule del] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1834 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1835 |
declare RTree.star_rpath[rule del] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1836 |
|
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1837 |
declare RTree.plus_rpath[rule del] |
95e7933968f8
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
80
diff
changeset
|
1838 |
|
178 | 1839 |
lemma fmap_children: |
1840 |
assumes "inj f" |
|
1841 |
shows "children ((map_prod f f) ` r) (f s) = f ` (children r s)" |
|
1842 |
using assms |
|
1843 |
apply (unfold children_def map_prod_def, auto) |
|
1844 |
by (drule_tac x = s and y = b in injD, auto) |
|
1845 |
||
1846 |
find_theorems subtree "op \<union>" |
|
1847 |
||
127
38c6acf03f68
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
1848 |
end |