author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Thu, 11 Jul 2013 16:46:05 +0100 | |
changeset 384 | 60bcf13adb77 |
parent 372 | 2c56b20032a7 |
permissions | -rw-r--r-- |
372
2c56b20032a7
made changes and updates to the journal paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
1 |
(* Author: Xingyuan Zhang, Chunhan Wu, Christian Urban *) |
42 | 2 |
theory Myhill_1 |
203 | 3 |
imports "Folds" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
4 |
"~~/src/HOL/Library/While_Combinator" |
42 | 5 |
begin |
6 |
||
203 | 7 |
section {* First direction of MN: @{text "finite partition \<Rightarrow> regular language"} *} |
8 |
||
9 |
notation |
|
10 |
conc (infixr "\<cdot>" 100) and |
|
11 |
star ("_\<star>" [101] 102) |
|
86 | 12 |
|
179 | 13 |
lemma Pair_Collect [simp]: |
48 | 14 |
shows "(x, y) \<in> {(x, y). P x y} \<longleftrightarrow> P x y" |
15 |
by simp |
|
16 |
||
86 | 17 |
text {* Myhill-Nerode relation *} |
18 |
||
48 | 19 |
definition |
181 | 20 |
str_eq :: "'a lang \<Rightarrow> ('a list \<times> 'a list) set" ("\<approx>_" [100] 100) |
48 | 21 |
where |
70 | 22 |
"\<approx>A \<equiv> {(x, y). (\<forall>z. x @ z \<in> A \<longleftrightarrow> y @ z \<in> A)}" |
48 | 23 |
|
181 | 24 |
abbreviation |
25 |
str_eq_applied :: "'a list \<Rightarrow> 'a lang \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<approx>_ _") |
|
26 |
where |
|
27 |
"x \<approx>A y \<equiv> (x, y) \<in> \<approx>A" |
|
28 |
||
48 | 29 |
definition |
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
|
30 |
finals :: "'a lang \<Rightarrow> 'a lang set" |
71 | 31 |
where |
108 | 32 |
"finals A \<equiv> {\<approx>A `` {s} | s . s \<in> A}" |
48 | 33 |
|
34 |
lemma lang_is_union_of_finals: |
|
70 | 35 |
shows "A = \<Union> finals A" |
36 |
unfolding finals_def |
|
37 |
unfolding Image_def |
|
181 | 38 |
unfolding str_eq_def |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
39 |
by (auto) (metis append_Nil2) |
70 | 40 |
|
79 | 41 |
lemma finals_in_partitions: |
42 |
shows "finals A \<subseteq> (UNIV // \<approx>A)" |
|
94 | 43 |
unfolding finals_def quotient_def |
76 | 44 |
by auto |
45 |
||
203 | 46 |
subsection {* Equational systems *} |
42 | 47 |
|
89 | 48 |
text {* The two kinds of terms in the rhs of equations. *} |
49 |
||
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
|
50 |
datatype 'a trm = |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
51 |
Lam "'a rexp" (* Lambda-marker *) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
52 |
| Trn "'a lang" "'a rexp" (* Transition *) |
70 | 53 |
|
166 | 54 |
fun |
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
|
55 |
lang_trm::"'a trm \<Rightarrow> 'a lang" |
166 | 56 |
where |
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
|
57 |
"lang_trm (Lam r) = lang r" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
58 |
| "lang_trm (Trn X r) = X \<cdot> lang r" |
42 | 59 |
|
166 | 60 |
fun |
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
|
61 |
lang_rhs::"('a trm) set \<Rightarrow> 'a lang" |
166 | 62 |
where |
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
|
63 |
"lang_rhs rhs = \<Union> (lang_trm ` rhs)" |
42 | 64 |
|
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
|
65 |
lemma lang_rhs_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
|
66 |
shows "lang_rhs {Trn X r | r. P r} = \<Union>{lang_trm (Trn X r) | r. P r}" |
166 | 67 |
by (auto) |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
68 |
|
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
|
69 |
lemma lang_rhs_union_distrib: |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
70 |
shows "lang_rhs A \<union> lang_rhs B = lang_rhs (A \<union> B)" |
96 | 71 |
by simp |
72 |
||
73 |
||
86 | 74 |
text {* Transitions between equivalence classes *} |
71 | 75 |
|
76 |
definition |
|
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
|
77 |
transition :: "'a lang \<Rightarrow> 'a \<Rightarrow> 'a lang \<Rightarrow> bool" ("_ \<Turnstile>_\<Rightarrow>_" [100,100,100] 100) |
71 | 78 |
where |
166 | 79 |
"Y \<Turnstile>c\<Rightarrow> X \<equiv> Y \<cdot> {[c]} \<subseteq> X" |
42 | 80 |
|
86 | 81 |
text {* Initial equational system *} |
82 |
||
42 | 83 |
definition |
96 | 84 |
"Init_rhs CS X \<equiv> |
42 | 85 |
if ([] \<in> X) then |
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
|
86 |
{Lam One} \<union> {Trn Y (Atom c) | Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X} |
42 | 87 |
else |
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
|
88 |
{Trn Y (Atom c)| Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X}" |
42 | 89 |
|
86 | 90 |
definition |
96 | 91 |
"Init CS \<equiv> {(X, Init_rhs CS X) | X. X \<in> CS}" |
75 | 92 |
|
93 |
||
203 | 94 |
subsection {* Arden Operation on equations *} |
42 | 95 |
|
70 | 96 |
fun |
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
|
97 |
Append_rexp :: "'a rexp \<Rightarrow> 'a trm \<Rightarrow> 'a trm" |
42 | 98 |
where |
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
|
99 |
"Append_rexp r (Lam rexp) = Lam (Times rexp r)" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
100 |
| "Append_rexp r (Trn X rexp) = Trn X (Times rexp r)" |
42 | 101 |
|
102 |
||
103 |
definition |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
104 |
"Append_rexp_rhs rhs rexp \<equiv> (Append_rexp rexp) ` rhs" |
42 | 105 |
|
86 | 106 |
definition |
94 | 107 |
"Arden X rhs \<equiv> |
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
|
108 |
Append_rexp_rhs (rhs - {Trn X r | r. Trn X r \<in> rhs}) (Star (\<Uplus> {r. Trn X r \<in> rhs}))" |
86 | 109 |
|
110 |
||
203 | 111 |
subsection {* Substitution Operation on equations *} |
86 | 112 |
|
42 | 113 |
definition |
94 | 114 |
"Subst rhs X xrhs \<equiv> |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
115 |
(rhs - {Trn X r | r. Trn X r \<in> rhs}) \<union> (Append_rexp_rhs xrhs (\<Uplus> {r. Trn X r \<in> rhs}))" |
97 | 116 |
|
42 | 117 |
definition |
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
|
118 |
Subst_all :: "('a lang \<times> ('a trm) set) set \<Rightarrow> 'a lang \<Rightarrow> ('a trm) set \<Rightarrow> ('a lang \<times> ('a trm) set) set" |
97 | 119 |
where |
94 | 120 |
"Subst_all ES X xrhs \<equiv> {(Y, Subst yrhs X xrhs) | Y yrhs. (Y, yrhs) \<in> ES}" |
86 | 121 |
|
91 | 122 |
definition |
96 | 123 |
"Remove ES X xrhs \<equiv> |
124 |
Subst_all (ES - {(X, xrhs)}) X (Arden X xrhs)" |
|
125 |
||
126 |
||
203 | 127 |
subsection {* While-combinator and invariants *} |
91 | 128 |
|
129 |
definition |
|
96 | 130 |
"Iter X ES \<equiv> (let (Y, yrhs) = SOME (Y, yrhs). (Y, yrhs) \<in> ES \<and> X \<noteq> Y |
95 | 131 |
in Remove ES Y yrhs)" |
42 | 132 |
|
97 | 133 |
lemma IterI2: |
134 |
assumes "(Y, yrhs) \<in> ES" |
|
135 |
and "X \<noteq> Y" |
|
136 |
and "\<And>Y yrhs. \<lbrakk>(Y, yrhs) \<in> ES; X \<noteq> Y\<rbrakk> \<Longrightarrow> Q (Remove ES Y yrhs)" |
|
137 |
shows "Q (Iter X ES)" |
|
138 |
unfolding Iter_def using assms |
|
139 |
by (rule_tac a="(Y, yrhs)" in someI2) (auto) |
|
140 |
||
141 |
abbreviation |
|
101 | 142 |
"Cond ES \<equiv> card ES \<noteq> 1" |
97 | 143 |
|
91 | 144 |
definition |
101 | 145 |
"Solve X ES \<equiv> while Cond (Iter X) ES" |
97 | 146 |
|
86 | 147 |
|
42 | 148 |
definition |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
149 |
"distinctness ES \<equiv> |
86 | 150 |
\<forall> X rhs rhs'. (X, rhs) \<in> ES \<and> (X, rhs') \<in> ES \<longrightarrow> rhs = rhs'" |
70 | 151 |
|
42 | 152 |
definition |
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
|
153 |
"soundness ES \<equiv> \<forall>(X, rhs) \<in> ES. X = lang_rhs rhs" |
70 | 154 |
|
42 | 155 |
definition |
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
|
156 |
"ardenable rhs \<equiv> (\<forall> Y r. Trn Y r \<in> rhs \<longrightarrow> [] \<notin> lang r)" |
42 | 157 |
|
158 |
definition |
|
110 | 159 |
"ardenable_all ES \<equiv> \<forall>(X, rhs) \<in> ES. ardenable rhs" |
42 | 160 |
|
161 |
definition |
|
103 | 162 |
"finite_rhs ES \<equiv> \<forall>(X, rhs) \<in> ES. finite rhs" |
163 |
||
164 |
lemma finite_rhs_def2: |
|
165 |
"finite_rhs ES = (\<forall> X rhs. (X, rhs) \<in> ES \<longrightarrow> finite rhs)" |
|
166 |
unfolding finite_rhs_def by auto |
|
42 | 167 |
|
168 |
definition |
|
104 | 169 |
"rhss rhs \<equiv> {X | X r. Trn X r \<in> rhs}" |
42 | 170 |
|
171 |
definition |
|
103 | 172 |
"lhss ES \<equiv> {Y | Y yrhs. (Y, yrhs) \<in> ES}" |
42 | 173 |
|
174 |
definition |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
175 |
"validity ES \<equiv> \<forall>(X, rhs) \<in> ES. rhss rhs \<subseteq> lhss ES" |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
176 |
|
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
177 |
lemma rhss_union_distrib: |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
178 |
shows "rhss (A \<union> B) = rhss A \<union> rhss B" |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
179 |
by (auto simp add: rhss_def) |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
180 |
|
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
181 |
lemma lhss_union_distrib: |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
182 |
shows "lhss (A \<union> B) = lhss A \<union> lhss B" |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
183 |
by (auto simp add: lhss_def) |
42 | 184 |
|
185 |
||
186 |
definition |
|
103 | 187 |
"invariant ES \<equiv> finite ES |
188 |
\<and> finite_rhs ES |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
189 |
\<and> soundness ES |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
190 |
\<and> distinctness ES |
110 | 191 |
\<and> ardenable_all ES |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
192 |
\<and> validity ES" |
42 | 193 |
|
96 | 194 |
|
195 |
lemma invariantI: |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
196 |
assumes "soundness ES" "finite ES" "distinctness ES" "ardenable_all ES" |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
197 |
"finite_rhs ES" "validity ES" |
96 | 198 |
shows "invariant ES" |
199 |
using assms by (simp add: invariant_def) |
|
200 |
||
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
201 |
|
79 | 202 |
lemma finite_Trn: |
203 |
assumes fin: "finite rhs" |
|
204 |
shows "finite {r. Trn Y r \<in> rhs}" |
|
372
2c56b20032a7
made changes and updates to the journal paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
205 |
using assms by (auto intro!: finite_vimageI simp add: inj_on_def) |
79 | 206 |
|
207 |
lemma finite_Lam: |
|
96 | 208 |
assumes fin: "finite rhs" |
79 | 209 |
shows "finite {r. Lam r \<in> rhs}" |
372
2c56b20032a7
made changes and updates to the journal paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
210 |
using assms by (auto intro!: finite_vimageI simp add: inj_on_def) |
42 | 211 |
|
166 | 212 |
lemma trm_soundness: |
42 | 213 |
assumes finite:"finite rhs" |
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
|
214 |
shows "lang_rhs ({Trn X r| r. Trn X r \<in> rhs}) = X \<cdot> (lang (\<Uplus>{r. Trn X r \<in> rhs}))" |
42 | 215 |
proof - |
79 | 216 |
have "finite {r. Trn X r \<in> rhs}" |
217 |
by (rule finite_Trn[OF finite]) |
|
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
|
218 |
then show "lang_rhs ({Trn X r| r. Trn X r \<in> rhs}) = X \<cdot> (lang (\<Uplus>{r. Trn X r \<in> rhs}))" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
219 |
by (simp only: lang_rhs_set lang_trm.simps) (auto simp add: conc_def) |
42 | 220 |
qed |
221 |
||
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
222 |
lemma lang_of_append_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
|
223 |
"lang_trm (Append_rexp r trm) = lang_trm trm \<cdot> lang r" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
224 |
by (induct rule: Append_rexp.induct) |
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
|
225 |
(auto simp add: conc_assoc) |
42 | 226 |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
227 |
lemma lang_of_append_rexp_rhs: |
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
|
228 |
"lang_rhs (Append_rexp_rhs rhs r) = lang_rhs rhs \<cdot> lang r" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
229 |
unfolding Append_rexp_rhs_def |
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
|
230 |
by (auto simp add: conc_def lang_of_append_rexp) |
42 | 231 |
|
232 |
||
203 | 233 |
subsection {* Intial Equational Systems *} |
42 | 234 |
|
235 |
lemma defined_by_str: |
|
100 | 236 |
assumes "s \<in> X" "X \<in> UNIV // \<approx>A" |
237 |
shows "X = \<approx>A `` {s}" |
|
238 |
using assms |
|
181 | 239 |
unfolding quotient_def Image_def str_eq_def |
100 | 240 |
by auto |
42 | 241 |
|
242 |
lemma every_eqclass_has_transition: |
|
243 |
assumes has_str: "s @ [c] \<in> X" |
|
100 | 244 |
and in_CS: "X \<in> UNIV // \<approx>A" |
166 | 245 |
obtains Y where "Y \<in> UNIV // \<approx>A" and "Y \<cdot> {[c]} \<subseteq> X" and "s \<in> Y" |
42 | 246 |
proof - |
100 | 247 |
def Y \<equiv> "\<approx>A `` {s}" |
248 |
have "Y \<in> UNIV // \<approx>A" |
|
42 | 249 |
unfolding Y_def quotient_def by auto |
250 |
moreover |
|
100 | 251 |
have "X = \<approx>A `` {s @ [c]}" |
42 | 252 |
using has_str in_CS defined_by_str by blast |
166 | 253 |
then have "Y \<cdot> {[c]} \<subseteq> X" |
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
|
254 |
unfolding Y_def Image_def conc_def |
181 | 255 |
unfolding str_eq_def |
42 | 256 |
by clarsimp |
257 |
moreover |
|
258 |
have "s \<in> Y" unfolding Y_def |
|
181 | 259 |
unfolding Image_def str_eq_def by simp |
100 | 260 |
ultimately show thesis using that by blast |
42 | 261 |
qed |
262 |
||
263 |
lemma l_eq_r_in_eqs: |
|
100 | 264 |
assumes X_in_eqs: "(X, rhs) \<in> Init (UNIV // \<approx>A)" |
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
|
265 |
shows "X = lang_rhs rhs" |
42 | 266 |
proof |
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
|
267 |
show "X \<subseteq> lang_rhs rhs" |
42 | 268 |
proof |
269 |
fix x |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
270 |
assume in_X: "x \<in> X" |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
271 |
{ assume empty: "x = []" |
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
|
272 |
then have "x \<in> lang_rhs rhs" using X_in_eqs in_X |
372
2c56b20032a7
made changes and updates to the journal paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
273 |
unfolding Init_def Init_rhs_def |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
274 |
by auto |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
275 |
} |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
276 |
moreover |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
277 |
{ assume not_empty: "x \<noteq> []" |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
278 |
then obtain s c where decom: "x = s @ [c]" |
372
2c56b20032a7
made changes and updates to the journal paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
279 |
using rev_cases by blast |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
280 |
have "X \<in> UNIV // \<approx>A" using X_in_eqs unfolding Init_def by auto |
166 | 281 |
then obtain Y where "Y \<in> UNIV // \<approx>A" "Y \<cdot> {[c]} \<subseteq> X" "s \<in> Y" |
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
|
282 |
using decom in_X every_eqclass_has_transition by metis |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
283 |
then have "x \<in> lang_rhs {Trn Y (Atom c)| Y c. Y \<in> UNIV // \<approx>A \<and> Y \<Turnstile>c\<Rightarrow> X}" |
71 | 284 |
unfolding transition_def |
372
2c56b20032a7
made changes and updates to the journal paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
285 |
using decom by (force simp add: conc_def) |
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
|
286 |
then have "x \<in> lang_rhs rhs" using X_in_eqs in_X |
372
2c56b20032a7
made changes and updates to the journal paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
287 |
unfolding Init_def Init_rhs_def by simp |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
288 |
} |
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
|
289 |
ultimately show "x \<in> lang_rhs rhs" by blast |
42 | 290 |
qed |
291 |
next |
|
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
|
292 |
show "lang_rhs rhs \<subseteq> X" using X_in_eqs |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
293 |
unfolding Init_def Init_rhs_def transition_def |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
294 |
by auto |
42 | 295 |
qed |
296 |
||
100 | 297 |
|
96 | 298 |
lemma finite_Init_rhs: |
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
|
299 |
fixes CS::"(('a::finite) lang) set" |
42 | 300 |
assumes finite: "finite CS" |
96 | 301 |
shows "finite (Init_rhs CS X)" |
372
2c56b20032a7
made changes and updates to the journal paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
302 |
using assms unfolding Init_rhs_def transition_def by simp |
42 | 303 |
|
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
|
304 |
|
96 | 305 |
lemma Init_ES_satisfies_invariant: |
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
|
306 |
fixes A::"(('a::finite) lang)" |
96 | 307 |
assumes finite_CS: "finite (UNIV // \<approx>A)" |
308 |
shows "invariant (Init (UNIV // \<approx>A))" |
|
309 |
proof (rule invariantI) |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
310 |
show "soundness (Init (UNIV // \<approx>A))" |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
311 |
unfolding soundness_def |
97 | 312 |
using l_eq_r_in_eqs by auto |
96 | 313 |
show "finite (Init (UNIV // \<approx>A))" using finite_CS |
314 |
unfolding Init_def by simp |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
315 |
show "distinctness (Init (UNIV // \<approx>A))" |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
316 |
unfolding distinctness_def Init_def by simp |
110 | 317 |
show "ardenable_all (Init (UNIV // \<approx>A))" |
318 |
unfolding ardenable_all_def Init_def Init_rhs_def ardenable_def |
|
103 | 319 |
by auto |
96 | 320 |
show "finite_rhs (Init (UNIV // \<approx>A))" |
321 |
using finite_Init_rhs[OF finite_CS] |
|
322 |
unfolding finite_rhs_def Init_def by auto |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
323 |
show "validity (Init (UNIV // \<approx>A))" |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
324 |
unfolding validity_def Init_def Init_rhs_def rhss_def lhss_def |
96 | 325 |
by auto |
42 | 326 |
qed |
327 |
||
203 | 328 |
subsection {* Interations *} |
42 | 329 |
|
179 | 330 |
lemma Arden_preserves_soundness: |
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
|
331 |
assumes l_eq_r: "X = lang_rhs rhs" |
110 | 332 |
and not_empty: "ardenable rhs" |
42 | 333 |
and finite: "finite rhs" |
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 |
shows "X = lang_rhs (Arden X rhs)" |
42 | 335 |
proof - |
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
|
336 |
def A \<equiv> "lang (\<Uplus>{r. Trn X r \<in> rhs})" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
337 |
def b \<equiv> "{Trn X r | r. Trn X r \<in> rhs}" |
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
|
338 |
def B \<equiv> "lang_rhs (rhs - b)" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
339 |
have not_empty2: "[] \<notin> A" |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
340 |
using finite_Trn[OF finite] not_empty |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
341 |
unfolding A_def ardenable_def by simp |
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
|
342 |
have "X = lang_rhs rhs" using l_eq_r by simp |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
343 |
also have "\<dots> = lang_rhs (b \<union> (rhs - b))" unfolding b_def by auto |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
344 |
also have "\<dots> = lang_rhs b \<union> B" unfolding B_def by (simp only: lang_rhs_union_distrib) |
166 | 345 |
also have "\<dots> = X \<cdot> A \<union> B" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
346 |
unfolding b_def |
166 | 347 |
unfolding trm_soundness[OF finite] |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
348 |
unfolding A_def |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
349 |
by blast |
166 | 350 |
finally have "X = X \<cdot> A \<union> B" . |
351 |
then have "X = B \<cdot> A\<star>" |
|
203 | 352 |
by (simp add: reversed_Arden[OF not_empty2]) |
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
|
353 |
also have "\<dots> = lang_rhs (Arden X rhs)" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
354 |
unfolding Arden_def A_def B_def b_def |
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
|
355 |
by (simp only: lang_of_append_rexp_rhs lang.simps) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
356 |
finally show "X = lang_rhs (Arden X rhs)" by simp |
42 | 357 |
qed |
358 |
||
179 | 359 |
lemma Append_preserves_finite: |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
360 |
"finite rhs \<Longrightarrow> finite (Append_rexp_rhs rhs r)" |
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
|
361 |
by (auto simp: Append_rexp_rhs_def) |
42 | 362 |
|
179 | 363 |
lemma Arden_preserves_finite: |
94 | 364 |
"finite rhs \<Longrightarrow> finite (Arden X rhs)" |
179 | 365 |
by (auto simp: Arden_def Append_preserves_finite) |
42 | 366 |
|
179 | 367 |
lemma Append_preserves_ardenable: |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
368 |
"ardenable rhs \<Longrightarrow> ardenable (Append_rexp_rhs rhs r)" |
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
|
369 |
apply (auto simp: ardenable_def Append_rexp_rhs_def) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
370 |
by (case_tac x, auto simp: conc_def) |
42 | 371 |
|
179 | 372 |
lemma ardenable_set_sub: |
110 | 373 |
"ardenable rhs \<Longrightarrow> ardenable (rhs - A)" |
374 |
by (auto simp:ardenable_def) |
|
42 | 375 |
|
179 | 376 |
lemma ardenable_set_union: |
110 | 377 |
"\<lbrakk>ardenable rhs; ardenable rhs'\<rbrakk> \<Longrightarrow> ardenable (rhs \<union> rhs')" |
378 |
by (auto simp:ardenable_def) |
|
42 | 379 |
|
179 | 380 |
lemma Arden_preserves_ardenable: |
110 | 381 |
"ardenable rhs \<Longrightarrow> ardenable (Arden X rhs)" |
179 | 382 |
by (simp only:Arden_def Append_preserves_ardenable ardenable_set_sub) |
42 | 383 |
|
384 |
||
179 | 385 |
lemma Subst_preserves_ardenable: |
110 | 386 |
"\<lbrakk>ardenable rhs; ardenable xrhs\<rbrakk> \<Longrightarrow> ardenable (Subst rhs X xrhs)" |
179 | 387 |
by (simp only: Subst_def Append_preserves_ardenable ardenable_set_union ardenable_set_sub) |
42 | 388 |
|
179 | 389 |
lemma Subst_preserves_soundness: |
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
|
390 |
assumes substor: "X = lang_rhs xrhs" |
42 | 391 |
and finite: "finite rhs" |
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
|
392 |
shows "lang_rhs (Subst rhs X xrhs) = lang_rhs rhs" (is "?Left = ?Right") |
42 | 393 |
proof- |
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
|
394 |
def A \<equiv> "lang_rhs (rhs - {Trn X r | r. Trn X r \<in> rhs})" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
395 |
have "?Left = A \<union> lang_rhs (Append_rexp_rhs xrhs (\<Uplus>{r. Trn X r \<in> rhs}))" |
94 | 396 |
unfolding Subst_def |
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
|
397 |
unfolding lang_rhs_union_distrib[symmetric] |
79 | 398 |
by (simp add: A_def) |
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
|
399 |
moreover have "?Right = A \<union> lang_rhs {Trn X r | r. Trn X r \<in> rhs}" |
42 | 400 |
proof- |
94 | 401 |
have "rhs = (rhs - {Trn X r | r. Trn X r \<in> rhs}) \<union> ({Trn X r | r. Trn X r \<in> rhs})" by auto |
79 | 402 |
thus ?thesis |
403 |
unfolding A_def |
|
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
|
404 |
unfolding lang_rhs_union_distrib |
79 | 405 |
by simp |
42 | 406 |
qed |
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
|
407 |
moreover |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
408 |
have "lang_rhs (Append_rexp_rhs xrhs (\<Uplus>{r. Trn X r \<in> rhs})) = lang_rhs {Trn X r | r. Trn X r \<in> rhs}" |
166 | 409 |
using finite substor by (simp only: lang_of_append_rexp_rhs trm_soundness) |
42 | 410 |
ultimately show ?thesis by simp |
411 |
qed |
|
412 |
||
179 | 413 |
lemma Subst_preserves_finite_rhs: |
94 | 414 |
"\<lbrakk>finite rhs; finite yrhs\<rbrakk> \<Longrightarrow> finite (Subst rhs Y yrhs)" |
179 | 415 |
by (auto simp: Subst_def Append_preserves_finite) |
42 | 416 |
|
179 | 417 |
lemma Subst_all_preserves_finite: |
110 | 418 |
assumes finite: "finite ES" |
94 | 419 |
shows "finite (Subst_all ES Y yrhs)" |
372
2c56b20032a7
made changes and updates to the journal paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
203
diff
changeset
|
420 |
using assms unfolding Subst_all_def by simp |
42 | 421 |
|
179 | 422 |
lemma Subst_all_preserves_finite_rhs: |
94 | 423 |
"\<lbrakk>finite_rhs ES; finite yrhs\<rbrakk> \<Longrightarrow> finite_rhs (Subst_all ES Y yrhs)" |
179 | 424 |
by (auto intro:Subst_preserves_finite_rhs simp add:Subst_all_def finite_rhs_def) |
42 | 425 |
|
179 | 426 |
lemma append_rhs_preserves_cls: |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
427 |
"rhss (Append_rexp_rhs rhs r) = rhss rhs" |
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
|
428 |
apply (auto simp: rhss_def Append_rexp_rhs_def) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
429 |
apply (case_tac xa, auto simp: image_def) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
430 |
by (rule_tac x = "Times ra r" in exI, rule_tac x = "Trn x ra" in bexI, simp+) |
42 | 431 |
|
94 | 432 |
lemma Arden_removes_cl: |
104 | 433 |
"rhss (Arden Y yrhs) = rhss yrhs - {Y}" |
179 | 434 |
apply (simp add:Arden_def append_rhs_preserves_cls) |
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
|
435 |
by (auto simp: rhss_def) |
42 | 436 |
|
179 | 437 |
lemma lhss_preserves_cls: |
103 | 438 |
"lhss (Subst_all ES Y yrhs) = lhss ES" |
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
|
439 |
by (auto simp: lhss_def Subst_all_def) |
42 | 440 |
|
94 | 441 |
lemma Subst_updates_cls: |
104 | 442 |
"X \<notin> rhss xrhs \<Longrightarrow> |
443 |
rhss (Subst rhs X xrhs) = rhss rhs \<union> rhss xrhs - {X}" |
|
179 | 444 |
apply (simp only:Subst_def append_rhs_preserves_cls rhss_union_distrib) |
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
|
445 |
by (auto simp: rhss_def) |
42 | 446 |
|
179 | 447 |
lemma Subst_all_preserves_validity: |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
448 |
assumes sc: "validity (ES \<union> {(Y, yrhs)})" (is "validity ?A") |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
449 |
shows "validity (Subst_all ES Y (Arden Y yrhs))" (is "validity ?B") |
110 | 450 |
proof - |
42 | 451 |
{ fix X xrhs' |
452 |
assume "(X, xrhs') \<in> ?B" |
|
453 |
then obtain xrhs |
|
94 | 454 |
where xrhs_xrhs': "xrhs' = Subst xrhs Y (Arden Y yrhs)" |
455 |
and X_in: "(X, xrhs) \<in> ES" by (simp add:Subst_all_def, blast) |
|
104 | 456 |
have "rhss xrhs' \<subseteq> lhss ?B" |
42 | 457 |
proof- |
103 | 458 |
have "lhss ?B = lhss ES" by (auto simp add:lhss_def Subst_all_def) |
104 | 459 |
moreover have "rhss xrhs' \<subseteq> lhss ES" |
42 | 460 |
proof- |
110 | 461 |
have "rhss xrhs' \<subseteq> rhss xrhs \<union> rhss (Arden Y yrhs) - {Y}" |
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
|
462 |
proof - |
104 | 463 |
have "Y \<notin> rhss (Arden Y yrhs)" |
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
|
464 |
using Arden_removes_cl by auto |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
465 |
thus ?thesis using xrhs_xrhs' by (auto simp: Subst_updates_cls) |
42 | 466 |
qed |
104 | 467 |
moreover have "rhss xrhs \<subseteq> lhss ES \<union> {Y}" using X_in sc |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
468 |
apply (simp only:validity_def lhss_union_distrib) |
103 | 469 |
by (drule_tac x = "(X, xrhs)" in bspec, auto simp:lhss_def) |
104 | 470 |
moreover have "rhss (Arden Y yrhs) \<subseteq> lhss ES \<union> {Y}" |
42 | 471 |
using sc |
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
|
472 |
by (auto simp add: Arden_removes_cl validity_def lhss_def) |
42 | 473 |
ultimately show ?thesis by auto |
474 |
qed |
|
475 |
ultimately show ?thesis by simp |
|
476 |
qed |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
477 |
} thus ?thesis by (auto simp only:Subst_all_def validity_def) |
42 | 478 |
qed |
479 |
||
96 | 480 |
lemma Subst_all_satisfies_invariant: |
86 | 481 |
assumes invariant_ES: "invariant (ES \<union> {(Y, yrhs)})" |
94 | 482 |
shows "invariant (Subst_all ES Y (Arden Y yrhs))" |
96 | 483 |
proof (rule invariantI) |
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
|
484 |
have Y_eq_yrhs: "Y = lang_rhs yrhs" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
485 |
using invariant_ES by (simp only:invariant_def soundness_def, blast) |
96 | 486 |
have finite_yrhs: "finite yrhs" |
86 | 487 |
using invariant_ES by (auto simp:invariant_def finite_rhs_def) |
179 | 488 |
have ardenable_yrhs: "ardenable yrhs" |
110 | 489 |
using invariant_ES by (auto simp:invariant_def ardenable_all_def) |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
490 |
show "soundness (Subst_all ES Y (Arden Y yrhs))" |
110 | 491 |
proof - |
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
|
492 |
have "Y = lang_rhs (Arden Y yrhs)" |
103 | 493 |
using Y_eq_yrhs invariant_ES finite_yrhs |
494 |
using finite_Trn[OF finite_yrhs] |
|
179 | 495 |
apply(rule_tac Arden_preserves_soundness) |
103 | 496 |
apply(simp_all) |
110 | 497 |
unfolding invariant_def ardenable_all_def ardenable_def |
103 | 498 |
apply(auto) |
499 |
done |
|
500 |
thus ?thesis using invariant_ES |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
501 |
unfolding invariant_def finite_rhs_def2 soundness_def Subst_all_def |
179 | 502 |
by (auto simp add: Subst_preserves_soundness simp del: lang_rhs.simps) |
96 | 503 |
qed |
504 |
show "finite (Subst_all ES Y (Arden Y yrhs))" |
|
179 | 505 |
using invariant_ES by (simp add:invariant_def Subst_all_preserves_finite) |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
506 |
show "distinctness (Subst_all ES Y (Arden Y yrhs))" |
110 | 507 |
using invariant_ES |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
508 |
unfolding distinctness_def Subst_all_def invariant_def by auto |
110 | 509 |
show "ardenable_all (Subst_all ES Y (Arden Y yrhs))" |
96 | 510 |
proof - |
511 |
{ fix X rhs |
|
512 |
assume "(X, rhs) \<in> ES" |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
513 |
hence "ardenable rhs" using invariant_ES |
110 | 514 |
by (auto simp add:invariant_def ardenable_all_def) |
179 | 515 |
with ardenable_yrhs |
110 | 516 |
have "ardenable (Subst rhs Y (Arden Y yrhs))" |
179 | 517 |
by (simp add:ardenable_yrhs |
518 |
Subst_preserves_ardenable Arden_preserves_ardenable) |
|
110 | 519 |
} thus ?thesis by (auto simp add:ardenable_all_def Subst_all_def) |
96 | 520 |
qed |
521 |
show "finite_rhs (Subst_all ES Y (Arden Y yrhs))" |
|
42 | 522 |
proof- |
86 | 523 |
have "finite_rhs ES" using invariant_ES |
524 |
by (simp add:invariant_def finite_rhs_def) |
|
94 | 525 |
moreover have "finite (Arden Y yrhs)" |
42 | 526 |
proof - |
86 | 527 |
have "finite yrhs" using invariant_ES |
528 |
by (auto simp:invariant_def finite_rhs_def) |
|
179 | 529 |
thus ?thesis using Arden_preserves_finite by auto |
42 | 530 |
qed |
531 |
ultimately show ?thesis |
|
179 | 532 |
by (simp add:Subst_all_preserves_finite_rhs) |
42 | 533 |
qed |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
534 |
show "validity (Subst_all ES Y (Arden Y yrhs))" |
179 | 535 |
using invariant_ES Subst_all_preserves_validity by (auto simp add: invariant_def) |
42 | 536 |
qed |
537 |
||
97 | 538 |
lemma Remove_in_card_measure: |
539 |
assumes finite: "finite ES" |
|
540 |
and in_ES: "(X, rhs) \<in> ES" |
|
541 |
shows "(Remove ES X rhs, ES) \<in> measure card" |
|
542 |
proof - |
|
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
|
543 |
def f \<equiv> "\<lambda> x. ((fst x)::'a lang, Subst (snd x) X (Arden X rhs))" |
97 | 544 |
def ES' \<equiv> "ES - {(X, rhs)}" |
545 |
have "Subst_all ES' X (Arden X rhs) = f ` ES'" |
|
546 |
apply (auto simp: Subst_all_def f_def image_def) |
|
547 |
by (rule_tac x = "(Y, yrhs)" in bexI, simp+) |
|
548 |
then have "card (Subst_all ES' X (Arden X rhs)) \<le> card ES'" |
|
549 |
unfolding ES'_def using finite by (auto intro: card_image_le) |
|
550 |
also have "\<dots> < card ES" unfolding ES'_def |
|
551 |
using in_ES finite by (rule_tac card_Diff1_less) |
|
552 |
finally show "(Remove ES X rhs, ES) \<in> measure card" |
|
553 |
unfolding Remove_def ES'_def by simp |
|
42 | 554 |
qed |
97 | 555 |
|
42 | 556 |
|
94 | 557 |
lemma Subst_all_cls_remains: |
558 |
"(X, xrhs) \<in> ES \<Longrightarrow> \<exists> xrhs'. (X, xrhs') \<in> (Subst_all ES Y yrhs)" |
|
97 | 559 |
by (auto simp: Subst_all_def) |
42 | 560 |
|
561 |
lemma card_noteq_1_has_more: |
|
103 | 562 |
assumes card:"Cond ES" |
563 |
and e_in: "(X, xrhs) \<in> ES" |
|
564 |
and finite: "finite ES" |
|
565 |
shows "\<exists>(Y, yrhs) \<in> ES. (X, xrhs) \<noteq> (Y, yrhs)" |
|
42 | 566 |
proof- |
103 | 567 |
have "card ES > 1" using card e_in finite |
568 |
by (cases "card ES") (auto) |
|
569 |
then have "card (ES - {(X, xrhs)}) > 0" |
|
570 |
using finite e_in by auto |
|
571 |
then have "(ES - {(X, xrhs)}) \<noteq> {}" using finite by (rule_tac notI, simp) |
|
572 |
then show "\<exists>(Y, yrhs) \<in> ES. (X, xrhs) \<noteq> (Y, yrhs)" |
|
573 |
by auto |
|
42 | 574 |
qed |
575 |
||
97 | 576 |
lemma iteration_step_measure: |
91 | 577 |
assumes Inv_ES: "invariant ES" |
42 | 578 |
and X_in_ES: "(X, xrhs) \<in> ES" |
105 | 579 |
and Cnd: "Cond ES " |
97 | 580 |
shows "(Iter X ES, ES) \<in> measure card" |
581 |
proof - |
|
105 | 582 |
have fin: "finite ES" using Inv_ES unfolding invariant_def by simp |
97 | 583 |
then obtain Y yrhs |
584 |
where Y_in_ES: "(Y, yrhs) \<in> ES" and not_eq: "(X, xrhs) \<noteq> (Y, yrhs)" |
|
105 | 585 |
using Cnd X_in_ES by (drule_tac card_noteq_1_has_more) (auto) |
97 | 586 |
then have "(Y, yrhs) \<in> ES " "X \<noteq> Y" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
587 |
using X_in_ES Inv_ES unfolding invariant_def distinctness_def |
103 | 588 |
by auto |
97 | 589 |
then show "(Iter X ES, ES) \<in> measure card" |
590 |
apply(rule IterI2) |
|
591 |
apply(rule Remove_in_card_measure) |
|
105 | 592 |
apply(simp_all add: fin) |
97 | 593 |
done |
594 |
qed |
|
595 |
||
596 |
lemma iteration_step_invariant: |
|
597 |
assumes Inv_ES: "invariant ES" |
|
598 |
and X_in_ES: "(X, xrhs) \<in> ES" |
|
105 | 599 |
and Cnd: "Cond ES" |
97 | 600 |
shows "invariant (Iter X ES)" |
42 | 601 |
proof - |
91 | 602 |
have finite_ES: "finite ES" using Inv_ES by (simp add: invariant_def) |
42 | 603 |
then obtain Y yrhs |
604 |
where Y_in_ES: "(Y, yrhs) \<in> ES" and not_eq: "(X, xrhs) \<noteq> (Y, yrhs)" |
|
105 | 605 |
using Cnd X_in_ES by (drule_tac card_noteq_1_has_more) (auto) |
103 | 606 |
then have "(Y, yrhs) \<in> ES" "X \<noteq> Y" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
607 |
using X_in_ES Inv_ES unfolding invariant_def distinctness_def |
103 | 608 |
by auto |
97 | 609 |
then show "invariant (Iter X ES)" |
610 |
proof(rule IterI2) |
|
611 |
fix Y yrhs |
|
612 |
assume h: "(Y, yrhs) \<in> ES" "X \<noteq> Y" |
|
613 |
then have "ES - {(Y, yrhs)} \<union> {(Y, yrhs)} = ES" by auto |
|
614 |
then show "invariant (Remove ES Y yrhs)" unfolding Remove_def |
|
110 | 615 |
using Inv_ES |
616 |
by (rule_tac Subst_all_satisfies_invariant) (simp) |
|
42 | 617 |
qed |
618 |
qed |
|
619 |
||
97 | 620 |
lemma iteration_step_ex: |
621 |
assumes Inv_ES: "invariant ES" |
|
622 |
and X_in_ES: "(X, xrhs) \<in> ES" |
|
105 | 623 |
and Cnd: "Cond ES" |
97 | 624 |
shows "\<exists>xrhs'. (X, xrhs') \<in> (Iter X ES)" |
625 |
proof - |
|
626 |
have finite_ES: "finite ES" using Inv_ES by (simp add: invariant_def) |
|
627 |
then obtain Y yrhs |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
628 |
where "(Y, yrhs) \<in> ES" "(X, xrhs) \<noteq> (Y, yrhs)" |
105 | 629 |
using Cnd X_in_ES by (drule_tac card_noteq_1_has_more) (auto) |
97 | 630 |
then have "(Y, yrhs) \<in> ES " "X \<noteq> Y" |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
631 |
using X_in_ES Inv_ES unfolding invariant_def distinctness_def |
103 | 632 |
by auto |
97 | 633 |
then show "\<exists>xrhs'. (X, xrhs') \<in> (Iter X ES)" |
634 |
apply(rule IterI2) |
|
635 |
unfolding Remove_def |
|
636 |
apply(rule Subst_all_cls_remains) |
|
637 |
using X_in_ES |
|
638 |
apply(auto) |
|
639 |
done |
|
640 |
qed |
|
641 |
||
91 | 642 |
|
203 | 643 |
subsection {* The conclusion of the first direction *} |
42 | 644 |
|
103 | 645 |
lemma Solve: |
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
|
646 |
fixes A::"('a::finite) lang" |
103 | 647 |
assumes fin: "finite (UNIV // \<approx>A)" |
648 |
and X_in: "X \<in> (UNIV // \<approx>A)" |
|
104 | 649 |
shows "\<exists>rhs. Solve X (Init (UNIV // \<approx>A)) = {(X, rhs)} \<and> invariant {(X, rhs)}" |
91 | 650 |
proof - |
104 | 651 |
def Inv \<equiv> "\<lambda>ES. invariant ES \<and> (\<exists>rhs. (X, rhs) \<in> ES)" |
103 | 652 |
have "Inv (Init (UNIV // \<approx>A))" unfolding Inv_def |
653 |
using fin X_in by (simp add: Init_ES_satisfies_invariant, simp add: Init_def) |
|
654 |
moreover |
|
655 |
{ fix ES |
|
656 |
assume inv: "Inv ES" and crd: "Cond ES" |
|
657 |
then have "Inv (Iter X ES)" |
|
658 |
unfolding Inv_def |
|
659 |
by (auto simp add: iteration_step_invariant iteration_step_ex) } |
|
660 |
moreover |
|
661 |
{ fix ES |
|
110 | 662 |
assume inv: "Inv ES" and not_crd: "\<not>Cond ES" |
663 |
from inv obtain rhs where "(X, rhs) \<in> ES" unfolding Inv_def by auto |
|
664 |
moreover |
|
665 |
from not_crd have "card ES = 1" by simp |
|
666 |
ultimately |
|
667 |
have "ES = {(X, rhs)}" by (auto simp add: card_Suc_eq) |
|
668 |
then have "\<exists>rhs'. ES = {(X, rhs')} \<and> invariant {(X, rhs')}" using inv |
|
669 |
unfolding Inv_def by auto } |
|
103 | 670 |
moreover |
671 |
have "wf (measure card)" by simp |
|
672 |
moreover |
|
673 |
{ fix ES |
|
674 |
assume inv: "Inv ES" and crd: "Cond ES" |
|
675 |
then have "(Iter X ES, ES) \<in> measure card" |
|
676 |
unfolding Inv_def |
|
97 | 677 |
apply(clarify) |
103 | 678 |
apply(rule_tac iteration_step_measure) |
97 | 679 |
apply(auto) |
103 | 680 |
done } |
681 |
ultimately |
|
104 | 682 |
show "\<exists>rhs. Solve X (Init (UNIV // \<approx>A)) = {(X, rhs)} \<and> invariant {(X, rhs)}" |
103 | 683 |
unfolding Solve_def by (rule while_rule) |
42 | 684 |
qed |
91 | 685 |
|
106 | 686 |
lemma every_eqcl_has_reg: |
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
|
687 |
fixes A::"('a::finite) lang" |
106 | 688 |
assumes finite_CS: "finite (UNIV // \<approx>A)" |
689 |
and X_in_CS: "X \<in> (UNIV // \<approx>A)" |
|
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
|
690 |
shows "\<exists>r. X = lang r" |
106 | 691 |
proof - |
692 |
from finite_CS X_in_CS |
|
693 |
obtain xrhs where Inv_ES: "invariant {(X, xrhs)}" |
|
694 |
using Solve by metis |
|
695 |
||
94 | 696 |
def A \<equiv> "Arden X xrhs" |
105 | 697 |
have "rhss xrhs \<subseteq> {X}" using Inv_ES |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
149
diff
changeset
|
698 |
unfolding validity_def invariant_def rhss_def lhss_def |
105 | 699 |
by auto |
700 |
then have "rhss A = {}" unfolding A_def |
|
701 |
by (simp add: Arden_removes_cl) |
|
702 |
then have eq: "{Lam r | r. Lam r \<in> A} = A" unfolding rhss_def |
|
703 |
by (auto, case_tac x, auto) |
|
704 |
||
96 | 705 |
have "finite A" using Inv_ES unfolding A_def invariant_def finite_rhs_def |
179 | 706 |
using Arden_preserves_finite by auto |
105 | 707 |
then have fin: "finite {r. Lam r \<in> A}" by (rule finite_Lam) |
708 |
||
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
|
709 |
have "X = lang_rhs xrhs" using Inv_ES unfolding invariant_def soundness_def |
105 | 710 |
by simp |
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
|
711 |
then have "X = lang_rhs A" using Inv_ES |
110 | 712 |
unfolding A_def invariant_def ardenable_all_def finite_rhs_def |
179 | 713 |
by (rule_tac Arden_preserves_soundness) (simp_all add: finite_Trn) |
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
|
714 |
then have "X = lang_rhs {Lam r | r. Lam r \<in> A}" using eq by simp |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
715 |
then have "X = lang (\<Uplus>{r. Lam r \<in> A})" using fin by auto |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
716 |
then show "\<exists>r. X = lang r" by blast |
42 | 717 |
qed |
718 |
||
96 | 719 |
lemma bchoice_finite_set: |
720 |
assumes a: "\<forall>x \<in> S. \<exists>y. x = f y" |
|
721 |
and b: "finite S" |
|
722 |
shows "\<exists>ys. (\<Union> S) = \<Union>(f ` ys) \<and> finite ys" |
|
723 |
using bchoice[OF a] b |
|
724 |
apply(erule_tac exE) |
|
725 |
apply(rule_tac x="fa ` S" in exI) |
|
726 |
apply(auto) |
|
727 |
done |
|
728 |
||
729 |
theorem Myhill_Nerode1: |
|
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
|
730 |
fixes A::"('a::finite) lang" |
70 | 731 |
assumes finite_CS: "finite (UNIV // \<approx>A)" |
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
|
732 |
shows "\<exists>r. A = lang r" |
42 | 733 |
proof - |
105 | 734 |
have fin: "finite (finals A)" |
96 | 735 |
using finals_in_partitions finite_CS by (rule finite_subset) |
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
|
736 |
have "\<forall>X \<in> (UNIV // \<approx>A). \<exists>r. X = lang r" |
42 | 737 |
using finite_CS every_eqcl_has_reg by blast |
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
|
738 |
then have a: "\<forall>X \<in> finals A. \<exists>r. X = lang r" |
96 | 739 |
using finals_in_partitions by auto |
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
|
740 |
then obtain rs::"('a rexp) set" where "\<Union> (finals A) = \<Union>(lang ` rs)" "finite rs" |
105 | 741 |
using fin by (auto dest: bchoice_finite_set) |
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
|
742 |
then have "A = lang (\<Uplus>rs)" |
96 | 743 |
unfolding lang_is_union_of_finals[symmetric] by simp |
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
|
744 |
then show "\<exists>r. A = lang r" by blast |
42 | 745 |
qed |
746 |
||
96 | 747 |
|
42 | 748 |
end |