Myhill_1.thy
changeset 170 b1258b7d2789
parent 166 7743d2ad71d1
child 179 edacc141060f
--- a/Myhill_1.thy	Fri Jun 03 13:59:21 2011 +0000
+++ b/Myhill_1.thy	Mon Jul 25 13:33:38 2011 +0000
@@ -1,5 +1,5 @@
 theory Myhill_1
-imports Regular
+imports More_Regular_Set
         "~~/src/HOL/Library/While_Combinator" 
 begin
 
@@ -12,12 +12,12 @@
 text {* Myhill-Nerode relation *}
 
 definition
-  str_eq_rel :: "lang \<Rightarrow> (string \<times> string) set" ("\<approx>_" [100] 100)
+  str_eq_rel :: "'a lang \<Rightarrow> ('a list \<times> 'a list) set" ("\<approx>_" [100] 100)
 where
   "\<approx>A \<equiv> {(x, y).  (\<forall>z. x @ z \<in> A \<longleftrightarrow> y @ z \<in> A)}"
 
 definition 
-  finals :: "lang \<Rightarrow> lang set"
+  finals :: "'a lang \<Rightarrow> 'a lang set"
 where
   "finals A \<equiv> {\<approx>A `` {s} | s . s \<in> A}"
 
@@ -37,35 +37,35 @@
 
 text {* The two kinds of terms in the rhs of equations. *}
 
-datatype trm = 
-   Lam "rexp"            (* Lambda-marker *)
- | Trn "lang" "rexp"     (* Transition *)
+datatype 'a trm = 
+   Lam "'a rexp"            (* Lambda-marker *)
+ | Trn "'a lang" "'a rexp"     (* Transition *)
 
 fun 
-  L_trm::"trm \<Rightarrow> lang"
+  lang_trm::"'a trm \<Rightarrow> 'a lang"
 where
-  "L_trm (Lam r) = L_rexp r" 
-| "L_trm (Trn X r) = X \<cdot> L_rexp r"
+  "lang_trm (Lam r) = lang r" 
+| "lang_trm (Trn X r) = X \<cdot> lang r"
 
 fun 
-  L_rhs::"trm set \<Rightarrow> lang"
+  lang_rhs::"('a trm) set \<Rightarrow> 'a lang"
 where 
-  "L_rhs rhs = \<Union> (L_trm ` rhs)"
+  "lang_rhs rhs = \<Union> (lang_trm ` rhs)"
 
-lemma L_rhs_set:
-  shows "L_rhs {Trn X r | r. P r} = \<Union>{L_trm (Trn X r) | r. P r}"
+lemma lang_rhs_set:
+  shows "lang_rhs {Trn X r | r. P r} = \<Union>{lang_trm (Trn X r) | r. P r}"
 by (auto)
 
-lemma L_rhs_union_distrib:
-  fixes A B::"trm set"
-  shows "L_rhs A \<union> L_rhs B = L_rhs (A \<union> B)"
+lemma lang_rhs_union_distrib:
+  fixes A B::"('a trm) set"
+  shows "lang_rhs A \<union> lang_rhs B = lang_rhs (A \<union> B)"
 by simp
 
 
 text {* Transitions between equivalence classes *}
 
 definition 
-  transition :: "lang \<Rightarrow> char \<Rightarrow> lang \<Rightarrow> bool" ("_ \<Turnstile>_\<Rightarrow>_" [100,100,100] 100)
+  transition :: "'a lang \<Rightarrow> 'a \<Rightarrow> 'a lang \<Rightarrow> bool" ("_ \<Turnstile>_\<Rightarrow>_" [100,100,100] 100)
 where
   "Y \<Turnstile>c\<Rightarrow> X \<equiv> Y \<cdot> {[c]} \<subseteq> X"
 
@@ -74,9 +74,9 @@
 definition
   "Init_rhs CS X \<equiv>  
       if ([] \<in> X) then 
-          {Lam EMPTY} \<union> {Trn Y (CHAR c) | Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X}
+          {Lam One} \<union> {Trn Y (Atom c) | Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X}
       else 
-          {Trn Y (CHAR c)| Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X}"
+          {Trn Y (Atom c)| Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X}"
 
 definition 
   "Init CS \<equiv> {(X, Init_rhs CS X) | X.  X \<in> CS}"
@@ -85,10 +85,10 @@
 section {* Arden Operation on equations *}
 
 fun 
