thys/BitCoded.thy
author Christian Urban <urbanc@in.tum.de>
Tue, 14 May 2019 21:43:11 +0100
changeset 322 22e34f93cd5d
parent 318 43e070803c1c
child 323 09ce1cdb70ab
permissions -rw-r--r--
updaed good
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
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   109
fun 
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   110
  erase :: "arexp \<Rightarrow> rexp"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   111
where
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   112
  "erase AZERO = ZERO"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   113
| "erase (AONE _) = ONE"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   114
| "erase (ACHAR _ c) = CHAR c"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   115
| "erase (AALTs _ []) = ZERO"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   116
| "erase (AALTs _ [r]) = (erase r)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   117
| "erase (AALTs bs (r#rs)) = ALT (erase r) (erase (AALTs bs rs))"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   118
| "erase (ASEQ _ r1 r2) = SEQ (erase r1) (erase r2)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   119
| "erase (ASTAR _ r) = STAR (erase r)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   120
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   121
fun nonalt :: "arexp \<Rightarrow> bool"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   122
  where
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   123
  "nonalt (AALTs bs2 rs) = False"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   124
| "nonalt r = True"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   125
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   126
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   127
fun good :: "arexp \<Rightarrow> bool" where
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   128
  "good AZERO = False"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   129
| "good (AONE cs) = True" 
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   130
| "good (ACHAR cs c) = True"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   131
| "good (AALTs cs []) = False"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   132
| "good (AALTs cs (r#rs)) = (\<forall>r' \<in> set (r#rs). good r')"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   133
| "good (ASEQ cs r1 r2) = (good r1 \<and> good r2)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   134
| "good (ASTAR cs r) = True"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   135
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   136
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   137
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   138
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   139
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
   140
  "fuse bs AZERO = AZERO"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   141
| "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
   142
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   143
| "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
   144
| "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
   145
| "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
   146
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   147
lemma fuse_append:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   148
  shows "fuse (bs1 @ bs2) r = fuse bs1 (fuse bs2 r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   149
  apply(induct r)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   150
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   151
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   152
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   153
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   154
fun intern :: "rexp \<Rightarrow> arexp" where
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   155
  "intern ZERO = AZERO"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   156
| "intern ONE = AONE []"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   157
| "intern (CHAR c) = ACHAR [] c"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   158
| "intern (ALT r1 r2) = AALT [] (fuse [Z] (intern r1)) 
295
c6ec5f369037 updated
Christian Urban <urbanc@in.tum.de>
parents: 293
diff changeset
   159
                                (fuse [S]  (intern r2))"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   160
| "intern (SEQ r1 r2) = ASEQ [] (intern r1) (intern r2)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   161
| "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
   162
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   163
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   164
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
   165
  "retrieve (AONE bs) Void = bs"
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   166
| "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
   167
| "retrieve (AALTs bs [r]) v = bs @ retrieve r v" 
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   168
| "retrieve (AALTs bs (r#rs)) (Left v) = bs @ retrieve r v"
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   169
| "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
   170
| "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
   171
| "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
   172
| "retrieve (ASTAR bs r) (Stars (v#vs)) = 
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   173
     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
   174
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   175
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   176
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   177
fun
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   178
 bnullable :: "arexp \<Rightarrow> bool"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   179
where
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   180
  "bnullable (AZERO) = False"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   181
| "bnullable (AONE bs) = True"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   182
| "bnullable (ACHAR bs c) = False"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   183
| "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   184
| "bnullable (ASEQ bs r1 r2) = (bnullable r1 \<and> bnullable r2)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   185
| "bnullable (ASTAR bs r) = True"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   186
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   187
fun 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   188
  bmkeps :: "arexp \<Rightarrow> bit list"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   189
where
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   190
  "bmkeps(AONE bs) = bs"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   191
| "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
   192
| "bmkeps(AALTs bs [r]) = bs @ (bmkeps r)"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   193
| "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
   194
| "bmkeps(ASTAR bs r) = bs @ [S]"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   195
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   196
159
940530087f30 updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 154
diff changeset
   197
fun
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   198
 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
   199
where
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   200
  "bder c (AZERO) = AZERO"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   201
| "bder c (AONE bs) = AZERO"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   202
| "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
   203
| "bder c (AALTs bs rs) = AALTs bs (map (bder c) rs)"
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   204
| "bder c (ASEQ bs r1 r2) = 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   205
     (if bnullable r1
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   206
      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
   207
      else ASEQ bs (bder c r1) r2)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   208
| "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
   209
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   210
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   211
fun 
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   212
  bders :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   213
where
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   214
  "bders r [] = r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   215
| "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
   216
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   217
lemma bders_append:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   218
  "bders r (s1 @ s2) = bders (bders r s1) s2"
287
95b3880d428f updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   219
  apply(induct s1 arbitrary: r s2)
95b3880d428f updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   220
  apply(simp_all)
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
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   223
lemma bnullable_correctness:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   224
  shows "nullable (erase r) = bnullable r"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   225
  apply(induct r rule: erase.induct)
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   226
  apply(simp_all)
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
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   229
lemma erase_fuse:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   230
  shows "erase (fuse bs r) = erase r"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   231
  apply(induct r rule: erase.induct)
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   232
  apply(simp_all)
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
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   235
lemma erase_intern [simp]:
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   236
  shows "erase (intern r) = r"
287
95b3880d428f updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   237
  apply(induct r)
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   238
  apply(simp_all add: erase_fuse)
