AFP-Submission/Simplifying.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 10 Jun 2016 23:53:46 +0100
changeset 195 c2d36c3cf8ad
parent 191 6bb15b8e6301
permissions -rw-r--r--
run all posix tests
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
191
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
(*  Title:       POSIX Lexing with Derivatives of Regular Expressions
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
    Authors:     Fahad Ausaf <fahad.ausaf at icloud.com>, 2016
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
                 Roy Dyckhoff <roy.dyckhoff at st-andrews.ac.uk>, 2016
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
                 Christian Urban <christian.urban at kcl.ac.uk>, 2016
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
    Maintainer:  Christian Urban <christian.urban at kcl.ac.uk>
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
*) 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
theory Simplifying
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
  imports "Lexer" 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
begin
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
section {* Lexer including simplifications *}
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
fun F_RIGHT where
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
  "F_RIGHT f v = Right (f v)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
fun F_LEFT where
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
  "F_LEFT f v = Left (f v)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
fun F_Plus where
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
  "F_Plus f\<^sub>1 f\<^sub>2 (Right v) = Right (f\<^sub>2 v)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
| "F_Plus f\<^sub>1 f\<^sub>2 (Left v) = Left (f\<^sub>1 v)"  
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
| "F_Plus f1 f2 v = v"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    27
fun F_Times1 where
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
  "F_Times1 f\<^sub>1 f\<^sub>2 v = Seq (f\<^sub>1 Void) (f\<^sub>2 v)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
fun F_Times2 where 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
  "F_Times2 f\<^sub>1 f\<^sub>2 v = Seq (f\<^sub>1 v) (f\<^sub>2 Void)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
fun F_Times where 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
  "F_Times f\<^sub>1 f\<^sub>2 (Seq v\<^sub>1 v\<^sub>2) = Seq (f\<^sub>1 v\<^sub>1) (f\<^sub>2 v\<^sub>2)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
| "F_Times f1 f2 v = v"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
fun simp_Plus where
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
  "simp_Plus (Zero, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (r\<^sub>2, F_RIGHT f\<^sub>2)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
| "simp_Plus (r\<^sub>1, f\<^sub>1) (Zero, f\<^sub>2) = (r\<^sub>1, F_LEFT f\<^sub>1)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    40
| "simp_Plus (r\<^sub>1, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (Plus r\<^sub>1 r\<^sub>2, F_Plus f\<^sub>1 f\<^sub>2)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
fun simp_Times where
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
  "simp_Times (One, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (r\<^sub>2, F_Times1 f\<^sub>1 f\<^sub>2)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
| "simp_Times (r\<^sub>1, f\<^sub>1) (One, f\<^sub>2) = (r\<^sub>1, F_Times2 f\<^sub>1 f\<^sub>2)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
| "simp_Times (r\<^sub>1, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (Times r\<^sub>1 r\<^sub>2, F_Times f\<^sub>1 f\<^sub>2)"  
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
lemma simp_Times_simps[simp]:
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
  "simp_Times p1 p2 = (if (fst p1 = One) then (fst p2, F_Times1 (snd p1) (snd p2))
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
                    else (if (fst p2 = One) then (fst p1, F_Times2 (snd p1) (snd p2))
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    50
                    else (Times (fst p1) (fst p2), F_Times (snd p1) (snd p2))))"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
by (induct p1 p2 rule: simp_Times.induct) (auto)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
lemma simp_Plus_simps[simp]:
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
  "simp_Plus p1 p2 = (if (fst p1 = Zero) then (fst p2, F_RIGHT (snd p2))
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
                    else (if (fst p2 = Zero) then (fst p1, F_LEFT (snd p1))
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
                    else (Plus (fst p1) (fst p2), F_Plus (snd p1) (snd p2))))"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
by (induct p1 p2 rule: simp_Plus.induct) (auto)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
fun 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
  simp :: "'a rexp \<Rightarrow> 'a rexp * ('a val \<Rightarrow> 'a val)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
where
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
  "simp (Plus r1 r2) = simp_Plus (simp r1) (simp r2)" 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
| "simp (Times r1 r2) = simp_Times (simp r1) (simp r2)" 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
| "simp r = (r, id)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
fun 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
  slexer :: "'a rexp \<Rightarrow> 'a list \<Rightarrow> ('a val) option"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
