thys2/LexerExt.thy
author Chengsong
Fri, 26 May 2023 08:09:30 +0100
changeset 646 56057198e4f5
parent 365 ec5e4fe4cc70
permissions -rw-r--r--
intro
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     1
   
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     2
theory LexerExt
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     3
  imports SpecExt 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     4
begin
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     5
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     6
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     7
section {* The Lexer Functions by Sulzmann and Lu  *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     8
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     9
fun 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    10
  mkeps :: "rexp \<Rightarrow> val"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    11
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    12
  "mkeps(ONE) = Void"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    13
| "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    14
| "mkeps(ALT r1 r2) = (if nullable(r1) then Left (mkeps r1) else Right (mkeps r2))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    15
| "mkeps(STAR r) = Stars []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    16
| "mkeps(UPNTIMES r n) = Stars []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    17
| "mkeps(NTIMES r n) = Stars (replicate n (mkeps r))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    18
| "mkeps(FROMNTIMES r n) = Stars (replicate n (mkeps r))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    19
| "mkeps(NMTIMES r n m) = Stars (replicate n (mkeps r))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    20
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    21
fun injval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    22
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    23
  "injval (CHAR d) c Void = Char d"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    24
| "injval (ALT r1 r2) c (Left v1) = Left(injval r1 c v1)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    25
| "injval (ALT r1 r2) c (Right v2) = Right(injval r2 c v2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    26
| "injval (SEQ r1 r2) c (Seq v1 v2) = Seq (injval r1 c v1) v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    27
| "injval (SEQ r1 r2) c (Left (Seq v1 v2)) = Seq (injval r1 c v1) v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    28
| "injval (SEQ r1 r2) c (Right v2) = Seq (mkeps r1) (injval r2 c v2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    29
| "injval (STAR r) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    30
| "injval (NTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    31
| "injval (FROMNTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    32
| "injval (UPNTIMES r n) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    33
| "injval (NMTIMES r n m) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    34
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    35
fun 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    36
  lexer :: "rexp \<Rightarrow> string \<Rightarrow> val option"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    37
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    38
  "lexer r [] = (if nullable r then Some(mkeps r) else None)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    39
| "lexer r (c#s) = (case (lexer (der c r) s) of  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    40
                    None \<Rightarrow> None
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    41
                  | Some(v) \<Rightarrow> Some(injval r c v))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    42
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    43
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    44
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    45
section {* Mkeps, Injval Properties *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    46
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    47
lemma mkeps_flat:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    48
  assumes "nullable(r)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    49
  shows "flat (mkeps r) = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    50
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    51
  apply(induct rule: nullable.induct) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    52
         apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    53
  by presburger  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    54
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    55
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    56
lemma mkeps_nullable:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    57
  assumes "nullable(r)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    58
  shows "\<Turnstile> mkeps r : r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    59
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    60
apply(induct rule: nullable.induct) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    61
         apply(auto intro: Prf.intros split: if_splits)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    62
  using Prf.intros(8) apply force
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    63
     apply(subst append.simps(1)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    64
     apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    65
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    66
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    67
       apply (simp add: mkeps_flat)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    68
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    69
  using Prf.intros(9) apply force
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    70
    apply(subst append.simps(1)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    71
     apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    72
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    73
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    74
       apply (simp add: mkeps_flat)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    75
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    76
  using Prf.intros(11) apply force
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    77
    apply(subst append.simps(1)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    78
     apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    79
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    80
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    81
    apply (simp add: mkeps_flat)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    82
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    83
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    84
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    85
    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    86
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    87
lemma Prf_injval_flat:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    88
  assumes "\<Turnstile> v : der c r" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    89
  shows "flat (injval r c v) = c # (flat v)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    90
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    91
apply(induct arbitrary: v rule: der.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    92
apply(auto elim!: Prf_elims intro: mkeps_flat split: if_splits)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    93
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    94
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    95
lemma Prf_injval:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    96
  assumes "\<Turnstile> v : der c r" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    97
  shows "\<Turnstile> (injval r c v) : r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    98
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    99
apply(induct r arbitrary: c v rule: rexp.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   100
apply(auto intro!: Prf.intros mkeps_nullable elim!: Prf_elims split: if_splits)[6]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   101
    apply(simp add: Prf_injval_flat)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   102
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   103
  apply(case_tac x2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   104
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   105
  apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   106
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   107
   apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   108
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   109
  apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   110
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   111
  using Prf.intros(7) Prf_injval_flat apply auto[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   112
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   113
    apply(case_tac x2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   114
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   115
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   116
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   117
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   118
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   119
  apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   120
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   121
    apply(subst append.simps(2)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   122
    apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   123
      apply(simp add: Prf_injval_flat)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   124
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   125
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   126
    prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   127
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   128
   apply(case_tac "x3a < x2")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   129
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   130
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   131
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   132
    apply(case_tac x2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   133
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   134
    apply(case_tac x3a)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   135
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   136
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   137
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   138
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   139
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   140
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   141
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   142
  using Prf.intros(12) Prf_injval_flat apply auto[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   143
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   144
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   145
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   146
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   147
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   148
    apply(subst append.simps(2)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   149
    apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   150
     apply(simp add: Prf_injval_flat)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   151
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   152
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   153
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   154
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   155
  using Prf.intros(12) Prf_injval_flat apply auto[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   156
    apply(case_tac x2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   157
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   158
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   159
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   160
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   161
    apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   162
    apply (simp add: Prf.intros(10) Prf_injval_flat)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   163
  using Prf.intros(10) Prf_injval_flat apply auto[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   164
  apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   165
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   166
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   167
    apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   168
    apply(subst append.simps(2)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   169
    apply(rule Prf.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   170
     apply(simp add: Prf_injval_flat)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   171
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   172
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   173
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   174
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   175
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   176
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   177
text {*
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   178
  Mkeps and injval produce, or preserve, Posix values.
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   179
*}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   180
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   181
lemma Posix_mkeps:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   182
  assumes "nullable r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   183
  shows "[] \<in> r \<rightarrow> mkeps r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   184
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   185
apply(induct r rule: nullable.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   186
apply(auto intro: Posix.intros simp add: nullable_correctness Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   187
apply(subst append.simps(1)[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   188
apply(rule Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   189
      apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   190
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   191
    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   192
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   193
lemma Posix_injval:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   194
  assumes "s \<in> (der c r) \<rightarrow> v" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   195
  shows "(c # s) \<in> r \<rightarrow> (injval r c v)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   196
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   197
proof(induct r arbitrary: s v rule: rexp.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   198
  case ZERO
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   199
  have "s \<in> der c ZERO \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   200
  then have "s \<in> ZERO \<rightarrow> v" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   201
  then have "False" by cases
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   202
  then show "(c # s) \<in> ZERO \<rightarrow> (injval ZERO c v)" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   203
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   204
  case ONE
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   205
  have "s \<in> der c ONE \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   206
  then have "s \<in> ZERO \<rightarrow> v" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   207
  then have "False" by cases
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   208
  then show "(c # s) \<in> ONE \<rightarrow> (injval ONE c v)" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   209
next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   210
  case (CHAR d)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   211
  consider (eq) "c = d" | (ineq) "c \<noteq> d" by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   212
  then show "(c # s) \<in> (CHAR d) \<rightarrow> (injval (CHAR d) c v)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   213
  proof (cases)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   214
    case eq
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   215
    have "s \<in> der c (CHAR d) \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   216
    then have "s \<in> ONE \<rightarrow> v" using eq by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   217
    then have eqs: "s = [] \<and> v = Void" by cases simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   218
    show "(c # s) \<in> CHAR d \<rightarrow> injval (CHAR d) c v" using eq eqs 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   219
    by (auto intro: Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   220
  next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   221
    case ineq
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   222
    have "s \<in> der c (CHAR d) \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   223
    then have "s \<in> ZERO \<rightarrow> v" using ineq by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   224
    then have "False" by cases
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   225
    then show "(c # s) \<in> CHAR d \<rightarrow> injval (CHAR d) c v" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   226
  qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   227
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   228
  case (ALT r1 r2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   229
  have IH1: "\<And>s v. s \<in> der c r1 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r1 \<rightarrow> injval r1 c v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   230
  have IH2: "\<And>s v. s \<in> der c r2 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r2 \<rightarrow> injval r2 c v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   231
  have "s \<in> der c (ALT r1 r2) \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   232
  then have "s \<in> ALT (der c r1) (der c r2) \<rightarrow> v" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   233
  then consider (left) v' where "v = Left v'" "s \<in> der c r1 \<rightarrow> v'" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   234
              | (right) v' where "v = Right v'" "s \<notin> L (der c r1)" "s \<in> der c r2 \<rightarrow> v'" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   235
              by cases auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   236
  then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   237
  proof (cases)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   238
    case left
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   239
    have "s \<in> der c r1 \<rightarrow> v'" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   240
    then have "(c # s) \<in> r1 \<rightarrow> injval r1 c v'" using IH1 by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   241
    then have "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c (Left v')" by (auto intro: Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   242
    then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" using left by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   243
  next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   244
    case right
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   245
    have "s \<notin> L (der c r1)" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   246
    then have "c # s \<notin> L r1" by (simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   247
    moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   248
    have "s \<in> der c r2 \<rightarrow> v'" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   249
    then have "(c # s) \<in> r2 \<rightarrow> injval r2 c v'" using IH2 by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   250
    ultimately have "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c (Right v')" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   251
      by (auto intro: Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   252
    then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" using right by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   253
  qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   254
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   255
  case (SEQ r1 r2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   256
  have IH1: "\<And>s v. s \<in> der c r1 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r1 \<rightarrow> injval r1 c v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   257
  have IH2: "\<And>s v. s \<in> der c r2 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r2 \<rightarrow> injval r2 c v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   258
  have "s \<in> der c (SEQ r1 r2) \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   259
  then consider 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   260
        (left_nullable) v1 v2 s1 s2 where 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   261
        "v = Left (Seq v1 v2)"  "s = s1 @ s2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   262
        "s1 \<in> der c r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" "nullable r1" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   263
        "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   264
      | (right_nullable) v1 s1 s2 where 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   265
        "v = Right v1" "s = s1 @ s2"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   266
        "s \<in> der c r2 \<rightarrow> v1" "nullable r1" "s1 @ s2 \<notin> L (SEQ (der c r1) r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   267
      | (not_nullable) v1 v2 s1 s2 where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   268
        "v = Seq v1 v2" "s = s1 @ s2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   269
        "s1 \<in> der c r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" "\<not>nullable r1" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   270
        "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   271
        by (force split: if_splits elim!: Posix_elims simp add: Sequ_def der_correctness Der_def)   
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   272
  then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   273
    proof (cases)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   274
      case left_nullable
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   275
      have "s1 \<in> der c r1 \<rightarrow> v1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   276
      then have "(c # s1) \<in> r1 \<rightarrow> injval r1 c v1" using IH1 by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   277
      moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   278
      have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   279
      then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by (simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   280
      ultimately have "((c # s1) @ s2) \<in> SEQ r1 r2 \<rightarrow> Seq (injval r1 c v1) v2" using left_nullable by (rule_tac Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   281
      then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using left_nullable by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   282
    next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   283
      case right_nullable
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   284
      have "nullable r1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   285
      then have "[] \<in> r1 \<rightarrow> (mkeps r1)" by (rule Posix_mkeps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   286
      moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   287
      have "s \<in> der c r2 \<rightarrow> v1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   288
      then have "(c # s) \<in> r2 \<rightarrow> (injval r2 c v1)" using IH2 by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   289
      moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   290
      have "s1 @ s2 \<notin> L (SEQ (der c r1) r2)" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   291
      then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = c # s \<and> [] @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" using right_nullable
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   292
        by(auto simp add: der_correctness Der_def append_eq_Cons_conv Sequ_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   293
      ultimately have "([] @ (c # s)) \<in> SEQ r1 r2 \<rightarrow> Seq (mkeps r1) (injval r2 c v1)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   294
      by(rule Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   295
      then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using right_nullable by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   296
    next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   297
      case not_nullable
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   298
      have "s1 \<in> der c r1 \<rightarrow> v1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   299
      then have "(c # s1) \<in> r1 \<rightarrow> injval r1 c v1" using IH1 by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   300
      moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   301
      have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r1) \<and> s\<^sub>4 \<in> L r2)" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   302
      then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by (simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   303
      ultimately have "((c # s1) @ s2) \<in> SEQ r1 r2 \<rightarrow> Seq (injval r1 c v1) v2" using not_nullable 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   304
        by (rule_tac Posix.intros) (simp_all) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   305
      then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using not_nullable by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   306
    qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   307
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   308
case (UPNTIMES r n s v)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   309
  have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   310
  have "s \<in> der c (UPNTIMES r n) \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   311
  then consider
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   312
      (cons) v1 vs s1 s2 where 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   313
        "v = Seq v1 (Stars vs)" "s = s1 @ s2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   314
        "s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (UPNTIMES r (n - 1)) \<rightarrow> (Stars vs)" "0 < n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   315
        "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (UPNTIMES r (n - 1)))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   316
    (* here *)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   317
    apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   318
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   319
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   320
    apply(subgoal_tac "\<exists>vss. v2 = Stars vss")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   321
    apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   322
    apply(drule_tac x="v1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   323
    apply(drule_tac x="vss" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   324
    apply(drule_tac x="s1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   325
    apply(drule_tac x="s2" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   326
     apply(simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   327
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   328
     apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   329
      done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   330
    then show "(c # s) \<in> (UPNTIMES r n) \<rightarrow> injval (UPNTIMES r n) c v" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   331
    proof (cases)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   332
      case cons
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   333
          have "s1 \<in> der c r \<rightarrow> v1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   334
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   335
        moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   336
          have "s2 \<in> (UPNTIMES r (n - 1)) \<rightarrow> Stars vs" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   337
        moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   338
          have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   339
          then have "flat (injval r c v1) = (c # s1)" by (rule Posix1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   340
          then have "flat (injval r c v1) \<noteq> []" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   341
        moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   342
          have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (UPNTIMES r (n - 1)))" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   343
          then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (n - 1)))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   344
            by (simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   345
        ultimately 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   346
        have "((c # s1) @ s2) \<in> UPNTIMES r n \<rightarrow> Stars (injval r c v1 # vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   347
           thm Posix.intros
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   348
           apply (rule_tac Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   349
               apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   350
              apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   351
            apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   352
           using Posix_elims(1) UPNTIMES.prems apply auto[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   353
             apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   354
             done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   355
        then show "(c # s) \<in> UPNTIMES r n \<rightarrow> injval (UPNTIMES r n) c v" using cons by(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   356
      qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   357
    next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   358
      case (STAR r)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   359
  have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   360
  have "s \<in> der c (STAR r) \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   361
  then consider
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   362
      (cons) v1 vs s1 s2 where 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   363
        "v = Seq v1 (Stars vs)" "s = s1 @ s2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   364
        "s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (STAR r) \<rightarrow> (Stars vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   365
        "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (STAR r))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   366
        apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   367
        apply(rotate_tac 3)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   368
        apply(erule_tac Posix_elims(6))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   369
        apply (simp add: Posix.intros(6))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   370
        using Posix.intros(7) by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   371
    then show "(c # s) \<in> STAR r \<rightarrow> injval (STAR r) c v" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   372
    proof (cases)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   373
      case cons
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   374
          have "s1 \<in> der c r \<rightarrow> v1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   375
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   376
        moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   377
          have "s2 \<in> STAR r \<rightarrow> Stars vs" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   378
        moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   379
          have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   380
          then have "flat (injval r c v1) = (c # s1)" by (rule Posix1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   381
          then have "flat (injval r c v1) \<noteq> []" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   382
        moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   383
          have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (STAR r))" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   384
          then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   385
            by (simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   386
        ultimately 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   387
        have "((c # s1) @ s2) \<in> STAR r \<rightarrow> Stars (injval r c v1 # vs)" by (rule Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   388
        then show "(c # s) \<in> STAR r \<rightarrow> injval (STAR r) c v" using cons by(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   389
    qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   390
  next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   391
    case (NTIMES r n s v)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   392
     have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   393
  have "s \<in> der c (NTIMES r n) \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   394
  then consider
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   395
      (cons) v1 vs s1 s2 where 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   396
        "v = Seq v1 (Stars vs)" "s = s1 @ s2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   397
        "s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (NTIMES r (n - 1)) \<rightarrow> (Stars vs)" "0 < n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   398
        "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (NTIMES r (n - 1)))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   399
    apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   400
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   401
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   402
    apply(subgoal_tac "\<exists>vss. v2 = Stars vss")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   403
    apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   404
    apply(drule_tac x="v1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   405
    apply(drule_tac x="vss" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   406
    apply(drule_tac x="s1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   407
    apply(drule_tac x="s2" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   408
     apply(simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   409
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   410
     apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   411
      done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   412
    then show "(c # s) \<in> (NTIMES r n) \<rightarrow> injval (NTIMES r n) c v" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   413
    proof (cases)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   414
      case cons
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   415
          have "s1 \<in> der c r \<rightarrow> v1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   416
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   417
        moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   418
          have "s2 \<in> (NTIMES r (n - 1)) \<rightarrow> Stars vs" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   419
        moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   420
          have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   421
          then have "flat (injval r c v1) = (c # s1)" by (rule Posix1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   422
          then have "flat (injval r c v1) \<noteq> []" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   423
        moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   424
          have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (NTIMES r (n - 1)))" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   425
          then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (NTIMES r (n - 1)))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   426
            by (simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   427
        ultimately 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   428
        have "((c # s1) @ s2) \<in> NTIMES r n \<rightarrow> Stars (injval r c v1 # vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   429
           apply (rule_tac Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   430
               apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   431
              apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   432
            apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   433
           using Posix_elims(1) NTIMES.prems apply auto[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   434
             apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   435
             done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   436
        then show "(c # s) \<in> NTIMES r n \<rightarrow> injval (NTIMES r n) c v" using cons by(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   437
      qed  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   438
  next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   439
    case (FROMNTIMES r n s v)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   440
  have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   441
  have "s \<in> der c (FROMNTIMES r n) \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   442
  then consider
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   443
      (cons) v1 vs s1 s2 where 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   444
        "v = Seq v1 (Stars vs)" "s = s1 @ s2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   445
        "s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (FROMNTIMES r (n - 1)) \<rightarrow> (Stars vs)" "0 < n"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   446
        "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (FROMNTIMES r (n - 1)))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   447
     | (null) v1 vs s1 s2 where 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   448
        "v = Seq v1 (Stars vs)" "s = s1 @ s2"  "s2 \<in> (STAR r) \<rightarrow> (Stars vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   449
        "s1 \<in> der c r \<rightarrow> v1" "n = 0"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   450
         "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (STAR r))"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   451
    apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   452
    prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   453
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   454
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   455
    apply(subgoal_tac "\<exists>vss. v2 = Stars vss")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   456
    apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   457
    apply(drule_tac x="v1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   458
    apply(drule_tac x="vss" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   459
    apply(drule_tac x="s1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   460
    apply(drule_tac x="s2" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   461
     apply(simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   462
      apply(rotate_tac 5)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   463
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   464
      apply(auto)[2]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   465
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   466
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   467
     apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   468
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   469
    apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   470
      apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits)      
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   471
    apply(subgoal_tac "\<exists>vss. v2 = Stars vss")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   472
     apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   473
    apply simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   474
      apply(rotate_tac 6)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   475
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   476
      apply(auto)[2]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   477
    done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   478
    then show "(c # s) \<in> (FROMNTIMES r n) \<rightarrow> injval (FROMNTIMES r n) c v" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   479
    proof (cases)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   480
      case cons
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   481
          have "s1 \<in> der c r \<rightarrow> v1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   482
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   483
        moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   484
          have "s2 \<in> (FROMNTIMES r (n - 1)) \<rightarrow> Stars vs" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   485
        moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   486
          have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   487
          then have "flat (injval r c v1) = (c # s1)" by (rule Posix1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   488
          then have "flat (injval r c v1) \<noteq> []" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   489
        moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   490
          have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (FROMNTIMES r (n - 1)))" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   491
          then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (FROMNTIMES r (n - 1)))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   492
            by (simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   493
        ultimately 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   494
        have "((c # s1) @ s2) \<in> FROMNTIMES r n \<rightarrow> Stars (injval r c v1 # vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   495
           apply (rule_tac Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   496
               apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   497
              apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   498
            apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   499
          using Posix_elims(1) FROMNTIMES.prems apply auto[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   500
          using cons(5) apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   501
             apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   502
             done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   503
        then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" using cons by(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   504
      next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   505
       case null
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   506
          have "s1 \<in> der c r \<rightarrow> v1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   507
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   508
          moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   509
            have "s2 \<in> STAR r \<rightarrow> Stars vs" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   510
          moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   511
          have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   512
          then have "flat (injval r c v1) = (c # s1)" by (rule Posix1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   513
          then have "flat (injval r c v1) \<noteq> []" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   514
          moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   515
             moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   516
          have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (STAR r))" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   517
          then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   518
            by (simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   519
        ultimately 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   520
        have "((c # s1) @ s2) \<in> FROMNTIMES r 0 \<rightarrow> Stars (injval r c v1 # vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   521
           apply (rule_tac Posix.intros) back
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   522
             apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   523
           done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   524
        then show "(c # s) \<in> FROMNTIMES r n \<rightarrow> injval (FROMNTIMES r n) c v" using null 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   525
          apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   526
          done  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   527
      qed  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   528
  next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   529
    case (NMTIMES r n m s v)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   530
      have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   531
  have "s \<in> der c (NMTIMES r n m) \<rightarrow> v" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   532
  then consider
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   533
      (cons) v1 vs s1 s2 where 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   534
        "v = Seq v1 (Stars vs)" "s = s1 @ s2" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   535
        "s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (NMTIMES r (n - 1) (m - 1)) \<rightarrow> (Stars vs)" "0 < n" "n \<le> m"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   536
        "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (NMTIMES r (n - 1) (m - 1)))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   537
     | (null) v1 vs s1 s2 where 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   538
        "v = Seq v1 (Stars vs)" "s = s1 @ s2"  "s2 \<in> (UPNTIMES r (m - 1)) \<rightarrow> (Stars vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   539
        "s1 \<in> der c r \<rightarrow> v1" "n = 0" "0 < m"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   540
         "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (UPNTIMES r (m - 1)))"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   541
    apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   542
    prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   543
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   544
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   545
    apply(subgoal_tac "\<exists>vss. v2 = Stars vss")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   546
    apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   547
    apply(drule_tac x="v1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   548
    apply(drule_tac x="vss" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   549
    apply(drule_tac x="s1" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   550
    apply(drule_tac x="s2" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   551
     apply(simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   552
      apply(rotate_tac 5)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   553
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   554
      apply(auto)[2]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   555
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   556
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   557
     apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   558
      
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   559
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   560
    apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   561
      apply(auto elim: Posix_elims simp add: der_correctness Der_def intro: Posix.intros split: if_splits)      
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   562
    apply(subgoal_tac "\<exists>vss. v2 = Stars vss")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   563
     apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   564
    apply simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   565
      apply(rotate_tac 6)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   566
    apply(erule Posix_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   567
      apply(auto)[2]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   568
    done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   569
    then show "(c # s) \<in> (NMTIMES r n m) \<rightarrow> injval (NMTIMES r n m) c v" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   570
    proof (cases)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   571
      case cons
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   572
          have "s1 \<in> der c r \<rightarrow> v1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   573
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   574
        moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   575
          have "s2 \<in> (NMTIMES r (n - 1) (m - 1)) \<rightarrow> Stars vs" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   576
        moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   577
          have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   578
          then have "flat (injval r c v1) = (c # s1)" by (rule Posix1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   579
          then have "flat (injval r c v1) \<noteq> []" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   580
        moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   581
          have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (NMTIMES r (n - 1) (m - 1)))" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   582
          then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (NMTIMES r (n - 1) (m - 1)))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   583
            by (simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   584
        ultimately 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   585
        have "((c # s1) @ s2) \<in> NMTIMES r n m \<rightarrow> Stars (injval r c v1 # vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   586
           apply (rule_tac Posix.intros)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   587
               apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   588
              apply(case_tac n)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   589
            apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   590
          using Posix_elims(1) NMTIMES.prems apply auto[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   591
          using cons(5) apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   592
           apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   593
            apply(rule cons)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   594
             done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   595
        then show "(c # s) \<in> NMTIMES r n m \<rightarrow> injval (NMTIMES r n m) c v" using cons by(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   596
      next 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   597
       case null
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   598
          have "s1 \<in> der c r \<rightarrow> v1" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   599
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   600
          moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   601
            have "s2 \<in> UPNTIMES r (m - 1) \<rightarrow> Stars vs" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   602
          moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   603
          have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   604
          then have "flat (injval r c v1) = (c # s1)" by (rule Posix1)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   605
          then have "flat (injval r c v1) \<noteq> []" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   606
          moreover
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   607
             moreover 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   608
          have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L (der c r) \<and> s\<^sub>4 \<in> L (UPNTIMES r (m - 1)))" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   609
          then have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (c # s1) @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (UPNTIMES r (m - 1)))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   610
            by (simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   611
        ultimately 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   612
        have "((c # s1) @ s2) \<in> NMTIMES r 0 m \<rightarrow> Stars (injval r c v1 # vs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   613
           apply (rule_tac Posix.intros) back
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   614
              apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   615
              apply(rule null)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   616
           done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   617
        then show "(c # s) \<in> NMTIMES r n m \<rightarrow> injval (NMTIMES r n m) c v" using null 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   618
          apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   619
          done  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   620
      qed    
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   621
qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   622
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   623
section {* Lexer Correctness *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   624
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   625
lemma lexer_correct_None:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   626
  shows "s \<notin> L r \<longleftrightarrow> lexer r s = None"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   627
apply(induct s arbitrary: r)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   628
apply(simp add: nullable_correctness)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   629
apply(drule_tac x="der a r" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   630
apply(auto simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   631
done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   632
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   633
lemma lexer_correct_Some:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   634
  shows "s \<in> L r \<longleftrightarrow> (\<exists>v. lexer r s = Some(v) \<and> s \<in> r \<rightarrow> v)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   635
apply(induct s arbitrary: r)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   636
apply(auto simp add: Posix_mkeps nullable_correctness)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   637
apply(drule_tac x="der a r" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   638
apply(simp add: der_correctness Der_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   639
apply(rule iffI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   640
apply(auto intro: Posix_injval simp add: Posix1(1))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   641
done 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   642
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   643
lemma lexer_correctness:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   644
  shows "(lexer r s = Some v) \<longleftrightarrow> s \<in> r \<rightarrow> v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   645
  and   "(lexer r s = None) \<longleftrightarrow> \<not>(\<exists>v. s \<in> r \<rightarrow> v)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   646
using Posix1(1) Posix_determ lexer_correct_None lexer_correct_Some apply fastforce
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   647
using Posix1(1) lexer_correct_None lexer_correct_Some by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   648
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   649
end