-  Append_rexp :: "rexp \<Rightarrow> trm \<Rightarrow> trm"
+  Append_rexp :: "'a rexp \<Rightarrow> 'a trm \<Rightarrow> 'a trm"
 where
-  "Append_rexp r (Lam rexp)   = Lam (SEQ rexp r)"
-| "Append_rexp r (Trn X rexp) = Trn X (SEQ rexp r)"
+  "Append_rexp r (Lam rexp)   = Lam (Times rexp r)"
+| "Append_rexp r (Trn X rexp) = Trn X (Times rexp r)"
 
 
 definition
@@ -96,7 +96,7 @@
 
 definition 
   "Arden X rhs \<equiv> 
-     Append_rexp_rhs (rhs - {Trn X r | r. Trn X r \<in> rhs}) (STAR (\<Uplus> {r. Trn X r \<in> rhs}))"
+     Append_rexp_rhs (rhs - {Trn X r | r. Trn X r \<in> rhs}) (Star (\<Uplus> {r. Trn X r \<in> rhs}))"
 
 
 section {* Substitution Operation on equations *}
@@ -106,7 +106,7 @@
         (rhs - {Trn X r | r. Trn X r \<in> rhs}) \<union> (Append_rexp_rhs xrhs (\<Uplus> {r. Trn X r \<in> rhs}))"
 
 definition
-  Subst_all :: "(lang \<times> trm set) set \<Rightarrow> lang \<Rightarrow> trm set \<Rightarrow> (lang \<times> trm set) set"
+  Subst_all :: "('a lang \<times> ('a trm) set) set \<Rightarrow> 'a lang \<Rightarrow> ('a trm) set \<Rightarrow> ('a lang \<times> ('a trm) set) set"
 where
   "Subst_all ES X xrhs \<equiv> {(Y, Subst yrhs X xrhs) | Y yrhs. (Y, yrhs) \<in> ES}"
 
@@ -143,10 +143,10 @@
      \<forall> X rhs rhs'. (X, rhs) \<in> ES \<and> (X, rhs') \<in> ES \<longrightarrow> rhs = rhs'"
 
 definition 
-  "soundness ES \<equiv> \<forall>(X, rhs) \<in> ES. X = L_rhs rhs"
+  "soundness ES \<equiv> \<forall>(X, rhs) \<in> ES. X = lang_rhs rhs"
 
 definition 
-  "ardenable rhs \<equiv> (\<forall> Y r. Trn Y r \<in> rhs \<longrightarrow> [] \<notin> L_rexp r)"
+  "ardenable rhs \<equiv> (\<forall> Y r. Trn Y r \<in> rhs \<longrightarrow> [] \<notin> lang r)"
 
 definition 
   "ardenable_all ES \<equiv> \<forall>(X, rhs) \<in> ES. ardenable rhs"
@@ -223,23 +223,23 @@
 
 lemma trm_soundness:
   assumes finite:"finite rhs"
-  shows "L_rhs ({Trn X r| r. Trn X r \<in> rhs}) = X \<cdot> (L_rexp (\<Uplus>{r. Trn X r \<in> rhs}))"
+  shows "lang_rhs ({Trn X r| r. Trn X r \<in> rhs}) = X \<cdot> (lang (\<Uplus>{r. Trn X r \<in> rhs}))"
 proof -
   have "finite {r. Trn X r \<in> rhs}" 
     by (rule finite_Trn[OF finite]) 
-  then show "L_rhs ({Trn X r| r. Trn X r \<in> rhs}) = X \<cdot> (L_rexp (\<Uplus>{r. Trn X r \<in> rhs}))"
-    by (simp only: L_rhs_set L_trm.simps) (auto simp add: Seq_def)
+  then show "lang_rhs ({Trn X r| r. Trn X r \<in> rhs}) = X \<cdot> (lang (\<Uplus>{r. Trn X r \<in> rhs}))"
+    by (simp only: lang_rhs_set lang_trm.simps) (auto simp add: conc_def)
 qed
 
 lemma lang_of_append_rexp:
-  "L_trm (Append_rexp r trm) = L_trm trm \<cdot> L_rexp r"
+  "lang_trm (Append_rexp r trm) = lang_trm trm \<cdot> lang r"
 by (induct rule: Append_rexp.induct)
