thys/Lexer.thy
author Chengsong
Thu, 07 Apr 2022 21:38:01 +0100
changeset 481 feacb89b784c
parent 362 e51c9a67a68d
permissions -rw-r--r--
christian's
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
   
185
841f7b9c0a6a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 172
diff changeset
     2
theory Lexer
266
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
     3
  imports Spec 
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
begin
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 287
diff changeset
     6
section {* The Lexer Functions by Sulzmann and Lu  (without simplification) *}
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
fun 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
  mkeps :: "rexp \<Rightarrow> val"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
where
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
    11
  "mkeps(ONE) = Void"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
| "mkeps(SEQ r1 r2) = Seq (mkeps r1) (mkeps r2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
| "mkeps(ALT r1 r2) = (if nullable(r1) then Left (mkeps r1) else Right (mkeps r2))"
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
    14
| "mkeps(STAR r) = Stars []"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
fun injval :: "rexp \<Rightarrow> char \<Rightarrow> val \<Rightarrow> val"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
where
362
e51c9a67a68d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 343
diff changeset
    18
  "injval (CH d) c Void = Char d"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    19
| "injval (ALT r1 r2) c (Left v1) = Left(injval r1 c v1)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    20
| "injval (ALT r1 r2) c (Right v2) = Right(injval r2 c v2)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    21
| "injval (SEQ r1 r2) c (Seq v1 v2) = Seq (injval r1 c v1) v2"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    22
| "injval (SEQ r1 r2) c (Left (Seq v1 v2)) = Seq (injval r1 c v1) v2"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    23
| "injval (SEQ r1 r2) c (Right v2) = Seq (mkeps r1) (injval r2 c v2)"
97
38696f516c6b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 95
diff changeset
    24
| "injval (STAR r) c (Seq v (Stars vs)) = Stars ((injval r c v) # vs)" 
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    25
266
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    26
fun 
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    27
  lexer :: "rexp \<Rightarrow> string \<Rightarrow> val option"
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    28
where
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    29
  "lexer r [] = (if nullable r then Some(mkeps r) else None)"
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    30
| "lexer r (c#s) = (case (lexer (der c r) s) of  
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    31
                    None \<Rightarrow> None
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    32
                  | Some(v) \<Rightarrow> Some(injval r c v))"
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
    33
266
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    34
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    35
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    36
section {* Mkeps, Injval Properties *}
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
    37
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    38
lemma mkeps_nullable:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    39
  assumes "nullable(r)" 
268
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    40
  shows "\<Turnstile> mkeps r : r"
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    41
using assms
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
    42
by (induct rule: nullable.induct) 
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
    43
   (auto intro: Prf.intros)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    44
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    45
lemma mkeps_flat:
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    46
  assumes "nullable(r)" 
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    47
  shows "flat (mkeps r) = []"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    48
using assms
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
    49
by (induct rule: nullable.induct) (auto)
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
    50
107
6adda4a667b1 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 106
diff changeset
    51
lemma Prf_injval_flat:
268
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    52
  assumes "\<Turnstile> v : der c r" 
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
  shows "flat (injval r c v) = c # (flat v)"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
using assms
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
    55
apply(induct c r arbitrary: v rule: der.induct)
265
d36be1e356c0 changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents: 264
diff changeset
    56
apply(auto elim!: Prf_elims intro: mkeps_flat split: if_splits)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
done
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
268
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    59
lemma Prf_injval:
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    60
  assumes "\<Turnstile> v : der c r" 
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    61
  shows "\<Turnstile> (injval r c v) : r"
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    62
using assms
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    63
apply(induct r arbitrary: c v rule: rexp.induct)
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    64
apply(auto intro!: Prf.intros mkeps_nullable elim!: Prf_elims split: if_splits)
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    65
apply(simp add: Prf_injval_flat)
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    66
done
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    67
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    68
6746f5e1f1f8 updated
Christian Urban <urbanc@in.tum.de>
parents: 266
diff changeset
    69
