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