-   (auto simp add: seq_assoc)
+   (auto simp add: conc_assoc)
 
 lemma lang_of_append_rexp_rhs:
-  "L_rhs (Append_rexp_rhs rhs r) = L_rhs rhs \<cdot> L_rexp r"
+  "lang_rhs (Append_rexp_rhs rhs r) = lang_rhs rhs \<cdot> lang r"
 unfolding Append_rexp_rhs_def
-by (auto simp add: Seq_def lang_of_append_rexp)
+by (auto simp add: conc_def lang_of_append_rexp)
 
 
 subsubsection {* Intial Equational System *}
@@ -263,7 +263,7 @@
   have "X = \<approx>A `` {s @ [c]}" 
     using has_str in_CS defined_by_str by blast
   then have "Y \<cdot> {[c]} \<subseteq> X" 
-    unfolding Y_def Image_def Seq_def
+    unfolding Y_def Image_def conc_def
     unfolding str_eq_rel_def
     by clarsimp
   moreover
@@ -274,14 +274,14 @@
 
 lemma l_eq_r_in_eqs:
   assumes X_in_eqs: "(X, rhs) \<in> Init (UNIV // \<approx>A)"
-  shows "X = L_rhs rhs"
+  shows "X = lang_rhs rhs"
 proof 
-  show "X \<subseteq> L_rhs rhs"
+  show "X \<subseteq> lang_rhs rhs"
   proof
     fix x
     assume in_X: "x \<in> X"
     { assume empty: "x = []"
-      then have "x \<in> L_rhs rhs" using X_in_eqs in_X
+      then have "x \<in> lang_rhs rhs" using X_in_eqs in_X
 	unfolding Init_def Init_rhs_def
         by auto
     }
@@ -291,43 +291,42 @@
 	using rev_cases by blast
       have "X \<in> UNIV // \<approx>A" using X_in_eqs unfolding Init_def by auto
       then obtain Y where "Y \<in> UNIV // \<approx>A" "Y \<cdot> {[c]} \<subseteq> X" "s \<in> Y"
-        using decom in_X every_eqclass_has_transition by blast
-      then have "x \<in> L_rhs {Trn Y (CHAR c)| Y c. Y \<in> UNIV // \<approx>A \<and> Y \<Turnstile>c\<Rightarrow> X}"
+        using decom in_X every_eqclass_has_transition by metis
+      then have "x \<in> lang_rhs {Trn Y (Atom c)| Y c. Y \<in> UNIV // \<approx>A \<and> Y \<Turnstile>c\<Rightarrow> X}"
         unfolding transition_def
-	using decom by (force simp add: Seq_def)
-      then have "x \<in> L_rhs rhs" using X_in_eqs in_X
+	using decom by (force simp add: conc_def)
+      then have "x \<in> lang_rhs rhs" using X_in_eqs in_X
 	unfolding Init_def Init_rhs_def by simp
     }
-    ultimately show "x \<in> L_rhs rhs" by blast
+    ultimately show "x \<in> lang_rhs rhs" by blast
   qed
 next
-  show "L_rhs rhs \<subseteq> X" using X_in_eqs
+  show "lang_rhs rhs \<subseteq> X" using X_in_eqs
     unfolding Init_def Init_rhs_def transition_def
     by auto 
 qed
 
-lemma test:
-  assumes X_in_eqs: "(X, rhs) \<in> Init (UNIV // \<approx>A)"
-  shows "X = \<Union> (L_trm `  rhs)"
-using assms l_eq_r_in_eqs by (simp)
 
 lemma finite_Init_rhs: 
+  fixes CS::"(('a::finite) lang) set"
   assumes finite: "finite CS"
   shows "finite (Init_rhs CS X)"
 proof-
-  def S \<equiv> "{(Y, c)| Y c. Y \<in> CS \<and> Y \<cdot> {[c]} \<subseteq> X}" 
-  def h \<equiv> "\<lambda> (Y, c). Trn Y (CHAR c)"
-  have "finite (CS \<times> (UNIV::char set))" using finite by auto
+  def S \<equiv> "{(Y, c)| Y c::'a. Y \<in> CS \<and> Y \<cdot> {[c]} \<subseteq> X}" 
+  def h \<equiv> "\<lambda> (Y, c::'a). Trn Y (Atom c)"
+  have "finite (CS \<times> (UNIV::('a::finite) set))" using finite by auto
   then have "finite S" using S_def 
     by (rule_tac B = "CS \<times> UNIV" in finite_subset) (auto)