266
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    70
text {*
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    71
  Mkeps and injval produce, or preserve, Posix values.
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
    72
*}
122
7c6c907660d8 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 121
diff changeset
    73
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
    74
lemma Posix_mkeps:
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
  assumes "nullable r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
  shows "[] \<in> r \<rightarrow> mkeps r"
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
using assms
185
841f7b9c0a6a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 172
diff changeset
    78
apply(induct r rule: nullable.induct)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
    79
apply(auto intro: Posix.intros simp add: nullable_correctness Sequ_def)
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
apply(subst append.simps(1)[symmetric])
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
    81
apply(rule Posix.intros)
123
1bee7006b92b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 122
diff changeset
    82
apply(auto)
91
f067e59b58d9 more lemmas for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 90
diff changeset
    83
done
89
9613e6ace30f added theory for star
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    84
172
cdc0bdcfba3f updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 151
diff changeset
    85
lemma Posix_injval:
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    86
  assumes "s \<in> (der c r) \<rightarrow> v"
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
    87
  shows "(c # s) \<in> r \<rightarrow> (injval r c v)"
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
    88
using assms
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
    89
proof(induct r arbitrary: s v rule: rexp.induct)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
    90
  case ZERO
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
    91
  have "s \<in> der c ZERO \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
    92
  then have "s \<in> ZERO \<rightarrow> v" by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
    93
  then have "False" by cases
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
    94
  then show "(c # s) \<in> ZERO \<rightarrow> (injval ZERO c v)" by simp
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
    95
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
    96
  case ONE
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
    97
  have "s \<in> der c ONE \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
    98
  then have "s \<in> ZERO \<rightarrow> v" by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
    99
  then have "False" by cases
143
1e7b36450d9a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 142
diff changeset
   100
  then show "(c # s) \<in> ONE \<rightarrow> (injval ONE c v)" by simp
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   101
next 
362
e51c9a67a68d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 343
diff changeset
   102
  case (CH d)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   103
  consider (eq) "c = d" | (ineq) "c \<noteq> d" by blast
362
e51c9a67a68d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 343
diff changeset
   104
  then show "(c # s) \<in> (CH d) \<rightarrow> (injval (CH d) c v)"
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   105
  proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   106
    case eq
362
e51c9a67a68d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 343
diff changeset
   107
    have "s \<in> der c (CH d) \<rightarrow> v" by fact
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   108
    then have "s \<in> ONE \<rightarrow> v" using eq by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   109
    then have eqs: "s = [] \<and> v = Void" by cases simp