287
95b3880d428f updated
Christian Urban <urbanc@in.tum.de>
parents: 286
diff changeset
   239
  done
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   240
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   241
lemma erase_bder [simp]:
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   242
  shows "erase (bder a r) = der a (erase r)"
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   243
  apply(induct r rule: erase.induct)
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   244
  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
   245
  done
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   246
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   247
lemma erase_bders [simp]:
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   248
  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
   249
  apply(induct s arbitrary: r )
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   250
  apply(simp_all)
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   251
  done
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   252
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   253
lemma retrieve_encode_STARS:
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   254
  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
   255
  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
   256
  using assms
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   257
  apply(induct vs)
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   258
  apply(simp_all)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   259
  done
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   260
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   261
lemma retrieve_fuse2:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   262
  assumes "\<Turnstile> v : (erase r)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   263
  shows "retrieve (fuse bs r) v = bs @ retrieve r v"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   264
  using assms
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   265
  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
   266
         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
   267
   defer
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   268
  using retrieve_encode_STARS
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   269
   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
   270
   apply(case_tac vs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   271
    apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   272
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   273
  (* AALTs  case *)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   274
  apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   275
  apply(case_tac x2a)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   276
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   277
   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
   278
  apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   279
   apply(case_tac list)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   280
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   281
  apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   282
  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
   283
  done
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   284
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   285
lemma retrieve_fuse:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   286
  assumes "\<Turnstile> v : r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   287
  shows "retrieve (fuse bs (intern r)) v = bs @ retrieve (intern r) v"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   288
  using assms 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   289
  by (simp_all add: retrieve_fuse2)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   290
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   291
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   292
lemma retrieve_code:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   293
  assumes "\<Turnstile> v : r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   294
  shows "code v = retrieve (intern r) v"
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   295
  using assms
311
8b8db9558ecf updated
Christian Urban <urbanc@in.tum.de>
parents: 307
diff changeset
   296
  apply(induct v r )
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   297
  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
   298
  done
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   299
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   300
lemma r:
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   301
  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
   302
  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
   303
  using assms
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   304
  apply(induct rs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   305
   apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   306
  done
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   307
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   308
lemma r0:
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   309
  assumes "bnullable a" 
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   310
  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
   311
  using assms
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   312
  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
   313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   314
lemma r1:
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   315
  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
   316
  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
   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)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   319
   apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   320
  done
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   321
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   322
lemma r2:
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   323
  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
   324
  shows "bnullable (AALTs bs rs)"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   325
  using assms
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   326
  apply(induct rs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   327
   apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   328
  done
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   329
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   330
lemma  r3:
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   331
  assumes "\<not> bnullable r" 
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   332
          " \<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
   333
  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
   334
         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
   335
  using assms
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   336
  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
   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(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   339
  using bnullable_correctness apply blast
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   340
    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
   341
   apply(subst retrieve_fuse2[symmetric])
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   342
  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
   343
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   344
  apply(case_tac "bnullable a")
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   345
  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
   346
  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
   347
  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
   348
  apply(drule meta_mp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   349
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   350
  apply(drule meta_mp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   351
   apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   352
  apply(subst retrieve_fuse2[symmetric])
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   353
  apply(case_tac rs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   354
    apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   355
   apply(auto)[1]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   356
      apply (simp add: bnullable_correctness)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   357
  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
   358
    apply (simp add: bnullable_correctness)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   359
  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
   360
  apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   361
  done
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   362
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   363
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   364
lemma t: 
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   365
  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
   366
          "nullable (erase (AALTs bs rs))"
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   367
  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
   368
  using assms
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   369
  apply(induct rs arbitrary: bs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   370
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   371
  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
   372
   apply(case_tac rs)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   373
     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
   374
   apply(subst r1)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   375
     apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   376
    apply(rule r2)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   377
     apply(assumption)
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
   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
   380
   apply(drule meta_mp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   381
    apply(auto)[1]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   382
   prefer 2
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   383
  apply(case_tac "bnullable a")
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   384
    apply(subst r0)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   385
     apply blast
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   386
    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
   387
  prefer 2
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   388
  using bnullable_correctness apply blast
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   389
  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
   390
  apply(subst r1)
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
  using r2 apply blast
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   393
  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
   394
   apply(drule meta_mp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   395
    apply(auto)[1]
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   396
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   397
  using r3 apply blast
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   398
  apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   399
  using r3 by blast
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   400
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   401
lemma bmkeps_retrieve:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   402
  assumes "nullable (erase r)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   403
  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
   404
  using assms
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   405
  apply(induct r)
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   406
         apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   407
        apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   408
       apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   409
    apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   410
   defer
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   411
   apply(simp)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   412
  apply(rule t)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   413
   apply(auto)
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   414
  done
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   415
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   416
lemma bder_retrieve:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   417
  assumes "\<Turnstile> v : der c (erase r)"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   418
  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
   419
  using assms
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   420
  apply(induct r arbitrary: v rule: erase.induct)
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   421
         apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   422
         apply(erule Prf_elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   423
        apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   424
        apply(erule Prf_elims) 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   425
        apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   426
      apply(case_tac "c = ca")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   427
       apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   428
       apply(erule Prf_elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   429
       apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   430
      apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   431
       apply(erule Prf_elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   432
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   433
      apply(erule Prf_elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   434
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   435
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   436
  apply(rename_tac "r\<^sub>1" "r\<^sub>2" rs v)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   437
    apply(erule Prf_elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   438
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   439
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   440
    apply(case_tac rs)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   441
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   442
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   443
  apply (smt Prf_elims(3) injval.simps(2) injval.simps(3) retrieve.simps(4) retrieve.simps(5) same_append_eq)
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   444
   apply(simp)
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   445
   apply(case_tac "nullable (erase r1)")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   446
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   447
  apply(erule Prf_elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   448
     apply(subgoal_tac "bnullable r1")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   449
  prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   450
  using bnullable_correctness apply blast
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   451
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   452
     apply(erule Prf_elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   453
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   454
   apply(subgoal_tac "bnullable r1")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   455
  prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   456
  using bnullable_correctness apply blast
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   457
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   458
    apply(simp add: retrieve_fuse2)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   459
    apply(simp add: bmkeps_retrieve)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   460
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   461
   apply(erule Prf_elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   462
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   463
  using bnullable_correctness apply blast
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   464
  apply(rename_tac bs r v)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   465
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   466
  apply(erule Prf_elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   467
     apply(clarify)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   468
  apply(erule Prf_elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   469
  apply(clarify)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   470
  apply(subst injval.simps)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   471
  apply(simp del: retrieve.simps)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   472
  apply(subst retrieve.simps)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   473
  apply(subst retrieve.simps)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   474
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   475
  apply(simp add: retrieve_fuse2)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   476
  done
313
3b8e3a156200 adapted the Bitcoded correctness proof to using AALTs
Christian Urban <urbanc@in.tum.de>
parents: 311
diff changeset
   477
  
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   478
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   479
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   480
lemma MAIN_decode:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   481
  assumes "\<Turnstile> v : ders s r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   482
  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
   483
  using assms
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   484
proof (induct s arbitrary: v rule: rev_induct)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   485
  case Nil
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   486
  have "\<Turnstile> v : ders [] r" by fact
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   487
  then have "\<Turnstile> v : r" by simp
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   488
  then have "Some v = decode (retrieve (intern r) v) r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   489
    using decode_code retrieve_code by auto
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   490
  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
   491
    by simp
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   492
next
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   493
  case (snoc c s v)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   494
  have IH: "\<And>v. \<Turnstile> v : ders s r \<Longrightarrow> 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   495
     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
   496
  have asm: "\<Turnstile> v : ders (s @ [c]) r" by fact
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   497
  then have asm2: "\<Turnstile> injval (ders s r) c v : ders s r" 
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   498
    by (simp add: Prf_injval ders_append)
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   499
  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
   500
    by (simp add: flex_append)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   501
  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
   502
    using asm2 IH by simp
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   503
  also have "... = decode (retrieve (bder c (bders (intern r) s)) v) r"
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   504
    using asm by (simp_all add: bder_retrieve ders_append)
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   505
  finally show "Some (flex r id (s @ [c]) v) = 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   506
                 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
   507
qed
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   508
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   509
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   510
definition blex where
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   511
 "blex a s \<equiv> if bnullable (bders a s) then Some (bmkeps (bders a s)) else None"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   512
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   513
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
   514
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   515
definition blexer where
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   516
 "blexer r s \<equiv> if bnullable (bders (intern r) s) then 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   517
                decode (bmkeps (bders (intern r) s)) r else None"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   518
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   519
lemma blexer_correctness:
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   520
  shows "blexer r s = lexer r s"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   521
proof -
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   522
  { define bds where "bds \<equiv> bders (intern r) s"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   523
    define ds  where "ds \<equiv> ders s r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   524
    assume asm: "nullable ds"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   525
    have era: "erase bds = ds" 
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   526
      unfolding ds_def bds_def by simp
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   527
    have mke: "\<Turnstile> mkeps ds : ds"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   528
      using asm by (simp add: mkeps_nullable)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   529
    have "decode (bmkeps bds) r = decode (retrieve bds (mkeps ds)) r"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   530
      using bmkeps_retrieve
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   531
      using asm era by (simp add: bmkeps_retrieve)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   532
    also have "... =  Some (flex r id s (mkeps ds))"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   533
      using mke by (simp_all add: MAIN_decode ds_def bds_def)
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   534
    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
   535
      unfolding bds_def ds_def .
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   536
  }
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   537
  then show "blexer r s = lexer r s"
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   538
    unfolding blexer_def lexer_flex
293
1a4e5b94293b updated
Christian Urban <urbanc@in.tum.de>
parents: 289
diff changeset
   539
    apply(subst bnullable_correctness[symmetric])
1a4e5b94293b updated
Christian Urban <urbanc@in.tum.de>
parents: 289
diff changeset
   540
    apply(simp)
1a4e5b94293b updated
Christian Urban <urbanc@in.tum.de>
parents: 289
diff changeset
   541
    done
289
807acaf7f599 updated
Christian Urban <urbanc@in.tum.de>
parents: 288
diff changeset
   542
qed
286
804fbb227568 added proof for bitcoded algorithm
Christian Urban <urbanc@in.tum.de>
parents: 256
diff changeset
   543
295
c6ec5f369037 updated
Christian Urban <urbanc@in.tum.de>
parents: 293
diff changeset
   544
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   545
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
   546
  where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   547
  "distinctBy [] f acc = []"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   548
| "distinctBy (x#xs) f acc = 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   549
     (if (f x) \<in> acc then distinctBy xs f acc 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   550
      else x # (distinctBy xs f ({f x} \<union> acc)))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   551
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   552
fun flts :: "arexp list \<Rightarrow> arexp list"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   553
  where 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   554
  "flts [] = []"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   555
| "flts (AZERO # rs) = flts rs"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   556
| "flts ((AALTs bs  rs1) # rs) = (map (fuse bs) rs1) @ flts rs"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   557
| "flts (r1 # rs) = r1 # flts rs"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   558
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   559
fun bsimp_ASEQ :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp \<Rightarrow> arexp"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   560
  where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   561
  "bsimp_ASEQ _ AZERO _ = AZERO"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   562
| "bsimp_ASEQ _ _ AZERO = AZERO"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   563
| "bsimp_ASEQ bs1 (AONE bs2) r2 = fuse (bs1 @ bs2) r2"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   564
| "bsimp_ASEQ bs1 r1 r2 = ASEQ  bs1 r1 r2"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   565
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   566
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   567
fun bsimp_AALTs :: "bit list \<Rightarrow> arexp list \<Rightarrow> arexp"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   568
  where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   569
  "bsimp_AALTs _ [] = AZERO"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   570
| "bsimp_AALTs bs1 [r] = fuse bs1 r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   571
| "bsimp_AALTs bs1 rs = AALTs bs1 rs"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   572
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   573
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   574
fun bsimp :: "arexp \<Rightarrow> arexp" 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   575
  where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   576
  "bsimp (ASEQ bs1 r1 r2) = bsimp_ASEQ bs1 (bsimp r1) (bsimp r2)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   577
| "bsimp (AALTs bs1 rs) = bsimp_AALTs bs1 (flts (map bsimp rs))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   578
| "bsimp r = r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   579
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   580
value "good (AALTs [] [AALTs [] [AONE []]])"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   581
value "bsimp (AALTs [] [AONE [], AALTs [] [AONE []]])"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   582
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   583
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   584
fun 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   585
  bders_simp :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   586
where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   587
  "bders_simp r [] = r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   588
| "bders_simp r (c # s) = bders_simp (bsimp (bder c r)) s"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   589
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   590
definition blexer_simp where
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   591
 "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
   592
                decode (bmkeps (bders_simp (intern r) s)) r else None"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   593
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   594
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   595
lemma asize0:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   596
  shows "0 < asize r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   597
  apply(induct  r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   598
       apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   599
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   600
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 bders_simp_append:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   603
  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
   604
  apply(induct s1 arbitrary: r s2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   605
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   606
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   607
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   608
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   609
lemma bsimp_ASEQ_size:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   610
  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
   611
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   612
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   613
  done
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   614
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   615
lemma fuse_size:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   616
  shows "asize (fuse bs r) = asize r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   617
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   618
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   619
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   620
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   621
lemma flts_size:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   622
  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
   623
  apply(induct rs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   624
        apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   625
  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
   626
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   627
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   628
lemma bsimp_AALTs_size:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   629
  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
   630
  apply(induct rs rule: bsimp_AALTs.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   631
  apply(auto simp add: fuse_size)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   632
  done
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   633
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   634
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   635
lemma bsimp_size:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   636
  shows "asize (bsimp r) \<le> asize r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   637
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   638
       apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   639
   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
   640
  apply(rule le_trans)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   641
   apply(rule bsimp_AALTs_size)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   642
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   643
   apply(rule le_trans)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   644
   apply(rule flts_size)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   645
  by (simp add: sum_list_mono)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   646
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   647
lemma bsimp_asize0:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   648
  shows "(\<Sum>x\<leftarrow>rs. asize (bsimp x)) \<le> sum_list (map asize rs)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   649
  apply(induct rs)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   650
   apply(auto)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   651
  by (simp add: add_mono bsimp_size)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   652
  
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
   653
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   654
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   655
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   656
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   657
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   658
lemma bsimp_AALTs_size2:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   659
  assumes "\<forall>r \<in> set  rs. nonalt r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   660
  shows "asize (bsimp_AALTs bs rs) \<ge> sum_list (map asize rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   661
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   662
  apply(induct rs rule: bsimp_AALTs.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   663
    apply(simp_all add: fuse_size)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   664
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   665
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   666
lemma qq:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   667
  shows "map (asize \<circ> fuse bs) rs = map asize rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   668
  apply(induct rs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   669
   apply(auto simp add: fuse_size)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   670
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   671
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   672
lemma flts_size2:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   673
  assumes "\<exists>bs rs'. AALTs bs  rs' \<in> set rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   674
  shows "sum_list (map asize (flts rs)) < sum_list (map asize rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   675
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   676
  apply(induct rs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   677
   apply(auto simp add: qq)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   678
   apply (simp add: flts_size less_Suc_eq_le)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   679
  apply(case_tac a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   680
       apply(auto simp add: qq)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   681
   prefer 2
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   682
   apply (simp add: flts_size le_imp_less_Suc)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   683
  using less_Suc_eq by auto
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   684
  
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   685
lemma L_bsimp_ASEQ:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   686
  "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
   687
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   688
  apply(simp_all)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   689
  by (metis erase_fuse fuse.simps(4))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   690
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   691
lemma L_bsimp_AALTs:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   692
  "L (erase (AALTs bs rs)) = L (erase (bsimp_AALTs bs rs))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   693
  apply(induct bs rs rule: bsimp_AALTs.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   694
  apply(simp_all add: erase_fuse)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   695
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   696
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   697
lemma L_erase_AALTs:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   698
  shows "L (erase (AALTs bs rs)) = \<Union> (L ` erase ` (set rs))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   699
  apply(induct rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   700
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   701
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   702
  apply(case_tac rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   703
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   704
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   705
  done
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 L_erase_flts:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   708
  shows "\<Union> (L ` erase ` (set (flts rs))) = \<Union> (L ` erase ` (set rs))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   709
  apply(induct rs rule: flts.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   710
        apply(simp_all)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   711
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   712
  using L_erase_AALTs erase_fuse apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   713
  by (simp add: L_erase_AALTs erase_fuse)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   714
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 L_bsimp_erase:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   717
  shows "L (erase r) = L (erase (bsimp r))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   718
  apply(induct r)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   719
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   720
  apply(simp)
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(auto simp add: Sequ_def)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   723
  apply(subst L_bsimp_ASEQ[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   724
  apply(auto simp add: Sequ_def)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   725
  apply(subst (asm)  L_bsimp_ASEQ[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   726
  apply(auto simp add: Sequ_def)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   727
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   728
   apply(subst L_bsimp_AALTs[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   729
   defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   730
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   731
  apply(subst (2)L_erase_AALTs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   732
  apply(subst L_erase_flts)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   733
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   734
   apply (simp add: L_erase_AALTs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   735
  using L_erase_AALTs by blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   736
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   737
lemma bsimp_ASEQ0:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   738
  shows "bsimp_ASEQ bs r1 AZERO = AZERO"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   739
  apply(induct r1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   740
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   741
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   742
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   743
314
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 bsimp_ASEQ1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   746
  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
   747
  shows "bsimp_ASEQ bs r1 r2 = ASEQ bs r1 r2"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   748
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   749
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   750
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   751
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   752
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   753
lemma bsimp_ASEQ2:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   754
  shows "bsimp_ASEQ bs (AONE bs1) r2 = fuse (bs @ bs1) r2"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   755
  apply(induct r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   756
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   757
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   758
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   759
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   760
lemma L_bders_simp:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   761
  shows "L (erase (bders_simp r s)) = L (erase (bders r s))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   762
  apply(induct s arbitrary: r rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   763
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   764
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   765
  apply(simp add: ders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   766
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   767
  apply(simp add: L_bsimp_erase[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   768
  by (simp add: der_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   769
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   770
lemma b1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   771
  "bsimp_ASEQ bs1 (AONE bs) r =  fuse (bs1 @ bs) r" 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   772
  apply(induct r)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   773
       apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   774
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   775
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   776
lemma b2:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   777
  assumes "bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   778
  shows "bmkeps (fuse bs r) = bs @ bmkeps r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   779
  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
   780
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   781
lemma b3:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   782
  shows "bnullable r = bnullable (bsimp r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   783
  using L_bsimp_erase bnullable_correctness nullable_correctness by auto
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   784
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   785
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   786
lemma b4:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   787
  shows "bnullable (bders_simp r s) = bnullable (bders r s)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   788
  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
   789
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   790
lemma q1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   791
  assumes "\<forall>r \<in> set rs. bmkeps(bsimp r) = bmkeps r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   792
  shows "map (\<lambda>r. bmkeps(bsimp r)) rs = map bmkeps rs"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   793
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   794
  apply(induct rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   795
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   796
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   797
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   798
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   799
lemma q3:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   800
  assumes "\<exists>r \<in> set rs. bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   801
  shows "bmkeps (AALTs bs rs) = bmkeps (bsimp_AALTs bs rs)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   802
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   803
  apply(induct bs rs rule: bsimp_AALTs.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   804
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   805
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   806
  apply (simp add: b2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   807
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   808
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   809
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   810
lemma qq1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   811
  assumes "\<exists>r \<in> set rs. bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   812
  shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   813
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   814
  apply(induct rs arbitrary: rs1 bs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   815
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   816
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   817
  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
   818
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   819
lemma qq2:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   820
  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
   821
  shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs1)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   822
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   823
  apply(induct rs arbitrary: rs1 bs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   824
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   825
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   826
  by (metis append_assoc in_set_conv_decomp r1 r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   827
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   828
lemma qq3:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   829
  shows "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   830
  apply(induct rs arbitrary: bs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   831
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   832
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   833
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
   834
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   835
lemma fuse_empty:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   836
  shows "fuse [] r = r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   837
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   838
       apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   839
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   840
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   841
lemma flts_fuse:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   842
  shows "map (fuse bs) (flts rs) = flts (map (fuse bs) rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   843
  apply(induct rs arbitrary: bs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   844
        apply(auto simp add: fuse_append)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   845
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   846
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   847
lemma bsimp_ASEQ_fuse:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   848
  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
   849
  apply(induct r1 r2 arbitrary: bs1 bs2 rule: bsimp_ASEQ.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   850
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   851
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   852
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   853
lemma bsimp_AALTs_fuse:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   854
  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
   855
  shows "fuse bs1 (bsimp_AALTs bs2 rs) = bsimp_AALTs (bs1 @ bs2) rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   856
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   857
  apply(induct bs2 rs arbitrary: bs1 rule: bsimp_AALTs.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   858
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   859
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   860
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   861
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   862
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   863
lemma bsimp_fuse:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   864
  shows "fuse bs (bsimp r) = bsimp (fuse bs r)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   865
apply(induct r arbitrary: bs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   866
       apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   867
      apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   868
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   869
    prefer 3
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   870
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   871
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   872
   apply (simp add: bsimp_ASEQ_fuse)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   873
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   874
  by (simp add: bsimp_AALTs_fuse fuse_append)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   875
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   876
lemma bsimp_fuse_AALTs:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   877
  shows "fuse bs (bsimp (AALTs [] rs)) = bsimp (AALTs bs rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   878
  apply(subst bsimp_fuse) 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   879
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   880
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   881
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   882
lemma bsimp_fuse_AALTs2:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   883
  shows "fuse bs (bsimp_AALTs [] rs) = bsimp_AALTs bs rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   884
  using bsimp_AALTs_fuse fuse_append by auto
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   885
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   886
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   887
lemma bsimp_ASEQ_idem:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   888
  assumes "bsimp (bsimp r1) = bsimp r1" "bsimp (bsimp r2) = bsimp r2"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   889
  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
   890
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   891
  apply(case_tac "bsimp r1 = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   892
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   893
 apply(case_tac "bsimp r2 = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   894
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   895
  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
   896
  apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   897
    apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   898
    apply(subst bsimp_ASEQ2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   899
   apply(subst bsimp_ASEQ2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   900
  apply (metis assms(2) bsimp_fuse)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   901
      apply(subst bsimp_ASEQ1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   902
      apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   903
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   904
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   905
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   906
fun nonnested :: "arexp \<Rightarrow> bool"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   907
  where
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   908
  "nonnested (AALTs bs2 []) = True"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   909
| "nonnested (AALTs bs2 ((AALTs bs1 rs1) # rs2)) = False"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   910
| "nonnested (AALTs bs2 (r # rs2)) = nonnested (AALTs bs2 rs2)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   911
| "nonnested r = True"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   912
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   913
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   914
lemma  k0:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   915
  shows "flts (r # rs1) = flts [r] @ flts rs1"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   916
  apply(induct r arbitrary: rs1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   917
   apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   918
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   919
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   920
lemma  k00:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   921
  shows "flts (rs1 @ rs2) = flts rs1 @ flts rs2"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   922
  apply(induct rs1 arbitrary: rs2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   923
   apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   924
  by (metis append.assoc k0)
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
lemma  k0a:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   927
  shows "flts [AALTs bs rs] = map (fuse bs)  rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   928
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   929
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   930
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   931
fun spill where
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   932
 "spill (AALTs bs rs) =  map (fuse bs) rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   933
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   934
lemma  k0a2:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   935
  assumes "\<not> nonalt r"  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   936
  shows "flts [r] = spill r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   937
  using  assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   938
  apply(case_tac r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   939
  apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   940
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   941
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   942
lemma  k0b:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   943
  assumes "nonalt r" "r \<noteq> AZERO"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   944
  shows "flts [r] = [r]"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   945
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   946
  apply(case_tac  r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   947
  apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   948
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   949
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   950
lemma nn1:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   951
  assumes "nonnested (AALTs bs rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   952
  shows "\<nexists>bs1 rs1. flts rs = [AALTs bs1 rs1]"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   953
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   954
  apply(induct rs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   955
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   956
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   957
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   958
lemma nn1q:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   959
  assumes "nonnested (AALTs bs rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   960
  shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set (flts rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   961
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   962
  apply(induct rs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   963
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   964
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   965
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   966
lemma nn1qq:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   967
  assumes "nonnested (AALTs bs rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   968
  shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set rs"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   969
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   970
  apply(induct rs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   971
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   972
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   973
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   974
lemma nn10:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   975
  assumes "nonnested (AALTs cs rs)" 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   976
  shows "nonnested (AALTs (bs @ cs) rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   977
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   978
  apply(induct rs arbitrary: cs bs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   979
   apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   980
  apply(case_tac a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   981
       apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   982
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   983
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   984
lemma nn11a:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   985
  assumes "nonalt r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   986
  shows "nonalt (fuse bs r)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   987
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   988
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   989
       apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   990
  done
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   991
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   992
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   993
lemma nn1a:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   994
  assumes "nonnested r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   995
  shows "nonnested (fuse bs r)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   996
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   997
  apply(induct bs r arbitrary: rule: fuse.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   998
       apply(simp_all add: nn10)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
   999
  done  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1000
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1001
lemma n0:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1002
  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
  1003
  apply(induct rs  arbitrary: bs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1004
   apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1005
    apply (metis list.set_intros(1) nn1qq nonalt.elims(3))
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1006
   apply (metis list.set_intros(2) nn1qq nonalt.elims(3))
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1007
  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
  1008
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1009
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1010
  
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 nn1c:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1013
  assumes "\<forall>r \<in> set rs. nonnested r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1014
  shows "\<forall>r \<in> set (flts rs). nonalt r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1015
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1016
  apply(induct rs rule: flts.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1017
        apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1018
  apply(rule nn11a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1019
  by (metis nn1qq nonalt.elims(3))
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1020
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1021
lemma nn1bb:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1022
  assumes "\<forall>r \<in> set rs. nonalt r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1023
  shows "nonnested (bsimp_AALTs bs rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1024
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1025
  apply(induct bs rs rule: bsimp_AALTs.induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1026
    apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1027
   apply (metis nn11a nonalt.simps(1) nonnested.elims(3))
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1028
  using n0 by auto
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1029
    
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1030
lemma nn1b:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1031
  shows "nonnested (bsimp r)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1032
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1033
       apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1034
  apply(case_tac "bsimp r1 = AZERO")
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(case_tac "bsimp r2 = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1037
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1038
    apply(subst bsimp_ASEQ0)
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
  apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1041
    apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1042
    apply(subst bsimp_ASEQ2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1043
  apply (simp add: nn1a)    
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1044
   apply(subst bsimp_ASEQ1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1045
      apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1046
  apply(rule nn1bb)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1047
  apply(auto)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1048
  by (metis (mono_tags, hide_lams) imageE nn1c set_map)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1049
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1050
lemma nn1d:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1051
  assumes "bsimp r = AALTs bs rs"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1052
  shows "\<forall>r1 \<in> set rs. \<forall>  bs. r1 \<noteq> AALTs bs  rs2"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1053
  using nn1b assms
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1054
  by (metis nn1qq)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1055
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1056
lemma nn_flts:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1057
  assumes "nonnested (AALTs bs rs)"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1058
  shows "\<forall>r \<in>  set (flts rs). nonalt r"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1059
  using assms
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1060
  apply(induct rs arbitrary: bs rule: flts.induct)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1061
        apply(auto)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1062
  done
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1063
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1064
lemma rt:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1065
  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
  1066
  apply(induct rs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1067
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1068
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1069
  apply(subst  k0)
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
  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
  1072
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1073
lemma bsimp_AALTs_qq:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1074
  assumes "1 < length rs"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1075
  shows "bsimp_AALTs bs rs = AALTs bs  rs"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1076
  using  assms
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1077
  apply(case_tac rs)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1078
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1079
  apply(case_tac list)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1080
   apply(simp_all)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1081
  done
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1082
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1083
lemma good_fuse:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1084
  shows "good (fuse bs r) = good r"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1085
  apply(induct r)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1086
       apply(auto)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1087
  apply (metis arexp.distinct(25) arexp.distinct(7) arexp.inject(4) good.elims(3) good.simps(4) good.simps(5))
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1088
  by (metis good.simps(4) good.simps(5) neq_Nil_conv)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1089
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1090
lemma good0:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1091
  assumes "rs \<noteq> Nil"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1092
  shows "good (bsimp_AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. good r)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1093
  using  assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1094
  apply(induct bs rs rule: bsimp_AALTs.induct)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1095
  apply(auto simp add: good_fuse)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1096
  done
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1097
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1098
lemma good0a:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1099
  assumes "flts (map bsimp rs) \<noteq> Nil"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1100
  shows "good (bsimp (AALTs bs rs)) \<longleftrightarrow> (\<forall>r \<in> set (flts (map bsimp rs)). good r)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1101
  using  assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1102
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1103
  apply(rule good0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1104
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1105
  done
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1106
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1107
lemma flts0:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1108
  assumes "r \<noteq> AZERO" "nonalt r"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1109
  shows "flts [r] \<noteq> []"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1110
  using  assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1111
  apply(induct r)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1112
       apply(simp_all)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1113
  done
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1114
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1115
lemma flts1:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1116
  assumes "good r" 
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1117
  shows "flts [r] \<noteq> []"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1118
  using  assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1119
  apply(induct r)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1120
       apply(simp_all)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1121
  apply(case_tac x2a)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1122
   apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1123
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1124
  done
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1125
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1126
lemma flts2:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1127
  assumes "good r" 
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1128
  shows "\<forall>r' \<in> set (flts [r]). good r'"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1129
  using  assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1130
  apply(induct r)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1131
       apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1132
      apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1133
     apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1134
    prefer 2
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1135
    apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1136
    apply(auto)[1]
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1137
  apply (metis good.simps(5) good_fuse in_set_insert insert_Nil list.exhaust)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1138
   prefer 2
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1139
   apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1140
  by fastforce
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1141
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1142
lemma flts3a:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1143
  assumes "good r" 
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1144
  shows "good (AALTs bs (flts [r]))"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1145
  using  assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1146
  by (metis flts1 flts2 good.simps(5) neq_Nil_conv)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1147
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1148
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1149
lemma flts3:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1150
  assumes "\<forall>r \<in> set rs. good r \<or> r = AZERO" 
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1151
  shows "\<forall>r \<in> set (flts rs). good r"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1152
  using  assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1153
  apply(induct rs arbitrary: rule: flts.induct)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1154
        apply(simp_all)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1155
  by (metis UnE flts2 k0a set_map)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1156
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1157
lemma flts3b:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1158
  assumes "\<exists>r\<in>set rs. good r"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1159
  shows "flts rs \<noteq> []"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1160
  using  assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1161
  apply(induct rs arbitrary: rule: flts.induct)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1162
        apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1163
       apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1164
      apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1165
      apply(auto)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1166
  done
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1167
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1168
lemma flts4:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1169
  assumes "bsimp_AALTs bs (flts rs) = AZERO"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1170
  shows "\<forall>r \<in> set rs. \<not> good r"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1171
  using assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1172
  apply(induct rs arbitrary: bs rule: flts.induct)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1173
        apply(auto)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1174
        defer
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1175
  apply (metis (no_types, lifting) Nil_is_append_conv append_self_conv2 bsimp_AALTs.elims butlast.simps(2) butlast_append flts3b nonalt.simps(1) nonalt.simps(2))
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1176
  apply (metis arexp.distinct(7) bsimp_AALTs.elims flts2 good.simps(1) good.simps(2) good0 k0b list.distinct(1) list.inject nonalt.simps(3))
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1177
  apply (metis arexp.distinct(3) arexp.distinct(7) bsimp_AALTs.elims fuse.simps(3) list.distinct(1) list.inject)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1178
  apply (metis arexp.distinct(7) bsimp_AALTs.elims good.simps(1) good.simps(6) good_fuse list.distinct(1) list.inject)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1179
  apply (metis arexp.distinct(7) bsimp_AALTs.elims list.distinct(1) list.inject)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1180
  apply (metis arexp.distinct(7) bsimp_AALTs.simps(2) bsimp_AALTs.simps(3) flts.simps(1) flts.simps(2) flts1 good.simps(7) good_fuse neq_Nil_conv)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1181
  by (metis (no_types, lifting) Nil_is_append_conv append_Nil2 arexp.distinct(7) bsimp_AALTs.elims butlast.simps(2) butlast_append flts1 flts2 good.simps(1) good0 k0a)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1182
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1183
lemma flts_nil:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1184
  assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow>
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1185
            good (bsimp y) \<or> bsimp y = AZERO"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1186
  and "\<forall>r\<in>set rs. \<not> good (bsimp r)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1187
  shows "flts (map bsimp rs) = []"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1188
  using assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1189
  apply(induct rs)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1190
   apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1191
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1192
  apply(subst k0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1193
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1194
  by force
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1195
  
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1196
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1197
lemma good1:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1198
  shows "good (bsimp a) \<or> bsimp a = AZERO"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1199
  apply(induct a taking: asize rule: measure_induct)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1200
  apply(case_tac x)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1201
       apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1202
      apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1203
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1204
  prefer 3
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1205
    apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1206
   prefer 2
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1207
  apply(simp only:)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1208
   apply(case_tac "x52")
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1209
    apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1210
   apply(simp only: good0a)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1211
  apply(frule_tac x="a" in spec)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1212
   apply(drule mp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1213
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1214
    apply(erule disjE)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1215
     prefer 2
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1216
     apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1217
   apply(frule_tac x="AALTs x51 list" in spec)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1218
   apply(drule mp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1219
  apply(simp add: asize0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1220
    apply(auto)[1]
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1221
  apply(frule_tac x="AALTs x51 list" in spec)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1222
   apply(drule mp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1223
    apply(simp add: asize0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1224
   apply(erule disjE)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1225
    apply(rule disjI1)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1226
  apply(simp add: good0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1227
    apply(subst good0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1228
     apply (metis Nil_is_append_conv flts1 k0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1229
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1230
    apply(subst k0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1231
    apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1232
    apply(auto)[1]
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1233
  using flts2 apply blast
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1234
    apply (metis good0 in_set_member member_rec(2))
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1235
   apply(simp) 
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1236
   apply(rule disjI1)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1237
   apply(drule flts4)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1238
   apply(subst k0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1239
   apply(subst good0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1240
    apply (metis append_is_Nil_conv flts1 k0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1241
   apply(auto)[1]
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1242
  using flts2 apply blast
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1243
  apply (metis add.commute add_lessD1 flts_nil list.distinct(1) list.set_cases not_less_eq)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1244
  (* SEQ case *)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1245
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1246
  apply(case_tac "bsimp x42 = AZERO")
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1247
    apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1248
 apply(case_tac "bsimp x43 = AZERO")
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1249
   apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1250
    apply(subst (2) bsimp_ASEQ0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1251
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1252
  apply(case_tac "\<exists>bs. bsimp x42 = AONE bs")
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1253
    apply(auto)[1]
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1254
   apply(subst bsimp_ASEQ2)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1255
  using good_fuse apply force
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1256
   apply(subst bsimp_ASEQ1)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1257
     apply(auto)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1258
  using less_add_Suc1 apply blast
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1259
  using less_add_Suc2 by blast
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1260
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1261
lemma flts_append:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1262
  "flts (xs1 @ xs2) = flts xs1 @ flts xs2"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1263
  apply(induct xs1  arbitrary: xs2  rule: rev_induct)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1264
   apply(auto)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1265
  apply(case_tac xs)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1266
   apply(auto)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1267
   apply(case_tac x)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1268
        apply(auto)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1269
  apply(case_tac x)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1270
        apply(auto)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1271
  done
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1272
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1273
lemma g1:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1274
  assumes "good (bsimp_AALTs bs rs)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1275
  shows "bsimp_AALTs bs rs = AALTs bs rs \<or> (\<exists>r. rs = [r] \<and> bsimp_AALTs bs [r] = fuse bs r)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1276
using assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1277
    apply(induct rs arbitrary: bs)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1278
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1279
  apply(case_tac rs)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1280
  apply(simp only:)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1281
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1282
  apply(case_tac  list)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1283
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1284
  by simp
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1285
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1286
lemma flts_idem:
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1287
  assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow>
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1288
            bsimp (bsimp y) = bsimp y"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1289
  shows "map bsimp (flts (map bsimp rs)) = flts (map bsimp rs)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1290
  using assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1291
  apply(induct rs)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1292
   apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1293
  apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1294
  apply(subst k0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1295
  apply(subst (2) k0) 
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1296
  apply(simp add: flts_append)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1297
  using good1
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1298
  apply -
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1299
  apply(drule_tac x="a" in meta_spec)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1300
  apply(erule disjE)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1301
  prefer 2
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1302
   apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1303
  using flts.simps
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1304
  apply(case_tac a)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1305
       apply(simp_all)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1306
   defer
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1307
   apply(drule g1)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1308
   apply(erule disjE)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1309
    apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1310
    defer
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1311
    apply(auto)[1]
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1312
    
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1313
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1314
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1315
lemma flts_idem:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1316
  assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow>
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1317
            bsimp (bsimp y) = bsimp y"
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1318
  shows "flts (map bsimp (flts (map bsimp rs))) = flts (map bsimp rs)"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1319
  using assms
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1320
  apply(induct rs)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1321
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1322
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1323
  apply(subst k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1324
  apply(subst (2) k0) 
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1325
  apply(simp add: flts_append)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1326
  using good1
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1327
  apply -
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1328
  apply(drule_tac x="a" in meta_spec)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1329
  apply(erule disjE)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1330
  prefer 2
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1331
   apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1332
  using flts.simps
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1333
  apply(case_tac a)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1334
       apply(simp_all)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1335
   defer
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1336
   apply(drule g1)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1337
   apply(erule disjE)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1338
    apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1339
    defer
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1340
    apply(auto)[1]
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1341
  
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1342
   apply(subst g1)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1343
    apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1344
   apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1345
  apply (me tis (full_types) arexp.inject(4) bsimp_AALTs.simps(2) flts3a fuse_empty g1 list.distinct(1))
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1346
  
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1347
  
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1348
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1349
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1350
  apply(case_tac "bsimp a = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1351
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1352
  apply(case_tac "nonalt (bsimp a)")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1353
  thm k0 k0a k0b
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1354
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1355
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1356
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1357
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1358
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1359
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1360
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1361
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1362
  apply(subst k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1363
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1364
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1365
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1366
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1367
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1368
  apply(simp add: k00)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1369
  apply(subst k0a2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1370
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1371
  apply(subst k0a2)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1372
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1373
  apply(case_tac a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1374
  apply(simp_all)
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1375
  oops
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1376
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1377
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1378
lemma flts_0:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1379
  assumes "nonnested (AALTs bs  rs)"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1380
  shows "\<forall>r \<in> set (flts rs). r \<noteq> AZERO"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1381
  using assms
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1382
  apply(induct rs arbitrary: bs rule: flts.induct)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1383
        apply(simp) 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1384
       apply(simp) 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1385
      defer
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1386
      apply(simp) 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1387
     apply(simp) 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1388
    apply(simp) 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1389
apply(simp) 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1390
  apply(rule ballI)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1391
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1392
  done
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1393
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1394
lemma flts_0a:
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1395
  assumes "nonnested (AALTs bs  rs)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1396
  shows "AZERO \<notin> set (flts rs)"
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1397
  using assms
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1398
  using flts_0 by blast 
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1399
  
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1400
lemma qqq1:
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1401
  shows "AZERO \<notin> set (flts (map bsimp rs))"
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1402
  by (metis ex_map_conv flts3 good.simps(1) good1)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1403
  
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1404
lemma cc:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1405
  assumes "bsimp (fuse bs' r) = (AALTs bs rs)" 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1406
  shows "\<forall>r \<in> set  rs. r \<noteq> AZERO"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1407
  using assms
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1408
 apply(induct r arbitrary: rs bs bs' rule: bsimp.induct)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1409
       apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1410
  apply(case_tac "bsimp r1 = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1411
    apply simp
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1412
   apply(case_tac "bsimp r2 = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1413
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1414
    apply(case_tac "\<exists>bs'. bsimp r1 = AONE bs'")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1415
     apply(auto)[1]
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1416
  apply (simp add: bsimp_ASEQ0)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1417
  apply(case_tac "\<exists>bs'. bsimp r1 = AONE bs'")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1418
    apply(auto)[2]
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1419
    apply (simp add: bsimp_ASEQ2)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1420
  using bsimp_fuse apply fastforce
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1421
    apply (simp add: bsimp_ASEQ1)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1422
   prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1423
      apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1424
     defer
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1425
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1426
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1427
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1428
  (* AALT case *)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1429
  apply(simp only: fuse.simps)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1430
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1431
  apply(case_tac "flts (map bsimp rs)")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1432
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1433
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1434
  apply(case_tac list)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1435
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1436
   apply(case_tac a)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1437
        apply(simp_all)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1438
   apply(auto)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1439
   apply (metis ex_map_conv list.set_intros(1) nn1b nn1c nonalt.simps(1))
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1440
  apply(case_tac rs)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1441
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1442
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1443
  apply(case_tac list)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1444
   apply(simp)  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1445
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1446
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1447
  apply(subgoal_tac "\<forall>r \<in> set (flts (map bsimp rs)). r \<noteq> AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1448
   prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1449
   apply(rule_tac bs="bs' @ bs1" in flts_0)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1450
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1451
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1452
  thm bsimp_AALTs_qq
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1453
  apply(case_tac "1 < length rs")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1454
  apply(drule_tac bsimp_AALTs_qq)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1455
  apply(subgoal_tac "nonnested (AALTs bs rsa)")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1456
   prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1457
   apply (metis nn1b)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1458
  apply(rule ballI)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1459
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1460
  apply(drule_tac x="r" in meta_spec)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1461
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1462
  (* HERE *)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1463
  apply(drule flts_0)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1464
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1465
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1466
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1467
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1468
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1469
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1470
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1471
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1472
  apply(subst 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1473
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1474
  apply (sm t arexp.distinct(15) arexp.distinct(21) arexp.distinct(25) arexp.distinct(29) arexp.inject(4) b1 fuse.elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1475
    
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1476
   prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1477
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1478
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1479
  apply(induct r arbitrary: rs bs bs' rule: bsimp.induct)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1480
       apply(auto)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1481
  apply(case_tac "bsimp r1 = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1482
    apply simp
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1483
   apply(case_tac "bsimp r2 = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1484
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1485
    apply(case_tac "\<exists>bs'. bsimp r1 = AONE bs'")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1486
     apply(auto)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1487
  apply (simp add: bsimp_ASEQ0)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1488
  apply(case_tac "\<exists>bs'. bsimp r1 = AONE bs'")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1489
    apply(auto)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1490
    apply (simp add: bsimp_ASEQ2)
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1491
  using bsimp_fuse apply fast force
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1492
   apply (simp add: bsimp_ASEQ1)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1493
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1494
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1495
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1496
  apply(subst 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1497
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1498
  apply (sm t arexp.distinct(15) arexp.distinct(21) arexp.distinct(25) arexp.distinct(29) arexp.inject(4) b1 fuse.elims)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1499
    
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1500
   prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1501
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1502
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1503
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1504
lemma ww1:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1505
  assumes "flts [r1] = [r2]" "r1 \<noteq> AZERO"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1506
  shows  "r1 = r2"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1507
  using assms
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1508
  apply(case_tac r1)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1509
       apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1510
      apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1511
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1512
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1513
   prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1514
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1515
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1516
  apply(auto)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1517
  oops
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1518
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1519
lemma bsimp_idem:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1520
  shows "bsimp (bsimp r) = bsimp r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1521
apply(induct r taking: "asize" rule: measure_induct)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1522
  apply(case_tac x)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1523
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1524
      apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1525
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1526
    prefer 3
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1527
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1528
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1529
   apply (simp add: bsimp_ASEQ_idem)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1530
  apply(clarify)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1531
  apply(case_tac x52)
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1532
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1533
  (* AALT case where rs is of the form _ # _ *)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1534
  apply(clarify)
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1535
  apply(simp)
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1536
  apply(case_tac "length (flts (bsimp a # map bsimp list)) \<le> 1")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1537
   prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1538
   apply(subst bsimp_AALTs_qq)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1539
    apply(auto)[1]
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1540
   apply(simp)
322
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1541
   apply(subst k0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1542
   apply(simp)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1543
   apply(simp add: flts_append)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1544
   apply(subst (2) k0)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1545
  
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1546
   apply(simp add: flts_append)
22e34f93cd5d updaed good
Christian Urban <urbanc@in.tum.de>
parents: 318
diff changeset
  1547
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1548
   prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1549
  apply(subgoal_tac "length (flts (bsimp a # map bsimp list)) = 0 \<or> 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1550
                     length (flts (bsimp a # map bsimp list)) = 1")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1551
    prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1552
    apply(auto)[1]
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1553
  using le_SucE apply blast
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1554
  apply(erule disjE)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1555
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1556
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1557
   apply(subst k0)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1558
   apply(subst (2)  k0)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1559
   apply(subst (asm) k0)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1560
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1561
  apply(subgoal_tac "length (flts [bsimp a]) = 1 \<or> 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1562
                     length (flts (map bsimp list)) = 1")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1563
    prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1564
  apply linarith
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1565
    apply(erule disjE)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1566
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1567
    prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1568
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1569
    apply(drule_tac x="AALTs x51 list" in  spec)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1570
    apply(drule mp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1571
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1572
  using asize0 apply blast
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1573
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1574
   apply(frule_tac x="a" in spec)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1575
  apply(drule mp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1576
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1577
   apply(subgoal_tac "\<exists>r. flts [bsimp a] = [r]")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1578
    prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1579
  apply (simp add: length_Suc_conv)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1580
   apply(clarify)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1581
   apply(simp only: )
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1582
  apply(case_tac "bsimp a = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1583
    apply simp
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1584
  apply(case_tac "\<exists>bs rs. bsimp a = AALTs bs rs")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1585
    apply(clarify)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1586
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1587
  apply(drule_tac x="AALTs bs rs" in spec)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1588
  apply(drule mp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1589
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1590
  apply (metis asize.simps(4) bsimp_size lessI less_le_trans trans_less_add1)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1591
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1592
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1593
    apply(subst ww)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1594
   apply(subst ww)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1595
   apply(frule_tac x="fuse x51 r" in spec)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1596
  apply(drule mp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1597
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1598
  apply (smt add.commute add_le_cancel_right fuse_size le_add2 le_trans list.map(1) list.simps(9) not_less not_less_eq rt sum_list.Cons)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1599
   apply(case_tac "bsimp a = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1600
    apply simp
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1601
  apply(case_tac "\<exists>bs rs. bsimp a = AALTs bs rs")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1602
    apply(clarify)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1603
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1604
   defer
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1605
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1606
  apply(
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1607
   apply(case_tac a)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1608
  apply(simp_all)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1609
   apply(subgoal_tac "\<exists>r. flts [bsimp a] = [r]")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1610
    prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1611
  apply (simp add: length_Suc_conv)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1612
   apply auto[1]
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1613
  apply(case_tac 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1614
  apply(clarify)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1615
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1616
  defer
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1617
    apply(auto)[1]
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1618
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1619
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1620
  apply(subst k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1621
  apply(subst (2) k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1622
  apply(case_tac "bsimp a = AZERO")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1623
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1624
   apply(frule_tac x="AALTs x51 (flts (map bsimp list))" in spec)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1625
   apply(drule mp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1626
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1627
  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
  1628
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1629
    apply(subst (asm) flts_idem)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1630
     apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1631
     apply(drule_tac  x="r" in spec)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1632
  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
  1633
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1634
  apply(subst flts_idem)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1635
   apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1636
     apply(drule_tac  x="r" in spec)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1637
  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
  1638
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1639
  apply(case_tac "nonalt (bsimp a)")
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1640
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1641
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1642
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1643
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1644
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1645
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1646
   apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1647
  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
  1648
   apply(drule mp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1649
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1650
    prefer 2
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1651
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1652
  apply(subst (asm) k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1653
  apply(subst (asm) flts_idem)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1654
     apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1655
  apply (simp add: sum_list_map_remove1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1656
  apply(subst (asm) k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1657
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1658
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1659
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1660
   apply(subst k0)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1661
  apply(subst flts_idem)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1662
     apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1663
     apply (simp add: sum_list_map_remove1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1664
  apply(subst k0b)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1665
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1666
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1667
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1668
lemma XX_bder:
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1669
  shows "bsimp (bder c (bsimp r)) = (bsimp \<circ> bder c) r"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1670
  apply(induct r)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1671
       apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1672
      apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1673
     apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1674
    prefer 3
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1675
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1676
  prefer 2
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1677
   apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1678
   apply(case_tac x2a)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1679
    apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1680
  apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1681
  apply(auto)[1]
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1682
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1683
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1684
lemma q3a:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1685
  assumes "\<exists>r \<in> set rs. bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1686
  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
  1687
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1688
  apply(induct rs arbitrary: bs bs1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1689
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1690
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1691
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1692
   apply (metis append_assoc b2 bnullable_correctness erase_fuse r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1693
  apply(case_tac "bnullable a")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1694
   apply (metis append.assoc b2 bnullable_correctness erase_fuse r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1695
  apply(case_tac rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1696
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1697
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1698
  apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1699
   apply (metis bnullable_correctness erase_fuse)+
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1700
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1701
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1702
lemma qq4:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1703
  assumes "\<exists>x\<in>set list. bnullable x"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1704
  shows "\<exists>x\<in>set (flts list). bnullable x"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1705
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1706
  apply(induct list rule: flts.induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1707
        apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1708
  by (metis UnCI bnullable_correctness erase_fuse imageI)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1709
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1710
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1711
lemma qs3:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1712
  assumes "\<exists>r \<in> set rs. bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1713
  shows "bmkeps (AALTs bs rs) = bmkeps (AALTs bs (flts rs))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1714
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1715
  apply(induct rs arbitrary: bs taking: size rule: measure_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1716
  apply(case_tac x)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1717
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1718
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1719
  apply(case_tac a)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1720
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1721
       apply (simp add: r1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1722
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1723
      apply (simp add: r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1724
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1725
     apply(case_tac "flts list")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1726
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1727
  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
  1728
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1729
     apply (simp add: r1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1730
    prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1731
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1732
    apply (simp add: r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1733
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1734
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1735
  apply(case_tac "\<exists>x\<in>set x52. bnullable x")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1736
  apply(case_tac "list")
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 (metis b2 fuse.simps(4) q3a r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1739
   apply(erule disjE)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1740
    apply(subst qq1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1741
     apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1742
     apply (metis bnullable_correctness erase_fuse)
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 (metis b2 fuse.simps(4) q3a r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1745
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1746
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1747
     apply(subst qq1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1748
      apply (metis bnullable_correctness erase_fuse image_eqI set_map)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1749
     apply (metis b2 fuse.simps(4) q3a r2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1750
  apply(subst qq1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1751
      apply (metis bnullable_correctness erase_fuse image_eqI set_map)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1752
    apply (metis b2 fuse.simps(4) q3a r2)
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
   apply(subst qq2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1755
     apply (metis bnullable_correctness erase_fuse imageE set_map)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1756
  prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1757
  apply(case_tac "list")
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 (simp add: qq4)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1761
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1762
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1763
   apply(case_tac list)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1764
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1765
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1766
   apply (simp add: r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1767
  apply(case_tac "bnullable (ASEQ x41 x42 x43)")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1768
   apply(case_tac list)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1769
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1770
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1771
   apply (simp add: r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1772
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1773
  using qq4 r1 r2 by auto
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1774
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1775
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1776
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1777
lemma k1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1778
  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
  1779
          "\<exists>x\<in>set x2a. bnullable x"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1780
        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
  1781
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1782
  apply(induct x2a)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1783
  apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1784
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1785
  apply(subst k0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1786
  apply(subst (2) k0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1787
  apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1788
  apply (metis b3 k0 list.set_intros(1) qs3 r0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1789
  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
  1790
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1791
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1792
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1793
lemma bmkeps_simp:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1794
  assumes "bnullable r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1795
  shows "bmkeps r = bmkeps (bsimp r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1796
  using  assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1797
  apply(induct r)
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
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1800
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1801
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1802
    prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1803
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1804
   apply(case_tac "bsimp r1 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1805
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1806
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1807
  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
  1808
 apply(case_tac "bsimp r2 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1809
    apply(simp)  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1810
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1811
  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
  1812
  apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1813
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1814
    apply(subst b1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1815
    apply(subst b2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1816
  apply(simp add: b3[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1817
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1818
   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
  1819
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1820
  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
  1821
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1822
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1823
  apply(subst q3[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1824
   apply simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1825
  using b3 qq4 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1826
  apply(subst qs3)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1827
   apply simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1828
  using k1 by blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1829
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1830
thm bmkeps_retrieve bmkeps_simp bder_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1831
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1832
lemma bmkeps_bder_AALTs:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1833
  assumes "\<exists>r \<in> set rs. bnullable (bder c r)" 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1834
  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
  1835
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1836
  apply(induct rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1837
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1838
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1839
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1840
  apply(case_tac rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1841
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1842
  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
  1843
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1844
  apply(case_tac  rs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1845
   apply(simp_all)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1846
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1847
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1848
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1849
fun extr :: "arexp  \<Rightarrow> (bit list) set" where
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1850
  "extr (AONE bs) = {bs}"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1851
| "extr (ACHAR bs c) = {bs}"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1852
| "extr (AALTs bs (r#rs)) = 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1853
     {bs @ bs' | bs'.  bs' \<in> extr r} \<union>
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1854
     {bs @ bs' | bs'.  bs' \<in> extr (AALTs [] rs)}"
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1855
| "extr (ASEQ bs r1 r2) = 
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1856
     {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
  1857
| "extr (ASTAR bs r) = {bs @ [S]} \<union>
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1858
     {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
  1859
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1860
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1861
lemma MAIN_decode:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1862
  assumes "\<Turnstile> v : ders s r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1863
  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
  1864
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1865
proof (induct s arbitrary: v rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1866
  case Nil
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1867
  have "\<Turnstile> v : ders [] r" by fact
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1868
  then have "\<Turnstile> v : r" by simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1869
  then have "Some v = decode (retrieve (intern r) v) r"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1870
    using decode_code retrieve_code by auto
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1871
  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
  1872
    by simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1873
next
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1874
  case (snoc c s v)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1875
  have IH: "\<And>v. \<Turnstile> v : ders s r \<Longrightarrow> 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1876
     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
  1877
  have asm: "\<Turnstile> v : ders (s @ [c]) r" by fact
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1878
  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
  1879
    by(simp add: Prf_injval ders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1880
  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
  1881
    by (simp add: flex_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1882
  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
  1883
    using asm2 IH by simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1884
  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
  1885
    using asm bder_retrieve ders_append 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1886
    apply -
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1887
    apply(drule_tac x="v" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1888
    apply(drule_tac x="c" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1889
    apply(drule_tac x="bders_simp (intern r) s" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1890
    apply(drule_tac  meta_mp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1891
     apply(simp add: ders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1892
     defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1893
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1894
    oops
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1895
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1896
fun vsimp :: "arexp \<Rightarrow> val \<Rightarrow> val"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1897
  where
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1898
  "vsimp (ASEQ _ (AONE _) r) (Seq v1 v2) = vsimp r v1"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1899
| "vsimp _ v = v" 
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1900
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1901
lemma fuse_vsimp:
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1902
  assumes "\<Turnstile> v : (erase r)"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1903
  shows "vsimp (fuse bs r) v = vsimp r v"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1904
  using assms
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1905
  apply(induct r arbitrary: v bs)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1906
       apply(simp_all)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1907
  apply(case_tac "\<exists>bs. r1 = AONE bs")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1908
   apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1909
   apply (metis Prf_elims(2) vsimp.simps(1))
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1910
  apply(erule Prf_elims)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1911
  apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1912
  apply(case_tac r1)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1913
       apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1914
  done  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1915
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1916
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1917
lemma retrieve_XXX0:
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1918
  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
  1919
              \<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
  1920
          "\<Turnstile> v : erase (AALTs bs rs)"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1921
        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
  1922
                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
  1923
  using assms
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1924
apply(induct rs arbitrary: bs v taking: size rule: measure_induct)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1925
  apply(case_tac x)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1926
   apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1927
  using Prf_elims(1) apply blast
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1928
  apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1929
  apply(case_tac list)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1930
   apply(simp_all)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1931
   apply(case_tac a)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1932
  apply(simp_all)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1933
  using Prf_elims(1) apply blast
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1934
       apply (metis erase.simps(2) fuse.simps(2) retrieve_fuse2)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1935
  using Prf_elims(5) apply force
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1936
     apply(erule Prf_elims)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1937
     apply(auto)[1]
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1938
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1939
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1940
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1941
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1942
  apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1943
       apply(erule Prf_elims)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1944
  using Prf_elims(1) apply b last
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1945
       apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1946
       apply (metis append_Ni l2 erase_fuse fuse.simps(4) retrieve_fuse2)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1947
  apply(case_tac rs)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1948
       apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1949
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1950
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1951
  oops
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1952
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1953
fun get where
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1954
  "get (Some v) = v"
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1955
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1956
  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1957
lemma retrieve_XXX:
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1958
  assumes "\<Turnstile> v : erase r" 
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1959
  shows "\<Turnstile> get (decode (code v) (erase (bsimp r))) : erase (bsimp r)"
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1960
  using assms
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1961
apply(induct r arbitrary: v)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1962
       apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1963
  using Prf_elims(1) apply auto[1]  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1964
      apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1965
  apply (simp add: decode_code)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1966
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1967
  apply (simp add: decode_code)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1968
    apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1969
    apply(erule Prf_elims)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1970
  apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1971
   apply(case_tac  "r1 = AZERO")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1972
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1973
  apply (meson Prf_elims(1) Prf_elims(2))
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1974
  apply(case_tac  "r2 = AZERO")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1975
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1976
     apply (meson Prf_elims(1) Prf_elims(2))
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1977
   apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1978
     apply(clarify)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1979
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1980
     apply(subst bsimp_ASEQ2)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1981
     apply(subst bsimp_ASEQ2)
317
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1982
     apply(simp add: erase_fuse)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1983
     apply(case_tac r1)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1984
          apply(simp_all)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1985
  using Prf_elims(4) apply fastforce
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1986
      apply(erule Prf_elims)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1987
      apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1988
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1989
      apply(simp)
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1990
  
db0ff630bbb7 updated
Christian Urban <urbanc@in.tum.de>
parents: 316
diff changeset
  1991
  
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1992
     defer
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1993
     apply(subst bsimp_ASEQ1)
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  1994
  using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fast force
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1995
  using L_bsimp_erase L_
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  1996
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1997
lemma retrieve_XXX:
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1998
  assumes "\<Turnstile> v : erase r" 
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  1999
  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
  2000
  using assms
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2001
  apply(induct r arbitrary: v)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2002
       apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2003
  using Prf_elims(1) apply blast
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2004
      apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2005
  using Prf_elims(4) apply fastforce
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2006
    apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2007
  apply blast
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2008
  apply simp
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2009
   apply(case_tac  "r1 = AZERO")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2010
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2011
  apply (meson Prf_elims(1) Prf_elims(2))
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2012
  apply(case_tac  "r2 = AZERO")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2013
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2014
     apply (meson Prf_elims(1) Prf_elims(2))
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2015
  apply(erule Prf_elims)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2016
  apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2017
   apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2018
     apply(clarify)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2019
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2020
    apply(subst bsimp_ASEQ2)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2021
     defer
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2022
     apply(subst bsimp_ASEQ1)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2023
  using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2024
  using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2025
      apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2026
    apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2027
  apply(drule_tac  x="v1" in meta_spec)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2028
  apply(drule_tac  x="v2" in meta_spec)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2029
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2030
  apply(clarify)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2031
     apply(rule_tac x="Seq v' v'a" in exI)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2032
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2033
  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
  2034
    prefer 3
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2035
  apply(drule_tac  x="v1" in meta_spec)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2036
  apply(drule_tac  x="v2" in meta_spec)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2037
     apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2038
    apply(clarify)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2039
    apply(rule_tac x="v'a" in exI)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2040
    apply(subst bsimp_ASEQ2)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2041
    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
  2042
   prefer 2  
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2043
   apply(auto)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2044
  apply(case_tac "x2a")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2045
   apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2046
  using Prf_elims(1) apply blast
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2047
  apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2048
  apply(case_tac "list")
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2049
   apply(simp)
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2050
  sorry  
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2051
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2052
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2053
lemma retrieve_XXX:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2054
  assumes "\<Turnstile> v : erase r" 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2055
  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
  2056
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2057
  apply(induct r arbitrary: v)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2058
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2059
  using Prf_elims(1) apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2060
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2061
  using Prf_elims(4) apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2062
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2063
  apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2064
  apply simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2065
   apply(case_tac  "r1 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2066
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2067
  apply (meson Prf_elims(1) Prf_elims(2))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2068
  apply(case_tac  "r2 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2069
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2070
     apply (meson Prf_elims(1) Prf_elims(2))
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2071
  apply(erule Prf_elims)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2072
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2073
   apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2074
     apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2075
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2076
    apply(subst bsimp_ASEQ2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2077
     defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2078
     apply(subst bsimp_ASEQ1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2079
  using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2080
  using L_bsimp_erase L_flat_Prf1 L_flat_Prf2 apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2081
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2082
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2083
  apply(drule_tac  x="v1" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2084
  apply(drule_tac  x="v2" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2085
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2086
  apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2087
     apply(rule_tac x="Seq v' v'a" in exI)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2088
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2089
  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
  2090
    prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2091
  apply(drule_tac  x="v1" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2092
  apply(drule_tac  x="v2" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2093
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2094
    apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2095
    apply(rule_tac x="v'a" in exI)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2096
    apply(subst bsimp_ASEQ2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2097
    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
  2098
   prefer 2  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2099
   apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2100
  apply(case_tac "x2a")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2101
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2102
  using Prf_elims(1) apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2103
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2104
  apply(case_tac "list")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2105
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2106
  sorry
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2107
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2108
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2109
lemma TEST:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2110
  assumes "\<Turnstile> v : ders s r"
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2111
  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
  2112
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2113
  apply(induct s arbitrary: r v rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2114
   apply(simp)
316
0eaa1851a5b6 updated
Christian Urban <urbanc@in.tum.de>
parents: 314
diff changeset
  2115
  
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2116
   defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2117
   apply(simp add: ders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2118
   apply(frule Prf_injval)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2119
  apply(drule_tac x="r" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2120
   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
  2121
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2122
   apply(simp add: bders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2123
   apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2124
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2125
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2126
  thm bder_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2127
  thm bmkeps_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2128
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2129
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2130
lemma bmkeps_simp2:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2131
  assumes "bnullable (bder c r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2132
  shows "bmkeps (bder c (bsimp r)) = bmkeps (bder c r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2133
  using  assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2134
  apply(induct r)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2135
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2136
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2137
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2138
  prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2139
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2140
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2141
   apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2142
     prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2143
     apply(case_tac "r1 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2144
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2145
   apply(case_tac "r2 = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2146
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2147
     apply(case_tac "\<exists>bs. (bsimp r1) = AONE bs")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2148
      apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2149
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2150
      apply(subst bsimp_ASEQ2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2151
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2152
   apply(simp add: bmkeps_simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2153
  apply(simp add: bders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2154
  apply(drule_tac x="bder a r" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2155
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2156
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2157
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2158
    prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2159
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2160
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2161
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2162
   apply(case_tac x2a)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2163
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2164
  apply(simp add: )
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2165
  apply(subst k0)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2166
   apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2167
    apply(case_tac list)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2168
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2169
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2170
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2171
   apply(case_tac  "r1=AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2172
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2173
   apply(case_tac  "r2=AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2174
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2175
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2176
   apply(case_tac  "\<exists>bs. r1=AONE bs")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2177
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2178
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2179
     apply(subst bsimp_ASEQ2)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2180
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2181
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2182
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2183
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2184
  apply(subst  bmkeps_bder_AALTs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2185
   apply(case_tac x2a)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2186
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2187
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2188
   apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2189
    apply(subst  bmkeps_bder_AALTs)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2190
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2191
   apply(case_tac a)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2192
  apply(simp_all)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2193
   apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2194
    apply(case_tac list)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2195
         apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2196
        apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2197
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2198
     prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2199
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2200
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2201
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2202
lemma bbs0:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2203
  shows "blexer_simp r [] = blexer r []"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2204
  apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2205
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2206
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2207
lemma bbs1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2208
  shows "blexer_simp r [c] = blexer r [c]"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2209
  apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2210
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2211
    defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2212
  using b3 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2213
  using b3 apply auto[1]  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2214
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2215
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2216
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2217
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2218
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2219
lemma bbs1:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2220
  shows "blexer_simp r [c1, c2] = blexer r [c1, c2]"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2221
  apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2222
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2223
    defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2224
  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
  2225
  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
  2226
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2227
  using b3 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2228
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2229
  using b3 bnullable_correctness apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2230
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2231
  using b3 bnullable_correctness mkeps_nullable apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2232
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2233
  using bnullable_correctness apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2234
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2235
  using bnullable_correctness mkeps_nullable apply force
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2236
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2237
  using bder_retrieve bmkeps_simp bmkeps_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2238
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2239
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2240
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2241
lemma bsimp_retrieve_bder:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2242
  assumes "\<Turnstile> v : der c (erase r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2243
  shows "retrieve (bder c r) v = retrieve (bsimp (bder c r)) v"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2244
  thm bder_retrieve bmkeps_simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2245
  apply(induct  r arbitrary: c v)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2246
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2247
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2248
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2249
    apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2250
     apply(case_tac "bsimp (bder c r1) = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2251
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2252
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2253
    prefer 3
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2254
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2255
  apply(auto elim!: Prf_elims)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2256
    apply(case_tac "(bsimp (fuse [Z] (bder c r))) = AZERO")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2257
     apply(simp)
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2258
     apply (met is L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) erase.simps(1) erase_bder erase_fuse)
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2259
    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
  2260
     apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2261
     apply(subgoal_tac "L (der c (erase r)) = {[]}")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2262
      prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2263
      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
  2264
     apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2265
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2266
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2267
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2268
    apply(subst bsimp_ASEQ1)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2269
       apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2270
      apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2271
  apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2272
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2273
     prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2274
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2275
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2276
lemma oo:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2277
  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
  2278
  apply(simp add: blexer_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2279
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2280
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2281
lemma oo2a:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2282
  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
  2283
          "bnullable (bders_simp (bsimp (bder c (intern r))) s)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2284
  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
  2285
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2286
  apply(simp add: blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2287
  apply(auto  split: option.split)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2288
    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
  2289
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2290
  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
  2291
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2292
  using L_bders_simp bnullable_correctness nullable_correctness apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2293
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2294
  thm bder_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2295
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2296
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2297
  apply(subst bder_retrieve[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2298
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2299
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2300
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2301
  apply(drule_tac x="bsimp (bder c (intern r))" in  spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2302
  apply(drule sym)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2303
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2304
   apply(subst blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2305
  apply(case_tac "bnullable (bders_simp (intern (der c r)) s)")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2306
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2307
  apply(auto split: option.split)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2308
  apply(subst oo)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2309
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2310
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2311
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2312
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2313
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2314
lemma oo3:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2315
  assumes "\<forall>r. bders r s = bders_simp r s"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2316
  shows "blexer_simp r (s @ [c]) = blexer r (s @ [c])"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2317
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2318
  apply(simp (no_asm) add: blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2319
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2320
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2321
  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
  2322
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2323
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2324
  using b3 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2325
  apply(simp add: blexer_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2326
  apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2327
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2328
  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
  2329
  apply(simp add: bders_append)     
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2330
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2331
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2332
lemma oo4:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2333
  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
  2334
  shows "bmkeps (bders_simp r (s @ [c])) = bmkeps (bders r (s @ [c]))"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2335
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2336
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2337
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2338
  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
  2339
  apply(simp add: bders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2340
  done
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2341
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2342
lemma oo4:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2343
  shows "blexer_simp r s = blexer r s"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2344
  apply(induct s arbitrary: r rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2345
   apply(simp only: blexer_simp_def blexer_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2346
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2347
  apply(simp only: blexer_simp_def blexer_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2348
  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
  2349
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2350
   apply (simp add: b4)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2351
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2352
  apply(rule impI)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2353
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2354
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2355
  using b3 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2356
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2357
  using b3 bnullable_correctness apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2358
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2359
  using b3 bnullable_correctness mkeps_nullable apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2360
  apply(simp add: bders_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2361
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2362
  using bnullable_correctness apply blast
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2363
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2364
  using bnullable_correctness mkeps_nullable apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2365
  apply(subst erase_bder)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2366
  apply(case_tac "xs \<in> L")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2367
  apply(subst (asm) (2) bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2368
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2369
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2370
  thm bmkeps_retrieve bmkeps_retrieve
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2371
  apply(subst bmkeps_retrieve[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2372
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2373
   apply (simp add: bnullable_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2374
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2375
   
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2376
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2377
  apply(induct s arbitrary: r rule: rev_induct) 
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2378
   apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2379
  apply(rule oo3)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2380
  apply(simp (no_asm) add: blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2381
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2382
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2383
  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
  2384
  apply(simp add: bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2385
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2386
  using b3 apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2387
  apply(simp add: blexer_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2388
  apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2389
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2390
  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
  2391
  apply(simp add: bders_append)     
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2392
  oops
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2393
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2394
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2395
lemma bnullable_simp:
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2396
  assumes "s \<in> L (erase r)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2397
  shows "bmkeps (bders r s) = bmkeps (bders_simp r s)"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2398
  using assms
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2399
  apply(induct s arbitrary: r rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2400
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2401
  apply(simp add: bders_append bders_simp_append)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2402
  apply(subst bmkeps_simp[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2403
  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
  2404
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2405
  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
  2406
  apply(subst bmkeps_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2407
  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
  2408
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2409
  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
  2410
  apply(subst bder_retrieve)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2411
  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
  2412
    
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2413
  apply(drule_tac x="bder a r" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2414
  apply(drule_tac  meta_mp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2415
  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
  2416
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2417
  oops
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2418
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2419
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2420
lemma
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2421
  shows "blexer r s = blexer_simp r s"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2422
  apply(induct s arbitrary: r rule: rev_induct)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2423
   apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2424
  apply(case_tac "xs @ [x] \<in> L r")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2425
   defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2426
   apply(subgoal_tac "blexer (ders xs r) [x] = None")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2427
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2428
    apply(subst blexer_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2429
    apply(simp (no_asm) add: lexer_correct_None)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2430
    apply(simp add: nullable_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2431
    apply(simp add: der_correctness ders_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2432
  apply(simp add: Der_def Ders_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2433
apply(subgoal_tac "blexer r (xs @ [x]) = None")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2434
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2435
    apply (simp add: blexer_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2436
  using lexer_correct_None apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2437
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2438
   apply(subgoal_tac "blexer_simp (ders xs r) [x] = None")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2439
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2440
  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
  2441
   apply(subgoal_tac "[] \<notin> L (erase (bders_simp (intern r) (xs @ [x])))")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2442
  prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2443
  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
  2444
  using blexer_simp_def bnullable_correctness lexer_correct_None apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2445
(* case xs @ [x] \<in> L r *)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2446
  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
  2447
   prefer 2  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2448
  using blexer_correctness lexer_correct_Some apply auto[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2449
    apply (simp add: Posix_injval Posix_mkeps)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2450
  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
  2451
  apply(clarify)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2452
  apply(subgoal_tac "blexer_simp (ders xs r) [x] = Some v")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2453
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2454
   apply(simp add: blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2455
   apply(auto)[1]
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2456
    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
  2457
  using b3 blexer_def apply fastforce
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2458
  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
  2459
   prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2460
   apply(simp add: blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2461
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2462
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2463
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2464
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2465
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2466
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2467
  apply(subst blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2468
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2469
  apply(auto)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2470
  apply(drule_tac x="der a r" in meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2471
  apply(subst blexer_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2472
   apply(subgoal_tac "bnullable (bders (intern r) (a # s))")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2473
    prefer 2
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2474
    apply (me tis Posix_injval blexer_correctness blexer_def lexer_correctness(2))
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2475
  apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2476
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2477
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2478
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2479
lemma
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2480
  shows "blexer r s = blexer_simp r s"
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2481
  apply(induct s arbitrary: r)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2482
   apply(simp add: blexer_def blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2483
  apply(case_tac "s \<in> L (der a r)")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2484
   defer
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2485
   apply(subgoal_tac "blexer (der a r) s = None")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2486
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2487
    apply (simp add: blexer_correctness lexer_correct_None)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2488
apply(subgoal_tac "blexer r (a # s) = None")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2489
    prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2490
    apply (simp add: blexer_correctness)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2491
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2492
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2493
   apply(subst blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2494
   apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2495
  apply(drule_tac  x="der a r" in  meta_spec)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2496
   apply(subgoal_tac "s \<notin> L(erase (bder a (intern  r)))")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2497
  prefer 2
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2498
    apply simp
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2499
   
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2500
   apply(simp only:)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2501
   apply(subst blexer_simp_def)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2502
   apply(subgoal_tac "\<not> bnullable (bders_simp (intern r) (a # s))")
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2503
    apply(simp)
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2504
   apply(subst bnullable_correctness[symmetric])
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2505
  apply(simp)
318
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2506
  oops
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2507
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2508
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2509
lemma flts_bsimp:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2510
  "flts (map bsimp rs) = map bsimp (flts rs)"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2511
apply(induct rs taking: size rule: measure_induct)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2512
  apply(case_tac x)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2513
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2514
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2515
  apply(induct rs rule: flts.induct)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2516
        apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2517
       apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2518
      defer
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2519
      apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2520
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2521
    defer
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2522
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2523
  apply(subst List.list.map(2))
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2524
   apply(simp only: flts.simps)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2525
   apply(subst k0)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2526
   apply(subst map_append)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2527
   apply(simp only:)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2528
   apply(simp del: bsimp.simps)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2529
   apply(case_tac rs1)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2530
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2531
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2532
  apply(case_tac list)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2533
    apply(simp_all)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2534
  thm map
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2535
  apply(subst map.simps)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2536
        apply(auto)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2537
   defer
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2538
  apply(case_tac "(bsimp va) = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2539
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2540
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2541
  using b3 apply for ce
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2542
   apply(case_tac "(bsimp a2) = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2543
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2544
  apply (me tis bder.simps(1) bsimp.simps(3) bsimp_AALTs.simps(1) bsimp_ASEQ0 bsimp_fuse flts.simps(1) flts.simps(2) fuse.simps(1))
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2545
    apply(case_tac "\<exists>bs. (bsimp a1) = AONE bs")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2546
     apply(clarify)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2547
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2548
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2549
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2550
lemma XXX:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2551
  shows "bsimp (bsimp a) = bsimp a"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2552
  sorry
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2553
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2554
lemma bder_fuse:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2555
  shows "bder c (fuse bs a) = fuse bs  (bder c a)"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2556
  apply(induct a arbitrary: bs c)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2557
       apply(simp_all)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2558
  done
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2559
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2560
lemma XXX2:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2561
  shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2562
  apply(induct a arbitrary: c)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2563
       apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2564
      apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2565
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2566
  prefer 3
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2567
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2568
   apply(auto)[1]
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2569
   apply(case_tac "(bsimp a1) = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2570
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2571
  using b3 apply force
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2572
   apply(case_tac "(bsimp a2) = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2573
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2574
  apply (metis bder.simps(1) bsimp.simps(3) bsimp_AALTs.simps(1) bsimp_ASEQ0 bsimp_fuse flts.simps(1) flts.simps(2) fuse.simps(1))
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2575
    apply(case_tac "\<exists>bs. (bsimp a1) = AONE bs")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2576
     apply(clarify)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2577
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2578
  apply(subst bsimp_ASEQ2)  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2579
     apply(subgoal_tac "bmkeps a1 = bs")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2580
      prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2581
      apply (simp add: bmkeps_simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2582
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2583
  apply(subst (1) bsimp_fuse[symmetric])
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2584
     defer
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2585
  apply(subst bsimp_ASEQ1)  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2586
        apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2587
       apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2588
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2589
     apply(auto)[1]
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2590
      apply (metis XXX bmkeps_simp bsimp_fuse)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2591
  using b3 apply blast
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2592
  apply (smt XXX b3 bder.simps(1) bder.simps(5) bnullable.simps(2) bsimp.simps(1) bsimp_ASEQ.simps(1) bsimp_ASEQ0 bsimp_ASEQ1)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2593
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2594
   prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2595
   apply(subst bder_fuse)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2596
  apply(subst bsimp_fuse[symmetric])
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2597
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2598
  sorry
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2599
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2600
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2601
thm bsimp_AALTs.simps
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2602
thm bsimp.simps
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2603
thm flts.simps
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2604
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2605
lemma XXX3:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2606
  "bsimp (bders (bsimp r) s) = bsimp (bders r s)"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2607
  apply(induct s arbitrary: r rule:  rev_induct)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2608
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2609
   apply (simp add: XXX)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2610
  apply(simp add: bders_append)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2611
  apply(subst (2) XXX2[symmetric])
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2612
  apply(subst XXX2[symmetric])
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2613
  apply(drule_tac x="r" in meta_spec)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2614
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2615
  done
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2616
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2617
lemma XXX4:
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2618
 "bders_simp (bsimp r) s = bsimp (bders r s)"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2619
  apply(induct s arbitrary: r)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2620
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2621
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2622
  by (metis XXX2)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2623
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2624
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2625
lemma
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2626
  assumes "bnullable (bder c r)"  "bnullable (bder c (bsimp r))"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2627
  shows "bmkeps (bder c r) = bmkeps (bder c (bsimp r))"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2628
 using  assms
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2629
  apply(induct r arbitrary: c)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2630
      apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2631
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2632
    apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2633
  prefer 3
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2634
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2635
  apply(auto)[1]
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2636
    apply(case_tac "(bsimp r1) = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2637
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2638
   apply(case_tac "(bsimp r2) = AZERO")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2639
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2640
  apply (simp add: bsimp_ASEQ0)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2641
    apply(case_tac "\<exists>bs. (bsimp r1) = AONE bs")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2642
     apply(clarify)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2643
     apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2644
     apply(subgoal_tac "bnullable r1")
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2645
      prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2646
  using b3 apply force
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2647
      apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2648
  apply(simp add: bsimp_ASEQ2) 
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2649
      prefer 2
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2650
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2651
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2652
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2653
  apply(subst bsimp_ASEQ2)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2654
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2655
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2656
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2657
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2658
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2659
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2660
lemma
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2661
  assumes  "bnullable (bders a (s1 @ s2))" "bnullable (bders (bsimp (bders a s1)) s2)"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2662
  shows "bmkeps (bders a (s1 @ s2)) = bmkeps (bders (bsimp (bders a s1)) s2)"
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2663
  using  assms
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2664
  apply(induct s2 arbitrary: a s1)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2665
   apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2666
  using bmkeps_simp apply blast
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2667
  apply(simp add: bders_append)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2668
  apply(drule_tac x="aa" in meta_spec)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2669
  apply(drule_tac x="s1 @ [a]" in meta_spec)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2670
  apply(drule meta_mp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2671
   apply(simp add: bders_append)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2672
  apply(simp add: bders_append)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2673
  apply(drule meta_mp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2674
   apply (metis b4 bders.simps(2) bders_simp.simps(2))
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2675
  apply(simp)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2676
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2677
   apply (met is b4 bders.simps(2) bders_simp.simps(2))
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2678
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2679
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2680
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2681
  using b3 apply blast
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2682
  using b3 apply auto[1]
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2683
  apply(auto simp add: blex_def)
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2684
    prefer 3
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2685
  
43e070803c1c updated
Christian Urban <urbanc@in.tum.de>
parents: 317
diff changeset
  2686
  
314
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2687
  
20a57552d722 updated
Christian Urban <urbanc@in.tum.de>
parents: 313
diff changeset
  2688
295
c6ec5f369037 updated
Christian Urban <urbanc@in.tum.de>
parents: 293
diff changeset
  2689
148
702ed601349b updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
  2690
end