--- a/thys/LexerExt.thy Tue Jan 25 13:12:50 2022 +0000
+++ b/thys/LexerExt.thy Thu Jan 27 23:25:26 2022 +0000
@@ -17,10 +17,15 @@
| "mkeps(NTIMES r n) = Stars (replicate n (mkeps r))"
| "mkeps(FROMNTIMES r n) = Stars (replicate n (mkeps r))"
| "mkeps(NMTIMES r n m) = Stars (replicate n (mkeps r))"
-
+| "mkeps(NOT ZERO) = Nt Void"
+| "mkeps(NOT (CH _ )) = Nt Void"
+| "mkeps(NOT (SEQ r1 r2)) = Seq (mkeps (NOT r1)) (mkeps (NOT r1))"
+| "mkeps(NOT (ALT r1 r2)) = (if nullable(r1) then Right (mkeps (NOT r2)) else (mkeps (NOT r1)))"
+
+
fun injval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val"
where
- "injval (CHAR d) c Void = Char d"
+ "injval (CH d) c Void = Char d"
| "injval (ALT r1 r2) c (Left v1) = Left(injval r1 c v1)"
| "injval (ALT r1 r2) c (Right v2) = Right(injval r2 c v2)"
| "injval (SEQ r1 r2) c (Seq v1 v2) = Seq (injval r1 c v1) v2"
@@ -49,9 +54,11 @@
shows "flat (mkeps r) = []"
using assms
apply(induct rule: nullable.induct)
- apply(auto)
- by presburger
-
+ apply(auto)
+ apply presburger
+ apply(case_tac r)
+ apply(auto)
+ sorry
lemma mkeps_nullable:
assumes "nullable(r)"
@@ -81,7 +88,7 @@
apply (simp add: mkeps_flat)
apply(simp)
apply(simp)
-done
+ sorry
lemma Prf_injval_flat:
@@ -90,7 +97,7 @@
using assms
apply(induct arbitrary: v rule: der.induct)
apply(auto elim!: Prf_elims intro: mkeps_flat split: if_splits)
-done
+ sorry
lemma Prf_injval:
assumes "\<Turnstile> v : der c r"
@@ -170,7 +177,8 @@
apply(simp add: Prf_injval_flat)
apply(simp)
apply(simp)
-done
+ sorry
+
@@ -186,8 +194,10 @@
apply(auto intro: Posix.intros simp add: nullable_correctness Sequ_def)
apply(subst append.simps(1)[symmetric])
apply(rule Posix.intros)
- apply(auto)
- done
+ apply(auto)
+ apply(case_tac r)
+ apply(auto)
+ sorry
lemma Posix_injval:
@@ -207,22 +217,22 @@
then have "False" by cases
then show "(c # s) \<in> ONE \<rightarrow> (injval ONE c v)" by simp
next
- case (CHAR d)
+ case (CH d)
consider (eq) "c = d" | (ineq) "c \<noteq> d" by blast
- then show "(c # s) \<in> (CHAR d) \<rightarrow> (injval (CHAR d) c v)"
+ then show "(c # s) \<in> (CH d) \<rightarrow> (injval (CH d) c v)"
proof (cases)
case eq
- have "s \<in> der c (CHAR d) \<rightarrow> v" by fact
+ have "s \<in> der c (CH d) \<rightarrow> v" by fact
then have "s \<in> ONE \<rightarrow> v" using eq by simp
then have eqs: "s = [] \<and> v = Void" by cases simp
- show "(c # s) \<in> CHAR d \<rightarrow> injval (CHAR d) c v" using eq eqs
+ show "(c # s) \<in> CH d \<rightarrow> injval (CH d) c v" using eq eqs
by (auto intro: Posix.intros)
next
case ineq
- have "s \<in> der c (CHAR d) \<rightarrow> v" by fact
+ have "s \<in> der c (CH d) \<rightarrow> v" by fact
then have "s \<in> ZERO \<rightarrow> v" using ineq by simp
then have "False" by cases
- then show "(c # s) \<in> CHAR d \<rightarrow> injval (CHAR d) c v" by simp
+ then show "(c # s) \<in> CH d \<rightarrow> injval (CH d) c v" by simp
qed
next
case (ALT r1 r2)
@@ -319,7 +329,6 @@
apply(simp)
apply(subgoal_tac "\<exists>vss. v2 = Stars vss")
apply(clarify)
- apply(drule_tac x="v1" in meta_spec)
apply(drule_tac x="vss" in meta_spec)
apply(drule_tac x="s1" in meta_spec)
apply(drule_tac x="s2" in meta_spec)
@@ -401,7 +410,6 @@
apply(simp)
apply(subgoal_tac "\<exists>vss. v2 = Stars vss")
apply(clarify)
- apply(drule_tac x="v1" in meta_spec)
apply(drule_tac x="vss" in meta_spec)
apply(drule_tac x="s1" in meta_spec)
apply(drule_tac x="s2" in meta_spec)
@@ -454,7 +462,6 @@
apply(simp)
apply(subgoal_tac "\<exists>vss. v2 = Stars vss")
apply(clarify)
- apply(drule_tac x="v1" in meta_spec)
apply(drule_tac x="vss" in meta_spec)
apply(drule_tac x="s1" in meta_spec)
apply(drule_tac x="s2" in meta_spec)
@@ -544,7 +551,6 @@
apply(simp)
apply(subgoal_tac "\<exists>vss. v2 = Stars vss")
apply(clarify)
- apply(drule_tac x="v1" in meta_spec)
apply(drule_tac x="vss" in meta_spec)
apply(drule_tac x="s1" in meta_spec)
apply(drule_tac x="s2" in meta_spec)
@@ -618,6 +624,9 @@
apply(simp)
done
qed
+ next
+ case (NOT r s v)
+ then show ?case sorry
qed
section {* Lexer Correctness *}