362
e51c9a67a68d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 343
diff changeset
   110
    show "(c # s) \<in> CH d \<rightarrow> injval (CH d) c v" using eq eqs 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   111
    by (auto intro: Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   112
  next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   113
    case ineq
362
e51c9a67a68d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 343
diff changeset
   114
    have "s \<in> der c (CH d) \<rightarrow> v" by fact
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   115
    then have "s \<in> ZERO \<rightarrow> v" using ineq by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   116
    then have "False" by cases
362
e51c9a67a68d updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 343
diff changeset
   117
    then show "(c # s) \<in> CH d \<rightarrow> injval (CH d) c v" by simp
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   118
  qed
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   119
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   120
  case (ALT r1 r2)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   121
  have IH1: "\<And>s v. s \<in> der c r1 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r1 \<rightarrow> injval r1 c v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   122
  have IH2: "\<And>s v. s \<in> der c r2 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r2 \<rightarrow> injval r2 c v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   123
  have "s \<in> der c (ALT r1 r2) \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   124
  then have "s \<in> ALT (der c r1) (der c r2) \<rightarrow> v" by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   125
  then consider (left) v' where "v = Left v'" "s \<in> der c r1 \<rightarrow> v'" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   126
              | (right) v' where "v = Right v'" "s \<notin> L (der c r1)" "s \<in> der c r2 \<rightarrow> v'" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   127
              by cases auto
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   128
  then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v"
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   129
  proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   130
    case left
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   131
    have "s \<in> der c r1 \<rightarrow> v'" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   132
    then have "(c # s) \<in> r1 \<rightarrow> injval r1 c v'" using IH1 by simp
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   133
    then have "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c (Left v')" by (auto intro: Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   134
    then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" using left by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   135
  next 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   136
    case right
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   137
    have "s \<notin> L (der c r1)" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   138
    then have "c # s \<notin> L r1" by (simp add: der_correctness Der_def)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   139
    moreover 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   140
    have "s \<in> der c r2 \<rightarrow> v'" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   141
    then have "(c # s) \<in> r2 \<rightarrow> injval r2 c v'" using IH2 by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   142
    ultimately have "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c (Right v')" 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   143
      by (auto intro: Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   144
    then show "(c # s) \<in> ALT r1 r2 \<rightarrow> injval (ALT r1 r2) c v" using right by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   145
  qed
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   146
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   147
  case (SEQ r1 r2)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   148
  have IH1: "\<And>s v. s \<in> der c r1 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r1 \<rightarrow> injval r1 c v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   149
  have IH2: "\<And>s v. s \<in> der c r2 \<rightarrow> v \<Longrightarrow> (c # s) \<in> r2 \<rightarrow> injval r2 c v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   150
  have "s \<in> der c (SEQ r1 r2) \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   151
  then consider 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   152
        (left_nullable) v1 v2 s1 s2 where 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   153
        "v = Left (Seq v1 v2)"  "s = s1 @ s2" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   154
        "s1 \<in> der c r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" "nullable r1" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   155
        "\<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)"
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   156
      | (right_nullable) v1 s1 s2 where 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   157
        "v = Right v1" "s = s1 @ s2"  
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   158
        "s \<in> der c r2 \<rightarrow> v1" "nullable r1" "s1 @ s2 \<notin> L (SEQ (der c r1) r2)"
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   159
      | (not_nullable) v1 v2 s1 s2 where
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   160
        "v = Seq v1 v2" "s = s1 @ s2" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   161
        "s1 \<in> der c r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" "\<not>nullable r1" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   162
        "\<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)"
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   163
        by (force split: if_splits elim!: Posix_elims simp add: Sequ_def der_correctness Der_def)   
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   164
  then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   165
    proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   166
      case left_nullable
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   167
      have "s1 \<in> der c r1 \<rightarrow> v1" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   168
      then have "(c # s1) \<in> r1 \<rightarrow> injval r1 c v1" using IH1 by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   169
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   170
      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
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   171
      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)
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   172
      ultimately have "((c # s1) @ s2) \<in> SEQ r1 r2 \<rightarrow> Seq (injval r1 c v1) v2" using left_nullable by (rule_tac Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   173
      then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using left_nullable by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   174
    next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   175
      case right_nullable
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   176
      have "nullable r1" by fact
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   177
      then have "[] \<in> r1 \<rightarrow> (mkeps r1)" by (rule Posix_mkeps)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   178
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   179
      have "s \<in> der c r2 \<rightarrow> v1" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   180
      then have "(c # s) \<in> r2 \<rightarrow> (injval r2 c v1)" using IH2 by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   181
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   182
      have "s1 @ s2 \<notin> L (SEQ (der c r1) r2)" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   183
      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
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   184
        by(auto simp add: der_correctness Der_def append_eq_Cons_conv Sequ_def)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   185
      ultimately have "([] @ (c # s)) \<in> SEQ r1 r2 \<rightarrow> Seq (mkeps r1) (injval r2 c v1)"
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   186
      by(rule Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   187
      then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using right_nullable by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   188
    next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   189
      case not_nullable
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   190
      have "s1 \<in> der c r1 \<rightarrow> v1" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   191
      then have "(c # s1) \<in> r1 \<rightarrow> injval r1 c v1" using IH1 by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   192
      moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   193
      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
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   194
      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)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   195
      ultimately have "((c # s1) @ s2) \<in> SEQ r1 r2 \<rightarrow> Seq (injval r1 c v1) v2" using not_nullable 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   196
        by (rule_tac Posix.intros) (simp_all) 
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   197
      then show "(c # s) \<in> SEQ r1 r2 \<rightarrow> injval (SEQ r1 r2) c v" using not_nullable by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   198
    qed
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   199
next
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   200
  case (STAR r)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   201
  have IH: "\<And>s v. s \<in> der c r \<rightarrow> v \<Longrightarrow> (c # s) \<in> r \<rightarrow> injval r c v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   202
  have "s \<in> der c (STAR r) \<rightarrow> v" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   203
  then consider
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   204
      (cons) v1 vs s1 s2 where 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   205
        "v = Seq v1 (Stars vs)" "s = s1 @ s2" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   206
        "s1 \<in> der c r \<rightarrow> v1" "s2 \<in> (STAR r) \<rightarrow> (Stars vs)"
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   207
        "\<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))" 
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   208
        apply(auto elim!: Posix_elims(1-5) simp add: der_correctness Der_def intro: Posix.intros)
142
08dcf0d20f15 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 127
diff changeset
   209
        apply(rotate_tac 3)
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   210
        apply(erule_tac Posix_elims(6))
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   211
        apply (simp add: Posix.intros(6))
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   212
        using Posix.intros(7) by blast
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   213
    then show "(c # s) \<in> STAR r \<rightarrow> injval (STAR r) c v" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   214
    proof (cases)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   215
      case cons
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   216
          have "s1 \<in> der c r \<rightarrow> v1" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   217
          then have "(c # s1) \<in> r \<rightarrow> injval r c v1" using IH by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   218
        moreover
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   219
          have "s2 \<in> STAR r \<rightarrow> Stars vs" by fact
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   220
        moreover 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   221
          have "(c # s1) \<in> r \<rightarrow> injval r c v1" by fact 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   222
          then have "flat (injval r c v1) = (c # s1)" by (rule Posix1)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   223
          then have "flat (injval r c v1) \<noteq> []" by simp
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   224
        moreover 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   225
          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
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   226
          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))" 
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   227
            by (simp add: der_correctness Der_def)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   228
        ultimately 
146
da81ffac4b10 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 145
diff changeset
   229
        have "((c # s1) @ s2) \<in> STAR r \<rightarrow> Stars (injval r c v1 # vs)" by (rule Posix.intros)
121
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   230
        then show "(c # s) \<in> STAR r \<rightarrow> injval (STAR r) c v" using cons by(simp)
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   231
    qed
4c85af262ee7 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 120
diff changeset
   232
qed
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
   233
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   234
266
fff2e1b40dfc updated
Christian Urban <urbanc@in.tum.de>
parents: 265
diff changeset
   235
section {* Lexer Correctness *}
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   236
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   237
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   238
lemma lexer_correct_None:
145
97735ef233be updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 144
diff changeset
   239
  shows "s \<notin> L r \<longleftrightarrow> lexer r s = None"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   240
  apply(induct s arbitrary: r)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   241
  apply(simp)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   242
  apply(simp add: nullable_correctness)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   243
  apply(simp)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   244
  apply(drule_tac x="der a r" in meta_spec) 
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   245
  apply(auto)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   246
  apply(auto simp add: der_correctness Der_def)
120
d74bfa11802c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 113
diff changeset
   247
done
106
489dfa0d7ec9 more cleaning and moving unnessary stuff to the end
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 105
diff changeset
   248
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   249
lemma lexer_correct_Some:
185
841f7b9c0a6a updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 172
diff changeset
   250
  shows "s \<in> L r \<longleftrightarrow> (\<exists>v. lexer r s = Some(v) \<and> s \<in> r \<rightarrow> v)"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   251
  apply(induct s arbitrary : r)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   252
  apply(simp only: lexer.simps)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   253
  apply(simp)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   254
  apply(simp add: nullable_correctness Posix_mkeps)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   255
  apply(drule_tac x="der a r" in meta_spec)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   256
  apply(simp (no_asm_use) add: der_correctness Der_def del: lexer.simps) 
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   257
  apply(simp del: lexer.simps)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   258
  apply(simp only: lexer.simps)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   259
  apply(case_tac "lexer (der a r) s = None")
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   260
   apply(auto)[1]
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   261
  apply(simp)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   262
  apply(erule exE)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   263
  apply(simp)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   264
  apply(rule iffI)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   265
  apply(simp add: Posix_injval)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   266
  apply(simp add: Posix1(1))
151
5a1196466a9c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 150
diff changeset
   267
done 
149
ec3d221bfc45 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 146
diff changeset
   268
186
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
   269
lemma lexer_correctness:
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
   270
  shows "(lexer r s = Some v) \<longleftrightarrow> s \<in> r \<rightarrow> v"
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
   271
  and   "(lexer r s = None) \<longleftrightarrow> \<not>(\<exists>v. s \<in> r \<rightarrow> v)"
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
   272
using Posix1(1) Posix_determ lexer_correct_None lexer_correct_Some apply fastforce
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
   273
using Posix1(1) lexer_correct_None lexer_correct_Some by blast
0b94800eb616 added corollary
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 185
diff changeset
   274
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   275
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 287
diff changeset
   276
subsection {* A slight reformulation of the lexer algorithm using stacked functions*}
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   277
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   278
fun flex :: "rexp \<Rightarrow> (val \<Rightarrow> val) => string \<Rightarrow> (val \<Rightarrow> val)"
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   279
  where
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   280
  "flex r f [] = f"
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   281
| "flex r f (c#s) = flex (der c r) (\<lambda>v. f (injval r c v)) s"  
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   282
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   283
lemma flex_fun_apply:
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   284
  shows "g (flex r f s v) = flex r (g o f) s v"
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   285
  apply(induct s arbitrary: g f r v)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   286
  apply(simp_all add: comp_def)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   287
  by meson
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   288
343
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   289
lemma flex_fun_apply2:
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   290
  shows "g (flex r id s v) = flex r g s v"
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   291
  by (simp add: flex_fun_apply)
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   292
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   293
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   294
lemma flex_append:
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   295
  shows "flex r f (s1 @ s2) = flex (ders s1 r) (flex r f s1) s2"
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   296
  apply(induct s1 arbitrary: s2 r f)
287
95b3880d428f updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   297
  apply(simp_all)
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   298
  done  
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   299
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   300
lemma lexer_flex:
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   301
  shows "lexer r s = (if nullable (ders s r) 
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   302
                      then Some(flex r id s (mkeps (ders s r))) else None)"
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   303
  apply(induct s arbitrary: r)
