# HG changeset patch # User Christian Urban # Date 1450569091 0 # Node ID 56dd3d1d479b70de6f15820f71a0cd322c66b5e3 # Parent 53d5f9a5bbd389ba60cf89968a31b6788df50567 added a proof about Values and PMatch diff -r 53d5f9a5bbd3 -r 56dd3d1d479b thys/Re.thy --- a/thys/Re.thy Fri Dec 18 14:25:22 2015 +0000 +++ b/thys/Re.thy Sat Dec 19 23:51:31 2015 +0000 @@ -434,6 +434,12 @@ None \ None | Some(v) \ Some(injval r c v))" +fun + lex2 :: "rexp \ string \ val" +where + "lex2 r [] = mkeps r" +| "lex2 r (c#s) = injval r c (lex2 (der c r) s)" + section {* Projection function *} @@ -614,6 +620,7 @@ \(\s3 s4. s3 \ [] \ s3 @ s4 = s2 \ (s1 @ s3) \ L r1 \ s4 \ L r2)\ \ (s1 @ s2) \ (SEQ r1 r2) \ (Seq v1 v2)" + lemma PMatch_mkeps: assumes "nullable r" shows "[] \ r \ mkeps r" @@ -648,7 +655,14 @@ apply (metis Prf.intros(1)) done -lemma PMAtch2: +lemma PMatch_Values: + assumes "s \ r \ v" + shows "v \ Values r s" +using assms +apply(simp add: Values_def PMatch1) +by (metis append_Nil2 prefix_def) + +lemma PMatch2: assumes "s \ (der c r) \ v" shows "(c#s) \ r \ (injval r c v)" using assms @@ -749,21 +763,73 @@ apply(simp) by (metis Cons_eq_append_conv) -lemma lex_correct: +lemma lex_correct1: + assumes "s \ L r" + shows "lex r s = None" +using assms +apply(induct s arbitrary: r) +apply(simp) +apply (metis nullable_correctness) +apply(auto) +apply(drule_tac x="der a r" in meta_spec) +apply(drule meta_mp) +apply(auto) +apply(simp add: L_flat_Prf) +by (metis v3 v4) + + +lemma lex_correct2: assumes "s \ L r" - shows "\v. lex r s = Some(v) \ flat v = s" + shows "\v. lex r s = Some(v) \ \ v : r \ flat v = s" using assms apply(induct s arbitrary: r) apply(simp) -apply (metis mkeps_flat nullable_correctness) +apply (metis mkeps_flat mkeps_nullable nullable_correctness) +apply(drule_tac x="der a r" in meta_spec) +apply(drule meta_mp) +apply(simp add: L_flat_Prf) +apply(auto) +apply (metis v3_proj v4_proj2) +apply (metis v3) +apply(rule v4) +by metis + +lemma lex_correct3: + assumes "s \ L r" + shows "\v. lex r s = Some(v) \ s \ r \ v" +using assms +apply(induct s arbitrary: r) +apply(simp) +apply (metis PMatch_mkeps nullable_correctness) apply(drule_tac x="der a r" in meta_spec) apply(drule meta_mp) -defer -apply(auto)[1] -oops +apply(simp add: L_flat_Prf) +apply(auto) +apply (metis v3_proj v4_proj2) +apply(rule PMatch2) +apply(simp) +done + +lemma lex_correct4: + assumes "s \ L r" + shows "s \ r \ (lex2 r s)" +using assms +apply(induct s arbitrary: r) +apply(simp) +apply (metis PMatch_mkeps nullable_correctness) +apply(simp) +apply(rule PMatch2) +apply(drule_tac x="der a r" in meta_spec) +apply(drule meta_mp) +apply(simp add: L_flat_Prf) +apply(auto) +apply (metis v3_proj v4_proj2) +done section {* Sulzmann's Ordering of values *} +thm PMatch.intros + inductive ValOrd :: "val \ rexp \ val \ bool" ("_ \_ _" [100, 100, 100] 100) where "v2 \r2 v2' \ (Seq v1 v2) \(SEQ r1 r2) (Seq v1 v2')"