thys/Re1.thy
changeset 75 f95a405c3180
parent 74 dfa9dbb8f8e6
child 76 39cef7b9212a
equal deleted inserted replaced
74:dfa9dbb8f8e6 75:f95a405c3180
    29 | EMPTY
    29 | EMPTY
    30 | CHAR char
    30 | CHAR char
    31 | SEQ rexp rexp
    31 | SEQ rexp rexp
    32 | ALT rexp rexp
    32 | ALT rexp rexp
    33 
    33 
       
    34 fun SEQS :: "rexp \<Rightarrow> rexp list \<Rightarrow> rexp"
       
    35 where
       
    36   "SEQS r [] = r"
       
    37 | "SEQS r (r'#rs) = SEQ r (SEQS r' rs)"
       
    38 
    34 section {* Semantics of Regular Expressions *}
    39 section {* Semantics of Regular Expressions *}
    35  
    40  
    36 fun
    41 fun
    37   L :: "rexp \<Rightarrow> string set"
    42   L :: "rexp \<Rightarrow> string set"
    38 where
    43 where
    48   "nullable (NULL) = False"
    53   "nullable (NULL) = False"
    49 | "nullable (EMPTY) = True"
    54 | "nullable (EMPTY) = True"
    50 | "nullable (CHAR c) = False"
    55 | "nullable (CHAR c) = False"
    51 | "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)"
    56 | "nullable (ALT r1 r2) = (nullable r1 \<or> nullable r2)"
    52 | "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)"
    57 | "nullable (SEQ r1 r2) = (nullable r1 \<and> nullable r2)"
       
    58 
       
    59 fun
       
    60  nullable_left :: "rexp \<Rightarrow> bool"
       
    61 where
       
    62   "nullable_left (NULL) = False"
       
    63 | "nullable_left (EMPTY) = True"
       
    64 | "nullable_left (CHAR c) = False"
       
    65 | "nullable_left (ALT r1 r2) = (nullable_left r1 \<or> nullable_left r2)"
       
    66 | "nullable_left (SEQ r1 r2) = nullable_left r1"
       
    67 
       
    68 lemma nullable_left:
       
    69   "nullable r \<Longrightarrow> nullable_left r"
       
    70 apply(induct r)
       
    71 apply(auto)
       
    72 done
       
    73 
    53 
    74 
    54 value "L(CHAR c)"
    75 value "L(CHAR c)"
    55 value "L(SEQ(CHAR c)(CHAR b))"
    76 value "L(SEQ(CHAR c)(CHAR b))"
    56 
    77 
    57 lemma nullable_correctness:
    78 lemma nullable_correctness:
    67 | Char char
    88 | Char char
    68 | Seq val val
    89 | Seq val val
    69 | Right val
    90 | Right val
    70 | Left val
    91 | Left val
    71 
    92 
       
    93 fun Seqs :: "val \<Rightarrow> val list \<Rightarrow> val"
       
    94 where
       
    95   "Seqs v [] = v"
       
    96 | "Seqs v (v'#vs) = Seq v (Seqs v' vs)"
       
    97 
       
    98 
    72 section {* The string behind a value *}
    99 section {* The string behind a value *}
    73 
   100 
    74 fun flat :: "val \<Rightarrow> string"
   101 fun flat :: "val \<Rightarrow> string"
    75 where
   102 where
    76   "flat(Void) = []"
   103   "flat(Void) = []"
    77 | "flat(Char c) = [c]"
   104 | "flat(Char c) = [c]"
    78 | "flat(Left v) = flat(v)"
   105 | "flat(Left v) = flat(v)"
    79 | "flat(Right v) = flat(v)"
   106 | "flat(Right v) = flat(v)"
    80 | "flat(Seq v1 v2) = flat(v1) @ flat(v2)"
   107 | "flat(Seq v1 v2) = flat(v1) @ flat(v2)"
    81 
   108 
       
   109 fun flat_left :: "val \<Rightarrow> string"
       
   110 where
       
   111   "flat_left(Void) = []"
       
   112 | "flat_left(Char c) = [c]"
       
   113 | "flat_left(Left v) = flat_left(v)"
       
   114 | "flat_left(Right v) = flat_left(v)"
       
   115 | "flat_left(Seq v1 v2) = flat_left(v1)"
       
   116 
       
   117 fun flat_right :: "val \<Rightarrow> string"
       
   118 where
       
   119   "flat_right(Void) = []"
       
   120 | "flat_right(Char c) = [c]"
       
   121 | "flat_right(Left v) = flat(v)"
       
   122 | "flat_right(Right v) = flat(v)"
       
   123 | "flat_right(Seq v1 v2) = flat(v2)"
       
   124 
    82 fun head :: "val \<Rightarrow> string"
   125 fun head :: "val \<Rightarrow> string"
    83 where
   126 where
    84   "head(Void) = []"
   127   "head(Void) = []"
    85 | "head(Char c) = [c]"
   128 | "head(Char c) = [c]"
    86 | "head(Left v) = head(v)"
   129 | "head(Left v) = head(v)"
   105 | "\<turnstile> v1 : r1 \<Longrightarrow> \<turnstile> Left v1 : ALT r1 r2"
   148 | "\<turnstile> v1 : r1 \<Longrightarrow> \<turnstile> Left v1 : ALT r1 r2"
   106 | "\<turnstile> v2 : r2 \<Longrightarrow> \<turnstile> Right v2 : ALT r1 r2"
   149 | "\<turnstile> v2 : r2 \<Longrightarrow> \<turnstile> Right v2 : ALT r1 r2"
   107 | "\<turnstile> Void : EMPTY"
   150 | "\<turnstile> Void : EMPTY"
   108 | "\<turnstile> Char c : CHAR c"
   151 | "\<turnstile> Char c : CHAR c"
   109 
   152 
       
   153 inductive Prfs :: "val list \<Rightarrow> rexp list \<Rightarrow> bool"  ("\<Turnstile> _ : _" [100, 100] 100)
       
   154 where
       
   155   "\<Turnstile> [] : []"
       
   156 | "\<lbrakk>\<turnstile>v : r; \<Turnstile> vs : rs\<rbrakk> \<Longrightarrow> \<Turnstile> (v#vs) : (r#rs)"
       
   157 
   110 fun mkeps :: "rexp \<Rightarrow> val"
   158 fun mkeps :: "rexp \<Rightarrow> val"
   111 where
   159 where
   112   "mkeps(EMPTY) = Void"
   160   "mkeps(EMPTY) = Void"
   113 | "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)"
   161 | "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)"
   114 | "mkeps(ALT r1 r2) = (if nullable(r1) then Left (mkeps r1) else Right (mkeps r2))"
   162 | "mkeps(ALT r1 r2) = (if nullable(r1) then Left (mkeps r1) else Right (mkeps r2))"
   127   assumes "nullable(r)" shows "flat (mkeps r) = []"
   175   assumes "nullable(r)" shows "flat (mkeps r) = []"
   128 using assms
   176 using assms
   129 apply(induct rule: nullable.induct)
   177 apply(induct rule: nullable.induct)
   130 apply(auto)
   178 apply(auto)
   131 done
   179 done
       
   180 
       
   181 lemma mkeps_flat_left:
       
   182   assumes "nullable(r)" shows "flat_left (mkeps r) = []"
       
   183 using assms
       
   184 apply(induct rule: nullable.induct)
       
   185 apply(auto)
       
   186 done
       
   187 
       
   188 
   132 
   189 
   133 text {*
   190 text {*
   134   The value mkeps returns is always the correct POSIX
   191   The value mkeps returns is always the correct POSIX
   135   value.
   192   value.
   136 *}
   193 *}
   140 
   197 
   141 
   198 
   142 lemma Prf_flat_L:
   199 lemma Prf_flat_L:
   143   assumes "\<turnstile> v : r" shows "flat v \<in> L r"
   200   assumes "\<turnstile> v : r" shows "flat v \<in> L r"
   144 using assms
   201 using assms
   145 apply(induct)
   202 apply(induct v r rule: Prf.induct)
   146 apply(auto simp add: Sequ_def)
   203 apply(auto simp add: Sequ_def)
   147 done
   204 done
   148 
   205 
   149 lemma L_flat_Prf:
   206 lemma L_flat_Prf:
   150   "L(r) = {flat v | v. \<turnstile> v : r}"
   207   "L(r) = {flat v | v. \<turnstile> v : r}"
   174 | "v2 \<succ>r2 v2' \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Right v2')"
   231 | "v2 \<succ>r2 v2' \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Right v2')"
   175 | "v1 \<succ>r1 v1' \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Left v1')"
   232 | "v1 \<succ>r1 v1' \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Left v1')"
   176 | "Void \<succ>EMPTY Void"
   233 | "Void \<succ>EMPTY Void"
   177 | "(Char c) \<succ>(CHAR c) (Char c)"
   234 | "(Char c) \<succ>(CHAR c) (Char c)"
   178 
   235 
       
   236 inductive ValOrd2 :: "val \<Rightarrow> rexp \<Rightarrow> nat \<Rightarrow> val \<Rightarrow> bool" ("_ \<sqsupset>_,_ _" [100, 100, 100, 100] 100)
       
   237 where
       
   238   "v2 \<sqsupset>r2,n v2' \<Longrightarrow> (Seq v1 v2) \<sqsupset>(SEQ r1 r2),(length (flat v1) + n) (Seq v1 v2')" 
       
   239 | "\<lbrakk>v1 \<sqsupset>r1,n v1'; v1 \<noteq> v1'\<rbrakk> \<Longrightarrow> (Seq v1 v2) \<sqsupset>(SEQ r1 r2),(n + length (flat v2)) (Seq v1' v2')" 
       
   240 | "length (flat v1) \<ge> length (flat v2) \<Longrightarrow> (Left v1) \<sqsupset>(ALT r1 r2),(length (flat v1)) (Right v2)"
       
   241 | "length (flat v2) > length (flat v1) \<Longrightarrow> (Right v2) \<sqsupset>(ALT r1 r2),(length (flat v2)) (Left v1)"
       
   242 | "v2 \<sqsupset>r2,n v2' \<Longrightarrow> (Right v2) \<sqsupset>(ALT r1 r2),n (Right v2')"
       
   243 | "v1 \<sqsupset>r1,n v1' \<Longrightarrow> (Left v1) \<sqsupset>(ALT r1 r2),n (Left v1')"
       
   244 | "Void \<sqsupset>EMPTY,0 Void"
       
   245 | "(Char c) \<sqsupset>(CHAR c),1 (Char c)"
       
   246 
       
   247 lemma 
       
   248   assumes "v1 \<sqsupset>r,n v2"
       
   249   shows "length(flat v1) = n"
       
   250 using assms
       
   251 apply(induct)
       
   252 apply(auto)
       
   253 done
       
   254 
       
   255 lemma 
       
   256   assumes "v1 \<sqsupset>r,n v2"
       
   257   shows "length(flat v2) <= n"
       
   258 using assms
       
   259 apply(induct)
       
   260 apply(auto)
       
   261 oops
       
   262 
   179 
   263 
   180 section {* The ordering is reflexive *}
   264 section {* The ordering is reflexive *}
   181 
   265 
   182 lemma ValOrd_refl:
   266 lemma ValOrd_refl:
   183   assumes "\<turnstile> v : r"
   267   assumes "\<turnstile> v : r"
   539 apply(simp_all)[5]
   623 apply(simp_all)[5]
   540 apply(simp)
   624 apply(simp)
   541 apply(case_tac "nullable r1")
   625 apply(case_tac "nullable r1")
   542 apply(simp)
   626 apply(simp)
   543 apply(erule Prf.cases)
   627 apply(erule Prf.cases)
   544 apply(simp_all)[5]
   628 apply(simp_all (no_asm_use))[5]
   545 apply(auto)[1]
   629 apply(auto)[1]
   546 apply(erule Prf.cases)
   630 apply(erule Prf.cases)
   547 apply(simp_all)[5]
   631 apply(simp_all)[5]
       
   632 apply(clarify)
       
   633 apply(simp only: injval.simps flat.simps)
   548 apply(auto)[1]
   634 apply(auto)[1]
   549 apply (metis mkeps_flat)
   635 apply (metis mkeps_flat)
   550 apply(simp)
   636 apply(simp)
   551 apply(erule Prf.cases)
   637 apply(erule Prf.cases)
   552 apply(simp_all)[5]
   638 apply(simp_all)[5]
   553 done
   639 done
       
   640 
       
   641 lemma v4_flat_left:
       
   642   assumes "\<turnstile> v : der c r" "\<not>(nullable_left r)" shows "flat_left (injval r c v) = c # (flat_left v)"
       
   643 using assms
       
   644 apply(induct arbitrary: v rule: der.induct)
       
   645 apply(simp)
       
   646 apply(erule Prf.cases)
       
   647 apply(simp_all)[5]
       
   648 apply(simp)
       
   649 apply(case_tac "c = c'")
       
   650 apply(simp)
       
   651 apply(erule Prf.cases)
       
   652 apply(simp_all)[5]
       
   653 apply(simp)
       
   654 apply(erule Prf.cases)
       
   655 apply(simp_all)[5]
       
   656 apply(simp)
       
   657 apply(erule Prf.cases)
       
   658 apply(simp_all)[5]
       
   659 apply(simp)
       
   660 apply(case_tac "nullable r1")
       
   661 apply(simp)
       
   662 apply(erule Prf.cases)
       
   663 apply(simp_all (no_asm_use))[5]
       
   664 apply(auto)[1]
       
   665 apply(erule Prf.cases)
       
   666 apply(simp_all)[5]
       
   667 apply(clarify)
       
   668 apply(simp only: injval.simps)
       
   669 apply (metis nullable_left)
       
   670 apply(simp)
       
   671 apply(erule Prf.cases)
       
   672 apply(simp_all)[5]
       
   673 done
       
   674 
   554 
   675 
   555 lemma v4_proj:
   676 lemma v4_proj:
   556   assumes "\<turnstile> v : r" and "\<exists>s. (flat v) = c # s"
   677   assumes "\<turnstile> v : r" and "\<exists>s. (flat v) = c # s"
   557   shows "c # flat (projval r c v) = flat v"
   678   shows "c # flat (projval r c v) = flat v"
   558 using assms
   679 using assms
   680 apply(simp_all)[5]
   801 apply(simp_all)[5]
   681 apply(auto)[1]
   802 apply(auto)[1]
   682 apply(simp add: v4)
   803 apply(simp add: v4)
   683 done
   804 done
   684 
   805 
   685 (*
       
   686 lemma 
       
   687  assumes "\<turnstile> v : der c r" "flat v \<noteq> []"
       
   688  shows "injval r c v \<succ>r mkeps r"
       
   689 using assms
       
   690 apply(induct c r arbitrary: v rule: der.induct)
       
   691 apply(simp_all)
       
   692 apply(erule Prf.cases)
       
   693 apply(simp_all)[5]
       
   694 apply(erule Prf.cases)
       
   695 apply(simp_all)[5]
       
   696 apply(case_tac "c = c'")
       
   697 apply(simp)
       
   698 apply(erule Prf.cases)
       
   699 apply(simp_all)[5]
       
   700 apply(simp)
       
   701 apply(erule Prf.cases)
       
   702 apply(simp_all)[5]
       
   703 apply(auto)[1]
       
   704 apply(erule Prf.cases)
       
   705 apply(simp_all)[5]
       
   706 apply(clarify)
       
   707 apply (metis ValOrd.intros(6))
       
   708 apply(clarify)
       
   709 apply (metis ValOrd.intros(4) drop_0 drop_all le_add2 list.distinct(1) list.size(3) mkeps_flat monoid_add_class.add.right_neutral nat_less_le v4)
       
   710 apply(erule Prf.cases)
       
   711 apply(simp_all)[5]
       
   712 apply(clarify)
       
   713 apply(rule ValOrd.intros)
       
   714 apply(simp)
       
   715 defer
       
   716 apply(rule ValOrd.intros)
       
   717 apply metis
       
   718 apply(case_tac "nullable r1")
       
   719 apply(simp)
       
   720 apply(erule Prf.cases)
       
   721 apply(simp_all)[5]
       
   722 apply(clarify)
       
   723 apply(erule Prf.cases)
       
   724 apply(simp_all)[5]
       
   725 apply(clarify)
       
   726 defer
       
   727 apply(clarify)
       
   728 apply(rule ValOrd.intros)
       
   729 apply metis
       
   730 apply(simp)
       
   731 apply(erule Prf.cases)
       
   732 apply(simp_all)[5]
       
   733 apply(clarify)
       
   734 defer
       
   735 apply(subst mkeps_flat)
       
   736 oops
       
   737 *)
       
   738 
       
   739 
       
   740 lemma LeftRight:
   806 lemma LeftRight:
   741   assumes "(Left v1) \<succ>(der c (ALT r1 r2)) (Right v2)"
   807   assumes "(Left v1) \<succ>(der c (ALT r1 r2)) (Right v2)"
   742   and "\<turnstile> v1 : der c r1" "\<turnstile> v2 : der c r2" 
   808   and "\<turnstile> v1 : der c r1" "\<turnstile> v2 : der c r2" 
   743   shows "(injval (ALT r1 r2) c (Left v1)) \<succ>(ALT r1 r2) (injval (ALT r1 r2) c (Right v2))"
   809   shows "(injval (ALT r1 r2) c (Left v1)) \<succ>(ALT r1 r2) (injval (ALT r1 r2) c (Right v2))"
   744 using assms
   810 using assms
   818 prefer 2
   884 prefer 2
   819 apply (metis list.distinct(1) mkeps_flat v4)
   885 apply (metis list.distinct(1) mkeps_flat v4)
   820 by (metis h)
   886 by (metis h)
   821 
   887 
   822 lemma Prf_inj_test:
   888 lemma Prf_inj_test:
   823   assumes "v1 \<succ>(der c r) v2" "\<turnstile> v1 : der c r" "\<turnstile> v2 : der c r" "flat v1 = flat v2"
   889   assumes "v1 \<succ>(der c r) v2" "\<turnstile> v1 : der c r" "\<turnstile> v2 : der c r"  "\<Turnstile> vs : rs" "flat v1 = flat v2"
   824   shows "(injval r c v1) \<succ>r (injval r c v2)"
   890   shows "Seqs (injval r c v1) vs \<succ>(SEQS r rs) Seqs (injval r c v2) vs"
   825 sorry
   891 using assms
       
   892 apply(induct arbitrary: v1 v2 vs rs rule: der.induct)
       
   893 (* NULL case *)
       
   894 apply(simp)
       
   895 apply(erule ValOrd.cases)
       
   896 apply(simp_all)[8]
       
   897 (* EMPTY case *)
       
   898 apply(simp)
       
   899 apply(erule ValOrd.cases)
       
   900 apply(simp_all)[8]
       
   901 (* CHAR case *)
       
   902 apply(case_tac "c = c'")
       
   903 apply(simp)
       
   904 apply(erule Prf.cases)
       
   905 apply(simp_all)[5]
       
   906 apply(erule Prf.cases)
       
   907 apply(simp_all)[5]
       
   908 apply (metis ValOrd.intros(8))
       
   909 apply(simp)
       
   910 apply(erule Prf.cases)
       
   911 apply(simp_all)[5]
       
   912 (* ALT case *)
       
   913 apply(simp)
       
   914 apply(erule Prf.cases)
       
   915 apply(simp_all)[5]
       
   916 apply(erule Prf.cases)
       
   917 apply(simp_all)[5]
       
   918 apply(erule ValOrd.cases)
       
   919 apply(simp_all)[8]
       
   920 apply (metis ValOrd.intros(6))
       
   921 apply(erule ValOrd.cases)
       
   922 apply(simp_all)[8]
       
   923 apply (metis LeftRight ValOrd.intros(3) der.simps(4) injval.simps(2) injval.simps(3))
       
   924 apply(erule Prf.cases)
       
   925 apply(simp_all)[5]
       
   926 apply(erule ValOrd.cases)
       
   927 apply(simp_all)[8]
       
   928 apply (metis RightLeft ValOrd.intros(4) der.simps(4) injval.simps(2) injval.simps(3))
       
   929 apply(erule ValOrd.cases)
       
   930 apply(simp_all)[8]
       
   931 apply (metis ValOrd.intros(5))
       
   932 (* SEQ case *)
       
   933 apply(simp)
       
   934 apply(case_tac "nullable r1")
       
   935 apply(simp)
       
   936 defer
       
   937 apply(simp)
       
   938 apply(erule Prf.cases)
       
   939 apply(simp_all)[5]
       
   940 apply(erule Prf.cases)
       
   941 apply(simp_all)[5]
       
   942 apply(clarify)
       
   943 apply(erule ValOrd.cases)
       
   944 apply(simp_all)[8]
       
   945 apply(clarify)
       
   946 apply(rule ValOrd.intros)
       
   947 apply(simp)
       
   948 apply(clarify)
       
   949 apply(rule ValOrd.intros(2))
       
   950 apply(rotate_tac 2)
       
   951 apply(drule_tac x="v1c" in meta_spec)
       
   952 apply(rotate_tac 10)
       
   953 apply(drule_tac x="v1'" in meta_spec)
       
   954 apply(drule_tac meta_mp)
       
   955 apply(assumption)
       
   956 apply(drule_tac meta_mp)
       
   957 apply(assumption)
       
   958 apply(drule_tac meta_mp)
       
   959 apply(assumption)
       
   960 apply(drule_tac meta_mp)
       
   961 apply(simp)
       
   962 apply(subst v4)
       
   963 apply(simp)
       
   964 apply(subst (asm) v4)
       
   965 apply(simp)
       
   966 apply(simp)
       
   967 apply(simp add: prefix_def)
       
   968 oops
   826 
   969 
   827 lemma Prf_inj:
   970 lemma Prf_inj:
   828   assumes "v1 \<succ>(der c r) v2" "\<turnstile> v1 : der c r" "\<turnstile> v2 : der c r" (*"flat v1 = flat v2"*)
   971   assumes "v1 \<succ>(der c r) v2" "\<turnstile> v1 : der c r" "\<turnstile> v2 : der c r" (*"flat v1 = flat v2"*)
   829   shows "(injval r c v1) \<succ>r (injval r c v2)"
   972   shows "(injval r c v1) \<succ>r (injval r c v2)"
   830 using assms
   973 using assms
   831 apply(induct arbitrary: v1 v2 rule: der.induct)
   974 apply(induct c r arbitrary: v1 v2 rule: der.induct)
   832 (* NULL case *)
   975 (* NULL case *)
   833 apply(simp)
   976 apply(simp)
   834 apply(erule ValOrd.cases)
   977 apply(erule ValOrd.cases)
   835 apply(simp_all)[8]
   978 apply(simp_all)[8]
   836 (* EMPTY case *)
   979 (* EMPTY case *)
   968 prefer 2
  1111 prefer 2
   969 thm mkeps_flat v4
  1112 thm mkeps_flat v4
   970 apply (metis list.distinct(1) mkeps_flat v4)
  1113 apply (metis list.distinct(1) mkeps_flat v4)
   971 oops
  1114 oops
   972 
  1115 
       
  1116 
   973 lemma POSIX_der:
  1117 lemma POSIX_der:
   974   assumes "POSIX v (der c r)" "\<turnstile> v : der c r"
  1118   assumes "POSIX v (der c r)" "\<turnstile> v : der c r"
   975   shows "POSIX (injval r c v) r"
  1119   shows "POSIX (injval r c v) r"
   976 using assms
  1120 using assms
   977 unfolding POSIX_def
  1121 unfolding POSIX_def
   978 apply(auto)
  1122 apply(auto)
   979 thm v3
  1123 thm v3
   980 apply (metis v3)
  1124 apply (erule v3)
   981 thm v4
  1125 thm v4
   982 apply(subst (asm) v4)
  1126 apply(subst (asm) v4)
   983 apply(assumption)
  1127 apply(assumption)
   984 apply(drule_tac x="projval r c v'" in spec)
  1128 apply(drule_tac x="projval r c v'" in spec)
   985 apply(drule mp)
  1129 apply(drule mp)
   996 apply(subst v4_proj)
  1140 apply(subst v4_proj)
   997 apply(simp)
  1141 apply(simp)
   998 apply(rule_tac x="flat v" in exI)
  1142 apply(rule_tac x="flat v" in exI)
   999 apply(simp)
  1143 apply(simp)
  1000 apply(simp)
  1144 apply(simp)
  1001 thm Prf_inj_test
  1145 oops
  1002 apply(drule Prf_inj_test)
  1146 
  1003 apply(simp)
  1147 lemma POSIX_der:
  1004 apply (metis v3_proj)
  1148   assumes "POSIX v (der c r)" "\<turnstile> v : der c r"
       
  1149   shows "POSIX (injval r c v) r"
       
  1150 using assms
       
  1151 apply(induct c r arbitrary: v rule: der.induct)
       
  1152 (* null case*)
       
  1153 apply(simp add: POSIX_def)
       
  1154 apply(auto)[1]
       
  1155 apply(erule Prf.cases)
       
  1156 apply(simp_all)[5]
       
  1157 apply(erule Prf.cases)
       
  1158 apply(simp_all)[5]
       
  1159 (* empty case *)
       
  1160 apply(simp add: POSIX_def)
       
  1161 apply(auto)[1]
       
  1162 apply(erule Prf.cases)
       
  1163 apply(simp_all)[5]
       
  1164 apply(erule Prf.cases)
       
  1165 apply(simp_all)[5]
       
  1166 (* char case *)
       
  1167 apply(simp add: POSIX_def)
       
  1168 apply(case_tac "c = c'")
       
  1169 apply(auto)[1]
       
  1170 apply(erule Prf.cases)
       
  1171 apply(simp_all)[5]
       
  1172 apply (metis Prf.intros(5))
       
  1173 apply(erule Prf.cases)
       
  1174 apply(simp_all)[5]
       
  1175 apply(erule Prf.cases)
       
  1176 apply(simp_all)[5]
       
  1177 apply (metis ValOrd.intros(8))
       
  1178 apply(auto)[1]
       
  1179 apply(erule Prf.cases)
       
  1180 apply(simp_all)[5]
       
  1181 apply(erule Prf.cases)
       
  1182 apply(simp_all)[5]
       
  1183 (* alt case *)
       
  1184 apply(erule Prf.cases)
       
  1185 apply(simp_all)[5]
       
  1186 apply(clarify)
       
  1187 apply(simp (no_asm) add: POSIX_def)
       
  1188 apply(auto)[1]
       
  1189 apply (metis Prf.intros(2) v3)
       
  1190 apply(rotate_tac 4)
       
  1191 apply(erule Prf.cases)
       
  1192 apply(simp_all)[5]
       
  1193 apply (metis POSIX_ALT2 POSIX_def ValOrd.intros(6))
       
  1194 apply (metis ValOrd.intros(3) order_refl)
       
  1195 apply(simp (no_asm) add: POSIX_def)
       
  1196 apply(auto)[1]
       
  1197 apply (metis Prf.intros(3) v3)
       
  1198 apply(rotate_tac 4)
       
  1199 apply(erule Prf.cases)
       
  1200 apply(simp_all)[5]
       
  1201 defer
       
  1202 apply (metis POSIX_ALT1a POSIX_def ValOrd.intros(5))
       
  1203 prefer 2
       
  1204 apply(subst (asm) (5) POSIX_def)
       
  1205 apply(auto)[1]
       
  1206 apply(rotate_tac 5)
       
  1207 apply(erule Prf.cases)
       
  1208 apply(simp_all)[5]
       
  1209 apply(rule ValOrd.intros)
       
  1210 apply(subst (asm) v4)
       
  1211 apply(simp)
       
  1212 apply(drule_tac x="Left (projval r1a c v1)" in spec)
       
  1213 apply(clarify)
       
  1214 apply(drule mp)
       
  1215 apply(rule conjI)
       
  1216 apply (metis Prf.intros(2) v3_proj)
       
  1217 apply(simp)
       
  1218 apply (metis v4_proj2)
       
  1219 apply(erule ValOrd.cases)
       
  1220 apply(simp_all)[8]
       
  1221 apply (metis less_not_refl v4_proj2)
       
  1222 (* seq case *)
       
  1223 apply(case_tac "nullable r1")
       
  1224 defer
       
  1225 apply(simp add: POSIX_def)
       
  1226 apply(auto)[1]
       
  1227 apply(erule Prf.cases)
       
  1228 apply(simp_all)[5]
       
  1229 apply (metis Prf.intros(1) v3)
       
  1230 apply(erule Prf.cases)
       
  1231 apply(simp_all)[5]
       
  1232 apply(erule Prf.cases)
       
  1233 apply(simp_all)[5]
       
  1234 apply(clarify)
       
  1235 apply(subst (asm) (3) v4)
       
  1236 apply(simp)
       
  1237 apply(simp)
       
  1238 apply(subgoal_tac "flat v1a \<noteq> []")
       
  1239 prefer 2
       
  1240 apply (metis Prf_flat_L nullable_correctness)
       
  1241 apply(subgoal_tac "\<exists>s. flat v1a = c # s")
       
  1242 prefer 2
       
  1243 apply (metis append_eq_Cons_conv)
       
  1244 apply(auto)[1]
       
  1245  
       
  1246 
       
  1247 apply(auto)
       
  1248 thm v3
       
  1249 apply (erule v3)
       
  1250 thm v4
       
  1251 apply(subst (asm) v4)
       
  1252 apply(assumption)
       
  1253 apply(drule_tac x="projval r c v'" in spec)
       
  1254 apply(drule mp)
       
  1255 apply(rule conjI)
       
  1256 thm v3_proj
       
  1257 apply(rule v3_proj)
       
  1258 apply(simp)
       
  1259 apply(rule_tac x="flat v" in exI)
       
  1260 apply(simp)
       
  1261 thm t
  1005 apply(rule_tac c="c" in  t)
  1262 apply(rule_tac c="c" in  t)
  1006 apply(simp)
  1263 apply(simp)
  1007 thm v4_proj
  1264 thm v4_proj
  1008 apply(subst v4_proj)
  1265 apply(subst v4_proj)
  1009 apply(simp)
  1266 apply(simp)
  1010 apply(rule_tac x="flat v" in exI)
  1267 apply(rule_tac x="flat v" in exI)
  1011 apply(simp)
  1268 apply(simp)
  1012 apply(simp)
  1269 apply(simp)
  1013 
  1270 oops
  1014 apply(simp add: Cons_eq_append_conv)
       
  1015 apply(auto)[1]
       
  1016 
       
  1017 
  1271 
  1018 
  1272 
  1019 lemma POSIX_ex: "\<turnstile> v : r \<Longrightarrow> \<exists>v. POSIX v r"
  1273 lemma POSIX_ex: "\<turnstile> v : r \<Longrightarrow> \<exists>v. POSIX v r"
  1020 apply(induct r arbitrary: v)
  1274 apply(induct r arbitrary: v)
  1021 apply(erule Prf.cases)
  1275 apply(erule Prf.cases)