where
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    69
  "slexer r [] = (if nullable r then Some(mkeps r) else None)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
| "slexer r (c#s) = (let (rs, fr) = simp (deriv c r) in
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
                         (case (slexer rs s) of  
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
                            None \<Rightarrow> None
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    73
                          | Some(v) \<Rightarrow> Some(injval r c (fr v))))"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
lemma slexer_better_simp:
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
  "slexer r (c#s) = (case (slexer (fst (simp (deriv c r))) s) of  
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
                            None \<Rightarrow> None
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
                          | Some(v) \<Rightarrow> Some(injval r c ((snd (simp (deriv c r))) v)))"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
by (auto split: prod.split option.split)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    81
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
lemma L_fst_simp:
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
  shows "lang r = lang (fst (simp r))"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    84
using assms
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    85
by (induct r) (auto)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    86
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    87
lemma Posix_simp:
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    88
  assumes "s \<in> (fst (simp r)) \<rightarrow> v" 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    89
  shows "s \<in> r \<rightarrow> ((snd (simp r)) v)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    90
using assms
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    91
proof(induct r arbitrary: s v rule: rexp.induct)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    92
  case (Plus r1 r2 s v)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    93
  have IH1: "\<And>s v. s \<in> fst (simp r1) \<rightarrow> v \<Longrightarrow> s \<in> r1 \<rightarrow> snd (simp r1) v" by fact
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    94
  have IH2: "\<And>s v. s \<in> fst (simp r2) \<rightarrow> v \<Longrightarrow> s \<in> r2 \<rightarrow> snd (simp r2) v" by fact
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    95
  have as: "s \<in> fst (simp (Plus r1 r2)) \<rightarrow> v" by fact
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    96
  consider (Zero_Zero) "fst (simp r1) = Zero" "fst (simp r2) = Zero"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    97
         | (Zero_NZero) "fst (simp r1) = Zero" "fst (simp r2) \<noteq> Zero"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
         | (NZero_Zero) "fst (simp r1) \<noteq> Zero" "fst (simp r2) = Zero"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
         | (NZero_NZero) "fst (simp r1) \<noteq> Zero" "fst (simp r2) \<noteq> Zero" by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   100
  then show "s \<in> Plus r1 r2 \<rightarrow> snd (simp (Plus r1 r2)) v" 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   101
    proof(cases)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
      case (Zero_Zero)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
      with as have "s \<in> Zero \<rightarrow> v" by simp 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
      then show "s \<in> Plus r1 r2 \<rightarrow> snd (simp (Plus r1 r2)) v" by (rule Posix_elims(1))
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   105
    next
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   106
      case (Zero_NZero)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   107
      with as have "s \<in> fst (simp r2) \<rightarrow> v" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   108
      with IH2 have "s \<in> r2 \<rightarrow> snd (simp r2) v" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
      moreover
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
      from Zero_NZero have "fst (simp r1) = Zero" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
      then have "lang (fst (simp r1)) = {}" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   112
      then have "lang r1 = {}" using L_fst_simp by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   113
      then have "s \<notin> lang r1" by simp 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   114
      ultimately have "s \<in> Plus r1 r2 \<rightarrow> Right (snd (simp r2) v)" by (rule Posix_Plus2)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   115
      then show "s \<in> Plus r1 r2 \<rightarrow> snd (simp (Plus r1 r2)) v"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   116
      using Zero_NZero by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   117
    next
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   118
      case (NZero_Zero)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   119
      with as have "s \<in> fst (simp r1) \<rightarrow> v" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   120
      with IH1 have "s \<in> r1 \<rightarrow> snd (simp r1) v" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   121
      then have "s \<in> Plus r1 r2 \<rightarrow> Left (snd (simp r1) v)" by (rule Posix_Plus1) 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   122
      then show "s \<in> Plus r1 r2 \<rightarrow> snd (simp (Plus r1 r2)) v" using NZero_Zero by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   123
    next
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   124
      case (NZero_NZero)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   125
      with as have "s \<in> Plus (fst (simp r1)) (fst (simp r2)) \<rightarrow> v" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   126
      then consider (Left) v1 where "v = Left v1" "s \<in> (fst (simp r1)) \<rightarrow> v1"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   127
                  | (Right) v2 where "v = Right v2" "s \<in> (fst (simp r2)) \<rightarrow> v2" "s \<notin> lang (fst (simp r1))"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   128
                  by (erule_tac Posix_elims(4)) 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   129
      then show "s \<in> Plus r1 r2 \<rightarrow> snd (simp (Plus r1 r2)) v"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   130
      proof(cases)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
        case (Left)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   132
        then have "v = Left v1" "s \<in> r1 \<rightarrow> (snd (simp r1) v1)" using IH1 by simp_all
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   133
        then show "s \<in> Plus r1 r2 \<rightarrow> snd (simp (Plus r1 r2)) v" using NZero_NZero
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   134
          by (simp_all add: Posix_Plus1)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   135
      next 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   136
        case (Right)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   137
        then have "v = Right v2" "s \<in> r2 \<rightarrow> (snd (simp r2) v2)" "s \<notin> lang r1" using IH2 L_fst_simp by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   138
        then show "s \<in> Plus r1 r2 \<rightarrow> snd (simp (Plus r1 r2)) v" using NZero_NZero
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   139
          by (simp_all add: Posix_Plus2)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   140
      qed
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
    qed
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   142
next
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
  case (Times r1 r2 s v)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
  have IH1: "\<And>s v. s \<in> fst (simp r1) \<rightarrow> v \<Longrightarrow> s \<in> r1 \<rightarrow> snd (simp r1) v" by fact
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   145
  have IH2: "\<And>s v. s \<in> fst (simp r2) \<rightarrow> v \<Longrightarrow> s \<in> r2 \<rightarrow> snd (simp r2) v" by fact
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   146
  have as: "s \<in> fst (simp (Times r1 r2)) \<rightarrow> v" by fact
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   147
  consider (One_One) "fst (simp r1) = One" "fst (simp r2) = One"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   148
         | (One_NOne) "fst (simp r1) = One" "fst (simp r2) \<noteq> One"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   149
         | (NOne_One) "fst (simp r1) \<noteq> One" "fst (simp r2) = One"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   150
         | (NOne_NOne) "fst (simp r1) \<noteq> One" "fst (simp r2) \<noteq> One" by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   151
  then show "s \<in> Times r1 r2 \<rightarrow> snd (simp (Times r1 r2)) v" 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   152
  proof(cases)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
      case (One_One)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   154
      with as have b: "s \<in> One \<rightarrow> v" by simp 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   155
      from b have "s \<in> r1 \<rightarrow> snd (simp r1) v" using IH1 One_One by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   156
      moreover
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   157
      from b have c: "s = []" "v = Void" using Posix_elims(2) by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   158
      moreover
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   159
      have "[] \<in> One \<rightarrow> Void" by (simp add: Posix_One)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   160
      then have "[] \<in> fst (simp r2) \<rightarrow> Void" using One_One by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   161
      then have "[] \<in> r2 \<rightarrow> snd (simp r2) Void" using IH2 by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   162
      ultimately have "([] @ []) \<in> Times r1 r2 \<rightarrow> Seq (snd (simp r1) Void) (snd (simp r2) Void)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   163
        using Posix_Times by blast 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   164
      then show "s \<in> Times r1 r2 \<rightarrow> snd (simp (Times r1 r2)) v" using c One_One by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   165
    next
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   166
      case (One_NOne)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   167
      with as have b: "s \<in> fst (simp r2) \<rightarrow> v" by simp 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   168
      from b have "s \<in> r2 \<rightarrow> snd (simp r2) v" using IH2 One_NOne by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   169
      moreover
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   170
      have "[] \<in> One \<rightarrow> Void" by (simp add: Posix_One)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   171
      then have "[] \<in> fst (simp r1) \<rightarrow> Void" using One_NOne by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   172
      then have "[] \<in> r1 \<rightarrow> snd (simp r1) Void" using IH1 by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   173
      moreover
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   174
      from One_NOne(1) have "lang (fst (simp r1)) = {[]}" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   175
      then have "lang r1 = {[]}" by (simp add: L_fst_simp[symmetric])
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   176
      ultimately have "([] @ s) \<in> Times r1 r2 \<rightarrow> Seq (snd (simp r1) Void) (snd (simp r2) v)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   177
        by(rule_tac Posix_Times) auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   178
      then show "s \<in> Times r1 r2 \<rightarrow> snd (simp (Times r1 r2)) v" using One_NOne by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   179
    next
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   180
      case (NOne_One)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   181
        with as have "s \<in> fst (simp r1) \<rightarrow> v" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   182
        with IH1 have "s \<in> r1 \<rightarrow> snd (simp r1) v" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   183
      moreover
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   184
        have "[] \<in> One \<rightarrow> Void" by (simp add: Posix_One)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   185
        then have "[] \<in> fst (simp r2) \<rightarrow> Void" using NOne_One by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   186
        then have "[] \<in> r2 \<rightarrow> snd (simp r2) Void" using IH2 by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   187
      ultimately have "(s @ []) \<in> Times r1 r2 \<rightarrow> Seq (snd (simp r1) v) (snd (simp r2) Void)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   188
        by(rule_tac Posix_Times) auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   189
      then show "s \<in> Times r1 r2 \<rightarrow> snd (simp (Times r1 r2)) v" using NOne_One by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   190
    next
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   191
      case (NOne_NOne)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   192
      with as have "s \<in> Times (fst (simp r1)) (fst (simp r2)) \<rightarrow> v" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   193
      then obtain s1 s2 v1 v2 where eqs: "s = s1 @ s2" "v = Seq v1 v2"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   194
                     "s1 \<in> (fst (simp r1)) \<rightarrow> v1" "s2 \<in> (fst (simp r2)) \<rightarrow> v2"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   195
                     "\<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> lang r1 \<and> s\<^sub>4 \<in> lang r2)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   196
                     by (erule_tac Posix_elims(5)) (auto simp add: L_fst_simp[symmetric]) 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   197
      then have "s1 \<in> r1 \<rightarrow> (snd (simp r1) v1)" "s2 \<in> r2 \<rightarrow> (snd (simp r2) v2)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   198
        using IH1 IH2 by auto             
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   199
      then show "s \<in> Times r1 r2 \<rightarrow> snd (simp (Times r1 r2)) v" using eqs NOne_NOne
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   200
        by(auto intro: Posix_Times)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   201
    qed
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   202
qed (simp_all)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   203
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   204
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   205
lemma slexer_correctness:
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   206
  shows "slexer r s = lexer r s"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   207
proof(induct s arbitrary: r)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   208
  case Nil
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   209
  show "slexer r [] = lexer r []" by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   210
next 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   211
  case (Cons c s r)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   212
  have IH: "\<And>r. slexer r s = lexer r s" by fact
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   213
  show "slexer r (c # s) = lexer r (c # s)" 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   214
   proof (cases "s \<in> lang (deriv c r)")
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   215
     case True
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   216
       assume a1: "s \<in> lang (deriv c r)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   217
       then obtain v1 where a2: "lexer (deriv c r) s = Some v1" "s \<in> deriv c r \<rightarrow> v1"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   218
         using lexer_correct_Some by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   219
       from a1 have "s \<in> lang (fst (simp (deriv c r)))" using L_fst_simp[symmetric] by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   220
       then obtain v2 where a3: "lexer (fst (simp (deriv c r))) s = Some v2" "s \<in> (fst (simp (deriv c r))) \<rightarrow> v2"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   221
          using lexer_correct_Some by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   222
       then have a4: "slexer (fst (simp (deriv c r))) s = Some v2" using IH by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   223
       from a3(2) have "s \<in> deriv c r \<rightarrow> (snd (simp (deriv c r))) v2" using Posix_simp by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   224
       with a2(2) have "v1 = (snd (simp (deriv c r))) v2" using Posix_determ by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   225
       with a2(1) a4 show "slexer r (c # s) = lexer r (c # s)" by (auto split: prod.split)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   226
     next 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   227
     case False
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   228
       assume b1: "s \<notin> lang (deriv c r)"
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   229
       then have "lexer (deriv c r) s = None" using lexer_correct_None by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   230
       moreover
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   231
       from b1 have "s \<notin> lang (fst (simp (deriv c r)))" using L_fst_simp[symmetric] by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   232
       then have "lexer (fst (simp (deriv c r))) s = None" using lexer_correct_None by auto
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   233
       then have "slexer (fst (simp (deriv c r))) s = None" using IH by simp
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   234
       ultimately show "slexer r (c # s) = lexer r (c # s)" 
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   235
         by (simp del: slexer.simps add: slexer_better_simp)
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   236
   qed
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   237
qed  
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   238
6bb15b8e6301 added files that were submitted to afp
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   239
end