diff -r 98d51a89d5a9 -r 654b542ce8db thys/LexerExt.thy --- a/thys/LexerExt.thy Tue Mar 07 00:24:10 2017 +0000 +++ b/thys/LexerExt.thy Wed Mar 08 10:32:51 2017 +0000 @@ -789,11 +789,10 @@ \(\s\<^sub>3 s\<^sub>4. s\<^sub>3 \ [] \ s\<^sub>3 @ s\<^sub>4 = s2 \ (s1 @ s\<^sub>3) \ L r \ s\<^sub>4 \ L (NMTIMES r n m))\ \ (s1 @ s2) \ NMTIMES r (Suc n) (Suc m) \ Stars (v # vs)" | Posix_NMTIMES2: "s \ UPNTIMES r m \ Stars vs \ s \ NMTIMES r 0 m \ Stars vs" -| Posix_PLUS1: "\s1 \ r \ v; s2 \ STAR r \ Stars vs; +| Posix_PLUS1: "\s1 \ r \ v; s2 \ STAR r \ Stars vs; flat v = [] \ flat (Stars vs) = []; \(\s\<^sub>3 s\<^sub>4. s\<^sub>3 \ [] \ s\<^sub>3 @ s\<^sub>4 = s2 \ (s1 @ s\<^sub>3) \ L r \ s\<^sub>4 \ L (STAR r))\ \ (s1 @ s2) \ PLUS r \ Stars (v # vs)" - inductive_cases Posix_elims: "s \ ZERO \ v" "s \ ONE \ v" @@ -822,6 +821,48 @@ done +lemma + "([] @ []) \ PLUS (ONE) \ Stars ([Void])" +apply(rule Posix_PLUS1) +apply(rule Posix.intros) +apply(rule Posix.intros) +apply(simp) +apply(simp) +done + +lemma + assumes "s \ r \ v" "flat v \ []" "\s' \ L r. length s' < length s" + shows "([] @ (s @ [])) \ PLUS (ALT ONE r) \ Stars ([Left Void, Right v])" +using assms +oops + +lemma + "([] @ ([] @ [])) \ FROMNTIMES (ONE) (Suc (Suc 0)) \ Stars ([Void, Void])" +apply(rule Posix.intros) +apply(rule Posix.intros) +apply(rule Posix.intros) +apply(rule Posix.intros) +apply(rule Posix.intros) +apply(rule Posix.intros) +apply(auto) +done + + +lemma + assumes "s \ r \ v" "flat v \ []" + "s \ PLUS (ALT ONE r) \ Stars ([Left(Void), Right(v)])" + shows "False" +using assms +apply(rotate_tac 2) +apply(erule_tac Posix.cases) +apply(simp_all) +apply(auto) +oops + + + + + lemma Posix1a: assumes "s \ r \ v" shows "\ v : r" @@ -1131,12 +1172,12 @@ next case (Posix_PLUS1 s1 r v s2 vs v2) have "(s1 @ s2) \ PLUS r \ v2" - "s1 \ r \ v" "s2 \ (STAR r) \ Stars vs" + "s1 \ r \ v" "s2 \ (STAR r) \ Stars vs" (*"flat v = [] \ flat (Stars vs) = []"*) "\ (\s\<^sub>3 s\<^sub>4. s\<^sub>3 \ [] \ s\<^sub>3 @ s\<^sub>4 = s2 \ s1 @ s\<^sub>3 \ L r \ s\<^sub>4 \ L (STAR r))" by fact+ then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \ r \ v'" "s2 \ (STAR r) \ (Stars vs')" apply(cases) apply (auto simp add: append_eq_append_conv2) using Posix1(1) apply fastforce - by (metis Posix1(1) Posix_PLUS1.hyps(5) append_Nil2 self_append_conv2) + by (metis Posix1(1) Posix_PLUS1.hyps(6) append_self_conv append_self_conv2) moreover have IHs: "\v2. s1 \ r \ v2 \ v = v2" "\v2. s2 \ STAR r \ v2 \ Stars vs = v2" by fact+ @@ -1533,36 +1574,32 @@ case (PLUS r) have IH: "\s v. s \ der c r \ v \ (c # s) \ r \ injval r c v" by fact have "s \ der c (PLUS r) \ v" by fact - then consider - (cons) v1 vs s1 s2 where - "v = Seq v1 (Stars vs)" "s = s1 @ s2" - "s1 \ der c r \ v1" "s2 \ (STAR r) \ (Stars vs)" - "\ (\s\<^sub>3 s\<^sub>4. s\<^sub>3 \ [] \ s\<^sub>3 @ s\<^sub>4 = s2 \ s1 @ s\<^sub>3 \ L (der c r) \ s\<^sub>4 \ L (STAR r))" - apply(simp) - apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros) - defer - apply(rotate_tac 3) - apply(erule_tac Posix_elims(6)) - apply (simp add: Posix.intros(6)) - using Posix.intros(7) by blast - then show "(c # s) \ PLUS r \ injval (PLUS r) c v" - proof (cases) - case cons - have "s1 \ der c r \ v1" by fact - then have "(c # s1) \ r \ injval r c v1" using IH by simp - moreover - have "s2 \ STAR r \ Stars vs" by fact - moreover - have "\ (\s\<^sub>3 s\<^sub>4. s\<^sub>3 \ [] \ s\<^sub>3 @ s\<^sub>4 = s2 \ s1 @ s\<^sub>3 \ L (der c r) \ s\<^sub>4 \ L (STAR r))" by fact - then have "\ (\s\<^sub>3 s\<^sub>4. s\<^sub>3 \ [] \ s\<^sub>3 @ s\<^sub>4 = s2 \ (c # s1) @ s\<^sub>3 \ L r \ s\<^sub>4 \ L (STAR r))" - by (simp add: der_correctness Der_def) - ultimately - have "((c # s1) @ s2) \ (PLUS r) \ Stars (injval r c v1 # vs)" - apply(rule_tac Posix.intros) - apply(simp_all) - done - then show "(c # s) \ PLUS r \ injval (PLUS r) c v" using cons by(simp) - qed + then show "(c # s) \ PLUS r \ injval (PLUS r) c v" + apply - + apply(erule Posix.cases) + apply(simp_all) + apply(auto) + apply(rotate_tac 3) + apply(erule Posix.cases) + apply(simp_all) + apply(subst append_Cons[symmetric]) + apply(rule Posix.intros) + using PLUS.hyps apply auto[1] + apply(rule Posix.intros) + apply(simp) + apply(simp) + apply(simp) + apply(simp) + apply(simp) + using Posix1a Prf_injval_flat apply auto[1] + apply(simp add: der_correctness Der_def) + apply(subst append_Nil2[symmetric]) + apply(rule Posix.intros) + using PLUS.hyps apply auto[1] + apply(rule Posix.intros) + apply(simp) + apply(simp) + done qed @@ -1602,5 +1639,8 @@ using Posix1(1) Posix_determ lexer_correct_None lexer_correct_Some apply fastforce using Posix1(1) lexer_correct_None lexer_correct_Some by blast +value "lexer (PLUS (ALT ONE (SEQ (CHAR (CHR ''a'')) (CHAR (CHR ''b''))))) [CHR ''a'', CHR ''b'']" + + unused_thms end \ No newline at end of file