Myhill.thy
changeset 57 76ab7c09d575
parent 56 b3898315e687
child 62 d94209ad2880
equal deleted inserted replaced
56:b3898315e687 57:76ab7c09d575
   256 
   256 
   257 text {*
   257 text {*
   258   Each case is given in a separate section, as well as the final main lemma. Detailed explainations accompanied by
   258   Each case is given in a separate section, as well as the final main lemma. Detailed explainations accompanied by
   259   illustrations are given for non-trivial cases.
   259   illustrations are given for non-trivial cases.
   260 
   260 
   261   
       
   262   For ever inductive case, there are two tasks, the easier one is to show the range finiteness of
   261   For ever inductive case, there are two tasks, the easier one is to show the range finiteness of
   263   of the tagging function based on the finiteness of component partitions, the
   262   of the tagging function based on the finiteness of component partitions, the
   264   difficult one is to show that strings with the same tag are equivalent with respect to the 
   263   difficult one is to show that strings with the same tag are equivalent with respect to the 
   265   composite language. Suppose the composite language be @{text "Lang"}, tagging function be 
   264   composite language. Suppose the composite language be @{text "Lang"}, tagging function be 
   266   @{text "tag"}, it amounts to show:
   265   @{text "tag"}, it amounts to show:
   481               unfolding Image_def str_eq_rel_def str_eq_def by auto
   480               unfolding Image_def str_eq_rel_def str_eq_def by auto
   482             with h3 show ?thesis unfolding str_eq_rel_def str_eq_def by simp
   481             with h3 show ?thesis unfolding str_eq_rel_def str_eq_def by simp
   483           qed
   482           qed
   484           -- {* Now, @{text "ya"} has all properties to be a qualified candidate:*}
   483           -- {* Now, @{text "ya"} has all properties to be a qualified candidate:*}
   485           with pref_ya ya_in 
   484           with pref_ya ya_in 
   486           show ?thesis using prems by blast
   485           show ?thesis using that by blast
   487         qed
   486         qed
   488           -- {* From the properties of @{text "ya"}, @{text "y @ z \<in> L\<^isub>1 ;; L\<^isub>2"} is derived easily.*}
   487           -- {* From the properties of @{text "ya"}, @{text "y @ z \<in> L\<^isub>1 ;; L\<^isub>2"} is derived easily.*}
   489         hence "y @ z \<in> L\<^isub>1 ;; L\<^isub>2" by (erule_tac prefixE, auto simp:Seq_def)
   488         hence "y @ z \<in> L\<^isub>1 ;; L\<^isub>2" by (erule_tac prefixE, auto simp:Seq_def)
   490       } moreover {
   489       } moreover {
   491         -- {* The other case is even more simpler: *}
   490         -- {* The other case is even more simpler: *}
   590   show ?case
   589   show ?case
   591   proof (cases "A = {}")
   590   proof (cases "A = {}")
   592     case True thus ?thesis by (rule_tac x = a in bexI, auto)
   591     case True thus ?thesis by (rule_tac x = a in bexI, auto)
   593   next
   592   next
   594     case False
   593     case False
   595     with prems obtain max 
   594     with insertI.hyps and False  
       
   595     obtain max 
   596       where h1: "max \<in> A" 
   596       where h1: "max \<in> A" 
   597       and h2: "\<forall>a\<in>A. f a \<le> f max" by blast
   597       and h2: "\<forall>a\<in>A. f a \<le> f max" by blast
   598     show ?thesis
   598     show ?thesis
   599     proof (cases "f a \<le> f max")
   599     proof (cases "f a \<le> f max")
   600       assume "f a \<le> f max"
   600       assume "f a \<le> f max"
   677         from tag_xy have "{\<approx>L\<^isub>1 `` {x - xa} |xa. xa < x \<and> xa \<in> L\<^isub>1\<star>} = 
   677         from tag_xy have "{\<approx>L\<^isub>1 `` {x - xa} |xa. xa < x \<and> xa \<in> L\<^isub>1\<star>} = 
   678           {\<approx>L\<^isub>1 `` {y - xa} |xa. xa < y \<and> xa \<in> L\<^isub>1\<star>}" (is "?left = ?right")
   678           {\<approx>L\<^isub>1 `` {y - xa} |xa. xa < y \<and> xa \<in> L\<^isub>1\<star>}" (is "?left = ?right")
   679           by (auto simp:tag_str_STAR_def)
   679           by (auto simp:tag_str_STAR_def)
   680         moreover have "\<approx>L\<^isub>1 `` {x - xa_max} \<in> ?left" using h1 h2 by auto
   680         moreover have "\<approx>L\<^isub>1 `` {x - xa_max} \<in> ?left" using h1 h2 by auto
   681         ultimately have "\<approx>L\<^isub>1 `` {x - xa_max} \<in> ?right" by simp
   681         ultimately have "\<approx>L\<^isub>1 `` {x - xa_max} \<in> ?right" by simp
   682         with prems show ?thesis apply 
   682         thus ?thesis using that 
   683           (simp add:Image_def str_eq_rel_def str_eq_def) by blast
   683           apply (simp add:Image_def str_eq_rel_def str_eq_def) by blast
   684       qed 
   684       qed 
   685       -- {*
   685       -- {*
   686           \begin{minipage}{0.8\textwidth}
   686           \begin{minipage}{0.8\textwidth}
   687           The @{text "?thesis"}, @{prop "y @ z \<in> L\<^isub>1\<star>"}, is a simple consequence
   687           The @{text "?thesis"}, @{prop "y @ z \<in> L\<^isub>1\<star>"}, is a simple consequence
   688           of the following proposition:
   688           of the following proposition:
   743           qed
   743           qed
   744           hence "(x - xa_max)@?za \<in> L\<^isub>1" using a_in by (auto elim:prefixE)
   744           hence "(x - xa_max)@?za \<in> L\<^isub>1" using a_in by (auto elim:prefixE)
   745           -- {* Now candidates @{text "?za"} and @{text "?zb"} have all the requred properteis. *}
   745           -- {* Now candidates @{text "?za"} and @{text "?zb"} have all the requred properteis. *}
   746           with eq_xya have "(y - ya) @ ?za \<in> L\<^isub>1" 
   746           with eq_xya have "(y - ya) @ ?za \<in> L\<^isub>1" 
   747             by (auto simp:str_eq_def str_eq_rel_def)
   747             by (auto simp:str_eq_def str_eq_rel_def)
   748            with eq_z and b_in prems
   748            with eq_z and b_in 
   749           show ?thesis by blast
   749           show ?thesis using that by blast
   750         qed
   750         qed
   751         -- {* 
   751         -- {* 
   752            @{text "?thesis"} can easily be shown using properties of @{text "za"} and @{text "zb"}:
   752            @{text "?thesis"} can easily be shown using properties of @{text "za"} and @{text "zb"}:
   753             *}
   753             *}
   754         have "((y - ya) @ za) @ zb \<in> L\<^isub>1\<star>" using  l_za ls_zb by blast
   754         have "((y - ya) @ za) @ zb \<in> L\<^isub>1\<star>" using  l_za ls_zb by blast
   761   -- {* By instantiating the reasoning pattern just derived for both directions:*} 
   761   -- {* By instantiating the reasoning pattern just derived for both directions:*} 
   762   from this [OF _ eq_tag] and this [OF _ eq_tag [THEN sym]]
   762   from this [OF _ eq_tag] and this [OF _ eq_tag [THEN sym]]
   763   -- {* The thesis is proved as a trival consequence: *} 
   763   -- {* The thesis is proved as a trival consequence: *} 
   764     show  ?thesis unfolding str_eq_def str_eq_rel_def by blast
   764     show  ?thesis unfolding str_eq_def str_eq_rel_def by blast
   765 qed
   765 qed
   766 
       
   767 
   766 
   768 lemma -- {* The oringal version with less explicit details. *}
   767 lemma -- {* The oringal version with less explicit details. *}
   769   fixes v w
   768   fixes v w
   770   assumes eq_tag: "tag_str_STAR L\<^isub>1 v = tag_str_STAR L\<^isub>1 w"
   769   assumes eq_tag: "tag_str_STAR L\<^isub>1 v = tag_str_STAR L\<^isub>1 w"
   771   shows "(v::string) \<approx>(L\<^isub>1\<star>) w"
   770   shows "(v::string) \<approx>(L\<^isub>1\<star>) w"
   813                                 auto simp:finite_strict_prefix_set)
   812                                 auto simp:finite_strict_prefix_set)
   814         moreover have "?S \<noteq> {}" using False xz_in_star
   813         moreover have "?S \<noteq> {}" using False xz_in_star
   815           by (simp, rule_tac x = "[]" in exI, auto simp:strict_prefix_def)
   814           by (simp, rule_tac x = "[]" in exI, auto simp:strict_prefix_def)
   816         ultimately have "\<exists> max \<in> ?S. \<forall> a \<in> ?S. length a \<le> length max" 
   815         ultimately have "\<exists> max \<in> ?S. \<forall> a \<in> ?S. length a \<le> length max" 
   817           using finite_set_has_max by blast
   816           using finite_set_has_max by blast
   818         with prems show ?thesis by blast
   817         thus ?thesis using that by blast
   819       qed
   818       qed
   820       obtain ya 
   819       obtain ya 
   821         where h5: "ya < y" and h6: "ya \<in> L\<^isub>1\<star>" and h7: "(x - x_max) \<approx>L\<^isub>1 (y - ya)"
   820         where h5: "ya < y" and h6: "ya \<in> L\<^isub>1\<star>" and h7: "(x - x_max) \<approx>L\<^isub>1 (y - ya)"
   822       proof-
   821       proof-
   823         from tag_xy have "{\<approx>L\<^isub>1 `` {x - xa} |xa. xa < x \<and> xa \<in> L\<^isub>1\<star>} = 
   822         from tag_xy have "{\<approx>L\<^isub>1 `` {x - xa} |xa. xa < x \<and> xa \<in> L\<^isub>1\<star>} = 
   824           {\<approx>L\<^isub>1 `` {y - xa} |xa. xa < y \<and> xa \<in> L\<^isub>1\<star>}" (is "?left = ?right")
   823           {\<approx>L\<^isub>1 `` {y - xa} |xa. xa < y \<and> xa \<in> L\<^isub>1\<star>}" (is "?left = ?right")
   825           by (auto simp:tag_str_STAR_def)
   824           by (auto simp:tag_str_STAR_def)
   826         moreover have "\<approx>L\<^isub>1 `` {x - x_max} \<in> ?left" using h1 h2 by auto
   825         moreover have "\<approx>L\<^isub>1 `` {x - x_max} \<in> ?left" using h1 h2 by auto
   827         ultimately have "\<approx>L\<^isub>1 `` {x - x_max} \<in> ?right" by simp
   826         ultimately have "\<approx>L\<^isub>1 `` {x - x_max} \<in> ?right" by simp
   828         with prems show ?thesis apply 
   827         with that show ?thesis apply 
   829           (simp add:Image_def str_eq_rel_def str_eq_def) by blast
   828           (simp add:Image_def str_eq_rel_def str_eq_def) by blast
   830       qed      
   829       qed      
   831       have "(y - ya) @ z \<in> L\<^isub>1\<star>" 
   830       have "(y - ya) @ z \<in> L\<^isub>1\<star>" 
   832       proof-
   831       proof-
   833         from h3 h1 obtain a b where a_in: "a \<in> L\<^isub>1" 
   832         from h3 h1 obtain a b where a_in: "a \<in> L\<^isub>1" 
   896 lemma rexp_imp_finite:
   895 lemma rexp_imp_finite:
   897   fixes r::"rexp"
   896   fixes r::"rexp"
   898   shows "finite (UNIV // \<approx>(L r))"
   897   shows "finite (UNIV // \<approx>(L r))"
   899 by (induct r) (auto)
   898 by (induct r) (auto)
   900 
   899 
   901 
       
   902 end
   900 end
   903 
       
   904 (*
       
   905 lemma refined_quotient_union_eq:
       
   906   assumes refined: "R1 \<subseteq> R2"
       
   907   and eq1: "equiv A R1" and eq2: "equiv A R2"
       
   908   and y_in: "y \<in> A"
       
   909   shows "\<Union>{R1 `` {x} | x. x \<in> (R2 `` {y})} = R2 `` {y}"
       
   910 proof
       
   911   show "\<Union>{R1 `` {x} |x. x \<in> R2 `` {y}} \<subseteq> R2 `` {y}" (is "?L \<subseteq> ?R")
       
   912   proof -
       
   913     { fix z
       
   914       assume zl: "z \<in> ?L" and nzr: "z \<notin> ?R"
       
   915       have "False"
       
   916       proof -
       
   917         from zl and eq1 eq2 and y_in 
       
   918         obtain x where xy2: "(x, y) \<in> R2" and zx1: "(z, x) \<in> R1"
       
   919           by (simp only:equiv_def sym_def, blast)
       
   920         have "(z, y) \<in> R2"
       
   921         proof -
       
   922           from zx1 and refined have "(z, x) \<in> R2" by blast
       
   923           moreover from xy2 have "(x, y) \<in> R2" .
       
   924           ultimately show ?thesis using eq2
       
   925             by (simp only:equiv_def, unfold trans_def, blast)
       
   926         qed
       
   927         with nzr eq2 show ?thesis by (auto simp:equiv_def sym_def)
       
   928       qed
       
   929     } thus ?thesis by blast
       
   930   qed
       
   931 next
       
   932   show "R2 `` {y} \<subseteq> \<Union>{R1 `` {x} |x. x \<in> R2 `` {y}}" (is "?L \<subseteq> ?R")
       
   933   proof
       
   934     fix x
       
   935     assume x_in: "x \<in> ?L"
       
   936     with eq1 eq2 have "x \<in> R1 `` {x}" 
       
   937       by (unfold equiv_def refl_on_def, auto)
       
   938     with x_in show "x \<in> ?R" by auto
       
   939   qed
       
   940 qed
       
   941 *)
       
   942 
       
   943 (*
       
   944 lemma refined_partition_finite:
       
   945   fixes R1 R2 A
       
   946   assumes fnt: "finite (A // R1)"
       
   947   and refined: "R1 \<subseteq> R2"
       
   948   and eq1: "equiv A R1" and eq2: "equiv A R2"
       
   949   shows "finite (A // R2)"
       
   950 proof -
       
   951   let ?f = "\<lambda> X. {R1 `` {x} | x. x \<in> X}" 
       
   952     and ?A = "(A // R2)" and ?B = "(A // R1)"
       
   953   show ?thesis
       
   954   proof(rule_tac f = ?f and A = ?A in finite_imageD)
       
   955     show "finite (?f ` ?A)"
       
   956     proof(rule finite_subset [of _ "Pow ?B"])
       
   957       from fnt show "finite (Pow (A // R1))" by simp
       
   958     next
       
   959       from eq2
       
   960       show " ?f ` A // R2 \<subseteq> Pow ?B"
       
   961         apply (unfold image_def Pow_def quotient_def, auto)
       
   962         by (rule_tac x = xb in bexI, simp, 
       
   963                  unfold equiv_def sym_def refl_on_def, blast)
       
   964     qed
       
   965   next
       
   966     show "inj_on ?f ?A"
       
   967     proof -
       
   968       { fix X Y
       
   969         assume X_in: "X \<in> ?A" and Y_in: "Y \<in> ?A" 
       
   970           and eq_f: "?f X = ?f Y" (is "?L = ?R")
       
   971         hence "X = Y"
       
   972         proof -
       
   973           from X_in eq2
       
   974           obtain x 
       
   975             where x_in: "x \<in> A" 
       
   976             and eq_x: "X = R2 `` {x}" (is "X = ?X")
       
   977             by (unfold quotient_def equiv_def refl_on_def, auto)
       
   978           from Y_in eq2 obtain y 
       
   979             where y_in: "y \<in> A"
       
   980             and eq_y: "Y = R2 `` {y}" (is "Y = ?Y")
       
   981             by (unfold quotient_def equiv_def refl_on_def, auto)
       
   982           have "?X = ?Y"
       
   983           proof -
       
   984             from eq_f have "\<Union> ?L = \<Union> ?R" by auto
       
   985             moreover have "\<Union> ?L = ?X"
       
   986             proof -
       
   987               from eq_x have "\<Union> ?L =  \<Union>{R1 `` {x} |x. x \<in> ?X}" by simp
       
   988               also from refined_quotient_union_eq [OF refined eq1 eq2 x_in]
       
   989               have "\<dots> = ?X" .
       
   990               finally show ?thesis .
       
   991             qed
       
   992             moreover have "\<Union> ?R = ?Y"
       
   993             proof -
       
   994               from eq_y have "\<Union> ?R =  \<Union>{R1 `` {y} |y. y \<in> ?Y}" by simp
       
   995               also from refined_quotient_union_eq [OF refined eq1 eq2 y_in]
       
   996               have "\<dots> = ?Y" .
       
   997               finally show ?thesis .
       
   998             qed
       
   999             ultimately show ?thesis by simp
       
  1000           qed
       
  1001           with eq_x eq_y show ?thesis by auto
       
  1002         qed
       
  1003       } thus ?thesis by (auto simp:inj_on_def)
       
  1004     qed
       
  1005   qed
       
  1006 qed
       
  1007 *)