diff -r 5b01f7c233f8 -r a33d3040bf7e thys/ReStar.thy --- a/thys/ReStar.thy Tue Feb 02 02:27:16 2016 +0000 +++ b/thys/ReStar.thy Fri Feb 05 10:16:10 2016 +0000 @@ -540,8 +540,8 @@ "Values (CHAR c) s = (if [c] \ s then {Char c} else {})" "Values (ALT r1 r2) s = {Left v | v. v \ Values r1 s} \ {Right v | v. v \ Values r2 s}" "Values (SEQ r1 r2) s = {Seq v1 v2 | v1 v2. v1 \ Values r1 s \ v2 \ Values r2 (rest v1 s)}" - "Values (STAR r) s = {Star []} \ {Star (v # vs) | v vs. v \ Values r s \ - Star vs \ Values (STAR r) (rest v s)}" + "Values (STAR r) s = + {Star []} \ {Star (v # vs) | v vs. v \ Values r s \ Star vs \ Values (STAR r) (rest v s)}" unfolding Values_def apply(auto) (*NULL*) @@ -589,8 +589,8 @@ "NValues (CHAR c) s = (if [c] \ s then {Char c} else {})" "NValues (ALT r1 r2) s = {Left v | v. v \ NValues r1 s} \ {Right v | v. v \ NValues r2 s}" "NValues (SEQ r1 r2) s = {Seq v1 v2 | v1 v2. v1 \ NValues r1 s \ v2 \ NValues r2 (rest v1 s)}" - "NValues (STAR r) s = {Star []} \ {Star (v # vs) | v vs. v \ NValues r s \ flat v \ [] \ - Star vs \ NValues (STAR r) (rest v s)}" + "NValues (STAR r) s = + {Star []} \ {Star (v # vs) | v vs. v \ NValues r s \ flat v \ [] \ Star vs \ NValues (STAR r) (rest v s)}" unfolding NValues_def apply(auto) (*NULL*) @@ -1217,6 +1217,15 @@ lemma lex_correct4: assumes "s \ L r" + shows "\v. lex r s = Some(v) \ \ v : r \ flat v = s" +using lex_correct3[OF assms] +apply(auto) +apply (metis PMatch1N) +by (metis PMatch1(2)) + + +lemma lex_correct5: + assumes "s \ L r" shows "s \ r \ (lex2 r s)" using assms apply(induct s arbitrary: r) @@ -1243,6 +1252,7 @@ thm PMatch.intros +(* inductive ValOrd :: "string \ val \ rexp \ val \ bool" ("_ \ _ \_ _" [100, 100, 100, 100] 100) where "\s2 \ v2 \r2 v2'; flat v1 = s1\ \ (s1 @ s2) \ (Seq v1 v2) \(SEQ r1 r2) (Seq v1 v2')" @@ -1253,7 +1263,7 @@ | "s \ v1 \r1 v1' \ s \ (Left v1) \(ALT r1 r2) (Left v1')" | "s \ Void \EMPTY Void" | "(c#s) \ (Char c) \(CHAR c) (Char c)" - +*) inductive ValOrd :: "val \ rexp \ val \ bool" ("_ \_ _" [100, 100, 100] 100) where @@ -1265,6 +1275,13 @@ | "v1 \r1 v1' \ (Left v1) \(ALT r1 r2) (Left v1')" | "Void \EMPTY Void" | "(Char c) \(CHAR c) (Char c)" +| "flat (Star (v # vs)) = [] \ (Star []) \(STAR r) (Star (v # vs))" +| "flat (Star (v # vs)) \ [] \ (Star (v # vs)) \(STAR r) (Star [])" +| "v1 \r v2 \ (Star (v1 # vs1)) \(STAR r) (Star (v2 # vs2))" +| "(Star vs1) \(STAR r) (Star vs2) \ (Star (v # vs1)) \(STAR r) (Star (v # vs2))" +| "(Star []) \(STAR r) (Star [])" + +(* lemma ValOrd_PMatch: assumes "s \ r \ v1" "\ v2 : r" "flat v2 \ s" @@ -1272,30 +1289,55 @@ using assms apply(induct r arbitrary: s v1 v2 rule: rexp.induct) apply(erule Prf.cases) -apply(simp_all)[5] +apply(simp_all)[7] apply(erule Prf.cases) -apply(simp_all)[5] +apply(simp_all)[7] apply(erule PMatch.cases) -apply(simp_all)[5] +apply(simp_all)[7] apply (metis ValOrd.intros(7)) apply(erule Prf.cases) -apply(simp_all)[5] +apply(simp_all)[7] apply(erule PMatch.cases) -apply(simp_all)[5] +apply(simp_all)[7] apply (metis ValOrd.intros(8)) defer apply(erule Prf.cases) -apply(simp_all)[5] +apply(simp_all)[7] apply(erule PMatch.cases) -apply(simp_all)[5] +apply(simp_all)[7] apply (metis ValOrd.intros(6)) apply (metis PMatch1(2) Prf_flat_L ValOrd.intros(4) length_sprefix sprefix_def) apply(clarify) apply(erule PMatch.cases) -apply(simp_all)[5] +apply(simp_all)[7] apply (metis PMatch1(2) ValOrd.intros(3) length_sprefix less_imp_le_nat order_refl sprefix_def) apply(clarify) apply (metis ValOrd.intros(5)) +(* Star case *) +apply(erule Prf.cases) +apply(simp_all)[7] +apply(erule PMatch.cases) +apply(simp_all) +apply (metis Nil_is_append_conv ValOrd.intros(10) flat.simps(7)) +apply (metis ValOrd.intros(13)) +apply(clarify) +apply(erule PMatch.cases) +apply(simp_all) +prefer 2 +apply(rule ValOrd.intros) +apply(simp add: prefix_def) +apply(rule ValOrd.intros) +apply(drule_tac x="s1" in meta_spec) +apply(drule_tac x="va" in meta_spec) +apply(drule_tac x="v" in meta_spec) +apply(drule_tac meta_mp) +apply(simp) +apply(drule_tac meta_mp) +apply(simp) +apply(drule_tac meta_mp) +apply(simp add: prefix_def) +apply(auto)[1] +prefer 3 (* Seq case *) apply(erule Prf.cases) apply(simp_all)[5] @@ -2870,4 +2912,7 @@ apply(auto simp add: POSIX_def)[1] apply(erule Prf.cases) apply(simp_all)[5] -oops \ No newline at end of file +oops +*) + +end \ No newline at end of file