thys/BitCoded.thy
author Christian Urban <urbanc@in.tum.de>
Thu, 11 Apr 2019 17:37:00 +0100
changeset 317 db0ff630bbb7
parent 316 0eaa1851a5b6
child 318 43e070803c1c
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
   
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
     2
theory BitCoded
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
     3
  imports "Lexer" 
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
begin
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
     6
section {* Bit-Encodings *}
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
     7
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
     8
datatype bit = Z | S
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
     9
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    10
fun 
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    11
  code :: "val \<Rightarrow> bit list"
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    12
where
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    13
  "code Void = []"
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    14
| "code (Char c) = []"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    15
| "code (Left v) = Z # (code v)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    16
| "code (Right v) = S # (code v)"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    17
| "code (Seq v1 v2) = (code v1) @ (code v2)"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    18
| "code (Stars []) = [S]"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    19
| "code (Stars (v # vs)) =  (Z # code v) @ code (Stars vs)"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    20
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    21
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    22
fun 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    23
  Stars_add :: "val \<Rightarrow> val \<Rightarrow> val"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    24
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    25
  "Stars_add v (Stars vs) = Stars (v # vs)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    26
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    27
function
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    28
  decode' :: "bit list \<Rightarrow> rexp \<Rightarrow> (val * bit list)"
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    29
where
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    30
  "decode' ds ZERO = (Void, [])"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    31
| "decode' ds ONE = (Void, ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    32
| "decode' ds (CHAR d) = (Char d, ds)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    33
| "decode' [] (ALT r1 r2) = (Void, [])"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    34
| "decode' (Z # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r1 in (Left v, ds'))"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    35
| "decode' (S # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r2 in (Right v, ds'))"
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    36
| "decode' ds (SEQ r1 r2) = (let (v1, ds') = decode' ds r1 in
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    37
                             let (v2, ds'') = decode' ds' r2 in (Seq v1 v2, ds''))"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    38
| "decode' [] (STAR r) = (Void, [])"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    39
| "decode' (S # ds) (STAR r) = (Stars [], ds)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    40
| "decode' (Z # ds) (STAR r) = (let (v, ds') = decode' ds r in
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    41
                                    let (vs, ds'') = decode' ds' (STAR r) 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    42
                                    in (Stars_add v vs, ds''))"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    43
by pat_completeness auto
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    44
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    45
lemma decode'_smaller:
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    46
  assumes "decode'_dom (ds, r)"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    47
  shows "length (snd (decode' ds r)) \<le> length ds"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    48