287
95b3880d428f updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   304
  apply(simp_all add: flex_fun_apply)
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   305
  done  
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   306
330
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   307
lemma Posix_flex:
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   308
  assumes "s2 \<in> (ders s1 r) \<rightarrow> v"
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   309
  shows "(s1 @ s2) \<in> r \<rightarrow> flex r id s1 v"
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   310
  using assms
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   311
  apply(induct s1 arbitrary: r v s2)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   312
  apply(simp)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   313
  apply(simp)  
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   314
  apply(drule_tac x="der a r" in meta_spec)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   315
  apply(drule_tac x="v" in meta_spec)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   316
  apply(drule_tac x="s2" in meta_spec)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   317
  apply(simp)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   318
  using  Posix_injval
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   319
  apply(drule_tac Posix_injval)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   320
  apply(subst (asm) (5) flex_fun_apply)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   321
  apply(simp)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   322
  done
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   323
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   324
lemma injval_inj:
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   325
  assumes "\<Turnstile> a : (der c r)" "\<Turnstile> v : (der c r)" "injval r c a = injval r c v" 
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   326
  shows "a = v"
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   327
  using  assms
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   328
  apply(induct r arbitrary: a c v)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   329
       apply(auto)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   330
  using Prf_elims(1) apply blast
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   331
  using Prf_elims(1) apply blast
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   332
     apply(case_tac "c = x")
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   333
      apply(auto)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   334
  using Prf_elims(4) apply auto[1]
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   335
  using Prf_elims(1) apply blast
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   336
    prefer 2
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   337
  apply (smt Prf_elims(3) injval.simps(2) injval.simps(3) val.distinct(25) val.inject(3) val.inject(4))
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   338
  apply(case_tac "nullable r1")
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   339
    apply(auto)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   340
    apply(erule Prf_elims)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   341
     apply(erule Prf_elims)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   342
     apply(erule Prf_elims)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   343
      apply(erule Prf_elims)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   344
      apply(auto)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   345
     apply (metis Prf_injval_flat list.distinct(1) mkeps_flat)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   346
  apply(erule Prf_elims)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   347
     apply(erule Prf_elims)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   348
  apply(auto)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   349
  using Prf_injval_flat mkeps_flat apply fastforce
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   350
  apply(erule Prf_elims)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   351
     apply(erule Prf_elims)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   352
   apply(auto)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   353
  apply(erule Prf_elims)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   354
     apply(erule Prf_elims)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   355
  apply(auto)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   356
   apply (smt Prf_elims(6) injval.simps(7) list.inject val.inject(5))
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   357
  by (smt Prf_elims(6) injval.simps(7) list.inject val.inject(5))
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   358
  
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   359
  
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   360
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   361
lemma uu:
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   362
  assumes "(c # s) \<in> r \<rightarrow> injval r c v" "\<Turnstile> v : (der c r)"
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   363
  shows "s \<in> der c r \<rightarrow> v"
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   364
  using assms
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   365
  apply -
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   366
  apply(subgoal_tac "lexer r (c # s) = Some (injval r c v)")
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   367
  prefer 2
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   368
  using lexer_correctness(1) apply blast
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   369
  apply(simp add: )
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   370
  apply(case_tac  "lexer (der c r) s")
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   371
   apply(simp)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   372
  apply(simp)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   373
  apply(case_tac "s \<in> der c r \<rightarrow> a")
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   374
   prefer 2
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   375
   apply (simp add: lexer_correctness(1))
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   376
  apply(subgoal_tac "\<Turnstile> a : (der c r)")
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   377
   prefer 2
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   378
  using Posix_Prf apply blast
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   379
  using injval_inj by blast
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   380
  
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   381
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   382
lemma Posix_flex2:
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   383
  assumes "(s1 @ s2) \<in> r \<rightarrow> flex r id s1 v" "\<Turnstile> v : ders s1 r"
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   384
  shows "s2 \<in> (ders s1 r) \<rightarrow> v"
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   385
  using assms
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   386
  apply(induct s1 arbitrary: r v s2 rule: rev_induct)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   387
  apply(simp)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   388
  apply(simp)  
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   389
  apply(drule_tac x="r" in meta_spec)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   390
  apply(drule_tac x="injval (ders xs r) x v" in meta_spec)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   391
  apply(drule_tac x="x#s2" in meta_spec)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   392
  apply(simp add: flex_append ders_append)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   393
  using Prf_injval uu by blast
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   394
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   395
lemma Posix_flex3:
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   396
  assumes "s1 \<in> r \<rightarrow> flex r id s1 v" "\<Turnstile> v : ders s1 r"
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   397
  shows "[] \<in> (ders s1 r) \<rightarrow> v"
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   398
  using assms
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   399
  by (simp add: Posix_flex2)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   400
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   401
lemma flex_injval:
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   402
  shows "flex (der a r) (injval r a) s v = injval r a (flex (der a r) id s v)"
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   403
  by (simp add: flex_fun_apply)
89e6605c4ca4 updated
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   404
  
343
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   405
lemma Prf_flex:
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   406
  assumes "\<Turnstile> v : ders s r"
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   407
  shows "\<Turnstile> flex r id s v : r"
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   408
  using assms
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   409
  apply(induct s arbitrary: v r)
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   410
  apply(simp)
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   411
  apply(simp)
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   412
  by (simp add: Prf_injval flex_injval)
f139bdc0dcd5 updated contains
Christian Urban <urbanc@in.tum.de>
parents: 330
diff changeset
   413
  
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 268
diff changeset
   414
95
a33d3040bf7e started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 94
diff changeset
   415
end