author | urbanc |
Thu, 11 Aug 2011 23:42:06 +0000 | |
changeset 194 | 5347d7556487 |
parent 187 | 9f46a9571e37 |
child 203 | 5d724fe0e096 |
permissions | -rw-r--r-- |
63 | 1 |
theory Myhill_2 |
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
2 |
imports Myhill_1 |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
3 |
"~~/src/HOL/Library/List_Prefix" |
63 | 4 |
begin |
5 |
||
166 | 6 |
section {* Direction @{text "regular language \<Rightarrow> finite partition"} *} |
63 | 7 |
|
8 |
definition |
|
181 | 9 |
tag_eq :: "('a list \<Rightarrow> 'b) \<Rightarrow> ('a list \<times> 'a list) set" ("=_=") |
63 | 10 |
where |
166 | 11 |
"=tag= \<equiv> {(x, y). tag x = tag y}" |
117 | 12 |
|
181 | 13 |
abbreviation |
14 |
tag_eq_applied :: "'a list \<Rightarrow> ('a list \<Rightarrow> 'b) \<Rightarrow> 'a list \<Rightarrow> bool" ("_ =_= _") |
|
15 |
where |
|
16 |
"x =tag= y \<equiv> (x, y) \<in> =tag=" |
|
17 |
||
183 | 18 |
lemma [simp]: |
181 | 19 |
shows "(\<approx>A) `` {x} = (\<approx>A) `` {y} \<longleftrightarrow> x \<approx>A y" |
183 | 20 |
unfolding str_eq_def by auto |
181 | 21 |
|
183 | 22 |
lemma refined_intro: |
181 | 23 |
assumes "\<And>x y z. \<lbrakk>x =tag= y; x @ z \<in> A\<rbrakk> \<Longrightarrow> y @ z \<in> A" |
24 |
shows "=tag= \<subseteq> \<approx>A" |
|
183 | 25 |
using assms unfolding str_eq_def tag_eq_def |
181 | 26 |
apply(clarify, simp (no_asm_use)) |
27 |
by metis |
|
28 |
||
117 | 29 |
lemma finite_eq_tag_rel: |
63 | 30 |
assumes rng_fnt: "finite (range tag)" |
109 | 31 |
shows "finite (UNIV // =tag=)" |
63 | 32 |
proof - |
119 | 33 |
let "?f" = "\<lambda>X. tag ` X" and ?A = "(UNIV // =tag=)" |
118 | 34 |
have "finite (?f ` ?A)" |
35 |
proof - |
|
119 | 36 |
have "range ?f \<subseteq> (Pow (range tag))" unfolding Pow_def by auto |
37 |
moreover |
|
38 |
have "finite (Pow (range tag))" using rng_fnt by simp |
|
39 |
ultimately |
|
40 |
have "finite (range ?f)" unfolding image_def by (blast intro: finite_subset) |
|
41 |
moreover |
|
42 |
have "?f ` ?A \<subseteq> range ?f" by auto |
|
43 |
ultimately show "finite (?f ` ?A)" by (rule rev_finite_subset) |
|
63 | 44 |
qed |
118 | 45 |
moreover |
119 | 46 |
have "inj_on ?f ?A" |
118 | 47 |
proof - |
48 |
{ fix X Y |
|
49 |
assume X_in: "X \<in> ?A" |
|
50 |
and Y_in: "Y \<in> ?A" |
|
51 |
and tag_eq: "?f X = ?f Y" |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
52 |
then obtain x y |
119 | 53 |
where "x \<in> X" "y \<in> Y" "tag x = tag y" |
181 | 54 |
unfolding quotient_def Image_def image_def tag_eq_def |
119 | 55 |
by (simp) (blast) |
56 |
with X_in Y_in |
|
118 | 57 |
have "X = Y" |
181 | 58 |
unfolding quotient_def tag_eq_def by auto |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
59 |
} |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
60 |
then show "inj_on ?f ?A" unfolding inj_on_def by auto |
118 | 61 |
qed |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
62 |
ultimately show "finite (UNIV // =tag=)" by (rule finite_imageD) |
63 | 63 |
qed |
64 |
||
65 |
lemma refined_partition_finite: |
|
118 | 66 |
assumes fnt: "finite (UNIV // R1)" |
63 | 67 |
and refined: "R1 \<subseteq> R2" |
118 | 68 |
and eq1: "equiv UNIV R1" and eq2: "equiv UNIV R2" |
69 |
shows "finite (UNIV // R2)" |
|
63 | 70 |
proof - |
118 | 71 |
let ?f = "\<lambda>X. {R1 `` {x} | x. x \<in> X}" |
72 |
and ?A = "UNIV // R2" and ?B = "UNIV // R1" |
|
73 |
have "?f ` ?A \<subseteq> Pow ?B" |
|
74 |
unfolding image_def Pow_def quotient_def by auto |
|
75 |
moreover |
|
76 |
have "finite (Pow ?B)" using fnt by simp |
|
77 |
ultimately |
|
78 |
have "finite (?f ` ?A)" by (rule finite_subset) |
|
79 |
moreover |
|
80 |
have "inj_on ?f ?A" |
|
81 |
proof - |
|
82 |
{ fix X Y |
|
83 |
assume X_in: "X \<in> ?A" and Y_in: "Y \<in> ?A" and eq_f: "?f X = ?f Y" |
|
84 |
from quotientE [OF X_in] |
|
85 |
obtain x where "X = R2 `` {x}" by blast |
|
86 |
with equiv_class_self[OF eq2] have x_in: "x \<in> X" by simp |
|
87 |
then have "R1 ``{x} \<in> ?f X" by auto |
|
88 |
with eq_f have "R1 `` {x} \<in> ?f Y" by simp |
|
89 |
then obtain y |
|
90 |
where y_in: "y \<in> Y" and eq_r1_xy: "R1 `` {x} = R1 `` {y}" by auto |
|
91 |
with eq_equiv_class[OF _ eq1] |
|
92 |
have "(x, y) \<in> R1" by blast |
|
93 |
with refined have "(x, y) \<in> R2" by auto |
|
94 |
with quotient_eqI [OF eq2 X_in Y_in x_in y_in] |
|
95 |
have "X = Y" . |
|
96 |
} |
|
97 |
then show "inj_on ?f ?A" unfolding inj_on_def by blast |
|
63 | 98 |
qed |
118 | 99 |
ultimately show "finite (UNIV // R2)" by (rule finite_imageD) |
63 | 100 |
qed |
101 |
||
102 |
lemma tag_finite_imageD: |
|
103 |
assumes rng_fnt: "finite (range tag)" |
|
187 | 104 |
and refined: "=tag= \<subseteq> \<approx>A" |
119 | 105 |
shows "finite (UNIV // \<approx>A)" |
106 |
proof (rule_tac refined_partition_finite [of "=tag="]) |
|
107 |
show "finite (UNIV // =tag=)" by (rule finite_eq_tag_rel[OF rng_fnt]) |
|
108 |
next |
|
187 | 109 |
show "=tag= \<subseteq> \<approx>A" using refined . |
119 | 110 |
next |
111 |
show "equiv UNIV =tag=" |
|
187 | 112 |
and "equiv UNIV (\<approx>A)" |
113 |
unfolding equiv_def str_eq_def tag_eq_def refl_on_def sym_def trans_def |
|
119 | 114 |
by auto |
63 | 115 |
qed |
116 |
||
117 |
||
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
118 |
subsection {* The proof *} |
63 | 119 |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
120 |
subsubsection {* The base case for @{const "Zero"} *} |
63 | 121 |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
122 |
lemma quot_zero_eq: |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
123 |
shows "UNIV // \<approx>{} = {UNIV}" |
181 | 124 |
unfolding quotient_def Image_def str_eq_def by auto |
63 | 125 |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
126 |
lemma quot_zero_finiteI [intro]: |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
127 |
shows "finite (UNIV // \<approx>{})" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
128 |
unfolding quot_zero_eq by simp |
63 | 129 |
|
130 |
||
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
131 |
subsubsection {* The base case for @{const "One"} *} |
63 | 132 |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
133 |
lemma quot_one_subset: |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
134 |
shows "UNIV // \<approx>{[]} \<subseteq> {{[]}, UNIV - {[]}}" |
63 | 135 |
proof |
136 |
fix x |
|
137 |
assume "x \<in> UNIV // \<approx>{[]}" |
|
187 | 138 |
then obtain y where h: "x = {z. y \<approx>{[]} z}" |
63 | 139 |
unfolding quotient_def Image_def by blast |
187 | 140 |
{ assume "y = []" |
141 |
with h have "x = {[]}" by (auto simp: str_eq_def) |
|
142 |
then have "x \<in> {{[]}, UNIV - {[]}}" by simp } |
|
143 |
moreover |
|
144 |
{ assume "y \<noteq> []" |
|
145 |
with h have "x = UNIV - {[]}" by (auto simp: str_eq_def) |
|
146 |
then have "x \<in> {{[]}, UNIV - {[]}}" by simp } |
|
147 |
ultimately show "x \<in> {{[]}, UNIV - {[]}}" by blast |
|
63 | 148 |
qed |
149 |
||
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
150 |
lemma quot_one_finiteI [intro]: |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
151 |
shows "finite (UNIV // \<approx>{[]})" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
152 |
by (rule finite_subset[OF quot_one_subset]) (simp) |
63 | 153 |
|
154 |
||
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
155 |
subsubsection {* The base case for @{const "Atom"} *} |
63 | 156 |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
157 |
lemma quot_atom_subset: |
63 | 158 |
"UNIV // (\<approx>{[c]}) \<subseteq> {{[]},{[c]}, UNIV - {[], [c]}}" |
159 |
proof |
|
160 |
fix x |
|
161 |
assume "x \<in> UNIV // \<approx>{[c]}" |
|
162 |
then obtain y where h: "x = {z. (y, z) \<in> \<approx>{[c]}}" |
|
163 |
unfolding quotient_def Image_def by blast |
|
164 |
show "x \<in> {{[]},{[c]}, UNIV - {[], [c]}}" |
|
165 |
proof - |
|
166 |
{ assume "y = []" hence "x = {[]}" using h |
|
181 | 167 |
by (auto simp: str_eq_def) } |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
168 |
moreover |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
169 |
{ assume "y = [c]" hence "x = {[c]}" using h |
181 | 170 |
by (auto dest!: spec[where x = "[]"] simp: str_eq_def) } |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
171 |
moreover |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
172 |
{ assume "y \<noteq> []" and "y \<noteq> [c]" |
63 | 173 |
hence "\<forall> z. (y @ z) \<noteq> [c]" by (case_tac y, auto) |
174 |
moreover have "\<And> p. (p \<noteq> [] \<and> p \<noteq> [c]) = (\<forall> q. p @ q \<noteq> [c])" |
|
175 |
by (case_tac p, auto) |
|
176 |
ultimately have "x = UNIV - {[],[c]}" using h |
|
181 | 177 |
by (auto simp add: str_eq_def) |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
178 |
} |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
179 |
ultimately show ?thesis by blast |
63 | 180 |
qed |
181 |
qed |
|
182 |
||
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
183 |
lemma quot_atom_finiteI [intro]: |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
184 |
shows "finite (UNIV // \<approx>{[c]})" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
185 |
by (rule finite_subset[OF quot_atom_subset]) (simp) |
63 | 186 |
|
187 |
||
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
188 |
subsubsection {* The inductive case for @{const Plus} *} |
63 | 189 |
|
190 |
definition |
|
181 | 191 |
tag_Plus :: "'a lang \<Rightarrow> 'a lang \<Rightarrow> 'a list \<Rightarrow> ('a lang \<times> 'a lang)" |
63 | 192 |
where |
183 | 193 |
"tag_Plus A B \<equiv> \<lambda>x. (\<approx>A `` {x}, \<approx>B `` {x})" |
63 | 194 |
|
181 | 195 |
lemma quot_plus_finiteI [intro]: |
119 | 196 |
assumes finite1: "finite (UNIV // \<approx>A)" |
197 |
and finite2: "finite (UNIV // \<approx>B)" |
|
198 |
shows "finite (UNIV // \<approx>(A \<union> B))" |
|
181 | 199 |
proof (rule_tac tag = "tag_Plus A B" in tag_finite_imageD) |
119 | 200 |
have "finite ((UNIV // \<approx>A) \<times> (UNIV // \<approx>B))" |
201 |
using finite1 finite2 by auto |
|
181 | 202 |
then show "finite (range (tag_Plus A B))" |
203 |
unfolding tag_Plus_def quotient_def |
|
119 | 204 |
by (rule rev_finite_subset) (auto) |
205 |
next |
|
183 | 206 |
show "=tag_Plus A B= \<subseteq> \<approx>(A \<union> B)" |
207 |
unfolding tag_eq_def tag_Plus_def str_eq_def by auto |
|
63 | 208 |
qed |
209 |
||
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
210 |
|
183 | 211 |
subsubsection {* The inductive case for @{text "Times"} *} |
63 | 212 |
|
181 | 213 |
definition |
184 | 214 |
"Partitions x \<equiv> {(x\<^isub>p, x\<^isub>s). x\<^isub>p @ x\<^isub>s = x}" |
181 | 215 |
|
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
216 |
lemma conc_partitions_elim: |
181 | 217 |
assumes "x \<in> A \<cdot> B" |
218 |
shows "\<exists>(u, v) \<in> Partitions x. u \<in> A \<and> v \<in> B" |
|
183 | 219 |
using assms unfolding conc_def Partitions_def |
181 | 220 |
by auto |
221 |
||
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
222 |
lemma conc_partitions_intro: |
181 | 223 |
assumes "(u, v) \<in> Partitions x \<and> u \<in> A \<and> v \<in> B" |
224 |
shows "x \<in> A \<cdot> B" |
|
183 | 225 |
using assms unfolding conc_def Partitions_def |
181 | 226 |
by auto |
227 |
||
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
228 |
lemma equiv_class_member: |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
229 |
assumes "x \<in> A" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
230 |
and "\<approx>A `` {x} = \<approx>A `` {y}" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
231 |
shows "y \<in> A" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
232 |
using assms |
183 | 233 |
apply(simp) |
234 |
apply(simp add: str_eq_def) |
|
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
235 |
apply(metis append_Nil2) |
181 | 236 |
done |
237 |
||
184 | 238 |
definition |
239 |
tag_Times :: "'a lang \<Rightarrow> 'a lang \<Rightarrow> 'a list \<Rightarrow> 'a lang \<times> 'a lang set" |
|
181 | 240 |
where |
184 | 241 |
"tag_Times A B \<equiv> \<lambda>x. (\<approx>A `` {x}, {(\<approx>B `` {x\<^isub>s}) | x\<^isub>p x\<^isub>s. x\<^isub>p \<in> A \<and> (x\<^isub>p, x\<^isub>s) \<in> Partitions x})" |
181 | 242 |
|
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
243 |
lemma tag_Times_injI: |
184 | 244 |
assumes a: "tag_Times A B x = tag_Times A B y" |
181 | 245 |
and c: "x @ z \<in> A \<cdot> B" |
246 |
shows "y @ z \<in> A \<cdot> B" |
|
247 |
proof - |
|
248 |
from c obtain u v where |
|
249 |
h1: "(u, v) \<in> Partitions (x @ z)" and |
|
250 |
h2: "u \<in> A" and |
|
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
251 |
h3: "v \<in> B" by (auto dest: conc_partitions_elim) |
181 | 252 |
from h1 have "x @ z = u @ v" unfolding Partitions_def by simp |
253 |
then obtain us |
|
254 |
where "(x = u @ us \<and> us @ z = v) \<or> (x @ us = u \<and> z = us @ v)" |
|
255 |
by (auto simp add: append_eq_append_conv2) |
|
256 |
moreover |
|
257 |
{ assume eq: "x = u @ us" "us @ z = v" |
|
184 | 258 |
have "(\<approx>B `` {us}) \<in> snd (tag_Times A B x)" |
259 |
unfolding Partitions_def tag_Times_def using h2 eq |
|
260 |
by (auto simp add: str_eq_def) |
|
261 |
then have "(\<approx>B `` {us}) \<in> snd (tag_Times A B y)" |
|
262 |
using a by simp |
|
181 | 263 |
then obtain u' us' where |
184 | 264 |
q1: "u' \<in> A" and |
181 | 265 |
q2: "\<approx>B `` {us} = \<approx>B `` {us'}" and |
184 | 266 |
q3: "(u', us') \<in> Partitions y" |
267 |
unfolding tag_Times_def by auto |
|
268 |
from q2 h3 eq |
|
181 | 269 |
have "us' @ z \<in> B" |
270 |
unfolding Image_def str_eq_def by auto |
|
184 | 271 |
then have "y @ z \<in> A \<cdot> B" using q1 q3 |
181 | 272 |
unfolding Partitions_def by auto |
273 |
} |
|
274 |
moreover |
|
275 |
{ assume eq: "x @ us = u" "z = us @ v" |
|
184 | 276 |
have "(\<approx>A `` {x}) = fst (tag_Times A B x)" |
277 |
by (simp add: tag_Times_def) |
|
278 |
then have "(\<approx>A `` {x}) = fst (tag_Times A B y)" |
|
181 | 279 |
using a by simp |
184 | 280 |
then have "\<approx>A `` {x} = \<approx>A `` {y}" |
281 |
by (simp add: tag_Times_def) |
|
181 | 282 |
moreover |
283 |
have "x @ us \<in> A" using h2 eq by simp |
|
284 |
ultimately |
|
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
285 |
have "y @ us \<in> A" using equiv_class_member |
181 | 286 |
unfolding Image_def str_eq_def by blast |
287 |
then have "(y @ us) @ v \<in> A \<cdot> B" |
|
288 |
using h3 unfolding conc_def by blast |
|
289 |
then have "y @ z \<in> A \<cdot> B" using eq by simp |
|
290 |
} |
|
291 |
ultimately show "y @ z \<in> A \<cdot> B" by blast |
|
292 |
qed |
|
293 |
||
294 |
lemma quot_conc_finiteI [intro]: |
|
295 |
assumes fin1: "finite (UNIV // \<approx>A)" |
|
296 |
and fin2: "finite (UNIV // \<approx>B)" |
|
297 |
shows "finite (UNIV // \<approx>(A \<cdot> B))" |
|
298 |
proof (rule_tac tag = "tag_Times A B" in tag_finite_imageD) |
|
183 | 299 |
have "\<And>x y z. \<lbrakk>tag_Times A B x = tag_Times A B y; x @ z \<in> A \<cdot> B\<rbrakk> \<Longrightarrow> y @ z \<in> A \<cdot> B" |
300 |
by (rule tag_Times_injI) |
|
301 |
(auto simp add: tag_Times_def tag_eq_def) |
|
302 |
then show "=tag_Times A B= \<subseteq> \<approx>(A \<cdot> B)" |
|
303 |
by (rule refined_intro) |
|
304 |
(auto simp add: tag_eq_def) |
|
63 | 305 |
next |
184 | 306 |
have *: "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))" |
63 | 307 |
using fin1 fin2 by auto |
181 | 308 |
show "finite (range (tag_Times A B))" |
309 |
unfolding tag_Times_def |
|
63 | 310 |
apply(rule finite_subset[OF _ *]) |
311 |
unfolding quotient_def |
|
312 |
by auto |
|
313 |
qed |
|
314 |
||
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
315 |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
316 |
subsubsection {* The inductive case for @{const "Star"} *} |
63 | 317 |
|
183 | 318 |
lemma star_partitions_elim: |
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
319 |
assumes "x @ z \<in> A\<star>" "x \<noteq> []" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
320 |
shows "\<exists>(u, v) \<in> Partitions (x @ z). u < x \<and> u \<in> A\<star> \<and> v \<in> A\<star>" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
321 |
proof - |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
322 |
have "([], x @ z) \<in> Partitions (x @ z)" "[] < x" "[] \<in> A\<star>" "x @ z \<in> A\<star>" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
323 |
using assms by (auto simp add: Partitions_def strict_prefix_def) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
324 |
then show "\<exists>(u, v) \<in> Partitions (x @ z). u < x \<and> u \<in> A\<star> \<and> v \<in> A\<star>" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
325 |
by blast |
63 | 326 |
qed |
327 |
||
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
328 |
lemma finite_set_has_max2: |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
329 |
"\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists> max \<in> A. \<forall> a \<in> A. length a \<le> length max" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
330 |
apply(induct rule:finite.induct) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
331 |
apply(simp) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
332 |
by (metis (full_types) all_not_in_conv insert_iff linorder_linear order_trans) |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
333 |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
334 |
lemma finite_strict_prefix_set: |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
335 |
shows "finite {xa. xa < (x::'a list)}" |
63 | 336 |
apply (induct x rule:rev_induct, simp) |
337 |
apply (subgoal_tac "{xa. xa < xs @ [x]} = {xa. xa < xs} \<union> {xs}") |
|
338 |
by (auto simp:strict_prefix_def) |
|
339 |
||
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
340 |
lemma append_eq_cases: |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
341 |
assumes a: "x @ y = m @ n" "m \<noteq> []" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
342 |
shows "x \<le> m \<or> m < x" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
343 |
unfolding prefix_def strict_prefix_def using a |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
344 |
by (auto simp add: append_eq_append_conv2) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
345 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
346 |
lemma star_spartitions_elim2: |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
347 |
assumes a: "x @ z \<in> A\<star>" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
348 |
and b: "x \<noteq> []" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
349 |
shows "\<exists>(u, v) \<in> Partitions x. \<exists> (u', v') \<in> Partitions z. u < x \<and> u \<in> A\<star> \<and> v @ u' \<in> A \<and> v' \<in> A\<star>" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
350 |
proof - |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
351 |
def S \<equiv> "{u | u v. (u, v) \<in> Partitions x \<and> u < x \<and> u \<in> A\<star> \<and> v @ z \<in> A\<star>}" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
352 |
have "finite {u. u < x}" by (rule finite_strict_prefix_set) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
353 |
then have "finite S" unfolding S_def |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
354 |
by (rule rev_finite_subset) (auto) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
355 |
moreover |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
356 |
have "S \<noteq> {}" using a b unfolding S_def Partitions_def |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
357 |
by (auto simp: strict_prefix_def) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
358 |
ultimately have "\<exists> u_max \<in> S. \<forall> u \<in> S. length u \<le> length u_max" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
359 |
using finite_set_has_max2 by blast |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
360 |
then obtain u_max v |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
361 |
where h0: "(u_max, v) \<in> Partitions x" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
362 |
and h1: "u_max < x" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
363 |
and h2: "u_max \<in> A\<star>" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
364 |
and h3: "v @ z \<in> A\<star>" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
365 |
and h4: "\<forall> u v. (u, v) \<in> Partitions x \<and> u < x \<and> u \<in> A\<star> \<and> v @ z \<in> A\<star> \<longrightarrow> length u \<le> length u_max" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
366 |
unfolding S_def Partitions_def by blast |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
367 |
have q: "v \<noteq> []" using h0 h1 b unfolding Partitions_def by auto |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
368 |
from h3 obtain a b |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
369 |
where i1: "(a, b) \<in> Partitions (v @ z)" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
370 |
and i2: "a \<in> A" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
371 |
and i3: "b \<in> A\<star>" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
372 |
and i4: "a \<noteq> []" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
373 |
unfolding Partitions_def |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
374 |
using q by (auto dest: star_decom) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
375 |
have "v \<le> a" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
376 |
proof (rule ccontr) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
377 |
assume a: "\<not>(v \<le> a)" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
378 |
from i1 have i1': "a @ b = v @ z" unfolding Partitions_def by simp |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
379 |
then have "a \<le> v \<or> v < a" using append_eq_cases q by blast |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
380 |
then have q: "a < v" using a unfolding strict_prefix_def prefix_def by auto |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
381 |
then obtain as where eq: "a @ as = v" unfolding strict_prefix_def prefix_def by auto |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
382 |
have "(u_max @ a, as) \<in> Partitions x" using eq h0 unfolding Partitions_def by auto |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
383 |
moreover |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
384 |
have "u_max @ a < x" using h0 eq q unfolding Partitions_def strict_prefix_def prefix_def by auto |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
385 |
moreover |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
386 |
have "u_max @ a \<in> A\<star>" using i2 h2 by simp |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
387 |
moreover |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
388 |
have "as @ z \<in> A\<star>" using i1' i2 i3 eq by auto |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
389 |
ultimately have "length (u_max @ a) \<le> length u_max" using h4 by blast |
183 | 390 |
with i4 show "False" by auto |
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
391 |
qed |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
392 |
with i1 obtain za zb |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
393 |
where k1: "v @ za = a" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
394 |
and k2: "(za, zb) \<in> Partitions z" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
395 |
and k4: "zb = b" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
396 |
unfolding Partitions_def prefix_def |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
397 |
by (auto simp add: append_eq_append_conv2) |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
398 |
show "\<exists> (u, v) \<in> Partitions x. \<exists> (u', v') \<in> Partitions z. u < x \<and> u \<in> A\<star> \<and> v @ u' \<in> A \<and> v' \<in> A\<star>" |
183 | 399 |
using h0 h1 h2 i2 i3 k1 k2 k4 unfolding Partitions_def by blast |
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
400 |
qed |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
401 |
|
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
402 |
definition |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
403 |
tag_Star :: "'a lang \<Rightarrow> 'a list \<Rightarrow> ('a lang) set" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
404 |
where |
187 | 405 |
"tag_Star A \<equiv> \<lambda>x. {\<approx>A `` {v} | u v. u < x \<and> u \<in> A\<star> \<and> (u, v) \<in> Partitions x}" |
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
406 |
|
183 | 407 |
lemma tag_Star_non_empty_injI: |
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
408 |
assumes a: "tag_Star A x = tag_Star A y" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
409 |
and c: "x @ z \<in> A\<star>" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
410 |
and d: "x \<noteq> []" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
411 |
shows "y @ z \<in> A\<star>" |
183 | 412 |
proof - |
413 |
obtain u v u' v' |
|
414 |
where a1: "(u, v) \<in> Partitions x" "(u', v')\<in> Partitions z" |
|
415 |
and a2: "u < x" |
|
416 |
and a3: "u \<in> A\<star>" |
|
417 |
and a4: "v @ u' \<in> A" |
|
418 |
and a5: "v' \<in> A\<star>" |
|
419 |
using c d by (auto dest: star_spartitions_elim2) |
|
420 |
have "(\<approx>A) `` {v} \<in> tag_Star A x" |
|
421 |
apply(simp add: tag_Star_def Partitions_def str_eq_def) |
|
422 |
using a1 a2 a3 by (auto simp add: Partitions_def) |
|
423 |
then have "(\<approx>A) `` {v} \<in> tag_Star A y" using a by simp |
|
424 |
then obtain u1 v1 |
|
425 |
where b1: "v \<approx>A v1" |
|
426 |
and b3: "u1 \<in> A\<star>" |
|
427 |
and b4: "(u1, v1) \<in> Partitions y" |
|
428 |
unfolding tag_Star_def by auto |
|
429 |
have c: "v1 @ u' \<in> A\<star>" using b1 a4 unfolding str_eq_def by simp |
|
430 |
have "u1 @ (v1 @ u') @ v' \<in> A\<star>" |
|
431 |
using b3 c a5 by (simp only: append_in_starI) |
|
432 |
then show "y @ z \<in> A\<star>" using b4 a1 |
|
433 |
unfolding Partitions_def by auto |
|
434 |
qed |
|
435 |
||
436 |
lemma tag_Star_empty_injI: |
|
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
437 |
assumes a: "tag_Star A x = tag_Star A y" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
438 |
and c: "x @ z \<in> A\<star>" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
439 |
and d: "x = []" |
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
440 |
shows "y @ z \<in> A\<star>" |
187 | 441 |
proof - |
442 |
from a have "{} = tag_Star A y" unfolding tag_Star_def using d by auto |
|
443 |
then have "y = []" |
|
444 |
unfolding tag_Star_def Partitions_def strict_prefix_def prefix_def |
|
445 |
by (auto) (metis Nil_in_star append_self_conv2) |
|
446 |
then show "y @ z \<in> A\<star>" using c d by simp |
|
447 |
qed |
|
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
448 |
|
63 | 449 |
lemma quot_star_finiteI [intro]: |
166 | 450 |
assumes finite1: "finite (UNIV // \<approx>A)" |
451 |
shows "finite (UNIV // \<approx>(A\<star>))" |
|
181 | 452 |
proof (rule_tac tag = "tag_Star A" in tag_finite_imageD) |
183 | 453 |
have "\<And>x y z. \<lbrakk>tag_Star A x = tag_Star A y; x @ z \<in> A\<star>\<rbrakk> \<Longrightarrow> y @ z \<in> A\<star>" |
454 |
by (case_tac "x = []") (blast intro: tag_Star_empty_injI tag_Star_non_empty_injI)+ |
|
455 |
then show "=(tag_Star A)= \<subseteq> \<approx>(A\<star>)" |
|
456 |
by (rule refined_intro) (auto simp add: tag_eq_def) |
|
63 | 457 |
next |
166 | 458 |
have *: "finite (Pow (UNIV // \<approx>A))" |
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
459 |
using finite1 by auto |
181 | 460 |
show "finite (range (tag_Star A))" |
183 | 461 |
unfolding tag_Star_def |
462 |
by (rule finite_subset[OF _ *]) |
|
463 |
(auto simp add: quotient_def) |
|
63 | 464 |
qed |
465 |
||
466 |
subsubsection{* The conclusion *} |
|
467 |
||
112 | 468 |
lemma Myhill_Nerode2: |
183 | 469 |
fixes r::"'a rexp" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
470 |
shows "finite (UNIV // \<approx>(lang r))" |
63 | 471 |
by (induct r) (auto) |
472 |
||
132 | 473 |
theorem Myhill_Nerode: |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
474 |
fixes A::"('a::finite) lang" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
475 |
shows "(\<exists>r. A = lang r) \<longleftrightarrow> finite (UNIV // \<approx>A)" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
476 |
using Myhill_Nerode1 Myhill_Nerode2 by auto |
112 | 477 |
|
183 | 478 |
end |