using assms
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    49
apply(induct ds r)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    50
apply(auto simp add: decode'.psimps split: prod.split)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    51
using dual_order.trans apply blast
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    52
by (meson dual_order.trans le_SucI)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    53
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    54
termination "decode'"  
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    55
apply(relation "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))") 
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    56
apply(auto dest!: decode'_smaller)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    57
by (metis less_Suc_eq_le snd_conv)
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    58
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    59
definition
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    60
  decode :: "bit list \<Rightarrow> rexp \<Rightarrow> val option"
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    61
where
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    62
  "decode ds r \<equiv> (let (v, ds') = decode' ds r 
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    63
                  in (if ds' = [] then Some v else None))"
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    64
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    65
lemma decode'_code_Stars:
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    66
  assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> (\<forall>x. decode' (code v @ x) r = (v, x)) \<and> flat v \<noteq> []" 
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    67
  shows "decode' (code (Stars vs) @ ds) (STAR r) = (Stars vs, ds)"
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    68
  using assms
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    69
  apply(induct vs)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    70
  apply(auto)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    71
  done
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    72
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    73
lemma decode'_code:
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    74
  assumes "\<Turnstile> v : r"
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    75
  shows "decode' ((code v) @ ds) r = (v, ds)"
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    76
using assms
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    77
  apply(induct v r arbitrary: ds) 
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    78
  apply(auto)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    79
  using decode'_code_Stars by blast
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    80
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    81
lemma decode_code:
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    82
  assumes "\<Turnstile> v : r"
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    83
  shows "decode (code v) r = Some v"
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    84
  using assms unfolding decode_def
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    85
  by (smt append_Nil2 decode'_code old.prod.case)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
    86
154
2de3cf684ba0 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 148
diff changeset
    87
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
    88
section {* Annotated Regular Expressions *}
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
    89
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
    90
datatype arexp = 
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    91
  AZERO
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    92
| AONE "bit list"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    93
| ACHAR "bit list" char
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    94
| ASEQ "bit list" arexp arexp
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
    95
| AALTs "bit list" "arexp list"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
    96
| ASTAR "bit list" arexp
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
    97
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
    98
abbreviation
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
    99
  "AALT bs r1 r2 \<equiv> AALTs bs [r1, r2]"
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   100
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   101
fun asize :: "arexp \<Rightarrow> nat" where
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   102
  "asize AZERO = 1"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   103
| "asize (AONE cs) = 1" 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   104
| "asize (ACHAR cs c) = 1"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   105
| "asize (AALTs cs rs) = Suc (sum_list (map asize rs))"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   106
| "asize (ASEQ cs r1 r2) = Suc (asize r1 + asize r2)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   107
| "asize (ASTAR cs r) = Suc (asize r)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   108
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   109
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   110
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   111
fun fuse :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp" where
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   112
  "fuse bs AZERO = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   113
| "fuse bs (AONE cs) = AONE (bs @ cs)" 
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   114
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   115
| "fuse bs (AALTs cs rs) = AALTs (bs @ cs) rs"
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   116
| "fuse bs (ASEQ cs r1 r2) = ASEQ (bs @ cs) r1 r2"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   117
| "fuse bs (ASTAR cs r) = ASTAR (bs @ cs) r"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   118
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   119
lemma fuse_append:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   120
  shows "fuse (bs1 @ bs2) r = fuse bs1 (fuse bs2 r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   121
  apply(induct r)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   122
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   123
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   124
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   125
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   126
fun intern :: "rexp \<Rightarrow> arexp" where
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   127
  "intern ZERO = AZERO"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   128
| "intern ONE = AONE []"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   129
| "intern (CHAR c) = ACHAR [] c"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   130
| "intern (ALT r1 r2) = AALT [] (fuse [Z] (intern r1)) 
295
c6ec5f369037 updated
Christian Urban <urbanc@in.tum.de>
parents: 293
diff changeset
   131
                                (fuse [S]  (intern r2))"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   132
| "intern (SEQ r1 r2) = ASEQ [] (intern r1) (intern r2)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   133
| "intern (STAR r) = ASTAR [] (intern r)"
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   134
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   135
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   136
fun retrieve :: "arexp \<Rightarrow> val \<Rightarrow> bit list" where
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   137
  "retrieve (AONE bs) Void = bs"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   138
| "retrieve (ACHAR bs c) (Char d) = bs"
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   139
| "retrieve (AALTs bs [r]) v = bs @ retrieve r v" 
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   140
| "retrieve (AALTs bs (r#rs)) (Left v) = bs @ retrieve r v"
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   141
| "retrieve (AALTs bs (r#rs)) (Right v) = bs @ retrieve (AALTs [] rs) v"
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   142
| "retrieve (ASEQ bs r1 r2) (Seq v1 v2) = bs @ retrieve r1 v1 @ retrieve r2 v2"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   143
| "retrieve (ASTAR bs r) (Stars []) = bs @ [S]"
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   144
| "retrieve (ASTAR bs r) (Stars (v#vs)) = 
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   145
     bs @ [Z] @ retrieve r v @ retrieve (ASTAR [] r) (Stars vs)"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   146
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   147
fun 
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   148
  erase :: "arexp \<Rightarrow> rexp"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   149
where
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   150
  "erase AZERO = ZERO"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   151
| "erase (AONE _) = ONE"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   152
| "erase (ACHAR _ c) = CHAR c"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   153
| "erase (AALTs _ []) = ZERO"
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   154
| "erase (AALTs _ [r]) = (erase r)"
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   155
| "erase (AALTs bs (r#rs)) = ALT (erase r) (erase (AALTs bs rs))"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   156
| "erase (ASEQ _ r1 r2) = SEQ (erase r1) (erase r2)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   157
| "erase (ASTAR _ r) = STAR (erase r)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   158
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   159
fun
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   160
 bnullable :: "arexp \<Rightarrow> bool"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   161
where
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   162
  "bnullable (AZERO) = False"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   163
| "bnullable (AONE bs) = True"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   164
| "bnullable (ACHAR bs c) = False"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   165
| "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   166
| "bnullable (ASEQ bs r1 r2) = (bnullable r1 \<and> bnullable r2)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   167
| "bnullable (ASTAR bs r) = True"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   168
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   169
fun 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   170
  bmkeps :: "arexp \<Rightarrow> bit list"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   171
where
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   172
  "bmkeps(AONE bs) = bs"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   173
| "bmkeps(ASEQ bs r1 r2) = bs @ (bmkeps r1) @ (bmkeps r2)"
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   174
| "bmkeps(AALTs bs [r]) = bs @ (bmkeps r)"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   175
| "bmkeps(AALTs bs (r#rs)) = (if bnullable(r) then bs @ (bmkeps r) else (bmkeps (AALTs bs rs)))"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   176
| "bmkeps(ASTAR bs r) = bs @ [S]"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   177
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   178
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   179
fun
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   180
 bder :: "char \<Rightarrow> arexp \<Rightarrow> arexp"
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   181
where
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   182
  "bder c (AZERO) = AZERO"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   183
| "bder c (AONE bs) = AZERO"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   184
| "bder c (ACHAR bs d) = (if c = d then AONE bs else AZERO)"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   185
| "bder c (AALTs bs rs) = AALTs bs (map (bder c) rs)"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   186
| "bder c (ASEQ bs r1 r2) = 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   187
     (if bnullable r1
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   188
      then AALT bs (ASEQ [] (bder c r1) r2) (fuse (bmkeps r1) (bder c r2))
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   189
      else ASEQ bs (bder c r1) r2)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   190
| "bder c (ASTAR bs r) = ASEQ bs (fuse [Z] (bder c r)) (ASTAR [] r)"
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   191
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   192
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   193
fun 
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   194
  bders :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   195
where
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   196
  "bders r [] = r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   197
| "bders r (c#s) = bders (bder c r) s"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   198
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   199
lemma bders_append:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   200
  "bders r (s1 @ s2) = bders (bders r s1) s2"
287
95b3880d428f updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   201
  apply(induct s1 arbitrary: r s2)
95b3880d428f updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   202
  apply(simp_all)
95b3880d428f updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   203
  done
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   204
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   205
lemma bnullable_correctness:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   206
  shows "nullable (erase r) = bnullable r"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   207
  apply(induct r rule: erase.induct)
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   208
  apply(simp_all)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   209
  done
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   210
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   211
lemma erase_fuse:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   212
  shows "erase (fuse bs r) = erase r"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   213
  apply(induct r rule: erase.induct)
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   214
  apply(simp_all)
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   215
  done
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   216
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   217
lemma erase_intern [simp]:
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   218
  shows "erase (intern r) = r"
287
95b3880d428f updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   219
  apply(induct r)
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   220
  apply(simp_all add: erase_fuse)
287
95b3880d428f updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   221
  done
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   222
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   223
lemma erase_bder [simp]:
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   224
  shows "erase (bder a r) = der a (erase r)"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   225
  apply(induct r rule: erase.induct)
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   226
  apply(simp_all add: erase_fuse bnullable_correctness)
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   227
  done
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   228
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   229
lemma erase_bders [simp]:
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   230
  shows "erase (bders r s) = ders s (erase r)"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   231
  apply(induct s arbitrary: r )
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   232
  apply(simp_all)
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   233
  done
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   234
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   235
lemma retrieve_encode_STARS:
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   236
  assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> code v = retrieve (intern r) v"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   237
  shows "code (Stars vs) = retrieve (ASTAR [] (intern r)) (Stars vs)"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   238
  using assms
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   239
  apply(induct vs)
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   240
  apply(simp_all)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   241
  done
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   242
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   243
lemma retrieve_fuse2:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   244
  assumes "\<Turnstile> v : (erase r)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   245
  shows "retrieve (fuse bs r) v = bs @ retrieve r v"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   246
  using assms
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   247
  apply(induct r arbitrary: v bs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   248
         apply(auto elim: Prf_elims)[4]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   249
   defer
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   250
  using retrieve_encode_STARS
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   251
   apply(auto elim!: Prf_elims)[1]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   252
   apply(case_tac vs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   253
    apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   254
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   255
  (* AALTs  case *)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   256
  apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   257
  apply(case_tac x2a)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   258
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   259
   apply(auto elim!: Prf_elims)[1]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   260
  apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   261
   apply(case_tac list)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   262
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   263
  apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   264
  apply(auto elim!: Prf_elims)[1]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   265
  done
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   266
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   267
lemma retrieve_fuse:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   268
  assumes "\<Turnstile> v : r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   269
  shows "retrieve (fuse bs (intern r)) v = bs @ retrieve (intern r) v"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   270
  using assms 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   271
  by (simp_all add: retrieve_fuse2)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   272
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   273
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   274
lemma retrieve_code:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   275
  assumes "\<Turnstile> v : r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   276
  shows "code v = retrieve (intern r) v"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   277
  using assms
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   278
  apply(induct v r )
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   279
  apply(simp_all add: retrieve_fuse retrieve_encode_STARS)
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   280
  done
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   281
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   282
lemma r:
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   283
  assumes "bnullable (AALTs bs (a # rs))"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   284
  shows "bnullable a \<or> (\<not> bnullable a \<and> bnullable (AALTs bs rs))"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   285
  using assms
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   286
  apply(induct rs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   287
   apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   288
  done
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   289
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   290
lemma r0:
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   291
  assumes "bnullable a" 
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   292
  shows  "bmkeps (AALTs bs (a # rs)) = bs @ (bmkeps a)"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   293
  using assms
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   294
  by (metis bmkeps.simps(3) bmkeps.simps(4) list.exhaust)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   295
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   296
lemma r1:
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   297
  assumes "\<not> bnullable a" "bnullable (AALTs bs rs)"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   298
  shows  "bmkeps (AALTs bs (a # rs)) = bmkeps (AALTs bs rs)"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   299
  using assms
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   300
  apply(induct rs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   301
   apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   302
  done
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   303
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   304
lemma r2:
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   305
  assumes "x \<in> set rs" "bnullable x"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   306
  shows "bnullable (AALTs bs rs)"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   307
  using assms
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   308
  apply(induct rs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   309
   apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   310
  done
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   311
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   312
lemma  r3:
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   313
  assumes "\<not> bnullable r" 
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   314
          " \<exists> x \<in> set rs. bnullable x"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   315
  shows "retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs))) =
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   316
         retrieve (AALTs bs (r # rs)) (mkeps (erase (AALTs bs (r # rs))))"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   317
  using assms
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   318
  apply(induct rs arbitrary: r bs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   319
   apply(auto)[1]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   320
  apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   321
  using bnullable_correctness apply blast
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   322
    apply(auto simp add: bnullable_correctness mkeps_nullable retrieve_fuse2)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   323
   apply(subst retrieve_fuse2[symmetric])
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   324
  apply (smt bnullable.simps(4) bnullable_correctness erase.simps(5) erase.simps(6) insert_iff list.exhaust list.set(2) mkeps.simps(3) mkeps_nullable)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   325
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   326
  apply(case_tac "bnullable a")
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   327
  apply (smt append_Nil2 bnullable.simps(4) bnullable_correctness erase.simps(5) erase.simps(6) fuse.simps(4) insert_iff list.exhaust list.set(2) mkeps.simps(3) mkeps_nullable retrieve_fuse2)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   328
  apply(drule_tac x="a" in meta_spec)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   329
  apply(drule_tac x="bs" in meta_spec)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   330
  apply(drule meta_mp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   331
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   332
  apply(drule meta_mp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   333
   apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   334
  apply(subst retrieve_fuse2[symmetric])
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   335
  apply(case_tac rs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   336
    apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   337
   apply(auto)[1]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   338
      apply (simp add: bnullable_correctness)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   339
  apply (metis append_Nil2 bnullable_correctness erase_fuse fuse.simps(4) list.set_intros(1) mkeps.simps(3) mkeps_nullable nullable.simps(4) r2)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   340
    apply (simp add: bnullable_correctness)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   341
  apply (metis append_Nil2 bnullable_correctness erase.simps(6) erase_fuse fuse.simps(4) list.set_intros(2) mkeps.simps(3) mkeps_nullable r2)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   342
  apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   343
  done
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   344
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   345
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   346
lemma t: 
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   347
  assumes "\<forall>r \<in> set rs. nullable (erase r) \<longrightarrow> bmkeps r = retrieve r (mkeps (erase r))" 
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   348
          "nullable (erase (AALTs bs rs))"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   349
  shows " bmkeps (AALTs bs rs) = retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs)))"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   350
  using assms
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   351
  apply(induct rs arbitrary: bs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   352
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   353
  apply(auto simp add: bnullable_correctness)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   354
   apply(case_tac rs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   355
     apply(auto simp add: bnullable_correctness)[2]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   356
   apply(subst r1)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   357
     apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   358
    apply(rule r2)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   359
     apply(assumption)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   360
    apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   361
   apply(drule_tac x="bs" in meta_spec)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   362
   apply(drule meta_mp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   363
    apply(auto)[1]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   364
   prefer 2
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   365
  apply(case_tac "bnullable a")
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   366
    apply(subst r0)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   367
     apply blast
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   368
    apply(subgoal_tac "nullable (erase a)")
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   369
  prefer 2
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   370
  using bnullable_correctness apply blast
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   371
  apply (metis (no_types, lifting) erase.simps(5) erase.simps(6) list.exhaust mkeps.simps(3) retrieve.simps(3) retrieve.simps(4))
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   372
  apply(subst r1)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   373
     apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   374
  using r2 apply blast
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   375
  apply(drule_tac x="bs" in meta_spec)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   376
   apply(drule meta_mp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   377
    apply(auto)[1]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   378
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   379
  using r3 apply blast
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   380
  apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   381
  using r3 by blast
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   382
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   383
lemma bmkeps_retrieve:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   384
  assumes "nullable (erase r)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   385
  shows "bmkeps r = retrieve r (mkeps (erase r))"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   386
  using assms
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   387
  apply(induct r)
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   388
         apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   389
        apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   390
       apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   391
    apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   392
   defer
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   393
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   394
  apply(rule t)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   395
   apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   396
  done
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   397
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   398
lemma bder_retrieve:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   399
  assumes "\<Turnstile> v : der c (erase r)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   400
  shows "retrieve (bder c r) v = retrieve r (injval (erase r) c v)"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   401
  using assms
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   402
  apply(induct r arbitrary: v rule: erase.induct)
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   403
  apply(auto elim!: Prf_elims simp add: retrieve_fuse2 bnullable_correctness bmkeps_retrieve)
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   404
  apply(case_tac va)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   405
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   406
  apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   407
  by (smt Prf_elims(3) injval.simps(2) injval.simps(3) retrieve.simps(4) retrieve.simps(5) same_append_eq)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   408
  
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   409
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   410
lemma MAIN_decode:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   411
  assumes "\<Turnstile> v : ders s r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   412
  shows "Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   413
  using assms
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   414
proof (induct s arbitrary: v rule: rev_induct)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   415
  case Nil
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   416
  have "\<Turnstile> v : ders [] r" by fact
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   417
  then have "\<Turnstile> v : r" by simp
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   418
  then have "Some v = decode (retrieve (intern r) v) r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   419
    using decode_code retrieve_code by auto
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   420
  then show "Some (flex r id [] v) = decode (retrieve (bders (intern r) []) v) r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   421
    by simp
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   422
next
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   423
  case (snoc c s v)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   424
  have IH: "\<And>v. \<Turnstile> v : ders s r \<Longrightarrow> 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   425
     Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r" by fact
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   426
  have asm: "\<Turnstile> v : ders (s @ [c]) r" by fact
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   427
  then have asm2: "\<Turnstile> injval (ders s r) c v : ders s r" 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   428
    by(simp add: Prf_injval ders_append)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   429
  have "Some (flex r id (s @ [c]) v) = Some (flex r id s (injval (ders s r) c v))"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   430
    by (simp add: flex_append)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   431
  also have "... = decode (retrieve (bders (intern r) s) (injval (ders s r) c v)) r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   432
    using asm2 IH by simp
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   433
  also have "... = decode (retrieve (bder c (bders (intern r) s)) v) r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   434
    using asm by(simp_all add: bder_retrieve ders_append)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   435
  finally show "Some (flex r id (s @ [c]) v) = 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   436
                 decode (retrieve (bders (intern r) (s @ [c])) v) r" by (simp add: bders_append)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   437
qed
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   438
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   439
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   440
definition blexer where
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   441
 "blexer r s \<equiv> if bnullable (bders (intern r) s) then 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   442
                decode (bmkeps (bders (intern r) s)) r else None"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   443
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   444
lemma blexer_correctness:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   445
  shows "blexer r s = lexer r s"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   446
proof -
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   447
  { define bds where "bds \<equiv> bders (intern r) s"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   448
    define ds  where "ds \<equiv> ders s r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   449
    assume asm: "nullable ds"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   450
    have era: "erase bds = ds" 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   451
      unfolding ds_def bds_def by simp
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   452
    have mke: "\<Turnstile> mkeps ds : ds"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   453
      using asm by (simp add: mkeps_nullable)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   454
    have "decode (bmkeps bds) r = decode (retrieve bds (mkeps ds)) r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   455
      using bmkeps_retrieve
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   456
      using asm era by (simp add: bmkeps_retrieve)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   457
    also have "... =  Some (flex r id s (mkeps ds))"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   458
      using mke by (simp_all add: MAIN_decode ds_def bds_def)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   459
    finally have "decode (bmkeps bds) r = Some (flex r id s (mkeps ds))" 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   460
      unfolding bds_def ds_def .
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   461
  }
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   462
  then show "blexer r s = lexer r s"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   463
    unfolding blexer_def lexer_flex
293
1a4e5b94293b updated
Christian Urban <urbanc@in.tum.de>
parents: 289
diff changeset
   464
    apply(subst bnullable_correctness[symmetric])
1a4e5b94293b updated
Christian Urban <urbanc@in.tum.de>
parents: 289
diff changeset
   465
    apply(simp)
1a4e5b94293b updated
Christian Urban <urbanc@in.tum.de>
parents: 289
diff changeset
   466
    done
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   467
qed
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   468
295
c6ec5f369037 updated
Christian Urban <urbanc@in.tum.de>
parents: 293
diff changeset
   469
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   470
fun distinctBy :: "'a list \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b set \<Rightarrow> 'a list"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   471
  where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   472
  "distinctBy [] f acc = []"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   473
| "distinctBy (x#xs) f acc = 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   474
     (if (f x) \<in> acc then distinctBy xs f acc 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   475
      else x # (distinctBy xs f ({f x} \<union> acc)))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   476
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   477
fun flts :: "arexp list \<Rightarrow> arexp list"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   478
  where 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   479
  "flts [] = []"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   480
| "flts (AZERO # rs) = flts rs"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   481
| "flts ((AALTs bs  rs1) # rs) = (map (fuse bs) rs1) @ flts rs"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   482
| "flts (r1 # rs) = r1 # flts rs"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   483
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   484
fun bsimp_ASEQ :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp \<Rightarrow> arexp"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   485
  where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   486
  "bsimp_ASEQ _ AZERO _ = AZERO"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   487
| "bsimp_ASEQ _ _ AZERO = AZERO"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   488
| "bsimp_ASEQ bs1 (AONE bs2) r2 = fuse (bs1 @ bs2) r2"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   489
| "bsimp_ASEQ bs1 r1 r2 = ASEQ  bs1 r1 r2"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   490
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   491
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   492
fun bsimp_AALTs :: "bit list \<Rightarrow> arexp list \<Rightarrow> arexp"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   493
  where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   494
  "bsimp_AALTs _ [] = AZERO"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   495
| "bsimp_AALTs bs1 [r] = fuse bs1 r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   496
| "bsimp_AALTs bs1 rs = AALTs bs1 rs"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   497
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   498
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   499
fun bsimp :: "arexp \<Rightarrow> arexp" 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   500
  where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   501
  "bsimp (ASEQ bs1 r1 r2) = bsimp_ASEQ bs1 (bsimp r1) (bsimp r2)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   502
| "bsimp (AALTs bs1 rs) = bsimp_AALTs bs1 (flts (map bsimp rs))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   503
| "bsimp r = r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   504
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   505
fun 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   506
  bders_simp :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   507
where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   508
  "bders_simp r [] = r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   509
| "bders_simp r (c # s) = bders_simp (bsimp (bder c r)) s"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   510
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   511
definition blexer_simp where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   512
 "blexer_simp r s \<equiv> if bnullable (bders_simp (intern r) s) then 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   513
                decode (bmkeps (bders_simp (intern r) s)) r else None"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   514
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   515
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   516
lemma asize0:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   517
  shows "0 < asize r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   518
  apply(induct  r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   519
       apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   520
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   521
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   522
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   523
lemma bders_simp_append:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   524
  shows "bders_simp r (s1 @ s2) = bders_simp (bders_simp r s1) s2"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   525
  apply(induct s1 arbitrary: r s2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   526
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   527
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   528
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   529
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   530
lemma bsimp_ASEQ_size:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   531
  shows "asize (bsimp_ASEQ bs r1 r2) \<le> Suc (asize r1 + asize r2)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   532
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   533
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   534
  done
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   535
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   536
lemma fuse_size:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   537
  shows "asize (fuse bs r) = asize r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   538
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   539
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   540
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   541
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   542
lemma flts_size:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   543
  shows "sum_list (map asize (flts rs)) \<le> sum_list (map asize rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   544
  apply(induct rs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   545
        apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   546
  by (metis (mono_tags, lifting) add_mono_thms_linordered_semiring(1) comp_apply fuse_size le_SucI order_refl sum_list_cong)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   547
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   548
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   549
lemma bsimp_AALTs_size:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   550
  shows "asize (bsimp_AALTs bs rs) \<le> Suc (sum_list (map asize rs))"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   551
  apply(induct rs rule: bsimp_AALTs.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   552
  apply(auto simp add: fuse_size)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   553
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   554
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   555
lemma bsimp_size:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   556
  shows "asize (bsimp r) \<le> asize r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   557
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   558
       apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   559
   apply (meson Suc_le_mono add_mono_thms_linordered_semiring(1) bsimp_ASEQ_size le_trans)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   560
  apply(rule le_trans)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   561
   apply(rule bsimp_AALTs_size)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   562
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   563
   apply(rule le_trans)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   564
   apply(rule flts_size)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   565
  by (simp add: sum_list_mono)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   566
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   567
fun nonalt :: "arexp \<Rightarrow> bool"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   568
  where
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   569
  "nonalt (AALTs bs2 rs) = False"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   570
| "nonalt r = True"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   571
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   572
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   573
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   574
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   575
lemma bsimp_AALTs_size2:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   576
  assumes "\<forall>r \<in> set  rs. nonalt r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   577
  shows "asize (bsimp_AALTs bs rs) \<ge> sum_list (map asize rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   578
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   579
  apply(induct rs rule: bsimp_AALTs.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   580
    apply(simp_all add: fuse_size)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   581
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   582
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   583
lemma qq:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   584
  shows "map (asize \<circ> fuse bs) rs = map asize rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   585
  apply(induct rs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   586
   apply(auto simp add: fuse_size)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   587
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   588
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   589
lemma flts_size2:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   590
  assumes "\<exists>bs rs'. AALTs bs  rs' \<in> set rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   591
  shows "sum_list (map asize (flts rs)) < sum_list (map asize rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   592
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   593
  apply(induct rs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   594
   apply(auto simp add: qq)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   595
   apply (simp add: flts_size less_Suc_eq_le)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   596
  apply(case_tac a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   597
       apply(auto simp add: qq)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   598
   prefer 2
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   599
   apply (simp add: flts_size le_imp_less_Suc)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   600
  using less_Suc_eq by auto
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   601
  
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   602
lemma L_bsimp_ASEQ:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   603
  "L (SEQ (erase r1) (erase r2)) = L (erase (bsimp_ASEQ bs r1 r2))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   604
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   605
  apply(simp_all)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   606
  by (metis erase_fuse fuse.simps(4))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   607
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   608
lemma L_bsimp_AALTs:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   609
  "L (erase (AALTs bs rs)) = L (erase (bsimp_AALTs bs rs))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   610
  apply(induct bs rs rule: bsimp_AALTs.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   611
  apply(simp_all add: erase_fuse)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   612
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   613
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   614
lemma L_erase_AALTs:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   615
  shows "L (erase (AALTs bs rs)) = \<Union> (L ` erase ` (set rs))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   616
  apply(induct rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   617
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   618
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   619
  apply(case_tac rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   620
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   621
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   622
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   623
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   624
lemma L_erase_flts:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   625
  shows "\<Union> (L ` erase ` (set (flts rs))) = \<Union> (L ` erase ` (set rs))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   626
  apply(induct rs rule: flts.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   627
        apply(simp_all)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   628
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   629
  using L_erase_AALTs erase_fuse apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   630
  by (simp add: L_erase_AALTs erase_fuse)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   631
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   632
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   633
lemma L_bsimp_erase:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   634
  shows "L (erase r) = L (erase (bsimp r))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   635
  apply(induct r)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   636
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   637
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   638
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   639
  apply(auto simp add: Sequ_def)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   640
  apply(subst L_bsimp_ASEQ[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   641
  apply(auto simp add: Sequ_def)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   642
  apply(subst (asm)  L_bsimp_ASEQ[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   643
  apply(auto simp add: Sequ_def)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   644
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   645
   apply(subst L_bsimp_AALTs[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   646
   defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   647
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   648
  apply(subst (2)L_erase_AALTs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   649
  apply(subst L_erase_flts)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   650
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   651
   apply (simp add: L_erase_AALTs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   652
  using L_erase_AALTs by blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   653
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   654
lemma bsimp_ASEQ0:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   655
  shows "bsimp_ASEQ bs r1 AZERO = AZERO"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   656
  apply(induct r1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   657
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   658
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   659
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   660
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   661
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   662
lemma bsimp_ASEQ1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   663
  assumes "r1 \<noteq> AZERO" "r2 \<noteq> AZERO" "\<forall>bs. r1 \<noteq> AONE bs"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   664
  shows "bsimp_ASEQ bs r1 r2 = ASEQ bs r1 r2"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   665
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   666
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   667
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   668
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   669
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   670
lemma bsimp_ASEQ2:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   671
  shows "bsimp_ASEQ bs (AONE bs1) r2 = fuse (bs @ bs1) r2"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   672
  apply(induct r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   673
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   674
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   675
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   676
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   677
lemma L_bders_simp:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   678
  shows "L (erase (bders_simp r s)) = L (erase (bders r s))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   679
  apply(induct s arbitrary: r rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   680
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   681
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   682
  apply(simp add: ders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   683
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   684
  apply(simp add: L_bsimp_erase[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   685
  by (simp add: der_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   686
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   687
lemma b1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   688
  "bsimp_ASEQ bs1 (AONE bs) r =  fuse (bs1 @ bs) r" 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   689
  apply(induct r)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   690
       apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   691
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   692
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   693
lemma b2:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   694
  assumes "bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   695
  shows "bmkeps (fuse bs r) = bs @ bmkeps r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   696
  by (simp add: assms bmkeps_retrieve bnullable_correctness erase_fuse mkeps_nullable retrieve_fuse2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   697
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   698
lemma b3:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   699
  shows "bnullable r = bnullable (bsimp r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   700
  using L_bsimp_erase bnullable_correctness nullable_correctness by auto
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   701
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   702
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   703
lemma b4:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   704
  shows "bnullable (bders_simp r s) = bnullable (bders r s)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   705
  by (metis L_bders_simp bnullable_correctness lexer.simps(1) lexer_correct_None option.distinct(1))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   706
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   707
lemma q1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   708
  assumes "\<forall>r \<in> set rs. bmkeps(bsimp r) = bmkeps r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   709
  shows "map (\<lambda>r. bmkeps(bsimp r)) rs = map bmkeps rs"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   710
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   711
  apply(induct rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   712
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   713
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   714
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   715
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   716
lemma q3:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   717
  assumes "\<exists>r \<in> set rs. bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   718
  shows "bmkeps (AALTs bs rs) = bmkeps (bsimp_AALTs bs rs)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   719
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   720
  apply(induct bs rs rule: bsimp_AALTs.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   721
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   722
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   723
  apply (simp add: b2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   724
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   725
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   726
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   727
lemma qq1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   728
  assumes "\<exists>r \<in> set rs. bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   729
  shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   730
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   731
  apply(induct rs arbitrary: rs1 bs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   732
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   733
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   734
  by (metis Nil_is_append_conv bmkeps.simps(4) neq_Nil_conv r0 split_list_last)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   735
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   736
lemma qq2:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   737
  assumes "\<forall>r \<in> set rs. \<not> bnullable r" "\<exists>r \<in> set rs1. bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   738
  shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs1)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   739
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   740
  apply(induct rs arbitrary: rs1 bs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   741
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   742
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   743
  by (metis append_assoc in_set_conv_decomp r1 r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   744
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   745
lemma qq3:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   746
  shows "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   747
  apply(induct rs arbitrary: bs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   748
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   749
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   750
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   751
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   752
lemma fuse_empty:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   753
  shows "fuse [] r = r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   754
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   755
       apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   756
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   757
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   758
lemma flts_fuse:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   759
  shows "map (fuse bs) (flts rs) = flts (map (fuse bs) rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   760
  apply(induct rs arbitrary: bs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   761
        apply(auto simp add: fuse_append)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   762
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   763
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   764
lemma bsimp_ASEQ_fuse:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   765
  shows "fuse bs1 (bsimp_ASEQ bs2 r1 r2) = bsimp_ASEQ (bs1 @ bs2) r1 r2"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   766
  apply(induct r1 r2 arbitrary: bs1 bs2 rule: bsimp_ASEQ.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   767
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   768
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   769
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   770
lemma bsimp_AALTs_fuse:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   771
  assumes "\<forall>r \<in> set rs. fuse bs1 (fuse bs2 r) = fuse (bs1 @ bs2) r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   772
  shows "fuse bs1 (bsimp_AALTs bs2 rs) = bsimp_AALTs (bs1 @ bs2) rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   773
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   774
  apply(induct bs2 rs arbitrary: bs1 rule: bsimp_AALTs.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   775
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   776
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   777
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   778
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   779
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   780
lemma bsimp_fuse:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   781
  shows "fuse bs (bsimp r) = bsimp (fuse bs r)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   782
apply(induct r arbitrary: bs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   783
       apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   784
      apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   785
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   786
    prefer 3
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   787
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   788
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   789
   apply (simp add: bsimp_ASEQ_fuse)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   790
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   791
  by (simp add: bsimp_AALTs_fuse fuse_append)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   792
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   793
lemma bsimp_fuse_AALTs:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   794
  shows "fuse bs (bsimp (AALTs [] rs)) = bsimp (AALTs bs rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   795
  apply(subst bsimp_fuse) 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   796
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   797
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   798
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   799
lemma bsimp_fuse_AALTs2:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   800
  shows "fuse bs (bsimp_AALTs [] rs) = bsimp_AALTs bs rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   801
  using bsimp_AALTs_fuse fuse_append by auto
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   802
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   803
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   804
lemma bsimp_ASEQ_idem:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   805
  assumes "bsimp (bsimp r1) = bsimp r1" "bsimp (bsimp r2) = bsimp r2"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   806
  shows "bsimp (bsimp_ASEQ x1 (bsimp r1) (bsimp r2)) = bsimp_ASEQ x1 (bsimp r1) (bsimp r2)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   807
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   808
  apply(case_tac "bsimp r1 = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   809
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   810
 apply(case_tac "bsimp r2 = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   811
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   812
  apply (metis bnullable.elims(2) bnullable.elims(3) bsimp.simps(3) bsimp_ASEQ.simps(2) bsimp_ASEQ.simps(3) bsimp_ASEQ.simps(4) bsimp_ASEQ.simps(5) bsimp_ASEQ.simps(6))  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   813
  apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   814
    apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   815
    apply(subst bsimp_ASEQ2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   816
   apply(subst bsimp_ASEQ2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   817
  apply (metis assms(2) bsimp_fuse)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   818
      apply(subst bsimp_ASEQ1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   819
      apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   820
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   821
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   822
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   823
fun nonnested :: "arexp \<Rightarrow> bool"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   824
  where
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   825
  "nonnested (AALTs bs2 []) = True"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   826
| "nonnested (AALTs bs2 ((AALTs bs1 rs1) # rs2)) = False"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   827
| "nonnested (AALTs bs2 (r # rs2)) = nonnested (AALTs bs2 rs2)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   828
| "nonnested r = True"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   829
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   830
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   831
lemma  k0:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   832
  shows "flts (r # rs1) = flts [r] @ flts rs1"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   833
  apply(induct r arbitrary: rs1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   834
   apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   835
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   836
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   837
lemma  k00:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   838
  shows "flts (rs1 @ rs2) = flts rs1 @ flts rs2"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   839
  apply(induct rs1 arbitrary: rs2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   840
   apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   841
  by (metis append.assoc k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   842
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   843
lemma  k0a:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   844
  shows "flts [AALTs bs rs] = map (fuse bs)  rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   845
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   846
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   847
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   848
fun spill where
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   849
 "spill (AALTs bs rs) =  map (fuse bs) rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   850
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   851
lemma  k0a2:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   852
  assumes "\<not> nonalt r"  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   853
  shows "flts [r] = spill r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   854
  using  assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   855
  apply(case_tac r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   856
  apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   857
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   858
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   859
lemma  k0b:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   860
  assumes "nonalt r" "r \<noteq> AZERO"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   861
  shows "flts [r] = [r]"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   862
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   863
  apply(case_tac  r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   864
  apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   865
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   866
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   867
lemma nn1:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   868
  assumes "nonnested (AALTs bs rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   869
  shows "\<nexists>bs1 rs1. flts rs = [AALTs bs1 rs1]"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   870
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   871
  apply(induct rs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   872
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   873
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   874
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   875
lemma nn1q:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   876
  assumes "nonnested (AALTs bs rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   877
  shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set (flts rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   878
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   879
  apply(induct rs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   880
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   881
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   882
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   883
lemma nn1qq:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   884
  assumes "nonnested (AALTs bs rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   885
  shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   886
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   887
  apply(induct rs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   888
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   889
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   890
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   891
lemma nn10:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   892
  assumes "nonnested (AALTs cs rs)" 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   893
  shows "nonnested (AALTs (bs @ cs) rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   894
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   895
  apply(induct rs arbitrary: cs bs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   896
   apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   897
  apply(case_tac a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   898
       apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   899
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   900
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   901
lemma nn11a:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   902
  assumes "nonalt r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   903
  shows "nonalt (fuse bs r)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   904
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   905
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   906
       apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   907
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   908
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   909
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   910
lemma nn1a:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   911
  assumes "nonnested r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   912
  shows "nonnested (fuse bs r)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   913
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   914
  apply(induct bs r arbitrary: rule: fuse.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   915
       apply(simp_all add: nn10)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   916
  done  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   917
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   918
lemma n0:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   919
  shows "nonnested (AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. nonalt r)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   920
  apply(induct rs  arbitrary: bs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   921
   apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   922
    apply (metis list.set_intros(1) nn1qq nonalt.elims(3))
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   923
   apply (metis list.set_intros(2) nn1qq nonalt.elims(3))
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   924
  by (metis nonalt.elims(2) nonnested.simps(3) nonnested.simps(4) nonnested.simps(5) nonnested.simps(6) nonnested.simps(7))
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   925
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   926
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   927
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   928
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   929
lemma nn1c:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   930
  assumes "\<forall>r \<in> set rs. nonnested r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   931
  shows "\<forall>r \<in> set (flts rs). nonalt r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   932
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   933
  apply(induct rs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   934
        apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   935
  apply(rule nn11a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   936
  by (metis nn1qq nonalt.elims(3))
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   937
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   938
lemma nn1bb:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   939
  assumes "\<forall>r \<in> set rs. nonalt r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   940
  shows "nonnested (bsimp_AALTs bs rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   941
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   942
  apply(induct bs rs rule: bsimp_AALTs.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   943
    apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   944
   apply (metis nn11a nonalt.simps(1) nonnested.elims(3))
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   945
  using n0 by auto
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   946
    
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   947
lemma nn1b:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   948
  shows "nonnested (bsimp r)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   949
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   950
       apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   951
  apply(case_tac "bsimp r1 = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   952
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   953
 apply(case_tac "bsimp r2 = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   954
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   955
    apply(subst bsimp_ASEQ0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   956
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   957
  apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   958
    apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   959
    apply(subst bsimp_ASEQ2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   960
  apply (simp add: nn1a)    
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   961
   apply(subst bsimp_ASEQ1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   962
      apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   963
  apply(rule nn1bb)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   964
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   965
  by (metis (mono_tags, hide_lams) imageE nn1c set_map)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   966
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   967
lemma rt:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   968
  shows "sum_list (map asize (flts (map bsimp rs))) \<le> sum_list (map asize rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   969
  apply(induct rs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   970
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   971
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   972
  apply(subst  k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   973
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   974
  by (smt add_le_cancel_right add_mono bsimp_size flts.simps(1) flts_size k0 le_iff_add list.simps(9) map_append sum_list.Cons sum_list.append trans_le_add1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   975
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   976
lemma flts_idem:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   977
  assumes "\<forall>r \<in> set rs. bsimp (bsimp r) = bsimp r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   978
  shows "flts (map bsimp (flts (map bsimp rs))) = flts (map bsimp rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   979
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   980
  apply(induct rs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   981
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   982
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   983
  apply(subst k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   984
  apply(subst (2) k0) 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   985
  apply(case_tac "bsimp a = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   986
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   987
  apply(case_tac "nonalt (bsimp a)")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   988
  thm k0 k0a k0b
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   989
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   990
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   991
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   992
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   993
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   994
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   995
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   996
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   997
  apply(subst k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   998
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   999
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1000
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1001
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1002
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1003
  apply(simp add: k00)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1004
  apply(subst k0a2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1005
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1006
  apply(subst k0a2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1007
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1008
  apply(case_tac a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1009
  apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1010
  sorry
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1011
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1012
lemma bsimp_AALTs_idem:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1013
  (*assumes "\<forall>r \<in> set rs. bsimp (bsimp r) = bsimp r \<and> nonalt (bsimp r)" *)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1014
  (*assumes "\<forall>r \<in> set rs. bsimp (bsimp r) = bsimp r" *)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1015
  shows "bsimp (bsimp_AALTs bs rs) = bsimp_AALTs bs (flts (map bsimp rs))"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1016
  apply(induct rs arbitrary: bs taking: "\<lambda>rs. sum_list (map asize rs)" rule: measure_induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1017
  apply(case_tac x)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1018
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1019
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1020
  apply(case_tac "\<exists>bs'  rs'. a = AALTs bs' rs'")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1021
   apply(clarify)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1022
  apply(case_tac list)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1023
        apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1024
       apply(simp) 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1025
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1026
  apply(drule_tac x="flts (rs' @ list)" in spec)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1027
  apply(erule impE)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1028
  prefer 2
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1029
  apply(case_tac a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1030
       apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1031
       apply(case_tac list)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1032
        apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1033
       apply(simp) 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1034
   apply(case_tac list)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1035
        apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1036
      apply(simp) 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1037
   apply(case_tac list)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1038
        apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1039
     apply(simp) 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1040
  prefer 3
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1041
   apply(case_tac list)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1042
        apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1043
       apply(simp) 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1044
   apply(case_tac list)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1045
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1046
      
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1047
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1048
       apply(simp) 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1049
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1050
      apply(case_tac "flts (map bsimp list)")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1051
       apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1052
      apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1053
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1054
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1055
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1056
   prefer 2
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1057
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1058
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1059
   apply(subst k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1060
   apply(subst (2) k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1061
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1062
  apply(case_tac a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1063
       apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1064
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1065
  prefer 2
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1066
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1067
  apply(case_tac r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1068
       apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1069
   apply(case_tac "bsimp x42 = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1070
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1071
 apply(case_tac "bsimp x43 = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1072
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1073
   apply(subst bsimp_ASEQ0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1074
   apply(subst bsimp_ASEQ0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1075
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1076
  apply(case_tac "\<exists>bs. bsimp x42 = AONE bs")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1077
    apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1078
    apply(subst bsimp_ASEQ2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1079
   apply(subst bsimp_ASEQ2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1080
  prefer 2
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1081
      apply(subst bsimp_ASEQ1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1082
      apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1083
  apply(subst bsimp_ASEQ1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1084
      apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1085
  apply(subst (asm) bsimp_ASEQ2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1086
   apply(subst (asm) bsimp_ASEQ2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1087
  using flts_fuse bsimp_fuse bsimp_fuse_AALTs bsimp_fuse_AALTs2 bsimp_AALTs.simps flts.simps
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1088
    
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1089
   apply(case_tac x43)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1090
        apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1091
    prefer 3
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1092
  oops
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1093
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1094
lemma bsimp_idem:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1095
  shows "bsimp (bsimp r) = bsimp r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1096
apply(induct r taking: "asize" rule: measure_induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1097
  apply(case_tac x)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1098
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1099
      apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1100
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1101
    prefer 3
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1102
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1103
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1104
   apply (simp add: bsimp_ASEQ_idem)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1105
  apply(clarify)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1106
  apply(case_tac x52)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1107
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1108
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1109
  apply(subst k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1110
  apply(subst (2) k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1111
  apply(case_tac "bsimp a = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1112
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1113
   apply(frule_tac x="AALTs x51 (flts (map bsimp list))" in spec)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1114
   apply(drule mp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1115
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1116
  apply (meson add_le_cancel_right asize0 le_trans not_le rt trans_le_add2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1117
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1118
    apply(subst (asm) flts_idem)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1119
     apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1120
     apply(drule_tac  x="r" in spec)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1121
  apply (metis add.commute add_lessD1 not_add_less1 not_less_eq sum_list_map_remove1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1122
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1123
  apply(subst flts_idem)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1124
   apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1125
     apply(drule_tac  x="r" in spec)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1126
  apply (metis add.commute add_lessD1 not_add_less1 not_less_eq sum_list_map_remove1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1127
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1128
  apply(case_tac "nonalt (bsimp a)")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1129
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1130
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1131
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1132
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1133
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1134
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1135
   apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1136
  apply(frule_tac x="AALTs x51 (bsimp a # flts (map bsimp list))" in spec)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1137
   apply(drule mp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1138
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1139
    prefer 2
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1140
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1141
  apply(subst (asm) k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1142
  apply(subst (asm) flts_idem)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1143
     apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1144
  apply (simp add: sum_list_map_remove1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1145
  apply(subst (asm) k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1146
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1147
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1148
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1149
   apply(subst k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1150
  apply(subst flts_idem)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1151
     apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1152
     apply (simp add: sum_list_map_remove1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1153
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1154
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1155
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1156
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1157
lemma XX_bder:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1158
  shows "bsimp (bder c (bsimp r)) = (bsimp \<circ> bder c) r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1159
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1160
       apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1161
      apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1162
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1163
    prefer 3
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1164
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1165
  prefer 2
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1166
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1167
   apply(case_tac x2a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1168
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1169
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1170
  apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1171
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1172
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1173
lemma q3a:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1174
  assumes "\<exists>r \<in> set rs. bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1175
  shows "bmkeps (AALTs bs (map (fuse bs1) rs)) = bmkeps (AALTs (bs@bs1) rs)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1176
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1177
  apply(induct rs arbitrary: bs bs1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1178
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1179
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1180
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1181
   apply (metis append_assoc b2 bnullable_correctness erase_fuse r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1182
  apply(case_tac "bnullable a")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1183
   apply (metis append.assoc b2 bnullable_correctness erase_fuse r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1184
  apply(case_tac rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1185
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1186
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1187
  apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1188
   apply (metis bnullable_correctness erase_fuse)+
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1189
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1190
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1191
lemma qq4:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1192
  assumes "\<exists>x\<in>set list. bnullable x"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1193
  shows "\<exists>x\<in>set (flts list). bnullable x"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1194
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1195
  apply(induct list rule: flts.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1196
        apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1197
  by (metis UnCI bnullable_correctness erase_fuse imageI)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1198
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1199
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1200
lemma qs3:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1201
  assumes "\<exists>r \<in> set rs. bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1202
  shows "bmkeps (AALTs bs rs) = bmkeps (AALTs bs (flts rs))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1203
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1204
  apply(induct rs arbitrary: bs taking: size rule: measure_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1205
  apply(case_tac x)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1206
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1207
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1208
  apply(case_tac a)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1209
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1210
       apply (simp add: r1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1211
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1212
      apply (simp add: r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1213
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1214
     apply(case_tac "flts list")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1215
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1216
  apply (metis L_erase_AALTs L_erase_flts L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(4) mkeps_nullable r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1217
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1218
     apply (simp add: r1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1219
    prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1220
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1221
    apply (simp add: r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1222
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1223
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1224
  apply(case_tac "\<exists>x\<in>set x52. bnullable x")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1225
  apply(case_tac "list")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1226
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1227
    apply (metis b2 fuse.simps(4) q3a r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1228
   apply(erule disjE)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1229
    apply(subst qq1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1230
     apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1231
     apply (metis bnullable_correctness erase_fuse)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1232
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1233
     apply (metis b2 fuse.simps(4) q3a r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1234
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1235
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1236
     apply(subst qq1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1237
      apply (metis bnullable_correctness erase_fuse image_eqI set_map)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1238
     apply (metis b2 fuse.simps(4) q3a r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1239
  apply(subst qq1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1240
      apply (metis bnullable_correctness erase_fuse image_eqI set_map)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1241
    apply (metis b2 fuse.simps(4) q3a r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1242
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1243
   apply(subst qq2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1244
     apply (metis bnullable_correctness erase_fuse imageE set_map)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1245
  prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1246
  apply(case_tac "list")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1247
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1248
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1249
   apply (simp add: qq4)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1250
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1251
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1252
   apply(case_tac list)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1253
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1254
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1255
   apply (simp add: r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1256
  apply(case_tac "bnullable (ASEQ x41 x42 x43)")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1257
   apply(case_tac list)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1258
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1259
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1260
   apply (simp add: r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1261
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1262
  using qq4 r1 r2 by auto
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1263
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1264
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1265
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1266
lemma k1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1267
  assumes "\<And>x2aa. \<lbrakk>x2aa \<in> set x2a; bnullable x2aa\<rbrakk> \<Longrightarrow> bmkeps x2aa = bmkeps (bsimp x2aa)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1268
          "\<exists>x\<in>set x2a. bnullable x"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1269
        shows "bmkeps (AALTs x1 (flts x2a)) = bmkeps (AALTs x1 (flts (map bsimp x2a)))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1270
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1271
  apply(induct x2a)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1272
  apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1273
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1274
  apply(subst k0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1275
  apply(subst (2) k0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1276
  apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1277
  apply (metis b3 k0 list.set_intros(1) qs3 r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1278
  by (smt b3 imageI insert_iff k0 list.set(2) qq3 qs3 r0 r1 set_map)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1279
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1280
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1281
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1282
lemma bmkeps_simp:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1283
  assumes "bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1284
  shows "bmkeps r = bmkeps (bsimp r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1285
  using  assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1286
  apply(induct r)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1287
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1288
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1289
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1290
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1291
    prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1292
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1293
   apply(case_tac "bsimp r1 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1294
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1295
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1296
  apply (metis L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(1) mkeps_nullable)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1297
 apply(case_tac "bsimp r2 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1298
    apply(simp)  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1299
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1300
  apply (metis L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(1) mkeps_nullable)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1301
  apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1302
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1303
    apply(subst b1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1304
    apply(subst b2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1305
  apply(simp add: b3[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1306
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1307
   apply(subgoal_tac "bsimp_ASEQ x1 (bsimp r1) (bsimp r2) = ASEQ x1 (bsimp r1) (bsimp r2)")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1308
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1309
  apply (smt b3 bnullable.elims(2) bsimp_ASEQ.simps(17) bsimp_ASEQ.simps(19) bsimp_ASEQ.simps(20) bsimp_ASEQ.simps(21) bsimp_ASEQ.simps(22) bsimp_ASEQ.simps(24) bsimp_ASEQ.simps(25) bsimp_ASEQ.simps(26) bsimp_ASEQ.simps(27) bsimp_ASEQ.simps(29) bsimp_ASEQ.simps(30) bsimp_ASEQ.simps(31))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1310
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1311
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1312
  apply(subst q3[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1313
   apply simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1314
  using b3 qq4 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1315
  apply(subst qs3)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1316
   apply simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1317
  using k1 by blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1318
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1319
thm bmkeps_retrieve bmkeps_simp bder_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1320
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1321
lemma bmkeps_bder_AALTs:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1322
  assumes "\<exists>r \<in> set rs. bnullable (bder c r)" 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1323
  shows "bmkeps (bder c (bsimp_AALTs bs rs)) = bmkeps (bsimp_AALTs bs (map (bder c) rs))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1324
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1325
  apply(induct rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1326
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1327
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1328
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1329
  apply(case_tac rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1330
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1331
  apply (metis (full_types) Prf_injval bder_retrieve bmkeps_retrieve bnullable_correctness erase_bder erase_fuse mkeps_nullable retrieve_fuse2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1332
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1333
  apply(case_tac  rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1334
   apply(simp_all)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1335
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1336
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1337
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1338
fun extr :: "arexp  \<Rightarrow> (bit list) set" where
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1339
  "extr (AONE bs) = {bs}"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1340
| "extr (ACHAR bs c) = {bs}"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1341
| "extr (AALTs bs (r#rs)) = 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1342
     {bs @ bs' | bs'.  bs' \<in> extr r} \<union>
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1343
     {bs @ bs' | bs'.  bs' \<in> extr (AALTs [] rs)}"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1344
| "extr (ASEQ bs r1 r2) = 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1345
     {bs @ bs1 @ bs2 | bs1 bs2. bs1 \<in> extr r1 \<and> bs2 \<in> extr r2}"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1346
| "extr (ASTAR bs r) = {bs @ [S]} \<union>
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1347
     {bs @ [Z] @ bs1 @ bs2 | bs1 bs2. bs1 \<in> extr r \<and> bs2 \<in> extr (ASTAR  [] r)}"
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1348
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1349
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1350
lemma MAIN_decode:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1351
  assumes "\<Turnstile> v : ders s r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1352
  shows "Some (flex r id s v) = decode (retrieve (bders_simp (intern r) s) v) r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1353
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1354
proof (induct s arbitrary: v rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1355
  case Nil
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1356
  have "\<Turnstile> v : ders [] r" by fact
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1357
  then have "\<Turnstile> v : r" by simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1358
  then have "Some v = decode (retrieve (intern r) v) r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1359
    using decode_code retrieve_code by auto
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1360
  then show "Some (flex r id [] v) = decode (retrieve (bders_simp (intern r) []) v) r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1361
    by simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1362
next
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1363
  case (snoc c s v)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1364
  have IH: "\<And>v. \<Turnstile> v : ders s r \<Longrightarrow> 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1365
     Some (flex r id s v) = decode (retrieve (bders_simp (intern r) s) v) r" by fact
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1366
  have asm: "\<Turnstile> v : ders (s @ [c]) r" by fact
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1367
  then have asm2: "\<Turnstile> injval (ders s r) c v : ders s r" 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1368
    by(simp add: Prf_injval ders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1369
  have "Some (flex r id (s @ [c]) v) = Some (flex r id s (injval (ders s r) c v))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1370
    by (simp add: flex_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1371
  also have "... = decode (retrieve (bders_simp (intern r) s) (injval (ders s r) c v)) r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1372
    using asm2 IH by simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1373
  also have "... = decode (retrieve (bder c (bders_simp (intern r) s)) v) r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1374
    using asm bder_retrieve ders_append 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1375
    apply -
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1376
    apply(drule_tac x="v" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1377
    apply(drule_tac x="c" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1378
    apply(drule_tac x="bders_simp (intern r) s" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1379
    apply(drule_tac  meta_mp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1380
     apply(simp add: ders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1381
     defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1382
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1383
    oops
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1384
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1385
fun vsimp :: "arexp \<Rightarrow> val \<Rightarrow> val"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1386
  where
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1387
  "vsimp (ASEQ _ (AONE _) r) (Seq v1 v2) = vsimp r v1"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1388
| "vsimp _ v = v" 
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1389
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1390
lemma fuse_vsimp:
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1391
  assumes "\<Turnstile> v : (erase r)"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1392
  shows "vsimp (fuse bs r) v = vsimp r v"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1393
  using assms
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1394
  apply(induct r arbitrary: v bs)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1395
       apply(simp_all)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1396
  apply(case_tac "\<exists>bs. r1 = AONE bs")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1397
   apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1398
   apply (metis Prf_elims(2) vsimp.simps(1))
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1399
  apply(erule Prf_elims)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1400
  apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1401
  apply(case_tac r1)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1402
       apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1403
  done  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1404
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1405
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1406
lemma retrieve_XXX0:
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1407
  assumes "\<And>r v. \<lbrakk>r \<in> set rs; \<Turnstile> v : erase r\<rbrakk> \<Longrightarrow> 
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1408
              \<exists>v'. \<Turnstile> v' : erase (bsimp r) \<and> retrieve (bsimp r) v' = retrieve r v"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1409
          "\<Turnstile> v : erase (AALTs bs rs)"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1410
        shows "\<exists>v'. \<Turnstile> v' : erase (bsimp_AALTs bs (flts (map bsimp rs))) \<and>
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1411
                retrieve (bsimp_AALTs bs (flts (map bsimp rs))) v' = retrieve (AALTs bs rs) v"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1412
  using assms
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1413
apply(induct rs arbitrary: bs v taking: size rule: measure_induct)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1414
  apply(case_tac x)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1415
   apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1416
  using Prf_elims(1) apply blast
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1417
  apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1418
  apply(case_tac list)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1419
   apply(simp_all)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1420
   apply(case_tac a)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1421
  apply(simp_all)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1422
  using Prf_elims(1) apply blast
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1423
       apply (metis erase.simps(2) fuse.simps(2) retrieve_fuse2)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1424
  using Prf_elims(5) apply force
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1425
     apply(erule Prf_elims)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1426
     apply(auto)[1]
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1427
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1428
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1429
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1430
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1431
  apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1432
       apply(erule Prf_elims)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1433
  using Prf_elims(1) apply b last
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1434
       apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1435
       apply (metis append_Ni l2 erase_fuse fuse.simps(4) retrieve_fuse2)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1436
  apply(case_tac rs)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1437
       apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1438
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1439
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1440
  oops
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1441
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1442
fun get where
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1443
  "get (Some v) = v"
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1444
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1445
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1446
lemma retrieve_XXX:
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1447
  assumes "\<Turnstile> v : erase r" 
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1448
  shows "\<Turnstile> get (decode (code v) (erase (bsimp r))) : erase (bsimp r)"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1449
  using assms
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1450
apply(induct r arbitrary: v)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1451
       apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1452
  using Prf_elims(1) apply auto[1]  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1453
      apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1454
  apply (simp add: decode_code)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1455
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1456
  apply (simp add: decode_code)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1457
    apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1458
    apply(erule Prf_elims)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1459
  apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1460
   apply(case_tac  "r1 = AZERO")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1461
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1462
  apply (meson Prf_elims(1) Prf_elims(2))
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1463
  apply(case_tac  "r2 = AZERO")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1464
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1465
     apply (meson Prf_elims(1) Prf_elims(2))
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1466
   apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1467
     apply(clarify)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1468
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1469
     apply(subst bsimp_ASEQ2)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1470
     apply(subst bsimp_ASEQ2)
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1471
     apply(simp add: erase_fuse)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1472
     apply(case_tac r1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1473
          apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1474
  using Prf_elims(4) apply fastforce
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1475
      apply(erule Prf_elims)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1476
      apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1477
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1478
      apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1479
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1480
  
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1481
     defer
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1482
     apply(subst bsimp_ASEQ1)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1483
  using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1484
  using L_bsimp_erase L_
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1485
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1486
lemma retrieve_XXX:
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1487
  assumes "\<Turnstile> v : erase r" 
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1488
  shows "\<Turnstile> (vsimp (bsimp r) v : erase (bsimp r)  \<and> retrieve (bsimp r) (vsimp (bsimp r) v) = retrieve r v"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1489
  using assms
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1490
  apply(induct r arbitrary: v)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1491
       apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1492
  using Prf_elims(1) apply blast
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1493
      apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1494
  using Prf_elims(4) apply fastforce
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1495
    apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1496
  apply blast
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1497
  apply simp
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1498
   apply(case_tac  "r1 = AZERO")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1499
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1500
  apply (meson Prf_elims(1) Prf_elims(2))
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1501
  apply(case_tac  "r2 = AZERO")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1502
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1503
     apply (meson Prf_elims(1) Prf_elims(2))
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1504
  apply(erule Prf_elims)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1505
  apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1506
   apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1507
     apply(clarify)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1508
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1509
    apply(subst bsimp_ASEQ2)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1510
     defer
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1511
     apply(subst bsimp_ASEQ1)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1512
  using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1513
  using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1514
      apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1515
    apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1516
  apply(drule_tac  x="v1" in meta_spec)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1517
  apply(drule_tac  x="v2" in meta_spec)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1518
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1519
  apply(clarify)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1520
     apply(rule_tac x="Seq v' v'a" in exI)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1521
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1522
  apply (metis Prf.intros(1) Prf_elims(1) bsimp_ASEQ1 erase.simps(1) retrieve.simps(6))
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1523
    prefer 3
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1524
  apply(drule_tac  x="v1" in meta_spec)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1525
  apply(drule_tac  x="v2" in meta_spec)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1526
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1527
    apply(clarify)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1528
    apply(rule_tac x="v'a" in exI)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1529
    apply(subst bsimp_ASEQ2)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1530
    apply (metis Prf_elims(4) append_assoc erase_fuse retrieve.simps(1) retrieve_fuse2)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1531
   prefer 2  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1532
   apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1533
  apply(case_tac "x2a")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1534
   apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1535
  using Prf_elims(1) apply blast
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1536
  apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1537
  apply(case_tac "list")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1538
   apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1539
  sorry  
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1540
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1541
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1542
lemma retrieve_XXX:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1543
  assumes "\<Turnstile> v : erase r" 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1544
  shows "\<exists>v'. \<Turnstile> v' : erase (bsimp r)  \<and> retrieve (bsimp r) v' = retrieve r v"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1545
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1546
  apply(induct r arbitrary: v)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1547
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1548
  using Prf_elims(1) apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1549
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1550
  using Prf_elims(4) apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1551
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1552
  apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1553
  apply simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1554
   apply(case_tac  "r1 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1555
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1556
  apply (meson Prf_elims(1) Prf_elims(2))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1557
  apply(case_tac  "r2 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1558
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1559
     apply (meson Prf_elims(1) Prf_elims(2))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1560
  apply(erule Prf_elims)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1561
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1562
   apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1563
     apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1564
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1565
    apply(subst bsimp_ASEQ2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1566
     defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1567
     apply(subst bsimp_ASEQ1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1568
  using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1569
  using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1570
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1571
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1572
  apply(drule_tac  x="v1" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1573
  apply(drule_tac  x="v2" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1574
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1575
  apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1576
     apply(rule_tac x="Seq v' v'a" in exI)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1577
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1578
  apply (metis Prf.intros(1) Prf_elims(1) bsimp_ASEQ1 erase.simps(1) retrieve.simps(6))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1579
    prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1580
  apply(drule_tac  x="v1" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1581
  apply(drule_tac  x="v2" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1582
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1583
    apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1584
    apply(rule_tac x="v'a" in exI)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1585
    apply(subst bsimp_ASEQ2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1586
    apply (metis Prf_elims(4) append_assoc erase_fuse retrieve.simps(1) retrieve_fuse2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1587
   prefer 2  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1588
   apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1589
  apply(case_tac "x2a")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1590
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1591
  using Prf_elims(1) apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1592
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1593
  apply(case_tac "list")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1594
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1595
  sorry
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1596
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1597
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1598
lemma TEST:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1599
  assumes "\<Turnstile> v : ders s r"
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1600
  shows "\<exists>v'. retrieve (bders (intern r) s) v' = retrieve (bsimp (bders (intern r) s)) v"
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1601
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1602
  apply(induct s arbitrary: r v rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1603
   apply(simp)
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1604
  
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1605
   defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1606
   apply(simp add: ders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1607
   apply(frule Prf_injval)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1608
  apply(drule_tac x="r" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1609
   apply(drule_tac x="injval (ders xs r) x v" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1610
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1611
   apply(simp add: bders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1612
   apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1613
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1614
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1615
  thm bder_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1616
  thm bmkeps_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1617
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1618
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1619
lemma bmkeps_simp2:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1620
  assumes "bnullable (bder c r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1621
  shows "bmkeps (bder c (bsimp r)) = bmkeps (bder c r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1622
  using  assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1623
  apply(induct r)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1624
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1625
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1626
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1627
  prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1628
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1629
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1630
   apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1631
     prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1632
     apply(case_tac "r1 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1633
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1634
   apply(case_tac "r2 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1635
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1636
     apply(case_tac "\<exists>bs. (bsimp r1) = AONE bs")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1637
      apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1638
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1639
      apply(subst bsimp_ASEQ2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1640
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1641
   apply(simp add: bmkeps_simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1642
  apply(simp add: bders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1643
  apply(drule_tac x="bder a r" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1644
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1645
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1646
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1647
    prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1648
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1649
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1650
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1651
   apply(case_tac x2a)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1652
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1653
  apply(simp add: )
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1654
  apply(subst k0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1655
   apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1656
    apply(case_tac list)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1657
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1658
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1659
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1660
   apply(case_tac  "r1=AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1661
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1662
   apply(case_tac  "r2=AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1663
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1664
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1665
   apply(case_tac  "\<exists>bs. r1=AONE bs")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1666
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1667
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1668
     apply(subst bsimp_ASEQ2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1669
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1670
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1671
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1672
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1673
  apply(subst  bmkeps_bder_AALTs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1674
   apply(case_tac x2a)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1675
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1676
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1677
   apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1678
    apply(subst  bmkeps_bder_AALTs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1679
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1680
   apply(case_tac a)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1681
  apply(simp_all)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1682
   apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1683
    apply(case_tac list)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1684
         apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1685
        apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1686
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1687
     prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1688
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1689
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1690
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1691
lemma bbs0:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1692
  shows "blexer_simp r [] = blexer r []"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1693
  apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1694
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1695
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1696
lemma bbs1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1697
  shows "blexer_simp r [c] = blexer r [c]"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1698
  apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1699
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1700
    defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1701
  using b3 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1702
  using b3 apply auto[1]  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1703
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1704
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1705
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1706
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1707
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1708
lemma bbs1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1709
  shows "blexer_simp r [c1, c2] = blexer r [c1, c2]"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1710
  apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1711
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1712
    defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1713
  apply (metis L_bsimp_erase bnullable_correctness der_correctness erase_bder lexer.simps(1) lexer_correct_None option.distinct(1))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1714
  apply (metis L_bsimp_erase bnullable_correctness der_correctness erase_bder lexer.simps(1) lexer_correct_None option.distinct(1))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1715
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1716
  using b3 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1717
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1718
  using b3 bnullable_correctness apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1719
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1720
  using b3 bnullable_correctness mkeps_nullable apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1721
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1722
  using bnullable_correctness apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1723
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1724
  using bnullable_correctness mkeps_nullable apply force
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1725
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1726
  using bder_retrieve bmkeps_simp bmkeps_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1727
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1728
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1729
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1730
lemma bsimp_retrieve_bder:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1731
  assumes "\<Turnstile> v : der c (erase r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1732
  shows "retrieve (bder c r) v = retrieve (bsimp (bder c r)) v"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1733
  thm bder_retrieve bmkeps_simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1734
  apply(induct  r arbitrary: c v)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1735
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1736
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1737
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1738
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1739
     apply(case_tac "bsimp (bder c r1) = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1740
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1741
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1742
    prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1743
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1744
  apply(auto elim!: Prf_elims)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1745
    apply(case_tac "(bsimp (fuse [Z] (bder c r))) = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1746
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1747
     apply (metis L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) erase.simps(1) erase_bder erase_fuse)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1748
    apply(case_tac "\<exists>bs. bsimp (fuse [Z] (bder c r)) = AONE bs")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1749
     apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1750
     apply(subgoal_tac "L (der c (erase r)) = {[]}")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1751
      prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1752
      apply (metis L.simps(2) L_bsimp_erase erase.simps(2) erase_bder erase_fuse)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1753
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1754
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1755
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1756
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1757
    apply(subst bsimp_ASEQ1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1758
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1759
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1760
  apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1761
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1762
     prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1763
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1764
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1765
lemma oo:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1766
  shows "(case (blexer (der c r) s) of None \<Rightarrow> None | Some v \<Rightarrow> Some (injval r c v)) = blexer r (c # s)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1767
  apply(simp add: blexer_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1768
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1769
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1770
lemma oo2a:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1771
  assumes "\<forall>r. bmkeps (bders_simp r s) = bmkeps (bders r s)" "c # s \<in> L r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1772
          "bnullable (bders_simp (bsimp (bder c (intern r))) s)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1773
  shows "(case (blexer_simp (der c r) s) of None \<Rightarrow> None | Some v \<Rightarrow> Some (injval r c v)) = blexer_simp r (c # s)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1774
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1775
  apply(simp add: blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1776
  apply(auto  split: option.split)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1777
    apply (metis blexer_correctness blexer_def lexer.simps(2) lexer_correct_None option.simps(4))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1778
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1779
  apply (metis L_bders_simp L_bsimp_erase Posix1(1) Posix_mkeps bnullable_correctness ders_correctness erase_bder erase_bders erase_intern lexer.simps(1) lexer_correct_None)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1780
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1781
  using L_bders_simp bnullable_correctness nullable_correctness apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1782
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1783
  thm bder_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1784
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1785
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1786
  apply(subst bder_retrieve[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1787
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1788
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1789
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1790
  apply(drule_tac x="bsimp (bder c (intern r))" in  spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1791
  apply(drule sym)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1792
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1793
   apply(subst blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1794
  apply(case_tac "bnullable (bders_simp (intern (der c r)) s)")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1795
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1796
  apply(auto split: option.split)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1797
  apply(subst oo)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1798
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1799
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1800
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1801
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1802
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1803
lemma oo3:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1804
  assumes "\<forall>r. bders r s = bders_simp r s"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1805
  shows "blexer_simp r (s @ [c]) = blexer r (s @ [c])"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1806
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1807
  apply(simp (no_asm) add: blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1808
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1809
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1810
  apply (metis L_bders_simp blexer_def bnullable_correctness lexer.simps(1) lexer_correct_None option.distinct(1))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1811
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1812
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1813
  using b3 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1814
  apply(simp add: blexer_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1815
  apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1816
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1817
  apply (metis (mono_tags, lifting) L_bders_simp Posix_mkeps append.right_neutral bders_simp.simps(1) bders_simp.simps(2) bders_simp_append bnullable_correctness lexer.simps(1) lexer_correct_None lexer_correctness(1) option.distinct(1))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1818
  apply(simp add: bders_append)     
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1819
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1820
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1821
lemma oo4:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1822
  assumes "\<forall>r. bmkeps (bders r s) = bmkeps (bders_simp r s)" "bnullable (bder c (bders r s))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1823
  shows "bmkeps (bders_simp r (s @ [c])) = bmkeps (bders r (s @ [c]))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1824
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1825
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1826
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1827
  apply (metis L_bders_simp bnullable_correctness der_correctness erase_bder lexer.simps(1) lexer_correct_None option.distinct(1))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1828
  apply(simp add: bders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1829
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1830
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1831
lemma oo4:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1832
  shows "blexer_simp r s = blexer r s"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1833
  apply(induct s arbitrary: r rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1834
   apply(simp only: blexer_simp_def blexer_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1835
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1836
  apply(simp only: blexer_simp_def blexer_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1837
  apply(subgoal_tac "bnullable (bders_simp (intern r) (xs @ [x])) = bnullable (bders (intern r) (xs @ [x]))")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1838
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1839
   apply (simp add: b4)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1840
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1841
  apply(rule impI)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1842
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1843
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1844
  using b3 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1845
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1846
  using b3 bnullable_correctness apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1847
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1848
  using b3 bnullable_correctness mkeps_nullable apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1849
  apply(simp add: bders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1850
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1851
  using bnullable_correctness apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1852
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1853
  using bnullable_correctness mkeps_nullable apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1854
  apply(subst erase_bder)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1855
  apply(case_tac "xs \<in> L")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1856
  apply(subst (asm) (2) bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1857
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1858
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1859
  thm bmkeps_retrieve bmkeps_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1860
  apply(subst bmkeps_retrieve[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1861
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1862
   apply (simp add: bnullable_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1863
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1864
   
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1865
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1866
  apply(induct s arbitrary: r rule: rev_induct) 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1867
   apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1868
  apply(rule oo3)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1869
  apply(simp (no_asm) add: blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1870
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1871
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1872
  apply (metis L_bders_simp blexer_def bnullable_correctness lexer.simps(1) lexer_correct_None option.distinct(1))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1873
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1874
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1875
  using b3 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1876
  apply(simp add: blexer_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1877
  apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1878
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1879
  apply (m etis (mono_tags, lifting) L_bders_simp Posix_mkeps append.right_neutral bders_simp.simps(1) bders_simp.simps(2) bders_simp_append bnullable_correctness lexer.simps(1) lexer_correct_None lexer_correctness(1) option.distinct(1))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1880
  apply(simp add: bders_append)     
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1881
  oops
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1882
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1883
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1884
lemma bnullable_simp:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1885
  assumes "s \<in> L (erase r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1886
  shows "bmkeps (bders r s) = bmkeps (bders_simp r s)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1887
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1888
  apply(induct s arbitrary: r rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1889
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1890
  apply(simp add: bders_append bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1891
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1892
  apply (metis L_bders_simp b3 bders_simp.simps(1) bders_simp.simps(2) bders_simp_append blexer_correctness blexer_def bnullable_correctness erase_bders erase_intern lexer.simps(1) lexer_correct_None lexer_correct_Some lexer_correctness(1))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1893
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1894
  apply (metis bders.simps(1) bders.simps(2) bders_append blexer_correctness blexer_def bnullable_correctness erase_bders erase_intern lexer_correct_Some option.distinct(1))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1895
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1896
  apply (metis L_bders_simp L_bsimp_erase Posix_mkeps bders_simp.simps(1) bders_simp.simps(2) bders_simp_append blexer_correctness blexer_def bnullable_correctness erase_bders erase_intern lexer.simps(1) lexer_correct_None lexer_correctness(2))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1897
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1898
  apply (metis bders.simps(1) bders.simps(2) bders_append blexer_correctness blexer_def bnullable_correctness erase_bder erase_bders erase_intern lexer_correct_Some mkeps_nullable option.distinct(1))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1899
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1900
  apply (metis L_bders_simp L_bsimp_erase Posix_mkeps bders_simp.simps(1) bders_simp.simps(2) bders_simp_append blexer_correctness blexer_def bnullable_correctness erase_bder erase_bders erase_intern lexer.simps(1) lexer_correct_None lexer_correctness(2) mkeps_nullable)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1901
    
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1902
  apply(drule_tac x="bder a r" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1903
  apply(drule_tac  meta_mp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1904
  apply (me tis erase_bder lexer.simps(2) lexer_correct_None option.simps(4))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1905
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1906
  oops
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1907
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1908
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1909
lemma
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1910
  shows "blexer r s = blexer_simp r s"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1911
  apply(induct s arbitrary: r rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1912
   apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1913
  apply(case_tac "xs @ [x] \<in> L r")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1914
   defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1915
   apply(subgoal_tac "blexer (ders xs r) [x] = None")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1916
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1917
    apply(subst blexer_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1918
    apply(simp (no_asm) add: lexer_correct_None)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1919
    apply(simp add: nullable_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1920
    apply(simp add: der_correctness ders_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1921
  apply(simp add: Der_def Ders_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1922
apply(subgoal_tac "blexer r (xs @ [x]) = None")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1923
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1924
    apply (simp add: blexer_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1925
  using lexer_correct_None apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1926
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1927
   apply(subgoal_tac "blexer_simp (ders xs r) [x] = None")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1928
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1929
  apply (metis L_bders_simp Posix_injval Posix_mkeps bders.simps(2) blexer_correctness blexer_simp_def bnullable_correctness ders.simps(1) erase_bder erase_bders erase_intern lexer_correct_None lexer_correctness(2))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1930
   apply(subgoal_tac "[] \<notin> L (erase (bders_simp (intern r) (xs @ [x])))")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1931
  prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1932
  apply(metis L_bders_simp Posix_injval bders.simps(2) blexer_correctness ders.simps(1) ders_append erase_bder erase_bders erase_intern lexer_correct_None lexer_correctness(2))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1933
  using blexer_simp_def bnullable_correctness lexer_correct_None apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1934
(* case xs @ [x] \<in> L r *)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1935
  apply(subgoal_tac "\<exists>v. blexer (ders xs r) [x] = Some v \<and> [x] \<in> (ders xs r) \<rightarrow> v")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1936
   prefer 2  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1937
  using blexer_correctness lexer_correct_Some apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1938
    apply (simp add: Posix_injval Posix_mkeps)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1939
  apply (metis ders.simps(1) ders.simps(2) ders_append lexer_correct_None lexer_flex)    
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1940
  apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1941
  apply(subgoal_tac "blexer_simp (ders xs r) [x] = Some v")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1942
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1943
   apply(simp add: blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1944
   apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1945
    apply (metis bders.simps(1) bders.simps(2) blexer_def bmkeps_simp option.simps(3))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1946
  using b3 blexer_def apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1947
  apply(subgoal_tac "blexer_simp (ders xs r) [x] = blexer_simp r (xs @ [x])")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1948
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1949
   apply(simp add: blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1950
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1951
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1952
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1953
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1954
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1955
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1956
  apply(subst blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1957
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1958
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1959
  apply(drule_tac x="der a r" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1960
  apply(subst blexer_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1961
   apply(subgoal_tac "bnullable (bders (intern r) (a # s))")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1962
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1963
    apply (metis Posix_injval blexer_correctness blexer_def lexer_correctness(2))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1964
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1965
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1966
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1967
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1968
lemma
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1969
  shows "blexer r s = blexer_simp r s"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1970
  apply(induct s arbitrary: r)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1971
   apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1972
  apply(case_tac "s \<in> L (der a r)")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1973
   defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1974
   apply(subgoal_tac "blexer (der a r) s = None")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1975
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1976
    apply (simp add: blexer_correctness lexer_correct_None)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1977
apply(subgoal_tac "blexer r (a # s) = None")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1978
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1979
    apply (simp add: blexer_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1980
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1981
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1982
   apply(subst blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1983
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1984
  apply(drule_tac  x="der a r" in  meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1985
   apply(subgoal_tac "s \<notin> L(erase (bder a (intern  r)))")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1986
  prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1987
    apply simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1988
   
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1989
   apply(simp only:)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1990
   apply(subst blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1991
   apply(subgoal_tac "\<not> bnullable (bders_simp (intern r) (a # s))")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1992
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1993
   apply(subst bnullable_correctness[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1994
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1995
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1996
295
c6ec5f369037 updated
Christian Urban <urbanc@in.tum.de>
parents: 293
diff changeset
  1997
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  1998
end