diff -r 663816814e3e -r 85fa86398d39 MyhillNerode.thy --- a/MyhillNerode.thy Wed Nov 03 21:42:44 2010 +0000 +++ b/MyhillNerode.thy Wed Nov 03 22:08:50 2010 +0000 @@ -740,8 +740,12 @@ shows "X = L xrhs" proof (cases "X = {[]}") case True - thus ?thesis using X_in_equas - by (simp add:equations_def equation_rhs_def lang_seq_def) + thus ?thesis using X_in_equas + unfolding equations_def + unfolding equation_rhs_def + apply(simp del: L_rhs.simps) + apply(simp add: lang_seq_def) + done next case False show ?thesis @@ -754,33 +758,32 @@ proof (cases "x = []") assume empty: "x = []" hence "x \ L (empty_rhs X)" using "(1)" - by (auto simp:empty_rhs_def lang_seq_def) + unfolding empty_rhs_def + by (simp add: lang_seq_def) thus ?thesis using X_in_equas False empty "(1)" unfolding equations_def equation_rhs_def by auto next assume not_empty: "x \ []" - hence "\ clist c. x = clist @ [c]" by (case_tac x rule:rev_cases, auto) - then obtain clist c where decom: "x = clist @ [c]" by blast - moreover have "\ Y. \Y \ UNIV Quo Lang; Y-c\X; clist \ Y\ - \ [c] \ L (folds ALT NULL {CHAR c |c. Y-c\X})" + then obtain clist c where decom: "x = clist @ [c]" + using rev_cases by blast + moreover have "\ Y. Y-c\X \ [c] \ L (folds ALT NULL {CHAR c |c. Y-c\X})" proof - fix Y - assume Y_is_eq_cl: "Y \ UNIV Quo Lang" - and Y_CT_X: "Y-c\X" - and clist_in_Y: "clist \ Y" + assume Y_CT_X: "Y-c\X" with finite_charset_rS show "[c] \ L (folds ALT NULL {CHAR c |c. Y-c\X})" - by (auto simp :fold_alt_null_eqs) + by (auto simp: fold_alt_null_eqs) qed hence "\Xa. Xa \ UNIV Quo Lang \ clist @ [c] \ Xa ; L (folds ALT NULL {CHAR c |c. Xa-c\X})" using X_in_equas False not_empty "(1)" decom - by (auto dest!:every_eqclass_has_ascendent simp:equations_def equation_rhs_def lang_seq_def) + by (auto dest!: every_eqclass_has_ascendent simp: equations_def equation_rhs_def lang_seq_def) then obtain Xa where - "Xa \ UNIV Quo Lang \ clist @ [c] \ Xa ; L (folds ALT NULL {CHAR c |c. Xa-c\X})" by blast + "Xa \ UNIV Quo Lang" "clist @ [c] \ Xa ; L (folds ALT NULL {CHAR c |c. Xa-c\X})" by blast hence "x \ L {(S, folds ALT NULL {CHAR c |c. S-c\X}) |S. S \ UNIV Quo Lang}" using X_in_equas "(1)" decom by (auto simp add:equations_def equation_rhs_def intro!:exI[where x = Xa]) - thus "x \ L xrhs" using X_in_equas False not_empty unfolding equations_def equation_rhs_def + thus "x \ L xrhs" using X_in_equas False not_empty + unfolding equations_def equation_rhs_def by auto qed qed @@ -791,11 +794,14 @@ assume "(2)": "x \ L xrhs" have "(2_1)": "\ s1 s2 r Xa. \s1 \ Xa; s2 \ L (folds ALT NULL {CHAR c |c. Xa-c\X})\ \ s1 @ s2 \ X" using finite_charset_rS - by (auto simp:CT_def lang_seq_def fold_alt_null_eqs) + unfolding CT_def + by (simp add: lang_seq_def fold_alt_null_eqs) (auto) have "(2_2)": "\ s1 s2 Xa r.\s1 \ Xa; s2 \ L r; (Xa, r) \ empty_rhs X\ \ s1 @ s2 \ X" - by (simp add:empty_rhs_def split:if_splits) - show "x \ X" using X_in_equas False "(2)" - by (auto intro:"(2_1)" "(2_2)" simp:equations_def equation_rhs_def lang_seq_def) + by (simp add: empty_rhs_def split: if_splits) + show "x \ X" using X_in_equas False "(2)" + unfolding equations_def + unfolding equation_rhs_def + by (auto intro:"(2_1)" "(2_2)" simp: lang_seq_def) qed qed qed @@ -1316,6 +1322,24 @@ lemma temp_set_ext[no_atp]: "(\x. (x:A) = (x:B)) \ (A = B)" by(auto intro:set_eqI) +lemma folds_simp_null [simp]: + "finite rs \ x \ L (folds ALT NULL rs) = (\r \ rs. x \ L r)" +apply (simp add: folds_def) +apply (rule someI2_ex) +apply (erule finite_imp_fold_graph) +apply (erule fold_graph.induct) +apply (auto) +done + +lemma folds_simp_empty [simp]: + "finite rs \ x \ L (folds ALT EMPTY rs) = ((\r \ rs. x \ L r) \ x = [])" +apply (simp add: folds_def) +apply (rule someI2_ex) +apply (erule finite_imp_fold_graph) +apply (erule fold_graph.induct) +apply (auto) +done + abbreviation str_eq ("_ \_ _") where @@ -1335,7 +1359,7 @@ text {* equivalence classes of x can be written - (\Lang)``{x} + UNIV // (\Lang)``{x} the language quotient can be written @@ -1367,17 +1391,79 @@ definition transitions :: "string set \ string set \ rexp set" ("_\\_") where - "X \\ Y \ {CHAR c | c. X ; {[c]} \ Y}" + "Y \\ X \ {CHAR c | c. Y ; {[c]} \ X}" definition - "rhs CS X \ { (Y, X \\Y) | Y. Y \ CS }" + transitions_rexp ("_ \\ _") +where + "Y \\ X \ if [] \ X then folds ALT EMPTY (Y \\X) else folds ALT NULL (Y \\X)" definition - "rhs_sem CS X \ { (Y; L (folds ALT NULL (X \\Y))) | Y. Y \ CS }" + "rhs CS X \ { (Y, Y \\X) | Y. Y \ CS }" + +definition + "rhs_sem CS X \ { (Y; L (Y \\ X)) | Y. Y \ CS }" definition "eqs CS \ (\X \ CS. {(X, rhs CS X)})" +definition + "eqs_sem CS \ (\X \ CS. {(X, rhs_sem CS X)})" + +(* +lemma + assumes X_in_equas: "(X, rhss) \ (eqs_sem (UNIV // (\Lang)))" + shows "X = \rhss" +using assms +proof (cases "X = {[]}") + case True + thus ?thesis using X_in_equas + by (simp add:equations_def equation_rhs_def lang_seq_def) +next + case False + show ?thesis + proof + show "X \ L xrhs" + proof + fix x + assume "(1)": "x \ X" + show "x \ L xrhs" + proof (cases "x = []") + assume empty: "x = []" + hence "x \ L (empty_rhs X)" using "(1)" + by (auto simp:empty_rhs_def lang_seq_def) + thus ?thesis using X_in_equas False empty "(1)" + unfolding equations_def equation_rhs_def by auto + next + assume not_empty: "x \ []" + hence "\ clist c. x = clist @ [c]" by (case_tac x rule:rev_cases, auto) + then obtain clist c where decom: "x = clist @ [c]" by blast + moreover have "\ Y. \Y \ UNIV Quo Lang; Y-c\X; clist \ Y\ + \ [c] \ L (folds ALT NULL {CHAR c |c. Y-c\X})" + proof - + fix Y + assume Y_is_eq_cl: "Y \ UNIV Quo Lang" + and Y_CT_X: "Y-c\X" + and clist_in_Y: "clist \ Y" + with finite_charset_rS + show "[c] \ L (folds ALT NULL {CHAR c |c. Y-c\X})" + by (auto simp :fold_alt_null_eqs) + qed + hence "\Xa. Xa \ UNIV Quo Lang \ clist @ [c] \ Xa ; L (folds ALT NULL {CHAR c |c. Xa-c\X})" + using X_in_equas False not_empty "(1)" decom + by (auto dest!:every_eqclass_has_ascendent simp:equations_def equation_rhs_def lang_seq_def) + then obtain Xa where + "Xa \ UNIV Quo Lang \ clist @ [c] \ Xa ; L (folds ALT NULL {CHAR c |c. Xa-c\X})" by blast + hence "x \ L {(S, folds ALT NULL {CHAR c |c. S-c\X}) |S. S \ UNIV Quo Lang}" + using X_in_equas "(1)" decom + by (auto simp add:equations_def equation_rhs_def intro!:exI[where x = Xa]) + thus "x \ L xrhs" using X_in_equas False not_empty unfolding equations_def equation_rhs_def + by auto + qed + qed + next +*) + lemma finite_rhs: assumes fin: "finite CS" shows "finite (rhs CS X)" @@ -1393,8 +1479,25 @@ done lemma - shows "X ; L (folds ALT NULL X \\ Y) \ Y" -by (auto simp add: transitions_def lang_seq_def fold_alt_null_eqs) + shows "X ; L (folds ALT NULL (X \\ Y)) \ Y" +by (auto simp add: transitions_def lang_seq_def) + +lemma + shows "X ; L (X \\ Y) \ Y" +apply (auto simp add: transitions_rexp_def transitions_def lang_seq_def) +oops + +lemma + "equation_rhs CS X = rhs CS X" +apply(simp only: rhs_def empty_rhs_def CT_def transitions_rexp_def transitions_def equation_rhs_def) +oops + + + +lemma + shows "X ; L (X \\ Y) \ Y" +apply (auto simp add: transitions_rexp_def transitions_def lang_seq_def) +oops lemma assumes a: "X \ (UNIV // (\Lang))" @@ -1405,27 +1508,62 @@ apply(simp) apply(simp add: quotient_def Image_def) apply(subst (4) mem_def) -apply(simp) -using a -apply(simp add: quotient_def Image_def) -apply(subst (asm) (2) mem_def) -apply(simp) -apply(rule_tac x="X" in exI) -apply(simp) -apply(erule exE) -apply(simp) -apply(rule temp_set_ext) -apply(simp) -apply(rule iffI) -apply(rule_tac x="x" in exI) -apply(simp) oops -lemma tt: "\A = B; C \ B\ \ C \ A" by simp + +lemma UNIV_eq_complement: + "UNIV // (\Lang) = UNIV // (\(- Lang))" +by auto + +lemma eq_inter: + fixes x y::"string" + shows "\x \L1 y; x \L2 y\ \ (x \(L1 \ L2) y)" +by auto + +lemma equ_union: + fixes x y::"string" + shows "\x \L1 y; x \L2 y\ \ (x \(L1 \ L2) y)" +by auto + +(* HERE *) + +lemma tt: + "R1 \ R2 \ R1 `` {x} \ R2 `` {x}" +unfolding Image_def +by auto + +lemma tt_aux: + "(\Lang) `` {x} = \x\Lang" +unfolding Image_def +unfolding equiv_class_def +unfolding equiv_str_def +unfolding mem_def +apply(simp) +done + +lemma tt_old: + "(\L1) \ (\L2) \ \x\L1 \ \x\L2" +unfolding tt_aux[symmetric] +apply(simp add: tt) +done + + + lemma - "UNIV//(\(L1 \ L2)) \ (UNIV//(\L1)) \ (UNIV//(\L2))" -unfolding quotient_def Image_def + assumes a: "finite (A // R1)" "R1 \ R2" + shows "card (A // R2) <= card (A // R1)" +using assms +apply(induct ) +unfolding quotient_def +apply(drule_tac tt) +sorry + +lemma other_direction_cu: + fixes r::"rexp" + shows "finite (UNIV // (\(L r)))" +apply(induct r) +apply(simp_all) oops