949 apply simp |
971 apply simp |
950 done*) |
972 done*) |
951 (*For star related bound*) |
973 (*For star related bound*) |
952 |
974 |
953 lemma star_is_a_singleton_list_derc: |
975 lemma star_is_a_singleton_list_derc: |
954 shows " \<exists>Ss. rders_simp (RSTAR r) [c] = rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)" |
976 shows " \<exists>Ss. rders_simp (RSTAR r) [c] = rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))" |
955 apply simp |
977 apply simp |
956 apply(rule_tac x = "[[c]]" in exI) |
978 apply(rule_tac x = "[[c]]" in exI) |
957 apply auto |
979 apply auto |
958 done |
980 apply(case_tac "rsimp (rder c r)") |
|
981 apply simp |
|
982 apply auto |
|
983 apply(subgoal_tac "rsimp (RSEQ x41 x42) = RSEQ x41 x42") |
|
984 prefer 2 |
|
985 apply (metis rsimp_idem) |
|
986 apply(subgoal_tac "rsimp x41 = x41") |
|
987 prefer 2 |
|
988 using rsimp_inner_idem1 apply blast |
|
989 apply(subgoal_tac "rsimp x42 = x42") |
|
990 prefer 2 |
|
991 using rsimp_inner_idem1 apply blast |
|
992 apply simp |
|
993 apply(subgoal_tac "map rsimp x5 = x5") |
|
994 prefer 2 |
|
995 using rsimp_inner_idem3 apply blast |
|
996 apply simp |
|
997 apply(subgoal_tac "rflts x5 = x5") |
|
998 prefer 2 |
|
999 using rsimp_inner_idem4 apply blast |
|
1000 apply simp |
|
1001 using rsimp_inner_idem4 by auto |
|
1002 |
|
1003 |
959 |
1004 |
960 lemma rder_rsimp_ALTs_commute: |
1005 lemma rder_rsimp_ALTs_commute: |
961 shows " (rder x (rsimp_ALTs rs)) = rsimp_ALTs (map (rder x) rs)" |
1006 shows " (rder x (rsimp_ALTs rs)) = rsimp_ALTs (map (rder x) rs)" |
962 apply(induct rs) |
1007 apply(induct rs) |
963 apply simp |
1008 apply simp |
964 apply(case_tac rs) |
1009 apply(case_tac rs) |
965 apply simp |
1010 apply simp |
966 apply auto |
1011 apply auto |
967 done |
1012 done |
968 |
1013 |
969 lemma double_nested_ALTs_under_rsimp: |
1014 |
970 shows "rsimp (rsimp_ALTs ((RALTS rs1) # rs)) = rsimp (RALTS (rs1 @ rs))" |
|
971 apply(case_tac rs1) |
|
972 apply simp |
|
973 |
|
974 apply (metis list.simps(8) list.simps(9) neq_Nil_conv rdistinct.simps(1) rflts.simps(1) rflts.simps(2) rsimp.simps(2) rsimp_ALTs.simps(1) rsimp_ALTs.simps(2) rsimp_ALTs.simps(3)) |
|
975 apply(case_tac rs) |
|
976 apply simp |
|
977 apply auto |
|
978 sorry |
|
979 |
1015 |
980 fun star_update :: "char \<Rightarrow> rrexp \<Rightarrow> char list list => char list list" where |
1016 fun star_update :: "char \<Rightarrow> rrexp \<Rightarrow> char list list => char list list" where |
981 "star_update c r [] = []" |
1017 "star_update c r [] = []" |
982 |"star_update c r (s # Ss) = (if (rnullable (rders_simp r s)) |
1018 |"star_update c r (s # Ss) = (if (rnullable (rders_simp r s)) |
983 then (s@[c]) # [c] # (star_update c r Ss) |
1019 then (s@[c]) # [c] # (star_update c r Ss) |
984 else s # (star_update c r Ss) )" |
1020 else s # (star_update c r Ss) )" |
985 |
1021 |
|
1022 lemma star_update_case1: |
|
1023 shows "rnullable (rders_simp r s) \<Longrightarrow> star_update c r (s # Ss) = (s @ [c]) # [c] # (star_update c r Ss)" |
|
1024 |
|
1025 by force |
|
1026 |
|
1027 lemma star_update_case2: |
|
1028 shows "\<not>rnullable (rders_simp r s) \<Longrightarrow> star_update c r (s # Ss) = s # (star_update c r Ss)" |
|
1029 by simp |
|
1030 |
|
1031 lemma rsimp_alts_idem: |
|
1032 shows "rsimp (rsimp_ALTs (a # as)) = rsimp (rsimp_ALTs (a # [(rsimp (rsimp_ALTs as))] ))" |
|
1033 sorry |
|
1034 |
|
1035 lemma rsimp_alts_idem2: |
|
1036 shows "rsimp (rsimp_ALTs (a # as)) = rsimp (rsimp_ALTs ((rsimp a) # [(rsimp (rsimp_ALTs as))] ))" |
|
1037 sorry |
|
1038 |
|
1039 lemma evolution_step1: |
|
1040 shows "rsimp |
|
1041 (rsimp_ALTs |
|
1042 (rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) = |
|
1043 rsimp |
|
1044 (rsimp_ALTs |
|
1045 (rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # [(rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)))])) " |
|
1046 using rsimp_alts_idem by auto |
|
1047 |
|
1048 lemma evolution_step2: |
|
1049 assumes " rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) = |
|
1050 rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))" |
|
1051 shows "rsimp |
|
1052 (rsimp_ALTs |
|
1053 (rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) = |
|
1054 rsimp |
|
1055 (rsimp_ALTs |
|
1056 (rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # [ rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))])) " |
|
1057 by (simp add: assms rsimp_alts_idem) |
|
1058 |
|
1059 |
|
1060 (* |
|
1061 proof (prove) |
|
1062 goal (1 subgoal): |
|
1063 1. map f (a # s) = f a # map f s |
|
1064 Auto solve_direct: the current goal can be solved directly with |
|
1065 HOL.nitpick_simp(115): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0 |
|
1066 List.list.map(2): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0 |
|
1067 List.list.simps(9): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0 |
|
1068 *) |
986 lemma starseq_list_evolution: |
1069 lemma starseq_list_evolution: |
987 fixes r :: rrexp and Ss :: "char list list" and x :: char |
1070 fixes r :: rrexp and Ss :: "char list list" and x :: char |
988 shows "rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss) ) = |
1071 shows "rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss) ) = |
989 rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)) )" |
1072 rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)) )" |
990 apply(induct Ss) |
1073 apply(induct Ss) |
991 apply simp |
1074 apply simp |
|
1075 apply(subst List.list.map(2)) |
|
1076 apply(subst evolution_step2) |
|
1077 apply simp |
|
1078 apply(case_tac "rnullable (rders_simp r a)") |
|
1079 apply(subst star_update_case1) |
|
1080 apply simp |
|
1081 apply(subst List.list.map)+ |
|
1082 sledgehammer |
992 sorry |
1083 sorry |
993 |
1084 |
994 |
1085 |
995 lemma star_seqs_produce_star_seqs: |
1086 lemma star_seqs_produce_star_seqs: |
996 shows "rsimp (rsimp_ALTs (map (rder x \<circ> (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) |
1087 shows "rsimp (rsimp_ALTs (map (rder x \<circ> (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) |
997 = rsimp (rsimp_ALTs (map ( (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r)))) Ss))" |
1088 = rsimp (rsimp_ALTs (map ( (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r)))) Ss))" |
998 by (meson comp_apply) |
1089 by (meson comp_apply) |
999 |
1090 |
1000 lemma der_seqstar_res: |
1091 lemma map_der_lambda_composition: |
1001 shows "rder x (RSEQ r1 r2) = RSEQ r3 r4" |
1092 shows "map (rder x) (map (\<lambda>s. f s) Ss) = map (\<lambda>s. (rder x (f s))) Ss" |
1002 oops |
1093 by force |
|
1094 |
|
1095 lemma ralts_vs_rsimpalts: |
|
1096 shows "rsimp (RALTS rs) = rsimp (rsimp_ALTs rs)" |
|
1097 sorry |
1003 |
1098 |
1004 lemma linearity_of_list_of_star_or_starseqs: |
1099 lemma linearity_of_list_of_star_or_starseqs: |
1005 fixes r::rrexp and Ss::"char list list" and x::char |
1100 fixes r::rrexp and Ss::"char list list" and x::char |
1006 shows "\<exists>Ssa. rsimp (rder x (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))) = |
1101 shows "\<exists>Ssa. rsimp (rder x (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))) = |
1007 rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ssa)" |
1102 rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ssa)))" |
1008 apply(simp add: rder_rsimp_ALTs_commute) |
1103 apply(subst rder_rsimp_ALTs_commute) |
1009 apply(induct Ss) |
1104 apply(subst map_der_lambda_composition) |
1010 apply simp |
1105 using starseq_list_evolution |
1011 apply (metis list.simps(8) rsimp_ALTs.simps(1)) |
1106 apply(rule_tac x = "star_update x r Ss" in exI) |
1012 |
1107 apply(subst ralts_vs_rsimpalts) |
1013 |
1108 by simp |
1014 sorry |
1109 |
|
1110 |
|
1111 |
|
1112 (*certified correctness---does not depend on any previous sorry*) |
|
1113 lemma star_list_push_der: shows " \<lbrakk>xs \<noteq> [] \<Longrightarrow> \<exists>Ss. rders_simp (RSTAR r) xs = rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)); |
|
1114 xs @ [x] \<noteq> []; xs \<noteq> []\<rbrakk> \<Longrightarrow> |
|
1115 \<exists>Ss. rders_simp (RSTAR r ) (xs @ [x]) = |
|
1116 rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) ) Ss) )" |
|
1117 apply(subgoal_tac "\<exists>Ss. rders_simp (RSTAR r) xs = rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))") |
|
1118 prefer 2 |
|
1119 apply blast |
|
1120 apply(erule exE) |
|
1121 apply(subgoal_tac "rders_simp (RSTAR r) (xs @ [x]) = rsimp (rder x (rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))") |
|
1122 prefer 2 |
|
1123 using rders_simp_append |
|
1124 using rders_simp_one_char apply presburger |
|
1125 apply(rule_tac x= "Ss" in exI) |
|
1126 apply(subgoal_tac " rsimp (rder x (rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) = |
|
1127 rsimp (rsimp (rder x (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))") |
|
1128 prefer 2 |
|
1129 using inside_simp_removal rsimp_idem apply presburger |
|
1130 apply(subgoal_tac "rsimp (rsimp (rder x (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) = |
|
1131 rsimp (rsimp (RALTS (map (rder x) (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))") |
|
1132 prefer 2 |
|
1133 using rder.simps(4) apply presburger |
|
1134 apply(subgoal_tac "rsimp (rsimp (RALTS (map (rder x) (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) = |
|
1135 rsimp (rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r)))) Ss)))") |
|
1136 apply (metis rsimp_idem) |
|
1137 by (metis map_der_lambda_composition) |
|
1138 |
|
1139 lemma simp_in_lambdas : |
|
1140 shows " |
|
1141 rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) ) Ss) ) = |
|
1142 rsimp (RALTS (map (\<lambda>s1. (rsimp (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))))) Ss))" |
|
1143 by (metis (no_types, lifting) comp_apply list.map_comp map_eq_conv rsimp.simps(2) rsimp_idem) |
|
1144 |
1015 |
1145 |
1016 lemma starder_is_a_list_of_stars_or_starseqs: |
1146 lemma starder_is_a_list_of_stars_or_starseqs: |
1017 shows "s \<noteq> [] \<Longrightarrow> \<exists>Ss. rders_simp (RSTAR r) s = rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)" |
1147 shows "s \<noteq> [] \<Longrightarrow> \<exists>Ss. rders_simp (RSTAR r) s = rsimp (RALTS( (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))" |
1018 apply(induct s rule: rev_induct) |
1148 apply(induct s rule: rev_induct) |
1019 apply simp |
1149 apply simp |
1020 apply(case_tac "xs = []") |
1150 apply(case_tac "xs = []") |
1021 using star_is_a_singleton_list_derc |
1151 using star_is_a_singleton_list_derc |
1022 apply(simp) |
1152 apply(simp) |
1023 apply auto |
1153 apply(subgoal_tac "\<exists>Ss. rders_simp (RSTAR r) (xs @ [x]) = |
1024 apply(simp add: rders_simp_append) |
1154 rsimp (RALTS (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss))") |
1025 using linearity_of_list_of_star_or_starseqs by blast |
1155 prefer 2 |
|
1156 using star_list_push_der apply presburger |
|
1157 |
|
1158 |
|
1159 sorry |
1026 |
1160 |
1027 |
1161 |
1028 lemma finite_star: |
1162 lemma finite_star: |
1029 shows "(\<forall>s. rsize (rders_simp r0 s) < N0 ) |
1163 shows "(\<forall>s. rsize (rders_simp r0 s) < N0 ) |
1030 \<Longrightarrow> \<exists>N3. \<forall>s.(rsize (rders_simp (RSTAR r0) s)) < N3" |
1164 \<Longrightarrow> \<exists>N3. \<forall>s.(rsize (rders_simp (RSTAR r0) s)) < N3" |