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