diff -r 440a01d100eb -r a761b8ac8488 MyhillNerode.thy --- a/MyhillNerode.thy Sat Oct 23 12:51:38 2010 +0000 +++ b/MyhillNerode.thy Sun Oct 24 01:17:44 2010 +0000 @@ -281,9 +281,8 @@ where "L1 Quo L2 \ { \x\L2 | x. x \ L1}" - lemma lang_eqs_union_of_eqcls: - "Lang = \ {X. X \ (UNIV Quo Lang) \ (\ x \ X. x \ Lang)}" + "Lang = (\ {X. X \ (UNIV Quo Lang) \ (\ x \ X. x \ Lang)})" proof show "Lang \ \{X \ UNIV Quo Lang. \x\X. x \ Lang}" proof @@ -305,6 +304,7 @@ by auto qed + lemma empty_notin_CS: "{} \ UNIV Quo Lang" apply (clarsimp simp:quot_def equiv_class_def) by (rule_tac x = x in exI, auto simp:equiv_str_def) @@ -317,7 +317,7 @@ definition CT :: "string set \ char \ string set \ bool" ("_-_\_" [99,99]99) where - "X-c\Y \ ((X;{[c]}) \ Y)" + "X-c\Y \ ( X; {[c]} \ Y)" types t_equa_rhs = "(string set \ rexp) set" @@ -345,7 +345,7 @@ equation_rhs :: "(string set) set \ string set \ t_equa_rhs" where "equation_rhs CS X \ if (X = {[]}) then {({[]}, EMPTY)} - else {(S, folds ALT NULL {CHAR c| c. S-c\X} )| S. S \ CS} \ empty_rhs X" + else {(S, folds ALT NULL {CHAR c| c. S-c\X} )| S. S \ CS} \ empty_rhs X" definition equations :: "(string set) set \ t_equas" @@ -505,7 +505,7 @@ where "merge_rhs rhs rhs' \ {(X, r). (\ r1 r2. ((X,r1) \ rhs \ (X, r2) \ rhs') \ r = ALT r1 r2) \ (\ r1. (X, r1) \ rhs \ (\ (\ r2. (X, r2) \ rhs')) \ r = r1) \ - (\ r2. (X, r2) \ rhs' \ (\ (\ r1. (X, r1) \ rhs)) \ r = r2) }" + (\ r2. (X, r2) \ rhs' \ (\ (\ r1. (X, r1) \ rhs)) \ r = r2) }" text {* rhs_subst rhs X=xrhs r: substitude all occurence of X in rhs((X,r) \ rhs) with xrhs *} @@ -631,7 +631,8 @@ definition Inv :: "string set \ t_equas \ bool" where "Inv X ES \ finite ES \ (\ rhs. (X, rhs) \ ES) \ distinct_equas ES \ - (\ X xrhs. (X, xrhs) \ ES \ ardenable (X, xrhs) \ X \ {} \ rhs_eq_cls xrhs \ insert {[]} (left_eq_cls ES))" + (\ X xrhs. (X, xrhs) \ ES \ ardenable (X, xrhs) \ X \ {} \ rhs_eq_cls xrhs + \ insert {[]} (left_eq_cls ES))" text {* TCon: Termination Condition of the equation-system decreasion. @@ -643,11 +644,14 @@ text {* The following is a iteration principle, and is the main framework for the proof: - 1: We can form the initial equation-system using "equations" defined above, and prove it has invariance Inv by lemma "init_ES_satisfy_Inv"; - 2: We can decrease the number of the equation-system using ardens_lemma_revised and substitution ("equas_subst", defined above), - and prove it holds the property "step" in "wf_iter" by lemma "iteration_step" - and finally using property Inv and TCon to prove the myhill-nerode theorem + 1: We can form the initial equation-system using "equations" defined above, + and prove it has invariance Inv by lemma "init_ES_satisfy_Inv"; + + 2: We can decrease the number of the equation-system using ardens_lemma_revised + and substitution ("equas_subst", defined above), + and prove it holds the property "step" in "wf_iter" by lemma "iteration_step" + and finally using property Inv and TCon to prove the myhill-nerode theorem *} lemma wf_iter [rule_format]: fixes f @@ -802,7 +806,8 @@ "(X, xrhs) \ equations CS \ no_EMPTY_rhs xrhs" apply (clarsimp simp add:equations_def equation_rhs_def) apply (simp add:no_EMPTY_rhs_def empty_rhs_def, auto) -apply (subgoal_tac "finite {CHAR c |c. Xa-c\X}", drule_tac x = "[]" in fold_alt_null_eqs, clarsimp, rule finite_charset_rS)+ +apply (subgoal_tac "finite {CHAR c |c. Xa-c\X}", + drule_tac x = "[]" in fold_alt_null_eqs, clarsimp, rule finite_charset_rS)+ done lemma init_ES_satisfy_ardenable: @@ -889,7 +894,8 @@ lemma ardenable_prop: assumes not_lambda: "Y \ {[]}" and ardable: "ardenable (Y, yrhs)" - shows "\ yrhs'. Y = L yrhs' \ distinct_rhs yrhs' \ rhs_eq_cls yrhs' = rhs_eq_cls yrhs - {Y}" (is "\ yrhs'. ?P yrhs'") + shows "\ yrhs'. Y = L yrhs' \ distinct_rhs yrhs' \ rhs_eq_cls yrhs' = rhs_eq_cls yrhs - {Y}" + (is "\ yrhs'. ?P yrhs'") proof (cases "(\ reg. (Y, reg) \ yrhs)") case True thus ?thesis @@ -1306,12 +1312,58 @@ text {* tests by Christian *} -(* Alternative definition for Quo *) +lemma temp_set_ext[no_atp]: "(\x. (x:A) = (x:B)) \ (A = B)" +by(auto intro:set_eqI) + +fun + MNRel +where + "MNRel Lang (x, y) = (x \Lang\ y)" + +lemma + "equiv UNIV (MNRel Lang)" +unfolding equiv_def +unfolding refl_on_def sym_def trans_def +apply(auto simp add: mem_def equiv_str_def) +done + +lemma + "(MNRel Lang)``{x} = \x\Lang" +unfolding equiv_class_def Image_def mem_def +by (simp) + +lemma tt: "\A = B; C \ B\ \ C \ A" by simp + +lemma + "UNIV//(MNRel (L1 \ L2)) \ (UNIV//(MNRel L1)) \ (UNIV//(MNRel L2))" +unfolding quotient_def +unfolding UNION_eq_Union_image +apply(rule tt) +apply(rule Un_Union_image[symmetric]) +apply(simp) +apply(rule UN_mono) +apply(simp) +apply(simp) +unfolding Image_def +unfolding mem_def +unfolding MNRel.simps +apply(simp) +oops + + + +text {* Alternative definition for Quo *} definition QUOT :: "string set \ (string set) set" where "QUOT Lang \ (\x. {\x\Lang})" +lemma test_01: + "Lang \ (\ QUOT Lang)" +unfolding QUOT_def equiv_class_def equiv_str_def +by (blast) + + (* by chunhan *) lemma quot_lambda: "QUOT {[]} = {{[]}, UNIV - {[]}}" proof @@ -1394,7 +1446,7 @@ proof - have "xa = [c] \ {y. xa \{[c]}\ y} = {[c]}" using in_eqiv apply (simp add:equiv_str_def) - apply (rule set_ext, rule iffI, simp) + apply (rule temp_set_ext, rule iffI, simp) apply (drule_tac x = "[]" in spec, auto) done thus "xa = [c] \ x = {[c]}" using in_eqiv by simp @@ -1403,7 +1455,7 @@ proof - have "\xa \ []; xa \ [c]\ \ {y. xa \{[c]}\ y} = UNIV - {[],[c]}" apply (clarsimp simp add:equiv_str_def) - apply (rule set_ext, rule iffI, simp) + apply (rule temp_set_ext, rule iffI, simp) apply (rule conjI) apply (drule_tac x = "[c]" in spec, simp) apply (drule_tac x = "[]" in spec, simp) @@ -1429,13 +1481,13 @@ moreover have "x = {[c]} \ x \ QUOT {[c]}" apply (simp add:QUOT_def equiv_class_def equiv_str_def) apply (rule_tac x = "[c]" in exI, simp) - apply (rule set_ext, rule iffI, simp+) + apply (rule temp_set_ext, rule iffI, simp+) by (drule_tac x = "[]" in spec, simp) moreover have "x = UNIV - {[],[c]} \ x \ QUOT {[c]}" using exist_another apply (clarsimp simp add:QUOT_def equiv_class_def equiv_str_def) apply (rule_tac x = "[a]" in exI, simp) - apply (rule set_ext, rule iffI, simp) + apply (rule temp_set_ext, rule iffI, simp) apply (clarsimp simp:quot_single_aux, simp) apply (rule conjI) apply (drule_tac x = "[c]" in spec, simp) @@ -1453,11 +1505,26 @@ apply (simp add:QUOT_def equiv_class_def equiv_str_def) sorry + +lemma a: + "\x \L1\ y \ x \L2\ y\ \ x \(L1 \ L2)\ y" +apply(simp add: equiv_str_def) +done + + +lemma QUOT_union: + "(QUOT (L1 \ L2)) \ ((QUOT L1) \ (QUOT L2))" +sorry + + lemma quot_alt: assumes finite1: "finite (QUOT L\<^isub>1)" and finite2: "finite (QUOT L\<^isub>2)" shows "finite (QUOT (L\<^isub>1 \ L\<^isub>2))" -sorry +apply(rule finite_subset) +apply(rule QUOT_union) +apply(simp add: finite1 finite2) +done lemma quot_star: assumes finite1: "finite (QUOT L\<^isub>1)" @@ -1470,67 +1537,10 @@ apply (simp add:QUOT_def equiv_class_def equiv_str_def) by (simp_all add:quot_lambda quot_single quot_seq quot_alt quot_star) - - - - - lemma test: "UNIV Quo Lang = QUOT Lang" by (auto simp add: quot_def QUOT_def) -lemma test1: - assumes finite_CS: "finite (QUOT Lang)" - shows "reg Lang" -using finite_CS -unfolding test[symmetric] -by (auto dest: myhill_nerode) - -lemma t1: "(QUOT {}) = {UNIV}" -apply(simp only: QUOT_def equiv_class_def equiv_str_def) -apply(simp) -done - -lemma t2: "{[]} \ (QUOT {[]})" -apply(simp only: QUOT_def equiv_class_def equiv_str_def) -apply(simp) -apply(simp add: set_eq_iff) -apply(rule_tac x="[]" in exI) -apply(simp) -by (metis eq_commute) - - -lemma t2': "X \ (QUOT {[]})" -apply(simp only: QUOT_def equiv_class_def equiv_str_def) -apply(simp) -apply(simp add: set_eq_iff) -apply(rule_tac x="[]" in exI) -apply(simp) -apply(rule allI) - -by (metis eq_commute) - -oops - -lemma - fixes r :: "rexp" - shows "finite (QUOT (L r))" -apply(induct r) -apply(simp add: t1) -apply(simp add: QUOT_def) -apply(simp add: equiv_class_def equiv_str_def) -apply(rule finite_UN_I) -oops - -lemma - fixes r :: "rexp" - shows "finite (UNIV Quo (L r))" -apply(induct r) -prefer 2 -apply(simp add: quot_def) -apply(simp add: equiv_class_def equiv_str_def) -apply(rule finite_UN_I) -apply(simp) end \ No newline at end of file