diff -r e2828c4a1e23 -r d36be1e356c0 thys/Lexer.thy --- a/thys/Lexer.thy Thu Jul 06 16:05:33 2017 +0100 +++ b/thys/Lexer.thy Tue Jul 18 18:39:20 2017 +0100 @@ -79,17 +79,20 @@ by (auto) (metis Star.simps) lemma Star_decomp: - assumes a: "c # x \ A\" - shows "\a b. x = a @ b \ c # a \ A \ b \ A\" -using a + assumes "c # x \ A\" + shows "\s1 s2. x = s1 @ s2 \ c # s1 \ A \ s2 \ A\" +using assms by (induct x\"c # x" rule: Star.induct) (auto simp add: append_eq_Cons_conv) lemma Star_Der_Sequ: shows "Der c (A\) \ (Der c A) ;; A\" unfolding Der_def -by(auto simp add: Der_def Sequ_def Star_decomp) - +apply(rule subsetI) +apply(simp) +unfolding Sequ_def +apply(simp) +by(auto simp add: Sequ_def Star_decomp) lemma Der_star [simp]: @@ -245,8 +248,7 @@ | "\ v2 : r2 \ \ Right v2 : ALT r1 r2" | "\ Void : ONE" | "\ Char c : CHAR c" -| "\ Stars [] : STAR r" -| "\\ v : r; \ Stars vs : STAR r\ \ \ Stars (v # vs) : STAR r" +| "\v \ set vs. \ v : r \ \ Stars vs : STAR r" inductive_cases Prf_elims: "\ v : ZERO" @@ -254,31 +256,25 @@ "\ v : ALT r1 r2" "\ v : ONE" "\ v : CHAR c" -(* "\ vs : STAR r"*) + "\ vs : STAR r" + +lemma Star_concat: + assumes "\s \ set ss. s \ A" + shows "concat ss \ A\" +using assms by (induct ss) (auto) + lemma Prf_flat_L: assumes "\ v : r" shows "flat v \ L r" using assms -by(induct v r rule: Prf.induct) - (auto simp add: Sequ_def) - -lemma Prf_Stars: - assumes "\v \ set vs. \ v : r" - shows "\ Stars vs : STAR r" -using assms -by(induct vs) (auto intro: Prf.intros) +by (induct v r rule: Prf.induct) + (auto simp add: Sequ_def Star_concat) lemma Prf_Stars_append: assumes "\ Stars vs1 : STAR r" "\ Stars vs2 : STAR r" shows "\ Stars (vs1 @ vs2) : STAR r" using assms -apply(induct vs1 arbitrary: vs2) -apply(auto intro: Prf.intros) -apply(erule Prf.cases) -apply(simp_all) -apply(auto intro: Prf.intros) -done - +by (auto intro!: Prf.intros elim!: Prf_elims) lemma Star_string: assumes "s \ A\" @@ -306,40 +302,45 @@ assumes "\ v : r" shows "flat v \ L r" using assms -by (induct)(auto simp add: Sequ_def) +by (induct) (auto simp add: Sequ_def Star_concat) lemma L_flat_Prf2: assumes "s \ L r" shows "\v. \ v : r \ flat v = s" using assms -apply(induct r arbitrary: s) -apply(auto simp add: Sequ_def intro: Prf.intros) -using Prf.intros(1) flat.simps(5) apply blast -using Prf.intros(2) flat.simps(3) apply blast -using Prf.intros(3) flat.simps(4) apply blast -apply(subgoal_tac "\vs::val list. concat (map flat vs) = s \ (\v \ set vs. \ v : r)") -apply(auto)[1] -apply(rule_tac x="Stars vs" in exI) -apply(simp) -apply (simp add: Prf_Stars) -apply(drule Star_string) -apply(auto) -apply(rule Star_val) -apply(auto) -done +proof(induct r arbitrary: s) + case (STAR r s) + have IH: "\s. s \ L r \ \v. \ v : r \ flat v = s" by fact + have "s \ L (STAR r)" by fact + then obtain ss where "concat ss = s" "\s \ set ss. s \ L r" + using Star_string by auto + then obtain vs where "concat (map flat vs) = s" "\v\set vs. \ v : r" + using IH Star_val by blast + then show "\v. \ v : STAR r \ flat v = s" + using Prf.intros(6) flat_Stars by blast +next + case (SEQ r1 r2 s) + then show "\v. \ v : SEQ r1 r2 \ flat v = s" + unfolding Sequ_def L.simps by (fastforce intro: Prf.intros) +next + case (ALT r1 r2 s) + then show "\v. \ v : ALT r1 r2 \ flat v = s" + unfolding L.simps by (fastforce intro: Prf.intros) +qed (auto intro: Prf.intros) lemma L_flat_Prf: "L(r) = {flat v | v. \ v : r}" using L_flat_Prf1 L_flat_Prf2 by blast +(* lemma Star_values_exists: assumes "s \ (L r)\" shows "\vs. concat (map flat vs) = s \ \ Stars vs : STAR r" using assms apply(drule_tac Star_string) apply(auto) -by (metis L_flat_Prf2 Prf_Stars Star_val) - +by (metis L_flat_Prf2 Prf.intros(6) Star_val) +*) section {* Sulzmann and Lu functions *} @@ -385,24 +386,14 @@ using assms apply(induct r arbitrary: c v rule: rexp.induct) apply(auto intro!: Prf.intros mkeps_nullable elim!: Prf_elims split: if_splits) -(* STAR *) -apply(rotate_tac 2) -apply(erule Prf.cases) -apply(simp_all)[7] -apply(auto) -apply (metis Prf.intros(6) Prf.intros(7)) -by (metis Prf.intros(7)) +done lemma Prf_injval_flat: assumes "\ v : der c r" shows "flat (injval r c v) = c # (flat v)" using assms apply(induct arbitrary: v rule: der.induct) -apply(auto elim!: Prf_elims split: if_splits) -apply(metis mkeps_flat) -apply(rotate_tac 2) -apply(erule Prf.cases) -apply(simp_all)[7] +apply(auto elim!: Prf_elims intro: mkeps_flat split: if_splits) done @@ -444,7 +435,9 @@ assumes "s \ r \ v" shows "\ v : r" using assms -by (induct s r v rule: Posix.induct)(auto intro: Prf.intros) +apply(induct s r v rule: Posix.induct) +apply(auto intro!: Prf.intros elim!: Prf_elims) +done lemma Posix_mkeps: