thys/Simplifying.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 16 May 2016 15:20:23 +0100
changeset 179 85766e408c66
parent 154 2de3cf684ba0
child 180 42ffaca7c85e
permissions -rw-r--r--
improved simplifying theory
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
theory Simplifying
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
  imports "ReStar" 
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
begin
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
section {* Lexer including simplifications *}
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
fun F_RIGHT where
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
  "F_RIGHT f v = Right (f v)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
fun F_LEFT where
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
  "F_LEFT f v = Left (f v)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
fun F_ALT where
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
  "F_ALT f\<^sub>1 f\<^sub>2 (Right v) = Right (f\<^sub>2 v)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
| "F_ALT f\<^sub>1 f\<^sub>2 (Left v) = Left (f\<^sub>1 v)"  
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
| "F_ALT f1 f2 v = v"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
fun F_SEQ1 where
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
  "F_SEQ1 f\<^sub>1 f\<^sub>2 v = Seq (f\<^sub>1 Void) (f\<^sub>2 v)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
fun F_SEQ2 where 
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    24
  "F_SEQ2 f\<^sub>1 f\<^sub>2 v = Seq (f\<^sub>1 v) (f\<^sub>2 Void)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
fun F_SEQ where 
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    27
  "F_SEQ 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)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
| "F_SEQ f1 f2 v = v"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
fun simp_ALT where
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    31
  "simp_ALT (ZERO, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (r\<^sub>2, F_RIGHT f\<^sub>2)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
| "simp_ALT (r\<^sub>1, f\<^sub>1) (ZERO, f\<^sub>2) = (r\<^sub>1, F_LEFT f\<^sub>1)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
| "simp_ALT (r\<^sub>1, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (ALT r\<^sub>1 r\<^sub>2, F_ALT f\<^sub>1 f\<^sub>2)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
fun simp_SEQ where
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
  "simp_SEQ (ONE, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (r\<^sub>2, F_SEQ1 f\<^sub>1 f\<^sub>2)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    37
| "simp_SEQ (r\<^sub>1, f\<^sub>1) (ONE, f\<^sub>2) = (r\<^sub>1, F_SEQ2 f\<^sub>1 f\<^sub>2)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
| "simp_SEQ (r\<^sub>1, f\<^sub>1) (r\<^sub>2, f\<^sub>2) = (SEQ r\<^sub>1 r\<^sub>2, F_SEQ f\<^sub>1 f\<^sub>2)"  
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
 
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
    40
lemma simp_SEQ_simps[simp]:
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
  "simp_SEQ p1 p2 = (if (fst p1 = ONE) then (fst p2, F_SEQ1 (snd p1) (snd p2))
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    42
                    else (if (fst p2 = ONE) then (fst p1, F_SEQ2 (snd p1) (snd p2))
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    43
                    else (SEQ (fst p1) (fst p2), F_SEQ (snd p1) (snd p2))))"
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
    44
by (induct p1 p2 rule: simp_SEQ.induct) (auto)
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
    46
lemma simp_ALT_simps[simp]:
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
  "simp_ALT p1 p2 = (if (fst p1 = ZERO) then (fst p2, F_RIGHT (snd p2))
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
                    else (if (fst p2 = ZERO) then (fst p1, F_LEFT (snd p1))
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
                    else (ALT (fst p1) (fst p2), F_ALT (snd p1) (snd p2))))"
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
    50
by (induct p1 p2 rule: simp_ALT.induct) (auto)
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    51
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    52
fun 
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
  simp :: "rexp \<Rightarrow> rexp * (val \<Rightarrow> val)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
where
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
  "simp (ALT r1 r2) = simp_ALT (simp r1) (simp r2)" 
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
| "simp (SEQ r1 r2) = simp_SEQ (simp r1) (simp r2)" 
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
| "simp r = (r, id)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    59
fun 
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    60
  slexer :: "rexp \<Rightarrow> string \<Rightarrow> val option"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    61
where
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    62
  "slexer r [] = (if nullable r then Some(mkeps r) else None)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    63
| "slexer r (c#s) = (let (rs, fr) = simp (der c r) in
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
                         (case (slexer rs s) of  
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    65
                            None \<Rightarrow> None
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
                          | Some(v) \<Rightarrow> Some(injval r c (fr v))))"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
179
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    69
lemma slexer_better_simp:
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    70
  "slexer r (c#s) = (case (slexer (fst (simp (der c r))) s) of  
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    71
                            None \<Rightarrow> None
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    72
                          | Some(v) \<Rightarrow> Some(injval r c ((snd (simp (der c r))) v)))"
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    73
by (auto split: prod.split option.split)
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    74
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    75
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
lemma L_fst_simp:
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
  shows "L(r) = L(fst (simp r))"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
using assms
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
    79
by (induct r) (auto)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
    80
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    81
lemma Posix_simp:
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
  assumes "s \<in> (fst (simp r)) \<rightarrow> v" 
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
  shows "s \<in> r \<rightarrow> ((snd (simp r)) v)"
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    84
using assms
179
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    85
apply(induct r arbitrary: s v rule: simp.induct)
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    86
apply(simp_all)
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    87
apply(auto)[1]
179
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    88
using Posix_elims(1) apply blast
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    89
apply (simp add: Posix_ALT1)
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    90
apply (metis L.simps(1) L_fst_simp Posix_ALT2 empty_iff)
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    91
apply (smt F_ALT.simps(1) F_ALT.simps(2) L_fst_simp Posix_ALT1 Posix_ALT2 Posix_elims(4))
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    92
apply(auto)[1]
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    93
apply (metis (no_types, lifting) Nil_is_append_conv Posix_SEQ Posix_elims(2))
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    94
apply(subst append_Nil2[symmetric])
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    95
apply(rule Posix_SEQ)
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    96
apply(simp)
179
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    97
using Posix_ONE apply blast
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    98
apply blast
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    99
apply(subst append_Nil[symmetric])
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   100
apply(rule Posix_SEQ)
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   101
using Posix_ONE apply blast
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   102
apply blast
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
apply(auto)[1]
179
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   104
apply (metis L.simps(2) L_fst_simp ex_in_conv insert_iff)
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   105
apply(erule Posix_elims)
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   106
apply(auto)
179
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   107
using L_fst_simp Posix_SEQ by auto
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   108
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
lemma slexer_correctness:
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
  shows "slexer r s = lexer r s"
179
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   112
proof(induct s arbitrary: r)
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   113
  case Nil
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   114
  show "slexer r [] = lexer r []" by simp
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   115
next 
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   116
  case (Cons c s r)
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   117
  have IH: "\<And>r. slexer r s = lexer r s" by fact
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   118
  show "slexer r (c # s) = lexer r (c # s)" 
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   119
   proof (cases "s \<in> L (der c r)")
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   120
     case True
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   121
       assume a1: "s \<in> L (der c r)"
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   122
       then obtain v1 where a2: "lexer (der c r) s = Some v1" "s \<in> der c r \<rightarrow> v1"
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   123
         using lexer_correct_Some by auto
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   124
       from a1 have "s \<in> L (fst (simp (der c r)))" using L_fst_simp[symmetric] by simp
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   125
       then obtain v2 where a3: "lexer (fst (simp (der c r))) s = Some v2" "s \<in> (fst (simp (der c r))) \<rightarrow> v2"
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   126
          using lexer_correct_Some by auto
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   127
       then have a4: "slexer (fst (simp (der c r))) s = Some v2" using IH by simp
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   128
       from a3(2) have "s \<in> der c r \<rightarrow> (snd (simp (der c r))) v2" using Posix_simp by simp
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   129
       with a2(2) have "v1 = (snd (simp (der c r))) v2" using Posix_determ by simp
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   130
       with a2(1) a4 show "slexer r (c # s) = lexer r (c # s)" by (auto split: prod.split)
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   131
     next 
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   132
     case False
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   133
       assume b1: "s \<notin> L (der c r)"
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   134
       then have "lexer (der c r) s = None" using lexer_correct_None by simp
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   135
       moreover
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   136
       from b1 have "s \<notin> L (fst (simp (der c r)))" using L_fst_simp[symmetric] by simp
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   137
       then have "lexer (fst (simp (der c r))) s = None" using lexer_correct_None by simp
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   138
       then have "slexer (fst (simp (der c r))) s = None" using IH by simp
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   139
       ultimately show "slexer r (c # s) = lexer r (c # s)" 
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   140
         by (simp del: slexer.simps add: slexer_better_simp)
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   141
   qed
85766e408c66 improved simplifying theory
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   142
qed  
150
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
09f81fee11ce updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
end