-  moreover have "{Trn Y (CHAR c) |Y c. Y \<in> CS \<and> Y \<cdot> {[c]} \<subseteq> X} = h ` S"
+  moreover have "{Trn Y (Atom c) |Y c::'a. Y \<in> CS \<and> Y \<cdot> {[c]} \<subseteq> X} = h ` S"
     unfolding S_def h_def image_def by auto
   ultimately
-  have "finite {Trn Y (CHAR c) |Y c. Y \<in> CS \<and> Y \<cdot> {[c]} \<subseteq> X}" by auto
+  have "finite {Trn Y (Atom c) |Y c. Y \<in> CS \<and> Y \<cdot> {[c]} \<subseteq> X}" by auto
   then show "finite (Init_rhs CS X)" unfolding Init_rhs_def transition_def by simp
 qed
 
+
 lemma Init_ES_satisfies_invariant:
+  fixes A::"(('a::finite) lang)"
   assumes finite_CS: "finite (UNIV // \<approx>A)"
   shows "invariant (Init (UNIV // \<approx>A))"
 proof (rule invariantI)
@@ -352,20 +351,20 @@
 subsubsection {* Interation step *}
 
 lemma Arden_keeps_eq:
-  assumes l_eq_r: "X = L_rhs rhs"
+  assumes l_eq_r: "X = lang_rhs rhs"
   and not_empty: "ardenable rhs"
   and finite: "finite rhs"
-  shows "X = L_rhs (Arden X rhs)"
+  shows "X = lang_rhs (Arden X rhs)"
 proof -
-  def A \<equiv> "L_rexp (\<Uplus>{r. Trn X r \<in> rhs})"
+  def A \<equiv> "lang (\<Uplus>{r. Trn X r \<in> rhs})"
   def b \<equiv> "{Trn X r | r. Trn X r \<in> rhs}"
-  def B \<equiv> "L_rhs (rhs - b)"
+  def B \<equiv> "lang_rhs (rhs - b)"
   have not_empty2: "[] \<notin> A" 
     using finite_Trn[OF finite] not_empty
     unfolding A_def ardenable_def by simp
-  have "X = L_rhs rhs" using l_eq_r by simp
-  also have "\<dots> = L_rhs (b \<union> (rhs - b))" unfolding b_def by auto
-  also have "\<dots> = L_rhs b \<union> B" unfolding B_def by (simp only: L_rhs_union_distrib)
+  have "X = lang_rhs rhs" using l_eq_r by simp
+  also have "\<dots> = lang_rhs (b \<union> (rhs - b))" unfolding b_def by auto
+  also have "\<dots> = lang_rhs b \<union> B" unfolding B_def by (simp only: lang_rhs_union_distrib)
   also have "\<dots> = X \<cdot> A \<union> B"
     unfolding b_def
     unfolding trm_soundness[OF finite]
@@ -374,24 +373,24 @@
   finally have "X = X \<cdot> A \<union> B" . 
   then have "X = B \<cdot> A\<star>"
     by (simp add: arden[OF not_empty2])
-  also have "\<dots> = L_rhs (Arden X rhs)"
+  also have "\<dots> = lang_rhs (Arden X rhs)"
     unfolding Arden_def A_def B_def b_def
-    by (simp only: lang_of_append_rexp_rhs L_rexp.simps)
-  finally show "X = L_rhs (Arden X rhs)" by simp
+    by (simp only: lang_of_append_rexp_rhs lang.simps)
+  finally show "X = lang_rhs (Arden X rhs)" by simp
 qed 
 
 lemma Append_keeps_finite:
   "finite rhs \<Longrightarrow> finite (Append_rexp_rhs rhs r)"
-by (auto simp:Append_rexp_rhs_def)
+by (auto simp: Append_rexp_rhs_def)
 
 lemma Arden_keeps_finite:
   "finite rhs \<Longrightarrow> finite (Arden X rhs)"
-by (auto simp:Arden_def Append_keeps_finite)
+by (auto simp: Arden_def Append_keeps_finite)
 
 lemma Append_keeps_nonempty:
   "ardenable rhs \<Longrightarrow> ardenable (Append_rexp_rhs rhs r)"
-apply (auto simp:ardenable_def Append_rexp_rhs_def)
-by (case_tac x, auto simp:Seq_def)
+apply (auto simp: ardenable_def Append_rexp_rhs_def)
+by (case_tac x, auto simp: conc_def)
 
 lemma nonempty_set_sub:
   "ardenable rhs \<Longrightarrow> ardenable (rhs - A)"
@@ -411,24 +410,25 @@
 by (simp only: Subst_def Append_keeps_nonempty nonempty_set_union nonempty_set_sub)
 
 lemma Subst_keeps_eq:
-  assumes substor: "X = L_rhs xrhs"
+  assumes substor: "X = lang_rhs xrhs"
   and finite: "finite rhs"
-  shows "L_rhs (Subst rhs X xrhs) = L_rhs rhs" (is "?Left = ?Right")
+  shows "lang_rhs (Subst rhs X xrhs) = lang_rhs rhs" (is "?Left = ?Right")
 proof-
-  def A \<equiv> "L_rhs (rhs - {Trn X r | r. Trn X r \<in> rhs})"
-  have "?Left = A \<union> L_rhs (Append_rexp_rhs xrhs (\<Uplus>{r. Trn X r \<in> rhs}))"
+  def A \<equiv> "lang_rhs (rhs - {Trn X r | r. Trn X r \<in> rhs})"
+  have "?Left = A \<union> lang_rhs (Append_rexp_rhs xrhs (\<Uplus>{r. Trn X r \<in> rhs}))"
     unfolding Subst_def
-    unfolding L_rhs_union_distrib[symmetric]
+    unfolding lang_rhs_union_distrib[symmetric]
     by (simp add: A_def)
-  moreover have "?Right = A \<union> L_rhs {Trn X r | r. Trn X r \<in> rhs}"
+  moreover have "?Right = A \<union> lang_rhs {Trn X r | r. Trn X r \<in> rhs}"
   proof-
     have "rhs = (rhs - {Trn X r | r. Trn X r \<in> rhs}) \<union> ({Trn X r | r. Trn X r \<in> rhs})" by auto
     thus ?thesis 
       unfolding A_def
-      unfolding L_rhs_union_distrib
+      unfolding lang_rhs_union_distrib
       by simp
   qed
-  moreover have "L_rhs (Append_rexp_rhs xrhs (\<Uplus>{r. Trn X r \<in> rhs})) = L_rhs {Trn X r | r. Trn X r \<in> rhs}" 
+  moreover 
+  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}" 
     using finite substor by (simp only: lang_of_append_rexp_rhs trm_soundness)
   ultimately show ?thesis by simp
 qed
@@ -441,8 +441,8 @@
   assumes finite: "finite ES"
   shows "finite (Subst_all ES Y yrhs)"
 proof -
-  def eqns \<equiv> "{(X::lang, rhs) |X rhs. (X, rhs) \<in> ES}"
-  def h \<equiv> "\<lambda>(X::lang, rhs). (X, Subst rhs Y yrhs)"
+  def eqns \<equiv> "{(X::'a lang, rhs) |X rhs. (X, rhs) \<in> ES}"
+  def h \<equiv> "\<lambda>(X::'a lang, rhs). (X, Subst rhs Y yrhs)"
   have "finite (h ` eqns)" using finite h_def eqns_def by auto
   moreover 
   have "Subst_all ES Y yrhs = h ` eqns" unfolding h_def eqns_def Subst_all_def by auto
@@ -456,24 +456,24 @@
 
 lemma append_rhs_keeps_cls:
   "rhss (Append_rexp_rhs rhs r) = rhss rhs"
-apply (auto simp:rhss_def Append_rexp_rhs_def)
-apply (case_tac xa, auto simp:image_def)
-by (rule_tac x = "SEQ ra r" in exI, rule_tac x = "Trn x ra" in bexI, simp+)
+apply (auto simp: rhss_def Append_rexp_rhs_def)
+apply (case_tac xa, auto simp: image_def)
+by (rule_tac x = "Times ra r" in exI, rule_tac x = "Trn x ra" in bexI, simp+)
 
 lemma Arden_removes_cl:
   "rhss (Arden Y yrhs) = rhss yrhs - {Y}"
 apply (simp add:Arden_def append_rhs_keeps_cls)
-by (auto simp:rhss_def)
+by (auto simp: rhss_def)
 
 lemma lhss_keeps_cls:
   "lhss (Subst_all ES Y yrhs) = lhss ES"
-by (auto simp:lhss_def Subst_all_def)
+by (auto simp: lhss_def Subst_all_def)
 
 lemma Subst_updates_cls:
   "X \<notin> rhss xrhs \<Longrightarrow> 
       rhss (Subst rhs X xrhs) = rhss rhs \<union> rhss xrhs - {X}"
 apply (simp only:Subst_def append_rhs_keeps_cls rhss_union_distrib)
-by (auto simp:rhss_def)
+by (auto simp: rhss_def)
 
 lemma Subst_all_keeps_validity:
   assumes sc: "validity (ES \<union> {(Y, yrhs)})"        (is "validity ?A")
@@ -490,17 +490,17 @@
       moreover have "rhss xrhs' \<subseteq> lhss ES"
       proof-
         have "rhss xrhs' \<subseteq>  rhss xrhs \<union> rhss (Arden Y yrhs) - {Y}"
-        proof-
+        proof -
           have "Y \<notin> rhss (Arden Y yrhs)" 
-            using Arden_removes_cl by simp
-          thus ?thesis using xrhs_xrhs' by (auto simp:Subst_updates_cls)
+            using Arden_removes_cl by auto
+          thus ?thesis using xrhs_xrhs' by (auto simp: Subst_updates_cls)
         qed
         moreover have "rhss xrhs \<subseteq> lhss ES \<union> {Y}" using X_in sc
           apply (simp only:validity_def lhss_union_distrib)
           by (drule_tac x = "(X, xrhs)" in bspec, auto simp:lhss_def)
         moreover have "rhss (Arden Y yrhs) \<subseteq> lhss ES \<union> {Y}" 
           using sc 
-          by (auto simp add:Arden_removes_cl validity_def lhss_def)
+          by (auto simp add: Arden_removes_cl validity_def lhss_def)
         ultimately show ?thesis by auto
       qed
       ultimately show ?thesis by simp
@@ -512,7 +512,7 @@
   assumes invariant_ES: "invariant (ES \<union> {(Y, yrhs)})"
   shows "invariant (Subst_all ES Y (Arden Y yrhs))"
 proof (rule invariantI)
-  have Y_eq_yrhs: "Y = L_rhs yrhs" 
+  have Y_eq_yrhs: "Y = lang_rhs yrhs" 
     using invariant_ES by (simp only:invariant_def soundness_def, blast)
    have finite_yrhs: "finite yrhs" 
     using invariant_ES by (auto simp:invariant_def finite_rhs_def)
@@ -520,7 +520,7 @@
     using invariant_ES by (auto simp:invariant_def ardenable_all_def)
   show "soundness (Subst_all ES Y (Arden Y yrhs))"
   proof -
-    have "Y = L_rhs (Arden Y yrhs)" 
+    have "Y = lang_rhs (Arden Y yrhs)" 
       using Y_eq_yrhs invariant_ES finite_yrhs
       using finite_Trn[OF finite_yrhs]
       apply(rule_tac Arden_keeps_eq)
@@ -530,7 +530,7 @@
       done
     thus ?thesis using invariant_ES
       unfolding invariant_def finite_rhs_def2 soundness_def Subst_all_def
-      by (auto simp add: Subst_keeps_eq simp del: L_rhs.simps)
+      by (auto simp add: Subst_keeps_eq simp del: lang_rhs.simps)
   qed
   show "finite (Subst_all ES Y (Arden Y yrhs))" 
     using invariant_ES by (simp add:invariant_def Subst_all_keeps_finite)
@@ -557,13 +557,13 @@
     proof -
       have "finite yrhs" using invariant_ES 
         by (auto simp:invariant_def finite_rhs_def)
-      thus ?thesis using Arden_keeps_finite by simp
+      thus ?thesis using Arden_keeps_finite by auto
     qed
     ultimately show ?thesis 
       by (simp add:Subst_all_keeps_finite_rhs)
   qed
   show "validity (Subst_all ES Y (Arden Y yrhs))"
-    using invariant_ES Subst_all_keeps_validity by (simp add:invariant_def)
+    using invariant_ES Subst_all_keeps_validity by (auto simp add: invariant_def)
 qed
 
 lemma Remove_in_card_measure:
@@ -571,7 +571,7 @@
   and     in_ES: "(X, rhs) \<in> ES"
   shows "(Remove ES X rhs, ES) \<in> measure card"
 proof -
-  def f \<equiv> "\<lambda> x. ((fst x)::lang, Subst (snd x) X (Arden X rhs))"
+  def f \<equiv> "\<lambda> x. ((fst x)::'a lang, Subst (snd x) X (Arden X rhs))"
   def ES' \<equiv> "ES - {(X, rhs)}"
   have "Subst_all ES' X (Arden X rhs) = f ` ES'" 
     apply (auto simp: Subst_all_def f_def image_def)
@@ -674,6 +674,7 @@
 subsubsection {* Conclusion of the proof *}
 
 lemma Solve:
+  fixes A::"('a::finite) lang"
   assumes fin: "finite (UNIV // \<approx>A)"
   and     X_in: "X \<in> (UNIV // \<approx>A)"
   shows "\<exists>rhs. Solve X (Init (UNIV // \<approx>A)) = {(X, rhs)} \<and> invariant {(X, rhs)}"
@@ -714,9 +715,10 @@
 qed
 
 lemma every_eqcl_has_reg:
+  fixes A::"('a::finite) lang"
   assumes finite_CS: "finite (UNIV // \<approx>A)"
   and X_in_CS: "X \<in> (UNIV // \<approx>A)"
-  shows "\<exists>r. X = L_rexp r" 
+  shows "\<exists>r. X = lang r" 
 proof -
   from finite_CS X_in_CS 
   obtain xrhs where Inv_ES: "invariant {(X, xrhs)}"
@@ -735,14 +737,14 @@
     using Arden_keeps_finite by auto
   then have fin: "finite {r. Lam r \<in> A}" by (rule finite_Lam)
 
-  have "X = L_rhs xrhs" using Inv_ES unfolding invariant_def soundness_def
+  have "X = lang_rhs xrhs" using Inv_ES unfolding invariant_def soundness_def
     by simp
-  then have "X = L_rhs A" using Inv_ES 
+  then have "X = lang_rhs A" using Inv_ES 
     unfolding A_def invariant_def ardenable_all_def finite_rhs_def 
     by (rule_tac Arden_keeps_eq) (simp_all add: finite_Trn)
-  then have "X = L_rhs {Lam r | r. Lam r \<in> A}" using eq by simp
-  then have "X = L_rexp (\<Uplus>{r. Lam r \<in> A})" using fin by auto
-  then show "\<exists>r. X = L_rexp r" by blast
+  then have "X = lang_rhs {Lam r | r. Lam r \<in> A}" using eq by simp
+  then have "X = lang (\<Uplus>{r. Lam r \<in> A})" using fin by auto
+  then show "\<exists>r. X = lang r" by blast
 qed
 
 lemma bchoice_finite_set:
@@ -756,20 +758,21 @@
 done
 
 theorem Myhill_Nerode1:
+  fixes A::"('a::finite) lang"
   assumes finite_CS: "finite (UNIV // \<approx>A)"
-  shows   "\<exists>r. A = L_rexp r"
+  shows   "\<exists>r. A = lang r"
 proof -
   have fin: "finite (finals A)" 
     using finals_in_partitions finite_CS by (rule finite_subset)
-  have "\<forall>X \<in> (UNIV // \<approx>A). \<exists>r. X = L_rexp r" 
+  have "\<forall>X \<in> (UNIV // \<approx>A). \<exists>r. X = lang r" 
     using finite_CS every_eqcl_has_reg by blast
-  then have a: "\<forall>X \<in> finals A. \<exists>r. X = L_rexp r"
+  then have a: "\<forall>X \<in> finals A. \<exists>r. X = lang r"
     using finals_in_partitions by auto
-  then obtain rs::"rexp set" where "\<Union> (finals A) = \<Union>(L_rexp ` rs)" "finite rs"
+  then obtain rs::"('a rexp) set" where "\<Union> (finals A) = \<Union>(lang ` rs)" "finite rs"
     using fin by (auto dest: bchoice_finite_set)
-  then have "A = L_rexp (\<Uplus>rs)" 
+  then have "A = lang (\<Uplus>rs)" 
     unfolding lang_is_union_of_finals[symmetric] by simp
-  then show "\<exists>r. A = L_rexp r" by blast
+  then show "\<exists>r. A = lang r" by blast
 qed