thys/BitCoded2CT.thy
author Chengsong
Fri, 13 Sep 2019 15:39:11 +0100
changeset 354 97741a7b8b37
parent 353 eb08de92c4dc
child 355 04391e303101
permissions -rw-r--r--
marked by QUESTION
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
350
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
     1
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
     2
theory BitCoded2CT
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
     3
  imports "Lexer" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
     4
begin
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
     5
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
     6
section \<open>Bit-Encodings\<close>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
     7
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
     8
datatype bit = Z | S
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
     9
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    10
fun 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    11
  code :: "val \<Rightarrow> bit list"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    12
where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    13
  "code Void = []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    14
| "code (Char c) = []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    15
| "code (Left v) = Z # (code v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    16
| "code (Right v) = S # (code v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    17
| "code (Seq v1 v2) = (code v1) @ (code v2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    18
| "code (Stars []) = [S]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    19
| "code (Stars (v # vs)) =  (Z # code v) @ code (Stars vs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    20
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    21
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    22
fun 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    23
  Stars_add :: "val \<Rightarrow> val \<Rightarrow> val"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    24
where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    25
  "Stars_add v (Stars vs) = Stars (v # vs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    26
| "Stars_add v _ = Stars [v]" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    27
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    28
function
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    29
  decode' :: "bit list \<Rightarrow> rexp \<Rightarrow> (val * bit list)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    30
where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    31
  "decode' ds ZERO = (Void, [])"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    32
| "decode' ds ONE = (Void, ds)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    33
| "decode' ds (CHAR d) = (Char d, ds)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    34
| "decode' [] (ALT r1 r2) = (Void, [])"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    35
| "decode' (Z # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r1 in (Left v, ds'))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    36
| "decode' (S # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r2 in (Right v, ds'))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    37
| "decode' ds (SEQ r1 r2) = (let (v1, ds') = decode' ds r1 in
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    38
                             let (v2, ds'') = decode' ds' r2 in (Seq v1 v2, ds''))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    39
| "decode' [] (STAR r) = (Void, [])"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    40
| "decode' (S # ds) (STAR r) = (Stars [], ds)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    41
| "decode' (Z # ds) (STAR r) = (let (v, ds') = decode' ds r in
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    42
                                    let (vs, ds'') = decode' ds' (STAR r) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    43
                                    in (Stars_add v vs, ds''))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    44
by pat_completeness auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    45
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    46
lemma decode'_smaller:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    47
  assumes "decode'_dom (ds, r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    48
  shows "length (snd (decode' ds r)) \<le> length ds"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    49
using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    50
apply(induct ds r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    51
apply(auto simp add: decode'.psimps split: prod.split)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    52
using dual_order.trans apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    53
by (meson dual_order.trans le_SucI)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    54
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    55
termination "decode'"  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    56
apply(relation "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))") 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    57
apply(auto dest!: decode'_smaller)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    58
by (metis less_Suc_eq_le snd_conv)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    59
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    60
definition
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    61
  decode :: "bit list \<Rightarrow> rexp \<Rightarrow> val option"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    62
where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    63
  "decode ds r \<equiv> (let (v, ds') = decode' ds r 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    64
                  in (if ds' = [] then Some v else None))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    65
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    66
lemma decode'_code_Stars:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    67
  assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> (\<forall>x. decode' (code v @ x) r = (v, x)) \<and> flat v \<noteq> []" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    68
  shows "decode' (code (Stars vs) @ ds) (STAR r) = (Stars vs, ds)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    69
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    70
  apply(induct vs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    71
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    72
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    73
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    74
lemma decode'_code:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    75
  assumes "\<Turnstile> v : r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    76
  shows "decode' ((code v) @ ds) r = (v, ds)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    77
using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    78
  apply(induct v r arbitrary: ds) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    79
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    80
  using decode'_code_Stars by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    81
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    82
lemma decode_code:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    83
  assumes "\<Turnstile> v : r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    84
  shows "decode (code v) r = Some v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    85
  using assms unfolding decode_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    86
  by (smt append_Nil2 decode'_code old.prod.case)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    87
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    88
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    89
section {* Annotated Regular Expressions *}
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    90
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    91
datatype arexp = 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    92
  AZERO
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    93
| AONE "bit list"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    94
| ACHAR "bit list" char
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    95
| ASEQ "bit list" arexp arexp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    96
| AALTs "bit list" "arexp list"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    97
| ASTAR "bit list" arexp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    98
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
    99
abbreviation
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   100
  "AALT bs r1 r2 \<equiv> AALTs bs [r1, r2]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   101
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   102
fun asize :: "arexp \<Rightarrow> nat" where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   103
  "asize AZERO = 1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   104
| "asize (AONE cs) = 1" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   105
| "asize (ACHAR cs c) = 1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   106
| "asize (AALTs cs rs) = Suc (sum_list (map asize rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   107
| "asize (ASEQ cs r1 r2) = Suc (asize r1 + asize r2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   108
| "asize (ASTAR cs r) = Suc (asize r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   109
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   110
fun 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   111
  erase :: "arexp \<Rightarrow> rexp"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   112
where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   113
  "erase AZERO = ZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   114
| "erase (AONE _) = ONE"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   115
| "erase (ACHAR _ c) = CHAR c"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   116
| "erase (AALTs _ []) = ZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   117
| "erase (AALTs _ [r]) = (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   118
| "erase (AALTs bs (r#rs)) = ALT (erase r) (erase (AALTs bs rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   119
| "erase (ASEQ _ r1 r2) = SEQ (erase r1) (erase r2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   120
| "erase (ASTAR _ r) = STAR (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   121
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   122
lemma decode_code_erase:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   123
  assumes "\<Turnstile> v : (erase  a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   124
  shows "decode (code v) (erase a) = Some v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   125
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   126
  by (simp add: decode_code) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   127
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   128
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   129
fun nonalt :: "arexp \<Rightarrow> bool"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   130
  where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   131
  "nonalt (AALTs bs2 rs) = False"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   132
| "nonalt r = True"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   133
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   134
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   135
fun good :: "arexp \<Rightarrow> bool" where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   136
  "good AZERO = False"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   137
| "good (AONE cs) = True" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   138
| "good (ACHAR cs c) = True"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   139
| "good (AALTs cs []) = False"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   140
| "good (AALTs cs [r]) = False"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   141
| "good (AALTs cs (r1#r2#rs)) = (\<forall>r' \<in> set (r1#r2#rs). good r' \<and> nonalt r')"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   142
| "good (ASEQ _ AZERO _) = False"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   143
| "good (ASEQ _ (AONE _) _) = False"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   144
| "good (ASEQ _ _ AZERO) = False"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   145
| "good (ASEQ cs r1 r2) = (good r1 \<and> good r2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   146
| "good (ASTAR cs r) = True"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   147
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   148
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   149
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   150
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   151
fun fuse :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp" where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   152
  "fuse bs AZERO = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   153
| "fuse bs (AONE cs) = AONE (bs @ cs)" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   154
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   155
| "fuse bs (AALTs cs rs) = AALTs (bs @ cs) rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   156
| "fuse bs (ASEQ cs r1 r2) = ASEQ (bs @ cs) r1 r2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   157
| "fuse bs (ASTAR cs r) = ASTAR (bs @ cs) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   158
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   159
lemma fuse_append:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   160
  shows "fuse (bs1 @ bs2) r = fuse bs1 (fuse bs2 r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   161
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   162
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   163
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   164
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   165
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   166
fun intern :: "rexp \<Rightarrow> arexp" where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   167
  "intern ZERO = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   168
| "intern ONE = AONE []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   169
| "intern (CHAR c) = ACHAR [] c"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   170
| "intern (ALT r1 r2) = AALT [] (fuse [Z] (intern r1)) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   171
                                (fuse [S]  (intern r2))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   172
| "intern (SEQ r1 r2) = ASEQ [] (intern r1) (intern r2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   173
| "intern (STAR r) = ASTAR [] (intern r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   174
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   175
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   176
fun retrieve :: "arexp \<Rightarrow> val \<Rightarrow> bit list" where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   177
  "retrieve (AONE bs) Void = bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   178
| "retrieve (ACHAR bs c) (Char d) = bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   179
| "retrieve (AALTs bs [r]) v = bs @ retrieve r v" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   180
| "retrieve (AALTs bs (r#rs)) (Left v) = bs @ retrieve r v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   181
| "retrieve (AALTs bs (r#rs)) (Right v) = bs @ retrieve (AALTs [] rs) v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   182
| "retrieve (ASEQ bs r1 r2) (Seq v1 v2) = bs @ retrieve r1 v1 @ retrieve r2 v2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   183
| "retrieve (ASTAR bs r) (Stars []) = bs @ [S]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   184
| "retrieve (ASTAR bs r) (Stars (v#vs)) = 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   185
     bs @ [Z] @ retrieve r v @ retrieve (ASTAR [] r) (Stars vs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   186
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   187
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   188
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   189
fun
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   190
 bnullable :: "arexp \<Rightarrow> bool"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   191
where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   192
  "bnullable (AZERO) = False"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   193
| "bnullable (AONE bs) = True"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   194
| "bnullable (ACHAR bs c) = False"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   195
| "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   196
| "bnullable (ASEQ bs r1 r2) = (bnullable r1 \<and> bnullable r2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   197
| "bnullable (ASTAR bs r) = True"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   198
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   199
fun 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   200
  bmkeps :: "arexp \<Rightarrow> bit list"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   201
where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   202
  "bmkeps(AONE bs) = bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   203
| "bmkeps(ASEQ bs r1 r2) = bs @ (bmkeps r1) @ (bmkeps r2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   204
| "bmkeps(AALTs bs [r]) = bs @ (bmkeps r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   205
| "bmkeps(AALTs bs (r#rs)) = (if bnullable(r) then bs @ (bmkeps r) else (bmkeps (AALTs bs rs)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   206
| "bmkeps(ASTAR bs r) = bs @ [S]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   207
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   208
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   209
fun
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   210
 bder :: "char \<Rightarrow> arexp \<Rightarrow> arexp"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   211
where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   212
  "bder c (AZERO) = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   213
| "bder c (AONE bs) = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   214
| "bder c (ACHAR bs d) = (if c = d then AONE bs else AZERO)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   215
| "bder c (AALTs bs rs) = AALTs bs (map (bder c) rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   216
| "bder c (ASEQ bs r1 r2) = 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   217
     (if bnullable r1
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   218
      then AALT bs (ASEQ [] (bder c r1) r2) (fuse (bmkeps r1) (bder c r2))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   219
      else ASEQ bs (bder c r1) r2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   220
| "bder c (ASTAR bs r) = ASEQ bs (fuse [Z] (bder c r)) (ASTAR [] r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   221
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   222
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   223
fun 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   224
  bders :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   225
where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   226
  "bders r [] = r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   227
| "bders r (c#s) = bders (bder c r) s"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   228
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   229
lemma bders_append:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   230
  "bders r (s1 @ s2) = bders (bders r s1) s2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   231
  apply(induct s1 arbitrary: r s2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   232
  apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   233
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   234
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   235
lemma bnullable_correctness:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   236
  shows "nullable (erase r) = bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   237
  apply(induct r rule: erase.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   238
  apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   239
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   240
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   241
lemma erase_fuse:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   242
  shows "erase (fuse bs r) = erase r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   243
  apply(induct r rule: erase.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   244
  apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   245
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   246
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   247
lemma erase_intern [simp]:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   248
  shows "erase (intern r) = r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   249
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   250
  apply(simp_all add: erase_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   251
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   252
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   253
lemma erase_bder [simp]:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   254
  shows "erase (bder a r) = der a (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   255
  apply(induct r rule: erase.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   256
  apply(simp_all add: erase_fuse bnullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   257
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   258
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   259
lemma erase_bders [simp]:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   260
  shows "erase (bders r s) = ders s (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   261
  apply(induct s arbitrary: r )
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   262
  apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   263
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   264
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   265
lemma retrieve_encode_STARS:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   266
  assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> code v = retrieve (intern r) v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   267
  shows "code (Stars vs) = retrieve (ASTAR [] (intern r)) (Stars vs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   268
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   269
  apply(induct vs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   270
  apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   271
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   272
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   273
lemma retrieve_fuse2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   274
  assumes "\<Turnstile> v : (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   275
  shows "retrieve (fuse bs r) v = bs @ retrieve r v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   276
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   277
  apply(induct r arbitrary: v bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   278
         apply(auto elim: Prf_elims)[4]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   279
   defer
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   280
  using retrieve_encode_STARS
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   281
   apply(auto elim!: Prf_elims)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   282
   apply(case_tac vs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   283
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   284
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   285
  (* AALTs  case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   286
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   287
  apply(case_tac x2a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   288
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   289
   apply(auto elim!: Prf_elims)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   290
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   291
   apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   292
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   293
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   294
  apply(auto elim!: Prf_elims)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   295
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   296
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   297
lemma retrieve_fuse:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   298
  assumes "\<Turnstile> v : r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   299
  shows "retrieve (fuse bs (intern r)) v = bs @ retrieve (intern r) v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   300
  using assms 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   301
  by (simp_all add: retrieve_fuse2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   302
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   303
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   304
lemma retrieve_code:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   305
  assumes "\<Turnstile> v : r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   306
  shows "code v = retrieve (intern r) v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   307
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   308
  apply(induct v r )
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   309
  apply(simp_all add: retrieve_fuse retrieve_encode_STARS)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   310
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   311
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   312
lemma r:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   313
  assumes "bnullable (AALTs bs (a # rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   314
  shows "bnullable a \<or> (\<not> bnullable a \<and> bnullable (AALTs bs rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   315
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   316
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   317
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   318
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   319
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   320
lemma r0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   321
  assumes "bnullable a" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   322
  shows  "bmkeps (AALTs bs (a # rs)) = bs @ (bmkeps a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   323
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   324
  by (metis bmkeps.simps(3) bmkeps.simps(4) list.exhaust)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   325
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   326
lemma r1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   327
  assumes "\<not> bnullable a" "bnullable (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   328
  shows  "bmkeps (AALTs bs (a # rs)) = bmkeps (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   329
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   330
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   331
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   332
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   333
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   334
lemma r2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   335
  assumes "x \<in> set rs" "bnullable x"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   336
  shows "bnullable (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   337
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   338
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   339
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   340
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   341
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   342
lemma  r3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   343
  assumes "\<not> bnullable r" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   344
          " \<exists> x \<in> set rs. bnullable x"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   345
  shows "retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs))) =
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   346
         retrieve (AALTs bs (r # rs)) (mkeps (erase (AALTs bs (r # rs))))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   347
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   348
  apply(induct rs arbitrary: r bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   349
   apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   350
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   351
  using bnullable_correctness apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   352
    apply(auto simp add: bnullable_correctness mkeps_nullable retrieve_fuse2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   353
   apply(subst retrieve_fuse2[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   354
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   355
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   356
  apply(case_tac "bnullable a")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   357
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   358
  apply(drule_tac x="a" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   359
  apply(drule_tac x="bs" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   360
  apply(drule meta_mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   361
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   362
  apply(drule meta_mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   363
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   364
  apply(subst retrieve_fuse2[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   365
  apply(case_tac rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   366
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   367
   apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   368
      apply (simp add: bnullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   369
  apply (metis append_Nil2 bnullable_correctness erase_fuse fuse.simps(4) list.set_intros(1) mkeps.simps(3) mkeps_nullable nullable.simps(4) r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   370
    apply (simp add: bnullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   371
  apply (metis append_Nil2 bnullable_correctness erase.simps(6) erase_fuse fuse.simps(4) list.set_intros(2) mkeps.simps(3) mkeps_nullable r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   372
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   373
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   374
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   375
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   376
lemma t: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   377
  assumes "\<forall>r \<in> set rs. nullable (erase r) \<longrightarrow> bmkeps r = retrieve r (mkeps (erase r))" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   378
          "nullable (erase (AALTs bs rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   379
  shows " bmkeps (AALTs bs rs) = retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   380
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   381
  apply(induct rs arbitrary: bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   382
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   383
  apply(auto simp add: bnullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   384
   apply(case_tac rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   385
     apply(auto simp add: bnullable_correctness)[2]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   386
   apply(subst r1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   387
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   388
    apply(rule r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   389
     apply(assumption)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   390
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   391
   apply(drule_tac x="bs" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   392
   apply(drule meta_mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   393
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   394
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   395
  apply(case_tac "bnullable a")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   396
    apply(subst r0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   397
     apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   398
    apply(subgoal_tac "nullable (erase a)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   399
  prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   400
  using bnullable_correctness apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   401
  apply (metis (no_types, lifting) erase.simps(5) erase.simps(6) list.exhaust mkeps.simps(3) retrieve.simps(3) retrieve.simps(4))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   402
  apply(subst r1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   403
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   404
  using r2 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   405
  apply(drule_tac x="bs" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   406
   apply(drule meta_mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   407
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   408
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   409
  using r3 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   410
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   411
  using r3 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   412
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   413
lemma bmkeps_retrieve:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   414
  assumes "nullable (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   415
  shows "bmkeps r = retrieve r (mkeps (erase r))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   416
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   417
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   418
         apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   419
        apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   420
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   421
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   422
   defer
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   423
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   424
  apply(rule t)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   425
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   426
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   427
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   428
lemma bder_retrieve:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   429
  assumes "\<Turnstile> v : der c (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   430
  shows "retrieve (bder c r) v = retrieve r (injval (erase r) c v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   431
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   432
  apply(induct r arbitrary: v rule: erase.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   433
         apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   434
         apply(erule Prf_elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   435
        apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   436
        apply(erule Prf_elims) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   437
        apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   438
      apply(case_tac "c = ca")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   439
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   440
       apply(erule Prf_elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   441
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   442
      apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   443
       apply(erule Prf_elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   444
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   445
      apply(erule Prf_elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   446
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   447
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   448
  apply(rename_tac "r\<^sub>1" "r\<^sub>2" rs v)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   449
    apply(erule Prf_elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   450
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   451
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   452
    apply(case_tac rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   453
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   454
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   455
  apply (smt Prf_elims(3) injval.simps(2) injval.simps(3) retrieve.simps(4) retrieve.simps(5) same_append_eq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   456
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   457
   apply(case_tac "nullable (erase r1)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   458
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   459
  apply(erule Prf_elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   460
     apply(subgoal_tac "bnullable r1")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   461
  prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   462
  using bnullable_correctness apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   463
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   464
     apply(erule Prf_elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   465
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   466
   apply(subgoal_tac "bnullable r1")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   467
  prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   468
  using bnullable_correctness apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   469
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   470
    apply(simp add: retrieve_fuse2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   471
    apply(simp add: bmkeps_retrieve)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   472
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   473
   apply(erule Prf_elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   474
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   475
  using bnullable_correctness apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   476
  apply(rename_tac bs r v)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   477
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   478
  apply(erule Prf_elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   479
     apply(clarify)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   480
  apply(erule Prf_elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   481
  apply(clarify)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   482
  apply(subst injval.simps)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   483
  apply(simp del: retrieve.simps)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   484
  apply(subst retrieve.simps)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   485
  apply(subst retrieve.simps)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   486
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   487
  apply(simp add: retrieve_fuse2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   488
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   489
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   490
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   491
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   492
lemma MAIN_decode:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   493
  assumes "\<Turnstile> v : ders s r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   494
  shows "Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   495
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   496
proof (induct s arbitrary: v rule: rev_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   497
  case Nil
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   498
  have "\<Turnstile> v : ders [] r" by fact
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   499
  then have "\<Turnstile> v : r" by simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   500
  then have "Some v = decode (retrieve (intern r) v) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   501
    using decode_code retrieve_code by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   502
  then show "Some (flex r id [] v) = decode (retrieve (bders (intern r) []) v) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   503
    by simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   504
next
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   505
  case (snoc c s v)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   506
  have IH: "\<And>v. \<Turnstile> v : ders s r \<Longrightarrow> 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   507
     Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r" by fact
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   508
  have asm: "\<Turnstile> v : ders (s @ [c]) r" by fact
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   509
  then have asm2: "\<Turnstile> injval (ders s r) c v : ders s r" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   510
    by (simp add: Prf_injval ders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   511
  have "Some (flex r id (s @ [c]) v) = Some (flex r id s (injval (ders s r) c v))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   512
    by (simp add: flex_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   513
  also have "... = decode (retrieve (bders (intern r) s) (injval (ders s r) c v)) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   514
    using asm2 IH by simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   515
  also have "... = decode (retrieve (bder c (bders (intern r) s)) v) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   516
    using asm by (simp_all add: bder_retrieve ders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   517
  finally show "Some (flex r id (s @ [c]) v) = 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   518
                 decode (retrieve (bders (intern r) (s @ [c])) v) r" by (simp add: bders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   519
qed
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   520
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   521
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   522
definition blex where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   523
 "blex a s \<equiv> if bnullable (bders a s) then Some (bmkeps (bders a s)) else None"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   524
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   525
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   526
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   527
definition blexer where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   528
 "blexer r s \<equiv> if bnullable (bders (intern r) s) then 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   529
                decode (bmkeps (bders (intern r) s)) r else None"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   530
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   531
lemma blexer_correctness:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   532
  shows "blexer r s = lexer r s"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   533
proof -
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   534
  { define bds where "bds \<equiv> bders (intern r) s"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   535
    define ds  where "ds \<equiv> ders s r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   536
    assume asm: "nullable ds"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   537
    have era: "erase bds = ds" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   538
      unfolding ds_def bds_def by simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   539
    have mke: "\<Turnstile> mkeps ds : ds"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   540
      using asm by (simp add: mkeps_nullable)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   541
    have "decode (bmkeps bds) r = decode (retrieve bds (mkeps ds)) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   542
      using bmkeps_retrieve
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   543
      using asm era by (simp add: bmkeps_retrieve)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   544
    also have "... =  Some (flex r id s (mkeps ds))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   545
      using mke by (simp_all add: MAIN_decode ds_def bds_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   546
    finally have "decode (bmkeps bds) r = Some (flex r id s (mkeps ds))" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   547
      unfolding bds_def ds_def .
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   548
  }
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   549
  then show "blexer r s = lexer r s"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   550
    unfolding blexer_def lexer_flex
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   551
    apply(subst bnullable_correctness[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   552
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   553
    done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   554
qed
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   555
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   556
lemma asize0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   557
  shows "0 < asize r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   558
  apply(induct  r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   559
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   560
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   561
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   562
lemma asize_fuse:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   563
  shows "asize (fuse bs r) = asize r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   564
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   565
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   566
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   567
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   568
lemma bder_fuse:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   569
  shows "bder c (fuse bs a) = fuse bs  (bder c a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   570
  apply(induct a arbitrary: bs c)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   571
  apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   572
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   573
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   574
lemma map_bder_fuse:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   575
  shows "map (bder c \<circ> fuse bs1) as1 = map (fuse bs1) (map (bder c) as1)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   576
  apply(induct as1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   577
  apply(auto simp add: bder_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   578
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   579
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   580
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   581
fun nonnested :: "arexp \<Rightarrow> bool"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   582
  where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   583
  "nonnested (AALTs bs2 []) = True"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   584
| "nonnested (AALTs bs2 ((AALTs bs1 rs1) # rs2)) = False"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   585
| "nonnested (AALTs bs2 (r # rs2)) = nonnested (AALTs bs2 rs2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   586
| "nonnested r = True"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   587
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   588
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   589
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   590
fun distinctBy :: "'a list \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b set \<Rightarrow> 'a list"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   591
  where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   592
  "distinctBy [] f acc = []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   593
| "distinctBy (x#xs) f acc = 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   594
     (if (f x) \<in> acc then distinctBy xs f acc 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   595
      else x # (distinctBy xs f ({f x} \<union> acc)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   596
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   597
fun flts :: "arexp list \<Rightarrow> arexp list"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   598
  where 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   599
  "flts [] = []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   600
| "flts (AZERO # rs) = flts rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   601
| "flts ((AALTs bs  rs1) # rs) = (map (fuse bs) rs1) @ flts rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   602
| "flts (r1 # rs) = r1 # flts rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   603
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   604
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   605
fun spill :: "arexp list \<Rightarrow> arexp list"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   606
  where 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   607
  "spill [] = []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   608
| "spill ((AALTs bs rs1) # rs) = (map (fuse bs) rs1) @ spill rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   609
| "spill (r1 # rs) = r1 # spill rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   610
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   611
lemma  spill_Cons:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   612
  shows "spill (r # rs1) = spill [r] @ spill rs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   613
  apply(induct r arbitrary: rs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   614
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   615
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   616
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   617
lemma  spill_append:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   618
  shows "spill (rs1 @ rs2) = spill rs1 @ spill rs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   619
  apply(induct rs1 arbitrary: rs2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   620
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   621
  by (metis append.assoc spill_Cons)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   622
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   623
fun bsimp_ASEQ :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp \<Rightarrow> arexp"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   624
  where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   625
  "bsimp_ASEQ _ AZERO _ = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   626
| "bsimp_ASEQ _ _ AZERO = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   627
| "bsimp_ASEQ bs1 (AONE bs2) r2 = fuse (bs1 @ bs2) r2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   628
| "bsimp_ASEQ bs1 r1 r2 = ASEQ  bs1 r1 r2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   629
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   630
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   631
fun bsimp_AALTs :: "bit list \<Rightarrow> arexp list \<Rightarrow> arexp"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   632
  where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   633
  "bsimp_AALTs _ [] = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   634
| "bsimp_AALTs bs1 [r] = fuse bs1 r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   635
| "bsimp_AALTs bs1 rs = AALTs bs1 rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   636
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   637
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   638
fun bsimp :: "arexp \<Rightarrow> arexp" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   639
  where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   640
  "bsimp (ASEQ bs1 r1 r2) = bsimp_ASEQ bs1 (bsimp r1) (bsimp r2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   641
| "bsimp (AALTs bs1 rs) = bsimp_AALTs bs1 (flts (map bsimp rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   642
| "bsimp r = r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   643
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   644
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   645
inductive contains2 :: "arexp \<Rightarrow> bit list \<Rightarrow> bool" ("_ >>2 _" [51, 50] 50)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   646
  where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   647
  "AONE bs >>2 bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   648
| "ACHAR bs c >>2 bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   649
| "\<lbrakk>a1 >>2 bs1; a2 >>2 bs2\<rbrakk> \<Longrightarrow> ASEQ bs a1 a2 >>2 bs @ bs1 @ bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   650
| "r >>2 bs1 \<Longrightarrow> AALTs bs (r#rs) >>2 bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   651
| "AALTs bs rs >>2 bs @ bs1 \<Longrightarrow> AALTs bs (r#rs) >>2 bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   652
| "ASTAR bs r >>2 bs @ [S]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   653
| "\<lbrakk>r >>2 bs1; ASTAR [] r >>2 bs2\<rbrakk> \<Longrightarrow> ASTAR bs r >>2 bs @ Z # bs1 @ bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   654
| "r >>2 bs \<Longrightarrow> (bsimp r) >>2 bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   655
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   656
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   657
inductive contains :: "arexp \<Rightarrow> bit list \<Rightarrow> bool" ("_ >> _" [51, 50] 50)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   658
  where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   659
  "AONE bs >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   660
| "ACHAR bs c >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   661
| "\<lbrakk>a1 >> bs1; a2 >> bs2\<rbrakk> \<Longrightarrow> ASEQ bs a1 a2 >> bs @ bs1 @ bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   662
| "r >> bs1 \<Longrightarrow> AALTs bs (r#rs) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   663
| "AALTs bs rs >> bs @ bs1 \<Longrightarrow> AALTs bs (r#rs) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   664
| "ASTAR bs r >> bs @ [S]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   665
| "\<lbrakk>r >> bs1; ASTAR [] r >> bs2\<rbrakk> \<Longrightarrow> ASTAR bs r >> bs @ Z # bs1 @ bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   666
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   667
lemma contains0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   668
  assumes "a >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   669
  shows "(fuse bs1 a) >> bs1 @ bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   670
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   671
  apply(induct arbitrary: bs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   672
  apply(auto intro: contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   673
       apply (metis append.assoc contains.intros(3))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   674
     apply (metis append.assoc contains.intros(4))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   675
  apply (metis append.assoc contains.intros(5))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   676
    apply (metis append.assoc contains.intros(6))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   677
   apply (metis append_assoc contains.intros(7))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   678
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   679
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   680
lemma contains1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   681
  assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> intern r >> code v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   682
  shows "ASTAR [] (intern r) >> code (Stars vs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   683
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   684
  apply(induct vs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   685
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   686
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   687
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   688
   apply(subst (2) append_Nil[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   689
  apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   690
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   691
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   692
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   693
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   694
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   695
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   696
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   697
lemma contains2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   698
  assumes "\<Turnstile> v : r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   699
  shows "(intern r) >> code v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   700
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   701
  apply(induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   702
       prefer 4
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   703
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   704
       apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   705
   prefer 4
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   706
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   707
      apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   708
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   709
  apply(subst (3) append_Nil[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   710
  apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   711
      apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   712
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   713
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   714
  apply(subst (9) append_Nil[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   715
    apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   716
    apply (metis append_Cons append_self_conv2 contains0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   717
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   718
     apply(subst (9) append_Nil[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   719
   apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   720
   back
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   721
   apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   722
  apply(drule_tac ?bs1.0="[S]" in contains0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   723
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   724
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   725
  apply(case_tac vs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   726
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   727
  apply (metis append_Nil contains.intros(6))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   728
  using contains1 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   729
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   730
lemma qq1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   731
  assumes "\<exists>r \<in> set rs. bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   732
  shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   733
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   734
  apply(induct rs arbitrary: rs1 bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   735
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   736
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   737
  by (metis Nil_is_append_conv bmkeps.simps(4) neq_Nil_conv r0 split_list_last)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   738
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   739
lemma qq2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   740
  assumes "\<forall>r \<in> set rs. \<not> bnullable r" "\<exists>r \<in> set rs1. bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   741
  shows "bmkeps (AALTs bs (rs @ rs1)) = bmkeps (AALTs bs rs1)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   742
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   743
  apply(induct rs arbitrary: rs1 bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   744
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   745
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   746
  by (metis append_assoc in_set_conv_decomp r1 r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   747
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   748
lemma qq2a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   749
  assumes "\<not> bnullable r" "\<exists>r \<in> set rs1. bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   750
  shows "bmkeps (AALTs bs (r # rs1)) = bmkeps (AALTs bs rs1)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   751
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   752
  by (simp add: r1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   753
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   754
lemma qq3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   755
  shows "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   756
  apply(induct rs arbitrary: bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   757
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   758
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   759
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   760
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   761
lemma qq4:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   762
  assumes "bnullable (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   763
  shows "bmkeps (AALTs bs rs) = bs @ bmkeps (AALTs [] rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   764
  by (metis append_Nil2 assms bmkeps_retrieve bnullable_correctness erase_fuse fuse.simps(4) mkeps_nullable retrieve_fuse2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   765
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   766
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   767
lemma contains3a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   768
  assumes "AALTs bs lst >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   769
  shows "AALTs bs (a # lst) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   770
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   771
  apply -
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   772
  by (simp add: contains.intros(5))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   773
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   774
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   775
lemma contains3b:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   776
  assumes "a >> bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   777
  shows "AALTs bs (a # lst) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   778
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   779
  apply -
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   780
  apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   781
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   782
  done   
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   783
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   784
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   785
lemma contains3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   786
  assumes "\<And>x. \<lbrakk>x \<in> set rs; bnullable x\<rbrakk> \<Longrightarrow> x >> bmkeps x" "x \<in> set rs" "bnullable x"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   787
  shows "AALTs bs rs >> bmkeps (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   788
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   789
  apply(induct rs arbitrary: bs x)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   790
   apply simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   791
  by (metis contains.intros(4) contains.intros(5) list.set_intros(1) list.set_intros(2) qq3 qq4 r r0 r1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   792
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   793
lemma cont1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   794
  assumes "\<And>v. \<Turnstile> v : erase r \<Longrightarrow> r >> retrieve r v" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   795
          "\<forall>v\<in>set vs. \<Turnstile> v : erase r \<and> flat v \<noteq> []" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   796
  shows "ASTAR bs r >> retrieve (ASTAR bs r) (Stars vs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   797
  using assms 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   798
  apply(induct vs arbitrary: bs r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   799
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   800
  using contains.intros(6) apply auto[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   801
  by (simp add: contains.intros(7))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   802
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   803
lemma contains4:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   804
  assumes "bnullable a"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   805
  shows "a >> bmkeps a"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   806
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   807
  apply(induct a rule: bnullable.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   808
       apply(auto intro: contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   809
  using contains3 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   810
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   811
lemma contains5:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   812
  assumes "\<Turnstile> v : r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   813
  shows "(intern r) >> retrieve (intern r) v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   814
  using contains2[OF assms] retrieve_code[OF assms]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   815
  by (simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   816
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   817
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   818
lemma contains6:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   819
  assumes "\<Turnstile> v : (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   820
  shows "r >> retrieve r v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   821
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   822
  apply(induct r arbitrary: v rule: erase.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   823
  apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   824
  using Prf_elims(1) apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   825
  using Prf_elims(4) contains.intros(1) apply force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   826
  using Prf_elims(5) contains.intros(2) apply force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   827
  apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   828
  using Prf_elims(1) apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   829
  apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   830
  using contains3b contains3a apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   831
    prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   832
  apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   833
    apply (metis Prf_elims(2) contains.intros(3) retrieve.simps(6))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   834
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   835
  apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   836
   apply (metis Prf_elims(6) cont1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   837
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   838
  apply(erule Prf_elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   839
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   840
   apply (simp add: contains3b)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   841
  using retrieve_fuse2 contains3b contains3a
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   842
  apply(subst retrieve_fuse2[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   843
  apply (metis append_Nil2 erase_fuse fuse.simps(4))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   844
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   845
  by (metis append_Nil2 erase_fuse fuse.simps(4))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   846
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   847
lemma contains7:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   848
  assumes "\<Turnstile> v : der c (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   849
  shows "(bder c r) >> retrieve r (injval (erase r) c v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   850
  using bder_retrieve[OF assms(1)] retrieve_code[OF assms(1)]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   851
  by (metis assms contains6 erase_bder)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   852
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   853
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   854
lemma contains7a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   855
  assumes "\<Turnstile> v : der c (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   856
  shows "r >> retrieve r (injval (erase r) c v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   857
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   858
  apply -
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   859
  apply(drule Prf_injval)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   860
  apply(drule contains6)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   861
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   862
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   863
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   864
lemma contains7b:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   865
  assumes "\<Turnstile> v : ders s (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   866
  shows "(bders r s) >> retrieve r (flex (erase r) id s v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   867
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   868
  apply(induct s arbitrary: r v)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   869
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   870
   apply (simp add: contains6)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   871
  apply(simp add: bders_append flex_append ders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   872
  apply(drule_tac x="bder a r" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   873
  apply(drule meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   874
  apply(drule meta_mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   875
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   876
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   877
  apply(subst (asm) bder_retrieve)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   878
   defer
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   879
  apply (simp add: flex_injval)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   880
  by (simp add: Prf_flex)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   881
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   882
lemma contains7_iff:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   883
  assumes "\<Turnstile> v : der c (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   884
  shows "(bder c r) >> retrieve r (injval (erase r) c v) \<longleftrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   885
                  r >> retrieve r (injval (erase r) c v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   886
  by (simp add: assms contains7 contains7a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   887
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   888
lemma contains8_iff:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   889
  assumes "\<Turnstile> v : ders s (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   890
  shows "(bders r s) >> retrieve r (flex (erase r) id s v) \<longleftrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   891
                  r >> retrieve r (flex (erase r) id s v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   892
  using Prf_flex assms contains6 contains7b by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   893
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   894
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   895
fun 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   896
  bders_simp :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   897
where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   898
  "bders_simp r [] = r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   899
| "bders_simp r (c # s) = bders_simp (bsimp (bder c r)) s"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   900
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   901
definition blexer_simp where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   902
 "blexer_simp r s \<equiv> if bnullable (bders_simp (intern r) s) then 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   903
                decode (bmkeps (bders_simp (intern r) s)) r else None"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   904
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   905
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   906
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   907
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   908
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   909
lemma bders_simp_append:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   910
  shows "bders_simp r (s1 @ s2) = bders_simp (bders_simp r s1) s2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   911
  apply(induct s1 arbitrary: r s2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   912
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   913
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   914
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   915
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   916
lemma bsimp_ASEQ_size:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   917
  shows "asize (bsimp_ASEQ bs r1 r2) \<le> Suc (asize r1 + asize r2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   918
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   919
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   920
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   921
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   922
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   923
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   924
lemma flts_size:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   925
  shows "sum_list (map asize (flts rs)) \<le> sum_list (map asize rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   926
  apply(induct rs rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   927
        apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   928
  by (simp add: asize_fuse comp_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   929
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   930
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   931
lemma bsimp_AALTs_size:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   932
  shows "asize (bsimp_AALTs bs rs) \<le> Suc (sum_list (map asize rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   933
  apply(induct rs rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   934
  apply(auto simp add: asize_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   935
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   936
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   937
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   938
lemma bsimp_size:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   939
  shows "asize (bsimp r) \<le> asize r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   940
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   941
       apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   942
   apply (meson Suc_le_mono add_mono_thms_linordered_semiring(1) bsimp_ASEQ_size le_trans)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   943
  apply(rule le_trans)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   944
   apply(rule bsimp_AALTs_size)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   945
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   946
   apply(rule le_trans)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   947
   apply(rule flts_size)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   948
  by (simp add: sum_list_mono)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   949
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   950
lemma bsimp_asize0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   951
  shows "(\<Sum>x\<leftarrow>rs. asize (bsimp x)) \<le> sum_list (map asize rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   952
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   953
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   954
  by (simp add: add_mono bsimp_size)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   955
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   956
lemma bsimp_AALTs_size2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   957
  assumes "\<forall>r \<in> set  rs. nonalt r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   958
  shows "asize (bsimp_AALTs bs rs) \<ge> sum_list (map asize rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   959
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   960
  apply(induct rs rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   961
    apply(simp_all add: asize_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   962
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   963
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   964
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   965
lemma qq:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   966
  shows "map (asize \<circ> fuse bs) rs = map asize rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   967
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   968
   apply(auto simp add: asize_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   969
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   970
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   971
lemma flts_size2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   972
  assumes "\<exists>bs rs'. AALTs bs  rs' \<in> set rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   973
  shows "sum_list (map asize (flts rs)) < sum_list (map asize rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   974
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   975
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   976
   apply(auto simp add: qq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   977
   apply (simp add: flts_size less_Suc_eq_le)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   978
  apply(case_tac a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   979
       apply(auto simp add: qq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   980
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   981
   apply (simp add: flts_size le_imp_less_Suc)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   982
  using less_Suc_eq by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   983
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   984
lemma bsimp_AALTs_size3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   985
  assumes "\<exists>r \<in> set  (map bsimp rs). \<not>nonalt r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   986
  shows "asize (bsimp (AALTs bs rs)) < asize (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   987
  using assms flts_size2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   988
  apply  -
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   989
  apply(clarify)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   990
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   991
  apply(drule_tac x="map bsimp rs" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   992
  apply(drule meta_mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   993
  apply (metis list.set_map nonalt.elims(3))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   994
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   995
  apply(rule order_class.order.strict_trans1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   996
   apply(rule bsimp_AALTs_size)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   997
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   998
  by (smt Suc_leI bsimp_asize0 comp_def le_imp_less_Suc le_trans map_eq_conv not_less_eq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
   999
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1000
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1001
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1002
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1003
lemma L_bsimp_ASEQ:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1004
  "L (SEQ (erase r1) (erase r2)) = L (erase (bsimp_ASEQ bs r1 r2))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1005
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1006
  apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1007
  by (metis erase_fuse fuse.simps(4))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1008
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1009
lemma L_bsimp_AALTs:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1010
  "L (erase (AALTs bs rs)) = L (erase (bsimp_AALTs bs rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1011
  apply(induct bs rs rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1012
  apply(simp_all add: erase_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1013
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1014
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1015
lemma L_erase_AALTs:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1016
  shows "L (erase (AALTs bs rs)) = \<Union> (L ` erase ` (set rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1017
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1018
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1019
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1020
  apply(case_tac rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1021
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1022
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1023
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1024
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1025
lemma L_erase_flts:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1026
  shows "\<Union> (L ` erase ` (set (flts rs))) = \<Union> (L ` erase ` (set rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1027
  apply(induct rs rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1028
        apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1029
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1030
  using L_erase_AALTs erase_fuse apply auto[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1031
  by (simp add: L_erase_AALTs erase_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1032
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1033
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1034
lemma L_bsimp_erase:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1035
  shows "L (erase r) = L (erase (bsimp r))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1036
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1037
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1038
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1039
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1040
  apply(auto simp add: Sequ_def)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1041
  apply(subst L_bsimp_ASEQ[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1042
  apply(auto simp add: Sequ_def)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1043
  apply(subst (asm)  L_bsimp_ASEQ[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1044
  apply(auto simp add: Sequ_def)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1045
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1046
   apply(subst L_bsimp_AALTs[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1047
   defer
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1048
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1049
  apply(subst (2)L_erase_AALTs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1050
  apply(subst L_erase_flts)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1051
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1052
   apply (simp add: L_erase_AALTs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1053
  using L_erase_AALTs by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1054
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1055
lemma bsimp_ASEQ0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1056
  shows "bsimp_ASEQ bs r1 AZERO = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1057
  apply(induct r1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1058
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1059
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1060
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1061
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1062
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1063
lemma bsimp_ASEQ1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1064
  assumes "r1 \<noteq> AZERO" "r2 \<noteq> AZERO" "\<forall>bs. r1 \<noteq> AONE bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1065
  shows "bsimp_ASEQ bs r1 r2 = ASEQ bs r1 r2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1066
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1067
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1068
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1069
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1070
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1071
lemma bsimp_ASEQ2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1072
  shows "bsimp_ASEQ bs (AONE bs1) r2 = fuse (bs @ bs1) r2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1073
  apply(induct r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1074
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1075
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1076
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1077
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1078
lemma L_bders_simp:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1079
  shows "L (erase (bders_simp r s)) = L (erase (bders r s))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1080
  apply(induct s arbitrary: r rule: rev_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1081
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1082
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1083
  apply(simp add: ders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1084
  apply(simp add: bders_simp_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1085
  apply(simp add: L_bsimp_erase[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1086
  by (simp add: der_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1087
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1088
lemma b1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1089
  "bsimp_ASEQ bs1 (AONE bs) r =  fuse (bs1 @ bs) r" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1090
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1091
       apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1092
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1093
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1094
lemma b2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1095
  assumes "bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1096
  shows "bmkeps (fuse bs r) = bs @ bmkeps r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1097
  by (simp add: assms bmkeps_retrieve bnullable_correctness erase_fuse mkeps_nullable retrieve_fuse2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1098
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1099
lemma b3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1100
  shows "bnullable r = bnullable (bsimp r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1101
  using L_bsimp_erase bnullable_correctness nullable_correctness by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1102
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1103
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1104
lemma b4:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1105
  shows "bnullable (bders_simp r s) = bnullable (bders r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1106
  by (metis L_bders_simp bnullable_correctness lexer.simps(1) lexer_correct_None option.distinct(1))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1107
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1108
lemma q1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1109
  assumes "\<forall>r \<in> set rs. bmkeps(bsimp r) = bmkeps r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1110
  shows "map (\<lambda>r. bmkeps(bsimp r)) rs = map bmkeps rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1111
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1112
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1113
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1114
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1115
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1116
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1117
lemma q3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1118
  assumes "\<exists>r \<in> set rs. bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1119
  shows "bmkeps (AALTs bs rs) = bmkeps (bsimp_AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1120
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1121
  apply(induct bs rs rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1122
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1123
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1124
  apply (simp add: b2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1125
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1126
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1127
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1128
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1129
lemma fuse_empty:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1130
  shows "fuse [] r = r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1131
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1132
       apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1133
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1134
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1135
lemma flts_fuse:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1136
  shows "map (fuse bs) (flts rs) = flts (map (fuse bs) rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1137
  apply(induct rs arbitrary: bs rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1138
        apply(auto simp add: fuse_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1139
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1140
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1141
lemma bsimp_ASEQ_fuse:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1142
  shows "fuse bs1 (bsimp_ASEQ bs2 r1 r2) = bsimp_ASEQ (bs1 @ bs2) r1 r2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1143
  apply(induct r1 r2 arbitrary: bs1 bs2 rule: bsimp_ASEQ.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1144
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1145
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1146
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1147
lemma bsimp_AALTs_fuse:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1148
  assumes "\<forall>r \<in> set rs. fuse bs1 (fuse bs2 r) = fuse (bs1 @ bs2) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1149
  shows "fuse bs1 (bsimp_AALTs bs2 rs) = bsimp_AALTs (bs1 @ bs2) rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1150
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1151
  apply(induct bs2 rs arbitrary: bs1 rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1152
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1153
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1154
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1155
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1156
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1157
lemma bsimp_fuse:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1158
  shows "fuse bs (bsimp r) = bsimp (fuse bs r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1159
apply(induct r arbitrary: bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1160
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1161
      apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1162
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1163
    prefer 3
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1164
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1165
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1166
   apply (simp add: bsimp_ASEQ_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1167
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1168
  by (simp add: bsimp_AALTs_fuse fuse_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1169
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1170
lemma bsimp_fuse_AALTs:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1171
  shows "fuse bs (bsimp (AALTs [] rs)) = bsimp (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1172
  apply(subst bsimp_fuse) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1173
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1174
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1175
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1176
lemma bsimp_fuse_AALTs2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1177
  shows "fuse bs (bsimp_AALTs [] rs) = bsimp_AALTs bs rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1178
  using bsimp_AALTs_fuse fuse_append by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1179
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1180
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1181
lemma bsimp_ASEQ_idem:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1182
  assumes "bsimp (bsimp r1) = bsimp r1" "bsimp (bsimp r2) = bsimp r2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1183
  shows "bsimp (bsimp_ASEQ x1 (bsimp r1) (bsimp r2)) = bsimp_ASEQ x1 (bsimp r1) (bsimp r2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1184
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1185
  apply(case_tac "bsimp r1 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1186
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1187
 apply(case_tac "bsimp r2 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1188
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1189
  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))  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1190
  apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1191
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1192
    apply(subst bsimp_ASEQ2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1193
   apply(subst bsimp_ASEQ2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1194
  apply (metis assms(2) bsimp_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1195
      apply(subst bsimp_ASEQ1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1196
      apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1197
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1198
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1199
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1200
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1201
lemma  k0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1202
  shows "flts (r # rs1) = flts [r] @ flts rs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1203
  apply(induct r arbitrary: rs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1204
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1205
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1206
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1207
lemma  k00:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1208
  shows "flts (rs1 @ rs2) = flts rs1 @ flts rs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1209
  apply(induct rs1 arbitrary: rs2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1210
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1211
  by (metis append.assoc k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1212
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1213
lemma  k0a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1214
  shows "flts [AALTs bs rs] = map (fuse bs)  rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1215
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1216
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1217
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1218
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1219
lemma  k0b:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1220
  assumes "nonalt r" "r \<noteq> AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1221
  shows "flts [r] = [r]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1222
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1223
  apply(case_tac  r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1224
  apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1225
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1226
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1227
lemma nn1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1228
  assumes "nonnested (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1229
  shows "\<nexists>bs1 rs1. flts rs = [AALTs bs1 rs1]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1230
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1231
  apply(induct rs rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1232
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1233
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1234
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1235
lemma nn1q:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1236
  assumes "nonnested (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1237
  shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set (flts rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1238
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1239
  apply(induct rs rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1240
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1241
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1242
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1243
lemma nn1qq:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1244
  assumes "nonnested (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1245
  shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1246
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1247
  apply(induct rs rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1248
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1249
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1250
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1251
lemma nn10:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1252
  assumes "nonnested (AALTs cs rs)" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1253
  shows "nonnested (AALTs (bs @ cs) rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1254
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1255
  apply(induct rs arbitrary: cs bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1256
   apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1257
  apply(case_tac a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1258
       apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1259
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1260
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1261
lemma nn11a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1262
  assumes "nonalt r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1263
  shows "nonalt (fuse bs r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1264
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1265
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1266
       apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1267
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1268
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1269
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1270
lemma nn1a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1271
  assumes "nonnested r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1272
  shows "nonnested (fuse bs r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1273
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1274
  apply(induct bs r arbitrary: rule: fuse.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1275
       apply(simp_all add: nn10)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1276
  done  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1277
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1278
lemma n0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1279
  shows "nonnested (AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. nonalt r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1280
  apply(induct rs  arbitrary: bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1281
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1282
    apply (metis list.set_intros(1) nn1qq nonalt.elims(3))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1283
   apply (metis list.set_intros(2) nn1qq nonalt.elims(3))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1284
  by (metis nonalt.elims(2) nonnested.simps(3) nonnested.simps(4) nonnested.simps(5) nonnested.simps(6) nonnested.simps(7))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1285
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1286
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1287
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1288
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1289
lemma nn1c:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1290
  assumes "\<forall>r \<in> set rs. nonnested r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1291
  shows "\<forall>r \<in> set (flts rs). nonalt r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1292
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1293
  apply(induct rs rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1294
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1295
  apply(rule nn11a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1296
  by (metis nn1qq nonalt.elims(3))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1297
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1298
lemma nn1bb:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1299
  assumes "\<forall>r \<in> set rs. nonalt r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1300
  shows "nonnested (bsimp_AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1301
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1302
  apply(induct bs rs rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1303
    apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1304
   apply (metis nn11a nonalt.simps(1) nonnested.elims(3))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1305
  using n0 by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1306
    
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1307
lemma nn1b:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1308
  shows "nonnested (bsimp r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1309
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1310
       apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1311
  apply(case_tac "bsimp r1 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1312
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1313
 apply(case_tac "bsimp r2 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1314
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1315
    apply(subst bsimp_ASEQ0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1316
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1317
  apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1318
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1319
    apply(subst bsimp_ASEQ2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1320
  apply (simp add: nn1a)    
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1321
   apply(subst bsimp_ASEQ1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1322
      apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1323
  apply(rule nn1bb)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1324
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1325
  by (metis (mono_tags, hide_lams) imageE nn1c set_map)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1326
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1327
lemma nn1d:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1328
  assumes "bsimp r = AALTs bs rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1329
  shows "\<forall>r1 \<in> set rs. \<forall>  bs. r1 \<noteq> AALTs bs  rs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1330
  using nn1b assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1331
  by (metis nn1qq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1332
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1333
lemma nn_flts:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1334
  assumes "nonnested (AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1335
  shows "\<forall>r \<in>  set (flts rs). nonalt r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1336
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1337
  apply(induct rs arbitrary: bs rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1338
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1339
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1340
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1341
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1342
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1343
lemma rt:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1344
  shows "sum_list (map asize (flts (map bsimp rs))) \<le> sum_list (map asize rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1345
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1346
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1347
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1348
  apply(subst  k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1349
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1350
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1351
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1352
lemma bsimp_AALTs_qq:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1353
  assumes "1 < length rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1354
  shows "bsimp_AALTs bs rs = AALTs bs  rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1355
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1356
  apply(case_tac rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1357
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1358
  apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1359
   apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1360
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1361
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1362
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1363
lemma bsimp_AALTs1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1364
  assumes "nonalt r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1365
  shows "bsimp_AALTs bs (flts [r]) = fuse bs r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1366
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1367
  apply(case_tac r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1368
   apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1369
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1370
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1371
lemma bbbbs:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1372
  assumes "good r" "r = AALTs bs1 rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1373
  shows "bsimp_AALTs bs (flts [r]) = AALTs bs (map (fuse bs1) rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1374
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1375
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1376
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1377
lemma bbbbs1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1378
  shows "nonalt r \<or> (\<exists>bs rs. r  = AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1379
  using nonalt.elims(3) by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1380
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1381
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1382
lemma good_fuse:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1383
  shows "good (fuse bs r) = good r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1384
  apply(induct r arbitrary: bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1385
       apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1386
     apply(case_tac r1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1387
          apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1388
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1389
          apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1390
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1391
            apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1392
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1393
           apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1394
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1395
          apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1396
  apply(case_tac r1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1397
          apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1398
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1399
           apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1400
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1401
           apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1402
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1403
           apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1404
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1405
         apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1406
  apply(case_tac x2a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1407
    apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1408
  apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1409
    apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1410
  apply(case_tac x2a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1411
    apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1412
  apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1413
    apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1414
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1415
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1416
lemma good0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1417
  assumes "rs \<noteq> Nil" "\<forall>r \<in> set rs. nonalt r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1418
  shows "good (bsimp_AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. good r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1419
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1420
  apply(induct bs rs rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1421
  apply(auto simp add: good_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1422
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1423
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1424
lemma good0a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1425
  assumes "flts (map bsimp rs) \<noteq> Nil" "\<forall>r \<in> set (flts (map bsimp rs)). nonalt r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1426
  shows "good (bsimp (AALTs bs rs)) \<longleftrightarrow> (\<forall>r \<in> set (flts (map bsimp rs)). good r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1427
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1428
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1429
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1430
  apply(subst (asm) good0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1431
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1432
    apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1433
   apply(subst good0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1434
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1435
    apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1436
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1437
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1438
lemma flts0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1439
  assumes "r \<noteq> AZERO" "nonalt r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1440
  shows "flts [r] \<noteq> []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1441
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1442
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1443
       apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1444
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1445
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1446
lemma flts1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1447
  assumes "good r" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1448
  shows "flts [r] \<noteq> []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1449
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1450
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1451
       apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1452
  apply(case_tac x2a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1453
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1454
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1455
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1456
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1457
lemma flts2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1458
  assumes "good r" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1459
  shows "\<forall>r' \<in> set (flts [r]). good r' \<and> nonalt r'"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1460
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1461
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1462
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1463
      apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1464
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1465
    prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1466
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1467
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1468
     apply (metis bsimp_AALTs.elims good.simps(4) good.simps(5) good.simps(6) good_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1469
  apply (metis bsimp_AALTs.elims good.simps(4) good.simps(5) good.simps(6) nn11a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1470
   apply fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1471
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1472
  done  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1473
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1474
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1475
lemma flts3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1476
  assumes "\<forall>r \<in> set rs. good r \<or> r = AZERO" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1477
  shows "\<forall>r \<in> set (flts rs). good r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1478
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1479
  apply(induct rs arbitrary: rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1480
        apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1481
  by (metis UnE flts2 k0a set_map)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1482
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1483
lemma flts3b:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1484
  assumes "\<exists>r\<in>set rs. good r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1485
  shows "flts rs \<noteq> []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1486
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1487
  apply(induct rs arbitrary: rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1488
        apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1489
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1490
      apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1491
      apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1492
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1493
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1494
lemma flts4:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1495
  assumes "bsimp_AALTs bs (flts rs) = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1496
  shows "\<forall>r \<in> set rs. \<not> good r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1497
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1498
  apply(induct rs arbitrary: bs rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1499
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1500
        defer
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1501
  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))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1502
  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))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1503
  apply (metis arexp.distinct(3) arexp.distinct(7) bsimp_AALTs.elims fuse.simps(3) list.distinct(1) list.inject)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1504
  apply (metis arexp.distinct(7) bsimp_AALTs.elims good.simps(1) good_fuse list.distinct(1) list.inject)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1505
    apply (metis arexp.distinct(7) bsimp_AALTs.elims list.distinct(1) list.inject)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1506
  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))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1507
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1508
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1509
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1510
lemma flts_nil:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1511
  assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1512
            good (bsimp y) \<or> bsimp y = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1513
  and "\<forall>r\<in>set rs. \<not> good (bsimp r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1514
  shows "flts (map bsimp rs) = []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1515
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1516
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1517
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1518
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1519
  apply(subst k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1520
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1521
  by force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1522
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1523
lemma flts_nil2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1524
  assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1525
            good (bsimp y) \<or> bsimp y = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1526
  and "bsimp_AALTs bs (flts (map bsimp rs)) = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1527
  shows "flts (map bsimp rs) = []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1528
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1529
  apply(induct rs arbitrary: bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1530
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1531
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1532
  apply(subst k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1533
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1534
  apply(subst (asm) k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1535
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1536
  apply (metis flts.simps(1) flts.simps(2) flts4 k0 less_add_Suc1 list.set_intros(1))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1537
  by (metis flts.simps(2) flts4 k0 less_add_Suc1 list.set_intros(1))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1538
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1539
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1540
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1541
lemma good_SEQ:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1542
  assumes "r1 \<noteq> AZERO" "r2 \<noteq> AZERO" "\<forall>bs. r1 \<noteq> AONE bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1543
  shows "good (ASEQ bs r1 r2) = (good r1 \<and> good r2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1544
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1545
  apply(case_tac r1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1546
       apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1547
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1548
          apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1549
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1550
         apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1551
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1552
        apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1553
  apply(case_tac r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1554
       apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1555
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1556
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1557
lemma good1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1558
  shows "good (bsimp a) \<or> bsimp a = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1559
  apply(induct a taking: asize rule: measure_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1560
  apply(case_tac x)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1561
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1562
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1563
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1564
  prefer 3
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1565
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1566
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1567
  (*  AALTs case  *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1568
  apply(simp only:)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1569
   apply(case_tac "x52")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1570
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1571
  thm good0a
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1572
   (*  AALTs list at least one - case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1573
   apply(simp only: )
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1574
  apply(frule_tac x="a" in spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1575
   apply(drule mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1576
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1577
   (* either first element is good, or AZERO *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1578
    apply(erule disjE)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1579
     prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1580
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1581
   (* in  the AZERO case, the size  is smaller *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1582
   apply(drule_tac x="AALTs x51 list" in spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1583
   apply(drule mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1584
     apply(simp add: asize0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1585
    apply(subst (asm) bsimp.simps)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1586
  apply(subst (asm) bsimp.simps)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1587
    apply(assumption)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1588
   (* in the good case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1589
  apply(frule_tac x="AALTs x51 list" in spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1590
   apply(drule mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1591
    apply(simp add: asize0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1592
   apply(erule disjE)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1593
    apply(rule disjI1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1594
  apply(simp add: good0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1595
    apply(subst good0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1596
      apply (metis Nil_is_append_conv flts1 k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1597
  apply (metis ex_map_conv list.simps(9) nn1b nn1c)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1598
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1599
    apply(subst k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1600
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1601
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1602
  using flts2 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1603
    apply(subst  (asm) good0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1604
      prefer 3
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1605
      apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1606
     apply auto[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1607
    apply (metis ex_map_conv nn1b nn1c)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1608
  (* in  the AZERO case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1609
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1610
   apply(frule_tac x="a" in spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1611
   apply(drule mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1612
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1613
   apply(erule disjE)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1614
    apply(rule disjI1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1615
    apply(subst good0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1616
  apply(subst k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1617
  using flts1 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1618
     apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1619
  apply (metis (no_types, hide_lams) ex_map_conv list.simps(9) nn1b nn1c)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1620
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1621
  apply(subst (asm) k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1622
  apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1623
  using flts2 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1624
  apply(frule_tac x="AALTs x51 list" in spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1625
   apply(drule mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1626
     apply(simp add: asize0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1627
    apply(erule disjE)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1628
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1629
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1630
  apply (metis add.left_commute flts_nil2 less_add_Suc1 less_imp_Suc_add list.distinct(1) list.set_cases nat.inject)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1631
   apply(subst (2) k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1632
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1633
  (* SEQ case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1634
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1635
  apply(case_tac "bsimp x42 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1636
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1637
 apply(case_tac "bsimp x43 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1638
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1639
    apply(subst (2) bsimp_ASEQ0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1640
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1641
  apply(case_tac "\<exists>bs. bsimp x42 = AONE bs")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1642
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1643
   apply(subst bsimp_ASEQ2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1644
  using good_fuse apply force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1645
   apply(subst bsimp_ASEQ1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1646
     apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1647
  apply(subst  good_SEQ)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1648
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1649
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1650
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1651
  using less_add_Suc1 less_add_Suc2 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1652
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1653
lemma good1a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1654
  assumes "L(erase a) \<noteq> {}"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1655
  shows "good (bsimp a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1656
  using good1 assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1657
  using L_bsimp_erase by force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1658
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1659
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1660
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1661
lemma flts_append:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1662
  "flts (xs1 @ xs2) = flts xs1 @ flts xs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1663
  apply(induct xs1  arbitrary: xs2  rule: rev_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1664
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1665
  apply(case_tac xs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1666
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1667
   apply(case_tac x)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1668
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1669
  apply(case_tac x)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1670
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1671
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1672
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1673
lemma g1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1674
  assumes "good (bsimp_AALTs bs rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1675
  shows "bsimp_AALTs bs rs = AALTs bs rs \<or> (\<exists>r. rs = [r] \<and> bsimp_AALTs bs [r] = fuse bs r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1676
using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1677
    apply(induct rs arbitrary: bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1678
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1679
  apply(case_tac rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1680
  apply(simp only:)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1681
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1682
  apply(case_tac  list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1683
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1684
  by simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1685
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1686
lemma flts_0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1687
  assumes "nonnested (AALTs bs  rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1688
  shows "\<forall>r \<in> set (flts rs). r \<noteq> AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1689
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1690
  apply(induct rs arbitrary: bs rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1691
        apply(simp) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1692
       apply(simp) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1693
      defer
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1694
      apply(simp) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1695
     apply(simp) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1696
    apply(simp) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1697
apply(simp) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1698
  apply(rule ballI)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1699
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1700
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1701
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1702
lemma flts_0a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1703
  assumes "nonnested (AALTs bs  rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1704
  shows "AZERO \<notin> set (flts rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1705
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1706
  using flts_0 by blast 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1707
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1708
lemma qqq1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1709
  shows "AZERO \<notin> set (flts (map bsimp rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1710
  by (metis ex_map_conv flts3 good.simps(1) good1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1711
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1712
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1713
fun nonazero :: "arexp \<Rightarrow> bool"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1714
  where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1715
  "nonazero AZERO = False"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1716
| "nonazero r = True"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1717
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1718
lemma flts_concat:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1719
  shows "flts rs = concat (map (\<lambda>r. flts [r]) rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1720
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1721
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1722
  apply(subst k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1723
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1724
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1725
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1726
lemma flts_single1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1727
  assumes "nonalt r" "nonazero r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1728
  shows "flts [r] = [r]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1729
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1730
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1731
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1732
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1733
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1734
lemma flts_qq:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1735
  assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow> good y \<longrightarrow> bsimp y = y" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1736
          "\<forall>r'\<in>set rs. good r' \<and> nonalt r'"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1737
  shows "flts (map bsimp rs) = rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1738
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1739
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1740
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1741
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1742
  apply(subst k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1743
  apply(subgoal_tac "flts [bsimp a] =  [a]")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1744
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1745
   apply(drule_tac x="a" in spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1746
   apply(drule mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1747
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1748
   apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1749
  using good.simps(1) k0b apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1750
  apply(auto)[1]  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1751
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1752
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1753
lemma test:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1754
  assumes "good r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1755
  shows "bsimp r = r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1756
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1757
  apply(induct r taking: "asize" rule: measure_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1758
  apply(erule good.elims)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1759
  apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1760
  apply(subst k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1761
  apply(subst (2) k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1762
                apply(subst flts_qq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1763
                  apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1764
                 apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1765
                apply (metis append_Cons append_Nil bsimp_AALTs.simps(3) good.simps(1) k0b)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1766
               apply force+
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1767
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1768
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1769
         apply force+
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1770
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1771
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1772
    apply force+
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1773
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1774
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1775
lemma test2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1776
  assumes "good r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1777
  shows "bsimp r = r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1778
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1779
  apply(induct r taking: "asize" rule: measure_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1780
  apply(case_tac x)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1781
       apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1782
   defer  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1783
  (* AALT case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1784
   apply(subgoal_tac "1 < length x52")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1785
    prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1786
    apply(case_tac x52)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1787
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1788
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1789
    apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1790
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1791
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1792
    apply(subst bsimp_AALTs_qq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1793
    prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1794
    apply(subst flts_qq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1795
      apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1796
     apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1797
   apply(case_tac x52)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1798
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1799
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1800
    apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1801
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1802
      apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1803
      apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1804
  apply (metis (no_types, lifting) bsimp_AALTs.elims good.simps(6) length_Cons length_pos_if_in_set list.size(3) nat_neq_iff)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1805
  apply(simp)  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1806
  apply(case_tac x52)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1807
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1808
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1809
    apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1810
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1811
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1812
   apply(subst k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1813
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1814
   apply(subst (2) k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1815
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1816
  apply (simp add: Suc_lessI flts1 one_is_add)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1817
  (* SEQ case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1818
  apply(case_tac "bsimp x42 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1819
   apply simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1820
  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)  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1821
   apply(case_tac "\<exists>bs'. bsimp x42 = AONE bs'")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1822
   apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1823
  defer
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1824
  apply(case_tac "bsimp x43 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1825
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1826
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1827
  apply(auto)  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1828
   apply (subst bsimp_ASEQ1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1829
      apply(auto)[3]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1830
   apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1831
    apply (metis bsimp.simps(3) good.simps(2) good_SEQ less_add_Suc1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1832
   apply (metis bsimp.simps(3) good.simps(2) good_SEQ less_add_Suc1 less_add_Suc2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1833
  apply (subst bsimp_ASEQ2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1834
  apply(drule_tac x="x42" in spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1835
  apply(drule mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1836
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1837
  apply(drule mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1838
   apply (metis bsimp.elims bsimp.simps(3) good.simps(10) good.simps(11) good.simps(2) good_SEQ)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1839
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1840
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1841
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1842
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1843
lemma bsimp_idem:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1844
  shows "bsimp (bsimp r) = bsimp r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1845
  using test good1
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1846
  by force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1847
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1848
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1849
lemma contains_ex1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1850
  assumes "a = AALTs bs1 [AZERO, AONE bs2]" "a >> bs" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1851
  shows "bsimp a >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1852
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1853
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1854
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1855
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1856
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1857
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1858
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1859
  using contains0 apply fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1860
  using contains.simps by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1861
    
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1862
lemma contains_ex2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1863
  assumes "a = AALTs bs1 [AZERO, AONE bs2, AALTs bs5 [AONE bs3, AZERO, AONE bs4]]" "a >> bs" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1864
  shows "bsimp a >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1865
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1866
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1867
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1868
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1869
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1870
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1871
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1872
  using contains3b apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1873
   apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1874
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1875
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1876
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1877
  apply (metis contains.intros(4) contains.intros(5) contains0 fuse.simps(2))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1878
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1879
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1880
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1881
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1882
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1883
  apply (metis contains.intros(4) contains.intros(5) contains0 fuse.simps(2))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1884
      apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1885
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1886
apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1887
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1888
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1889
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1890
lemma contains48:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1891
  assumes "\<And>x2aa bs bs1. \<lbrakk>x2aa \<in> set x2a; fuse bs x2aa >> bs @ bs1\<rbrakk> \<Longrightarrow> x2aa >> bs1" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1892
          "AALTs (bs @ x1) x2a >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1893
        shows "AALTs x1 x2a >> bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1894
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1895
  apply(induct x2a arbitrary: bs x1 bs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1896
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1897
   apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1898
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1899
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1900
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1901
  apply (simp add: contains.intros(4))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1902
  using contains.intros(5) by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1903
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1904
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1905
lemma contains49:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1906
  assumes "fuse bs a >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1907
  shows "a >> bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1908
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1909
  apply(induct a arbitrary: bs bs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1910
       apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1911
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1912
      apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1913
            apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1914
  apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1915
    apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1916
            apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1917
     apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1918
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1919
            apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1920
  apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1921
     apply(auto)[2]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1922
  prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1923
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1924
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1925
  apply (simp add: contains.intros(6))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1926
  using contains.intros(7) apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1927
  using contains48 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1928
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1929
lemma contains50:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1930
  assumes "bsimp_AALTs bs rs2 >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1931
  shows "bsimp_AALTs bs (rs1 @ rs2) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1932
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1933
  apply(induct rs1 arbitrary: bs rs2 bs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1934
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1935
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1936
  apply(case_tac rs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1937
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1938
   apply(case_tac rs2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1939
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1940
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1941
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1942
  apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1943
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1944
    apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1945
    back
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1946
    apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1947
  using contains49 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1948
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1949
  using contains.intros(5) apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1950
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1951
  by (metis bsimp_AALTs.elims contains.intros(4) contains.intros(5) contains49 list.distinct(1))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1952
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1953
lemma contains51:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1954
  assumes "bsimp_AALTs bs [r] >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1955
  shows "bsimp_AALTs bs ([r] @ rs2) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1956
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1957
  apply(induct rs2 arbitrary: bs r bs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1958
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1959
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1960
  using contains.intros(4) contains49 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1961
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1962
lemma contains51a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1963
  assumes "bsimp_AALTs bs rs2 >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1964
  shows "bsimp_AALTs bs (rs2 @ [r]) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1965
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1966
  apply(induct rs2 arbitrary: bs r bs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1967
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1968
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1969
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1970
  apply(case_tac rs2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1971
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1972
  using contains3b contains49 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1973
  apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1974
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1975
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1976
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1977
  using contains.intros(4) apply auto[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1978
   apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1979
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1980
    apply (simp add: contains.intros(4) contains.intros(5))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1981
   apply (simp add: contains.intros(5))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1982
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1983
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1984
   apply (simp add: contains.intros(4))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1985
   apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1986
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1987
  using contains.intros(4) contains.intros(5) apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1988
  using contains.intros(5) by blast  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1989
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1990
lemma contains51b:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1991
  assumes "bsimp_AALTs bs rs >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1992
  shows "bsimp_AALTs bs (rs @ rs2) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1993
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1994
  apply(induct rs2 arbitrary: bs rs bs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1995
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1996
  using contains51a by fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1997
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1998
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  1999
lemma contains51c:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2000
  assumes "AALTs (bs @ bs2) rs >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2001
  shows "bsimp_AALTs bs (map (fuse bs2) rs) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2002
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2003
  apply(induct rs arbitrary: bs bs1 bs2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2004
       apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2005
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2006
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2007
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2008
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2009
  using contains0 contains51 apply auto[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2010
  by (metis append.left_neutral append_Cons contains50 list.simps(9))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2011
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2012
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2013
lemma contains51d:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2014
  assumes "fuse bs r >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2015
  shows "bsimp_AALTs bs (flts [r]) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2016
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2017
  apply(induct r arbitrary: bs bs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2018
       apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2019
  by (simp add: contains51c)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2020
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2021
lemma contains52:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2022
  assumes "\<exists>r \<in> set rs. (fuse bs r) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2023
  shows "bsimp_AALTs bs (flts rs) >> bs @ bs1"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2024
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2025
  apply(induct rs arbitrary: bs bs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2026
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2027
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2028
   defer
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2029
   apply (metis contains50 k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2030
  apply(subst k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2031
  apply(rule contains51b)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2032
  using contains51d by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2033
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2034
lemma contains55:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2035
  assumes "a >> bs" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2036
  shows "bsimp a >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2037
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2038
  apply(induct a bs arbitrary:)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2039
        apply(auto intro: contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2040
    apply(case_tac "bsimp a1 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2041
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2042
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2043
  apply(case_tac "bsimp a2 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2044
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2045
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2046
  apply(case_tac "\<exists>bs. bsimp a1 = AONE bs")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2047
     apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2048
     apply(rotate_tac 1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2049
     apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2050
           apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2051
     apply (simp add: b1 contains0 fuse_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2052
    apply (simp add: bsimp_ASEQ1 contains.intros(3))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2053
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2054
   apply(case_tac rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2055
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2056
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2057
   apply (metis contains50 k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2058
  (* AALTS case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2059
  apply(rule contains52)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2060
  apply(rule_tac x="bsimp r" in bexI)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2061
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2062
  using contains0 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2063
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2064
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2065
lemma q3a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2066
  assumes "\<exists>r \<in> set rs. bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2067
  shows "bmkeps (AALTs bs (map (fuse bs1) rs)) = bmkeps (AALTs (bs@bs1) rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2068
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2069
  apply(induct rs arbitrary: bs bs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2070
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2071
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2072
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2073
   apply (metis append_assoc b2 bnullable_correctness erase_fuse r0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2074
  apply(case_tac "bnullable a")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2075
   apply (metis append.assoc b2 bnullable_correctness erase_fuse r0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2076
  apply(case_tac rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2077
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2078
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2079
  apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2080
   apply (metis bnullable_correctness erase_fuse)+
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2081
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2082
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2083
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2084
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2085
lemma qq4a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2086
  assumes "\<exists>x\<in>set list. bnullable x"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2087
  shows "\<exists>x\<in>set (flts list). bnullable x"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2088
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2089
  apply(induct list rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2090
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2091
  by (metis UnCI bnullable_correctness erase_fuse imageI)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2092
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2093
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2094
lemma qs3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2095
  assumes "\<exists>r \<in> set rs. bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2096
  shows "bmkeps (AALTs bs rs) = bmkeps (AALTs bs (flts rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2097
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2098
  apply(induct rs arbitrary: bs taking: size rule: measure_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2099
  apply(case_tac x)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2100
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2101
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2102
  apply(case_tac a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2103
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2104
       apply (simp add: r1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2105
      apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2106
      apply (simp add: r0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2107
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2108
     apply(case_tac "flts list")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2109
      apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2110
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2111
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2112
     apply (simp add: r1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2113
    prefer 3
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2114
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2115
    apply (simp add: r0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2116
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2117
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2118
  apply(case_tac "\<exists>x\<in>set x52. bnullable x")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2119
  apply(case_tac "list")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2120
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2121
    apply (metis b2 fuse.simps(4) q3a r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2122
   apply(erule disjE)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2123
    apply(subst qq1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2124
     apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2125
     apply (metis bnullable_correctness erase_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2126
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2127
     apply (metis b2 fuse.simps(4) q3a r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2128
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2129
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2130
     apply(subst qq1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2131
      apply (metis bnullable_correctness erase_fuse image_eqI set_map)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2132
     apply (metis b2 fuse.simps(4) q3a r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2133
  apply(subst qq1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2134
      apply (metis bnullable_correctness erase_fuse image_eqI set_map)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2135
    apply (metis b2 fuse.simps(4) q3a r2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2136
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2137
   apply(subst qq2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2138
     apply (metis bnullable_correctness erase_fuse imageE set_map)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2139
  prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2140
  apply(case_tac "list")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2141
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2142
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2143
   apply (simp add: qq4a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2144
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2145
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2146
   apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2147
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2148
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2149
   apply (simp add: r0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2150
  apply(case_tac "bnullable (ASEQ x41 x42 x43)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2151
   apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2152
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2153
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2154
   apply (simp add: r0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2155
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2156
  using qq4a r1 r2 by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2157
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2158
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2159
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2160
lemma k1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2161
  assumes "\<And>x2aa. \<lbrakk>x2aa \<in> set x2a; bnullable x2aa\<rbrakk> \<Longrightarrow> bmkeps x2aa = bmkeps (bsimp x2aa)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2162
          "\<exists>x\<in>set x2a. bnullable x"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2163
        shows "bmkeps (AALTs x1 (flts x2a)) = bmkeps (AALTs x1 (flts (map bsimp x2a)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2164
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2165
  apply(induct x2a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2166
  apply fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2167
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2168
  apply(subst k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2169
  apply(subst (2) k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2170
  apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2171
  apply (metis b3 k0 list.set_intros(1) qs3 r0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2172
  by (smt b3 imageI insert_iff k0 list.set(2) qq3 qs3 r0 r1 set_map)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2173
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2174
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2175
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2176
lemma bmkeps_simp:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2177
  assumes "bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2178
  shows "bmkeps r = bmkeps (bsimp r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2179
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2180
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2181
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2182
      apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2183
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2184
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2185
    prefer 3
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2186
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2187
   apply(case_tac "bsimp r1 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2188
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2189
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2190
  apply (metis L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(1) mkeps_nullable)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2191
 apply(case_tac "bsimp r2 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2192
    apply(simp)  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2193
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2194
  apply (metis L_bsimp_erase L_flat_Prf1 L_flat_Prf2 Prf_elims(1) bnullable_correctness erase.simps(1) mkeps_nullable)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2195
  apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2196
    apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2197
    apply(subst b1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2198
    apply(subst b2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2199
  apply(simp add: b3[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2200
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2201
   apply(subgoal_tac "bsimp_ASEQ x1 (bsimp r1) (bsimp r2) = ASEQ x1 (bsimp r1) (bsimp r2)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2202
    prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2203
  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))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2204
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2205
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2206
  thm q3
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2207
  apply(subst q3[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2208
   apply simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2209
  using b3 qq4a apply auto[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2210
  apply(subst qs3)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2211
   apply simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2212
  using k1 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2213
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2214
thm bmkeps_retrieve bmkeps_simp bder_retrieve
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2215
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2216
lemma bmkeps_bder_AALTs:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2217
  assumes "\<exists>r \<in> set rs. bnullable (bder c r)" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2218
  shows "bmkeps (bder c (bsimp_AALTs bs rs)) = bmkeps (bsimp_AALTs bs (map (bder c) rs))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2219
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2220
  apply(induct rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2221
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2222
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2223
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2224
  apply(case_tac rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2225
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2226
  apply (metis (full_types) Prf_injval bder_retrieve bmkeps_retrieve bnullable_correctness erase_bder erase_fuse mkeps_nullable retrieve_fuse2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2227
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2228
  apply(case_tac  rs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2229
   apply(simp_all)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2230
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2231
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2232
lemma bbs0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2233
  shows "blexer_simp r [] = blexer r []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2234
  apply(simp add: blexer_def blexer_simp_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2235
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2236
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2237
lemma bbs1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2238
  shows "blexer_simp r [c] = blexer r [c]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2239
  apply(simp add: blexer_def blexer_simp_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2240
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2241
    defer
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2242
  using b3 apply auto[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2243
  using b3 apply auto[1]  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2244
  apply(subst bmkeps_simp[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2245
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2246
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2247
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2248
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2249
lemma oo:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2250
  shows "(case (blexer (der c r) s) of None \<Rightarrow> None | Some v \<Rightarrow> Some (injval r c v)) = blexer r (c # s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2251
  apply(simp add: blexer_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2252
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2253
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2254
lemma XXX2_helper:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2255
  assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow> good y \<longrightarrow> bsimp y = y" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2256
          "\<forall>r'\<in>set rs. good r' \<and> nonalt r'"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2257
  shows "flts (map (bsimp \<circ> bder c) (flts (map bsimp rs))) = flts (map (bsimp \<circ> bder c) rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2258
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2259
  apply(induct rs arbitrary: c)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2260
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2261
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2262
  apply(subst k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2263
  apply(simp add: flts_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2264
  apply(subst (2) k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2265
  apply(simp add: flts_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2266
  apply(subgoal_tac "flts [a] =  [a]")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2267
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2268
  using good.simps(1) k0b apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2269
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2270
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2271
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2272
lemma bmkeps_good:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2273
  assumes "good a"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2274
  shows "bmkeps (bsimp a) = bmkeps a"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2275
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2276
  using test2 by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2277
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2278
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2279
lemma xxx_bder:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2280
  assumes "good r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2281
  shows "L (erase r) \<noteq> {}"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2282
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2283
  apply(induct r rule: good.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2284
  apply(auto simp add: Sequ_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2285
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2286
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2287
lemma xxx_bder2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2288
  assumes "L (erase (bsimp r)) = {}"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2289
  shows "bsimp r = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2290
  using assms xxx_bder test2 good1
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2291
  by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2292
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2293
lemma XXX2aa:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2294
  assumes "good a"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2295
  shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2296
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2297
  by (simp add: test2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2298
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2299
lemma XXX2aa_ders:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2300
  assumes "good a"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2301
  shows "bsimp (bders (bsimp a) s) = bsimp (bders a s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2302
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2303
  by (simp add: test2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2304
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2305
lemma XXX4a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2306
  shows "good (bders_simp (bsimp r) s)  \<or> bders_simp (bsimp r) s = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2307
  apply(induct s arbitrary: r rule:  rev_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2308
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2309
  apply (simp add: good1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2310
  apply(simp add: bders_simp_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2311
  apply (simp add: good1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2312
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2313
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2314
lemma XXX4a_good:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2315
  assumes "good a"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2316
  shows "good (bders_simp a s) \<or> bders_simp a s = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2317
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2318
  apply(induct s arbitrary: a rule:  rev_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2319
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2320
  apply(simp add: bders_simp_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2321
  apply (simp add: good1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2322
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2323
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2324
lemma XXX4a_good_cons:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2325
  assumes "s \<noteq> []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2326
  shows "good (bders_simp a s) \<or> bders_simp a s = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2327
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2328
  apply(case_tac s)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2329
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2330
  using XXX4a by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2331
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2332
lemma XXX4b:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2333
  assumes "good a" "L (erase (bders_simp a s)) \<noteq> {}"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2334
  shows "good (bders_simp a s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2335
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2336
  apply(induct s arbitrary: a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2337
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2338
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2339
  apply(subgoal_tac "L (erase (bder a aa)) = {} \<or> L (erase (bder a aa)) \<noteq> {}")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2340
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2341
   apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2342
  apply(erule disjE)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2343
   apply(subgoal_tac "bsimp (bder a aa) = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2344
    prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2345
  using L_bsimp_erase xxx_bder2 apply auto[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2346
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2347
  apply (metis L.simps(1) XXX4a erase.simps(1))  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2348
  apply(drule_tac x="bsimp (bder a aa)" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2349
  apply(drule meta_mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2350
  apply simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2351
  apply(rule good1a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2352
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2353
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2354
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2355
lemma bders_AZERO:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2356
  shows "bders AZERO s = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2357
  and   "bders_simp AZERO s = AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2358
   apply (induct s)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2359
     apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2360
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2361
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2362
lemma LA:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2363
  assumes "\<Turnstile> v : ders s (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2364
  shows "retrieve (bders r s) v = retrieve r (flex (erase r) id s v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2365
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2366
  apply(induct s arbitrary: r v rule: rev_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2367
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2368
  apply(simp add: bders_append ders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2369
  apply(subst bder_retrieve)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2370
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2371
  apply(drule Prf_injval)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2372
  by (simp add: flex_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2373
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2374
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2375
lemma LB:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2376
  assumes "s \<in> (erase r) \<rightarrow> v" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2377
  shows "retrieve r v = retrieve r (flex (erase r) id s (mkeps (ders s (erase r))))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2378
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2379
  apply(induct s arbitrary: r v rule: rev_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2380
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2381
   apply(subgoal_tac "v = mkeps (erase r)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2382
    prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2383
  apply (simp add: Posix1(1) Posix_determ Posix_mkeps nullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2384
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2385
  apply(simp add: flex_append ders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2386
  by (metis Posix_determ Posix_flex Posix_injval Posix_mkeps ders_snoc lexer_correctness(2) lexer_flex)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2387
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2388
lemma LB_sym:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2389
  assumes "s \<in> (erase r) \<rightarrow> v" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2390
  shows "retrieve r v = retrieve r (flex (erase r) id s (mkeps (erase (bders r s))))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2391
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2392
  by (simp add: LB)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2393
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2394
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2395
lemma LC:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2396
  assumes "s \<in> (erase r) \<rightarrow> v" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2397
  shows "retrieve r v = retrieve (bders r s) (mkeps (erase (bders r s)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2398
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2399
  by (metis LA LB Posix1(1) assms lexer_correct_None lexer_flex mkeps_nullable)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2400
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2401
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2402
lemma L0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2403
  assumes "bnullable a"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2404
  shows "retrieve (bsimp a) (mkeps (erase (bsimp a))) = retrieve a (mkeps (erase a))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2405
  using assms b3 bmkeps_retrieve bmkeps_simp bnullable_correctness
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2406
  by (metis b3 bmkeps_retrieve bmkeps_simp bnullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2407
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2408
thm bmkeps_retrieve
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2409
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2410
lemma L0a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2411
  assumes "s \<in> L(erase a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2412
  shows "retrieve (bsimp (bders a s)) (mkeps (erase (bsimp (bders a s)))) = 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2413
         retrieve (bders a s) (mkeps (erase (bders a s)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2414
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2415
  by (metis L0 bnullable_correctness erase_bders lexer_correct_None lexer_flex)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2416
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2417
lemma L0aa:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2418
  assumes "s \<in> L (erase a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2419
  shows "[] \<in> erase (bsimp (bders a s)) \<rightarrow> mkeps (erase (bsimp (bders a s)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2420
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2421
  by (metis Posix_mkeps b3 bnullable_correctness erase_bders lexer_correct_None lexer_flex)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2422
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2423
lemma L0aaa:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2424
  assumes "[c] \<in> L (erase a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2425
  shows "[c] \<in> (erase a) \<rightarrow> flex (erase a) id [c] (mkeps (erase (bder c a)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2426
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2427
  by (metis bders.simps(1) bders.simps(2) erase_bders lexer_correct_None lexer_correct_Some lexer_flex option.inject)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2428
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2429
lemma L0aaaa:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2430
  assumes "[c] \<in> L (erase a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2431
  shows "[c] \<in> (erase a) \<rightarrow> flex (erase a) id [c] (mkeps (erase (bders a [c])))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2432
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2433
  using L0aaa by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2434
    
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2435
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2436
lemma L02:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2437
  assumes "bnullable (bder c a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2438
  shows "retrieve (bsimp a) (flex (erase (bsimp a)) id [c] (mkeps (erase (bder c (bsimp a))))) = 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2439
         retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a))))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2440
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2441
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2442
  using bder_retrieve L0 bmkeps_simp bmkeps_retrieve L0  LA LB
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2443
  apply(subst bder_retrieve[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2444
  apply (metis L_bsimp_erase bnullable_correctness der_correctness erase_bder mkeps_nullable nullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2445
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2446
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2447
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2448
lemma L02_bders:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2449
  assumes "bnullable (bders a s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2450
  shows "retrieve (bsimp a) (flex (erase (bsimp a)) id s (mkeps (erase (bders (bsimp a) s)))) = 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2451
         retrieve (bders (bsimp a) s) (mkeps (erase (bders (bsimp a) s)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2452
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2453
  by (metis LA L_bsimp_erase bnullable_correctness ders_correctness erase_bders mkeps_nullable nullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2454
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2455
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2456
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2457
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2458
lemma L03:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2459
  assumes "bnullable (bder c a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2460
  shows "retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a)))) =
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2461
         bmkeps (bsimp (bder c (bsimp a)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2462
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2463
  by (metis L0 L_bsimp_erase bmkeps_retrieve bnullable_correctness der_correctness erase_bder nullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2464
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2465
lemma L04:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2466
  assumes "bnullable (bder c a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2467
  shows "retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a)))) =
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2468
         retrieve (bsimp (bder c (bsimp a))) (mkeps (erase (bsimp (bder c (bsimp a)))))"     
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2469
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2470
  by (metis L0 L_bsimp_erase bnullable_correctness der_correctness erase_bder nullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2471
    
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2472
lemma L05:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2473
  assumes "bnullable (bder c a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2474
  shows "retrieve (bder c (bsimp a)) (mkeps (erase (bder c (bsimp a)))) =
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2475
         retrieve (bsimp (bder c (bsimp a))) (mkeps (erase (bsimp (bder c (bsimp a)))))" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2476
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2477
  using L04 by auto 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2478
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2479
lemma L06:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2480
  assumes "bnullable (bder c a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2481
  shows "bmkeps (bder c (bsimp a)) = bmkeps (bsimp (bder c (bsimp a)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2482
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2483
  by (metis L03 L_bsimp_erase bmkeps_retrieve bnullable_correctness der_correctness erase_bder nullable_correctness) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2484
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2485
lemma L07:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2486
  assumes "s \<in> L (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2487
  shows "retrieve r (flex (erase r) id s (mkeps (ders s (erase r)))) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2488
            = retrieve (bders r s) (mkeps (erase (bders r s)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2489
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2490
  using LB LC lexer_correct_Some by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2491
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2492
lemma L06_2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2493
  assumes "bnullable (bders a [c,d])"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2494
  shows "bmkeps (bders (bsimp a) [c,d]) = bmkeps (bsimp (bders (bsimp a) [c,d]))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2495
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2496
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2497
  by (metis L_bsimp_erase bmkeps_simp bnullable_correctness der_correctness erase_bder nullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2498
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2499
lemma L06_bders:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2500
  assumes "bnullable (bders a s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2501
  shows "bmkeps (bders (bsimp a) s) = bmkeps (bsimp (bders (bsimp a) s))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2502
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2503
  by (metis L_bsimp_erase bmkeps_simp bnullable_correctness ders_correctness erase_bders nullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2504
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2505
lemma LLLL:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2506
  shows "L (erase a) =  L (erase (bsimp a))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2507
  and "L (erase a) = {flat v | v. \<Turnstile> v: (erase a)}"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2508
  and "L (erase a) = {flat v | v. \<Turnstile> v: (erase (bsimp a))}"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2509
  using L_bsimp_erase apply(blast)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2510
  apply (simp add: L_flat_Prf)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2511
  using L_bsimp_erase L_flat_Prf apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2512
  done  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2513
    
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2514
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2515
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2516
lemma L07XX:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2517
  assumes "s \<in> L (erase a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2518
  shows "s \<in> erase a \<rightarrow> flex (erase a) id s (mkeps (ders s (erase a)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2519
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2520
  by (meson lexer_correct_None lexer_correctness(1) lexer_flex)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2521
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2522
lemma LX0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2523
  assumes "s \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2524
  shows "decode (bmkeps (bders (intern r) s)) r = Some(flex r id s (mkeps (ders s r)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2525
  by (metis assms blexer_correctness blexer_def lexer_correct_None lexer_flex)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2526
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2527
lemma L1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2528
  assumes "s \<in> r \<rightarrow> v" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2529
  shows "decode (bmkeps (bders (intern r) s)) r = Some v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2530
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2531
  by (metis blexer_correctness blexer_def lexer_correctness(1) option.distinct(1))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2532
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2533
lemma L2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2534
  assumes "s \<in> (der c r) \<rightarrow> v" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2535
  shows "decode (bmkeps (bders (intern r) (c # s))) r = Some (injval r c v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2536
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2537
  apply(subst bmkeps_retrieve)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2538
  using Posix1(1) lexer_correct_None lexer_flex apply fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2539
  using MAIN_decode
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2540
  apply(subst MAIN_decode[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2541
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2542
   apply (meson Posix1(1) lexer_correct_None lexer_flex mkeps_nullable)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2543
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2544
  apply(subgoal_tac "v = flex (der c r) id s (mkeps (ders s (der c r)))")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2545
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2546
   apply (metis Posix_determ lexer_correctness(1) lexer_flex option.distinct(1))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2547
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2548
  apply(subgoal_tac "injval r c (flex (der c r) id s (mkeps (ders s (der c r)))) =
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2549
    (flex (der c r) ((\<lambda>v. injval r c v) o id) s (mkeps (ders s (der c r))))")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2550
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2551
  using flex_fun_apply by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2552
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2553
lemma L3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2554
  assumes "s2 \<in> (ders s1 r) \<rightarrow> v" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2555
  shows "decode (bmkeps (bders (intern r) (s1 @ s2))) r = Some (flex r id s1 v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2556
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2557
  apply(induct s1 arbitrary: r s2 v rule: rev_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2558
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2559
  using L1 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2560
  apply(simp add: ders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2561
  apply(drule_tac x="r" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2562
  apply(drule_tac x="x # s2" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2563
  apply(drule_tac x="injval (ders xs r) x v" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2564
  apply(drule meta_mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2565
   defer
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2566
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2567
   apply(simp add:  flex_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2568
  by (simp add: Posix_injval)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2569
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2570
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2571
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2572
lemma bders_snoc:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2573
  "bder c (bders a s) = bders a (s @ [c])"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2574
  apply(simp add: bders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2575
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2576
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2577
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2578
lemma QQ1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2579
  shows "bsimp (bders (bsimp a) []) = bders_simp (bsimp a) []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2580
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2581
  apply(simp add: bsimp_idem)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2582
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2583
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2584
lemma QQ2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2585
  shows "bsimp (bders (bsimp a) [c]) = bders_simp (bsimp a) [c]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2586
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2587
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2588
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2589
lemma XXX2a_long:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2590
  assumes "good a"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2591
  shows "bsimp (bder c (bsimp a)) = bsimp (bder c a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2592
  using  assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2593
  apply(induct a arbitrary: c taking: asize rule: measure_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2594
  apply(case_tac x)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2595
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2596
      apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2597
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2598
  prefer 3
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2599
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2600
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2601
   apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2602
apply(case_tac "x42 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2603
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2604
   apply(case_tac "x43 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2605
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2606
  using test2 apply force  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2607
  apply(case_tac "\<exists>bs. x42 = AONE bs")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2608
     apply(clarify)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2609
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2610
    apply(subst bsimp_ASEQ1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2611
       apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2612
  using b3 apply force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2613
  using bsimp_ASEQ0 test2 apply force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2614
  thm good_SEQ test2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2615
     apply (simp add: good_SEQ test2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2616
    apply (simp add: good_SEQ test2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2617
  apply(case_tac "x42 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2618
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2619
   apply(case_tac "x43 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2620
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2621
  apply (simp add: bsimp_ASEQ0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2622
  apply(case_tac "\<exists>bs. x42 = AONE bs")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2623
     apply(clarify)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2624
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2625
    apply(subst bsimp_ASEQ1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2626
      apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2627
  using bsimp_ASEQ0 test2 apply force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2628
     apply (simp add: good_SEQ test2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2629
    apply (simp add: good_SEQ test2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2630
  apply (simp add: good_SEQ test2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2631
  (* AALTs case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2632
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2633
  using test2 by fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2634
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2635
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2636
lemma bder_bsimp_AALTs:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2637
  shows "bder c (bsimp_AALTs bs rs) = bsimp_AALTs bs (map (bder c) rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2638
  apply(induct bs rs rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2639
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2640
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2641
   apply (simp add: bder_fuse)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2642
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2643
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2644
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2645
lemma flts_nothing:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2646
  assumes "\<forall>r \<in> set rs. r \<noteq> AZERO" "\<forall>r \<in> set rs. nonalt r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2647
  shows "flts rs = rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2648
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2649
  apply(induct rs rule: flts.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2650
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2651
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2652
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2653
lemma flts_flts:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2654
  assumes "\<forall>r \<in> set rs. good r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2655
  shows "flts (flts rs) = flts rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2656
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2657
  apply(induct rs taking: "\<lambda>rs. sum_list  (map asize rs)" rule: measure_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2658
  apply(case_tac x)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2659
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2660
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2661
  apply(case_tac a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2662
       apply(simp_all  add: bder_fuse flts_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2663
  apply(subgoal_tac "\<forall>r \<in> set x52. r \<noteq> AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2664
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2665
  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)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2666
  apply(subgoal_tac "\<forall>r \<in> set x52. nonalt r")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2667
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2668
   apply (metis n0 nn1b test2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2669
  by (metis flts_fuse flts_nothing)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2670
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2671
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2672
lemma iii:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2673
  assumes "bsimp_AALTs bs rs \<noteq> AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2674
  shows "rs \<noteq> []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2675
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2676
  apply(induct bs  rs rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2677
    apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2678
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2679
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2680
lemma CT1_SEQ:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2681
  shows "bsimp (ASEQ bs a1 a2) = bsimp (ASEQ bs (bsimp a1) (bsimp a2))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2682
  apply(simp add: bsimp_idem)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2683
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2684
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2685
lemma CT1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2686
  shows "bsimp (AALTs bs as) = bsimp (AALTs bs (map  bsimp as))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2687
  apply(induct as arbitrary: bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2688
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2689
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2690
  by (simp add: bsimp_idem comp_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2691
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2692
lemma CT1a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2693
  shows "bsimp (AALT bs a1 a2) = bsimp(AALT bs (bsimp a1) (bsimp a2))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2694
  by (metis CT1 list.simps(8) list.simps(9))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2695
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2696
lemma WWW2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2697
  shows "bsimp (bsimp_AALTs bs1 (flts (map bsimp as1))) =
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2698
         bsimp_AALTs bs1 (flts (map bsimp as1))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2699
  by (metis bsimp.simps(2) bsimp_idem)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2700
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2701
lemma CT1b:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2702
  shows "bsimp (bsimp_AALTs bs as) = bsimp (bsimp_AALTs bs (map bsimp as))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2703
  apply(induct bs as rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2704
    apply(auto simp add: bsimp_idem)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2705
  apply (simp add: bsimp_fuse bsimp_idem)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2706
  by (metis bsimp_idem comp_apply)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2707
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2708
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2709
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2710
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2711
(* CT *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2712
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2713
lemma CTa:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2714
  assumes "\<forall>r \<in> set as. nonalt r \<and> r \<noteq> AZERO"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2715
  shows  "flts as = as"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2716
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2717
  apply(induct as)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2718
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2719
  apply(case_tac as)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2720
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2721
  apply (simp add: k0b)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2722
  using flts_nothing by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2723
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2724
lemma CT0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2725
  assumes "\<forall>r \<in> set as1. nonalt r \<and> r \<noteq> AZERO" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2726
  shows "flts [bsimp_AALTs bs1 as1] =  flts (map (fuse bs1) as1)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2727
  using assms CTa
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2728
  apply(induct as1 arbitrary: bs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2729
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2730
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2731
  apply(case_tac as1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2732
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2733
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2734
proof -
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2735
fix a :: arexp and as1a :: "arexp list" and bs1a :: "bit list" and aa :: arexp and list :: "arexp list"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2736
  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)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2737
  assume a2: "\<And>as. \<forall>r\<in>set as. nonalt r \<and> r \<noteq> AZERO \<Longrightarrow> flts as = as"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2738
  assume a3: "as1a = aa # list"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2739
  have "flts [a] = [a]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2740
using a1 k0b by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2741
then show "fuse bs1a a # fuse bs1a aa # map (fuse bs1a) list = flts (fuse bs1a a # fuse bs1a aa # map (fuse bs1a) list)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2742
  using a3 a2 a1 by (metis (no_types) append.left_neutral append_Cons flts_fuse k00 k0b list.simps(9))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2743
qed
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2744
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2745
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2746
lemma CT01:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2747
  assumes "\<forall>r \<in> set as1. nonalt r \<and> r \<noteq> AZERO" "\<forall>r \<in> set as2. nonalt r \<and> r \<noteq> AZERO" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2748
  shows "flts [bsimp_AALTs bs1 as1, bsimp_AALTs bs2 as2] =  flts ((map (fuse bs1) as1) @ (map (fuse bs2) as2))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2749
  using assms CT0
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2750
  by (metis k0 k00)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2751
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2752
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2753
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2754
lemma CT_exp:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2755
  assumes "\<forall>a \<in> set as. bsimp (bder c (bsimp a)) = bsimp (bder c a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2756
  shows "map bsimp (map (bder c) as) = map bsimp (map (bder c) (map bsimp as))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2757
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2758
  apply(induct as)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2759
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2760
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2761
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2762
lemma asize_set:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2763
  assumes "a \<in> set as"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2764
  shows "asize a < Suc (sum_list (map asize as))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2765
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2766
  apply(induct as arbitrary: a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2767
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2768
  using le_add2 le_less_trans not_less_eq by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2769
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2770
lemma L_erase_bder_simp:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2771
  shows "L (erase (bsimp (bder a r))) = L (der a (erase (bsimp r)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2772
  using L_bsimp_erase der_correctness by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2773
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2774
lemma PPP0: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2775
  assumes "s \<in> r \<rightarrow> v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2776
  shows "(bders (intern r) s) >> code v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2777
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2778
  by (smt L07 L1 LX0 Posix1(1) Posix_Prf contains6 erase_bders erase_intern lexer_correct_None lexer_flex mkeps_nullable option.inject retrieve_code)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2779
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2780
thm L07 L1 LX0 Posix1(1) Posix_Prf contains6 erase_bders erase_intern lexer_correct_None lexer_flex mkeps_nullable option.inject retrieve_code
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2781
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2782
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2783
lemma PPP0_isar: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2784
  assumes "s \<in> r \<rightarrow> v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2785
  shows "(bders (intern r) s) >> code v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2786
proof -
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2787
  from assms have a1: "\<Turnstile> v : r" using Posix_Prf by simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2788
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2789
  from assms have "s \<in> L r" using Posix1(1) by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2790
  then have "[] \<in> L (ders s r)" by (simp add: ders_correctness Ders_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2791
  then have a2: "\<Turnstile> mkeps (ders s r) : ders s r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2792
    by (simp add: mkeps_nullable nullable_correctness) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2793
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2794
  have "retrieve (bders (intern r) s) (mkeps (ders s r)) =  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2795
        retrieve (intern r) (flex r id s (mkeps (ders s r)))" using a2 LA LB bder_retrieve  by simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2796
  also have "... = retrieve (intern r) v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2797
    using LB assms by auto 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2798
  also have "... = code v" using a1 by (simp add: retrieve_code) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2799
  finally have "retrieve (bders (intern r) s) (mkeps (ders s r)) = code v" by simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2800
  moreover
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2801
  have "\<Turnstile> mkeps (ders s r) : erase (bders (intern r) s)" using a2 by simp 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2802
  then have "bders (intern r) s >> retrieve (bders (intern r) s) (mkeps (ders s r))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2803
    by (rule contains6)  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2804
  ultimately
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2805
  show "(bders (intern r) s) >> code v" by simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2806
qed
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2807
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2808
lemma PPP0b: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2809
  assumes "s \<in> r \<rightarrow> v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2810
  shows "(intern r) >> code v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2811
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2812
  using Posix_Prf contains2 by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2813
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2814
lemma PPP0_eq:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2815
  assumes "s \<in> r \<rightarrow> v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2816
  shows "(intern r >> code v) = (bders (intern r) s >> code v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2817
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2818
  using PPP0_isar PPP0b by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2819
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2820
lemma f_cont1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2821
  assumes "fuse bs1 a >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2822
  shows "\<exists>bs2. bs = bs1 @ bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2823
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2824
  apply(induct a arbitrary: bs1 bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2825
       apply(auto elim: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2826
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2827
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2828
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2829
lemma f_cont2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2830
  assumes "bsimp_AALTs bs1 as >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2831
  shows "\<exists>bs2. bs = bs1 @ bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2832
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2833
  apply(induct bs1 as arbitrary: bs rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2834
    apply(auto elim: contains.cases f_cont1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2835
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2836
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2837
lemma contains_SEQ1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2838
  assumes "bsimp_ASEQ bs r1 r2 >> bsX"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2839
  shows "\<exists>bs1 bs2. r1 >> bs1 \<and> r2 >> bs2 \<and> bsX = bs @ bs1 @ bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2840
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2841
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2842
  apply(case_tac "r1 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2843
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2844
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2845
  apply(case_tac "r2 = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2846
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2847
   apply(simp add: bsimp_ASEQ0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2848
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2849
  apply(case_tac "\<exists>bsX. r1 = AONE bsX")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2850
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2851
   apply(simp add: bsimp_ASEQ2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2852
   apply (metis append_assoc contains.intros(1) contains49 f_cont1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2853
  apply(simp add: bsimp_ASEQ1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2854
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2855
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2856
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2857
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2858
lemma contains59:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2859
  assumes "AALTs bs rs >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2860
  shows "\<exists>r \<in> set rs. (fuse bs r) >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2861
 using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2862
  apply(induct rs arbitrary: bs bs2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2863
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2864
   apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2865
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2866
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2867
       apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2868
  using contains0 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2869
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2870
lemma contains60:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2871
  assumes "\<exists>r \<in> set rs. fuse bs r >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2872
  shows "AALTs bs rs >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2873
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2874
  apply(induct rs arbitrary: bs bs2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2875
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2876
  apply (metis contains3b contains49 f_cont1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2877
  using contains.intros(5) f_cont1 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2878
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2879
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2880
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2881
lemma contains61:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2882
  assumes "bsimp_AALTs bs rs >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2883
  shows "\<exists>r \<in> set rs. (fuse bs r) >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2884
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2885
  apply(induct arbitrary: bs2 rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2886
    apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2887
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2888
  using contains59 by fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2889
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2890
lemma contains61b:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2891
  assumes "bsimp_AALTs bs rs >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2892
  shows "\<exists>r \<in> set (flts rs). (fuse bs r) >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2893
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2894
  apply(induct bs rs arbitrary: bs2 rule: bsimp_AALTs.induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2895
    apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2896
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2897
  using contains51d contains61 f_cont1 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2898
  by (metis bsimp_AALTs.simps(3) contains52 contains61 f_cont2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2899
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2900
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2901
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2902
lemma contains61a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2903
  assumes "\<exists>r \<in> set rs. (fuse bs r) >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2904
  shows "bsimp_AALTs bs rs >> bs2" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2905
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2906
  apply(induct rs arbitrary: bs2 bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2907
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2908
   apply (metis bsimp_AALTs.elims contains60 list.distinct(1) list.inject list.set_intros(1))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2909
  by (metis append_Cons append_Nil contains50 f_cont2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2910
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2911
lemma contains62:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2912
  assumes "bsimp_AALTs bs (rs1 @ rs2) >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2913
  shows "bsimp_AALTs bs rs1 >> bs2 \<or> bsimp_AALTs bs rs2 >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2914
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2915
  apply -
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2916
  apply(drule contains61)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2917
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2918
   apply(case_tac rs1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2919
    apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2920
  apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2921
     apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2922
  apply (simp add: contains60)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2923
   apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2924
    apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2925
  apply (simp add: contains60)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2926
  apply (meson contains60 list.set_intros(2))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2927
   apply(case_tac rs2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2928
    apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2929
  apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2930
     apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2931
  apply (simp add: contains60)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2932
   apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2933
    apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2934
  apply (simp add: contains60)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2935
  apply (meson contains60 list.set_intros(2))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2936
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2937
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2938
lemma contains63:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2939
  assumes "AALTs bs (map (fuse bs1) rs) >> bs3"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2940
  shows "AALTs (bs @ bs1) rs >> bs3"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2941
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2942
  apply(induct rs arbitrary: bs bs1 bs3)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2943
   apply(auto elim: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2944
    apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2945
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2946
  apply (simp add: contains0 contains60 fuse_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2947
  by (metis contains.intros(5) contains59 f_cont1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2948
    
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2949
lemma contains64:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2950
  assumes "bsimp_AALTs bs (flts rs1 @ flts rs2) >> bs2" "\<forall>r \<in> set rs2. \<not> fuse bs r >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2951
  shows "bsimp_AALTs bs (flts rs1) >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2952
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2953
  apply(induct rs2 arbitrary: rs1 bs bs2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2954
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2955
  apply(drule_tac x="rs1" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2956
    apply(drule_tac x="bs" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2957
  apply(drule_tac x="bs2" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2958
  apply(drule meta_mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2959
   apply(drule contains61)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2960
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2961
  using contains51b contains61a f_cont1 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2962
  apply(subst (asm) k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2963
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2964
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2965
  using contains50 contains61a f_cont1 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2966
  apply(case_tac a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2967
       apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2968
  by (metis contains60 fuse_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2969
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2970
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2971
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2972
lemma contains65:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2973
  assumes "bsimp_AALTs bs (flts rs) >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2974
  shows "\<exists>r \<in> set rs. (fuse bs r) >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2975
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2976
  apply(induct rs arbitrary: bs bs2 taking: "\<lambda>rs. sum_list (map asize rs)" rule: measure_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2977
  apply(case_tac x)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2978
        apply(auto elim: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2979
  apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2980
   apply(auto elim: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2981
   apply(case_tac a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2982
        apply(auto elim: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2983
   apply(drule contains61)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2984
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2985
   apply (metis contains60 fuse_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2986
  apply(case_tac lista)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2987
   apply(auto elim: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2988
   apply(subst (asm) k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2989
   apply(drule contains62)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2990
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2991
   apply(case_tac a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2992
         apply(auto elim: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2993
   apply(case_tac x52)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2994
   apply(auto elim: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2995
  apply(case_tac list)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2996
   apply(auto elim: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2997
  apply (simp add: contains60 fuse_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2998
   apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  2999
          apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3000
     apply (metis append.left_neutral contains0 contains60 fuse.simps(4) in_set_conv_decomp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3001
  apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3002
          apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3003
     apply (metis contains0 contains60 fuse.simps(4) list.set_intros(1) list.set_intros(2))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3004
  apply (simp add: contains.intros(5) contains63)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3005
   apply(case_tac aa)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3006
        apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3007
  apply (meson contains60 contains61 contains63)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3008
  apply(subst (asm) k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3009
  apply(drule contains64)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3010
   apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3011
  by (metis append_Nil2 bsimp_AALTs.simps(2) contains50 contains61a contains64 f_cont2 flts.simps(1))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3012
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3013
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3014
lemma contains55a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3015
  assumes "bsimp r >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3016
  shows "r >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3017
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3018
  apply(induct r arbitrary: bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3019
       apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3020
   apply(frule contains_SEQ1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3021
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3022
   apply (simp add: contains.intros(3))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3023
  apply(frule f_cont2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3024
  apply(auto) 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3025
  apply(drule contains65)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3026
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3027
  using contains0 contains49 contains60 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3028
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3029
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3030
lemma PPP1_eq:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3031
  shows "bsimp r >> bs \<longleftrightarrow> r >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3032
  using contains55 contains55a by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3033
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3034
lemma retrieve_code_bder:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3035
  assumes "\<Turnstile> v : der c r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3036
  shows "code (injval r c v) = retrieve (bder c (intern r)) v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3037
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3038
  by (simp add: Prf_injval bder_retrieve retrieve_code)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3039
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3040
lemma Etrans:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3041
  assumes "a >> s" "s = t" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3042
  shows "a >> t"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3043
  using assms by simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3044
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3045
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3046
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3047
lemma retrieve_code_bders:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3048
  assumes "\<Turnstile> v : ders s r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3049
  shows "code (flex r id s v) = retrieve (bders (intern r) s) v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3050
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3051
  apply(induct s arbitrary: v r rule: rev_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3052
   apply(auto simp add: ders_append flex_append bders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3053
  apply (simp add: retrieve_code)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3054
  apply(frule Prf_injval)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3055
  apply(drule_tac meta_spec)+
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3056
  apply(drule meta_mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3057
   apply(assumption)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3058
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3059
  apply(subst bder_retrieve)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3060
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3061
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3062
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3063
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3064
lemma contains70:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3065
 assumes "s \<in> L(r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3066
 shows "bders (intern r) s >> code (flex r id s (mkeps (ders s r)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3067
  apply(subst PPP0_eq[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3068
   apply (meson assms lexer_correct_None lexer_correctness(1) lexer_flex)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3069
  by (metis L07XX PPP0b assms erase_intern)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3070
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3071
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3072
lemma contains_equiv_def:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3073
  shows " (AALTs bs as >> bs@bs1) \<longleftrightarrow> (\<exists>a\<in>set as. a >> bs1)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3074
  by (meson contains0 contains49 contains59 contains60)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3075
351
ab8977636927 question marked by HERE
Chengsong
parents: 350
diff changeset
  3076
lemma i_know_it_must_be_a_theorem_but_dunno_its_name:
ab8977636927 question marked by HERE
Chengsong
parents: 350
diff changeset
  3077
  assumes "a \<and> (a=b) "
ab8977636927 question marked by HERE
Chengsong
parents: 350
diff changeset
  3078
  shows"b"
ab8977636927 question marked by HERE
Chengsong
parents: 350
diff changeset
  3079
  using assms
ab8977636927 question marked by HERE
Chengsong
parents: 350
diff changeset
  3080
  apply -
ab8977636927 question marked by HERE
Chengsong
parents: 350
diff changeset
  3081
  by auto
ab8977636927 question marked by HERE
Chengsong
parents: 350
diff changeset
  3082
352
744c32aceea6 question
Chengsong
parents: 351
diff changeset
  3083
lemma concat_def:
744c32aceea6 question
Chengsong
parents: 351
diff changeset
  3084
  shows"[]@lst=lst"
353
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3085
  apply auto
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3086
  done
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3087
354
97741a7b8b37 marked by QUESTION
Chengsong
parents: 353
diff changeset
  3088
lemma derc_alt00:
97741a7b8b37 marked by QUESTION
Chengsong
parents: 353
diff changeset
  3089
  assumes " bder c a >> bs" and "bder c (bsimp a) >> bs"
97741a7b8b37 marked by QUESTION
Chengsong
parents: 353
diff changeset
  3090
  shows "bder c (bsimp_AALTs [] (flts [bsimp a])) >> bs"
97741a7b8b37 marked by QUESTION
Chengsong
parents: 353
diff changeset
  3091
  oops
97741a7b8b37 marked by QUESTION
Chengsong
parents: 353
diff changeset
  3092
350
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3093
lemma derc_alt:
354
97741a7b8b37 marked by QUESTION
Chengsong
parents: 353
diff changeset
  3094
  assumes "bder c (AALTs [] as) >> bs" 
97741a7b8b37 marked by QUESTION
Chengsong
parents: 353
diff changeset
  3095
(*QUESTION*)
97741a7b8b37 marked by QUESTION
Chengsong
parents: 353
diff changeset
  3096
and "\<forall> a \<in> as. (bder c a >> bs) \<Rightarrow> (bder c (bsimp a) >> bs)"
350
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3097
  shows "bder c (bsimp(AALTs [] as)) >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3098
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3099
  apply -
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3100
  using contains_equiv_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3101
  apply -
351
ab8977636927 question marked by HERE
Chengsong
parents: 350
diff changeset
  3102
  apply(simp add: bder.simps)
350
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3103
  apply(drule_tac  x="[]" in meta_spec)
351
ab8977636927 question marked by HERE
Chengsong
parents: 350
diff changeset
  3104
  apply(drule_tac x="map (bder c) as" in meta_spec)
350
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3105
  apply(drule_tac x="bs" in meta_spec)
353
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3106
  
352
744c32aceea6 question
Chengsong
parents: 351
diff changeset
  3107
  apply(simp add:List.append.simps(1))
353
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3108
  apply(erule bexE)
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3109
  apply(subgoal_tac "\<exists>list1 list2. as = list1 @ [a] @ list2")
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3110
   prefer 2
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3111
  using split_list_last apply fastforce
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3112
  apply(erule exE)+
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3113
  apply(rule_tac t="as" and  s="list1@[a]@list2" in subst)
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3114
   apply simp
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3115
  (*find_theorems "map _ _ = _"*)
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3116
  apply(subst map_append)+
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3117
  apply(subst k00)+
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3118
  apply(case_tac "flts (map bsimp list1) = Nil")
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3119
  apply(case_tac "flts (map bsimp list2) = Nil")
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3120
  apply simp
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3121
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3122
eb08de92c4dc so far so good
Chengsong
parents: 352
diff changeset
  3123
  (*find_theorems "flts _ = _ "*)
352
744c32aceea6 question
Chengsong
parents: 351
diff changeset
  3124
(*  (*HERE*)
744c32aceea6 question
Chengsong
parents: 351
diff changeset
  3125
  apply(drule  i_know_it_must_be_a_theorem_but_dunno_its_name)
744c32aceea6 question
Chengsong
parents: 351
diff changeset
  3126
*)
744c32aceea6 question
Chengsong
parents: 351
diff changeset
  3127
350
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3128
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3129
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3130
lemma transfer:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3131
  assumes " (a \<Rightarrow> c) \<and> (c \<Rightarrow> b)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3132
  shows "a \<Rightarrow> b"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3133
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3134
(*if we have proved that a can prove c, to prove a can prove b, we
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3135
then have the option to just show that c can prove b *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3136
(*how to express the above using drule+mp and a lemma*)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3137
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3138
definition FC where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3139
 "FC a s v = retrieve a (flex (erase a) id s v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3140
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3141
definition FE where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3142
 "FE a s = retrieve a (flex (erase a) id s (mkeps (ders s (erase a))))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3143
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3144
definition PV where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3145
  "PV r s v = flex r id s v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3146
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3147
definition PX where
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3148
  "PX r s = PV r s (mkeps (ders s r))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3149
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3150
lemma FE_PX:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3151
  shows "FE r s = retrieve r (PX (erase r) s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3152
  unfolding FE_def PX_def PV_def by(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3153
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3154
lemma FE_PX_code:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3155
  assumes "s \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3156
  shows "FE (intern r) s = code (PX r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3157
  unfolding FE_def PX_def PV_def 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3158
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3159
  by (metis L07XX Posix_Prf erase_intern retrieve_code)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3160
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3161
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3162
lemma PV_id[simp]:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3163
  shows "PV r [] v = v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3164
  by (simp add: PV_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3165
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3166
lemma PX_id[simp]:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3167
  shows "PX r [] = mkeps r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3168
  by (simp add: PX_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3169
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3170
lemma PV_cons:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3171
  shows "PV r (c # s) v = injval r c (PV (der c r) s v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3172
  apply(simp add: PV_def flex_fun_apply)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3173
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3174
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3175
lemma PX_cons:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3176
  shows "PX r (c # s) = injval r c (PX (der c r) s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3177
  apply(simp add: PX_def PV_cons)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3178
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3179
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3180
lemma PV_append:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3181
  shows "PV r (s1 @ s2) v = PV r s1 (PV (ders s1 r) s2 v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3182
  apply(simp add: PV_def flex_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3183
  by (simp add: flex_fun_apply2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3184
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3185
lemma PX_append:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3186
  shows "PX r (s1 @ s2) = PV r s1 (PX (ders s1 r) s2)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3187
  by (simp add: PV_append PX_def ders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3188
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3189
lemma code_PV0: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3190
  shows "PV r (c # s) v = injval r c (PV (der c r) s v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3191
  unfolding PX_def PV_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3192
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3193
  by (simp add: flex_injval)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3194
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3195
lemma code_PX0: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3196
  shows "PX r (c # s) = injval r c (PX (der c r) s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3197
  unfolding PX_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3198
  apply(simp add: code_PV0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3199
  done  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3200
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3201
lemma Prf_PV:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3202
  assumes "\<Turnstile> v : ders s r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3203
  shows "\<Turnstile> PV r s v : r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3204
  using assms unfolding PX_def PV_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3205
  apply(induct s arbitrary: v r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3206
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3207
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3208
  by (simp add: Prf_injval flex_injval)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3209
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3210
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3211
lemma Prf_PX:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3212
  assumes "s \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3213
  shows "\<Turnstile> PX r s : r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3214
  using assms unfolding PX_def PV_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3215
  using L1 LX0 Posix_Prf lexer_correct_Some by fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3216
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3217
lemma PV1: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3218
  assumes "\<Turnstile> v : ders s r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3219
  shows "(intern r) >> code (PV r s v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3220
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3221
  by (simp add: Prf_PV contains2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3222
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3223
lemma PX1: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3224
  assumes "s \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3225
  shows "(intern r) >> code (PX r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3226
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3227
  by (simp add: Prf_PX contains2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3228
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3229
lemma PX2: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3230
  assumes "s \<in> L (der c r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3231
  shows "bder c (intern r) >> code (injval r c (PX (der c r) s))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3232
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3233
  by (simp add: Prf_PX contains6 retrieve_code_bder)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3234
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3235
lemma PX2a: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3236
  assumes "c # s \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3237
  shows "bder c (intern r) >> code (injval r c (PX (der c r) s))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3238
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3239
  using PX2 lexer_correct_None by force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3240
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3241
lemma PX2b: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3242
  assumes "c # s \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3243
  shows "bder c (intern r) >> code (PX r (c # s))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3244
  using assms unfolding PX_def PV_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3245
  by (metis Der_def L07XX PV_def PX2a PX_def Posix_determ Posix_injval der_correctness erase_intern mem_Collect_eq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3246
    
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3247
lemma PV3: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3248
  assumes "\<Turnstile> v : ders s r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3249
  shows "bders (intern r) s >> code (PV r s v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3250
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3251
  using PX_def PV_def contains70
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3252
  by (simp add: contains6 retrieve_code_bders)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3253
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3254
lemma PX3: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3255
  assumes "s \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3256
  shows "bders (intern r) s >> code (PX r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3257
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3258
  using PX_def PV_def contains70 by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3259
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3260
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3261
lemma PV_bders_iff:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3262
  assumes "\<Turnstile> v : ders s r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3263
  shows "bders (intern r) s >> code (PV r s v) \<longleftrightarrow> (intern r) >> code (PV r s v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3264
  by (simp add: PV1 PV3 assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3265
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3266
lemma PX_bders_iff:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3267
  assumes "s \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3268
  shows "bders (intern r) s >> code (PX r s) \<longleftrightarrow> (intern r) >> code (PX r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3269
  by (simp add: PX1 PX3 assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3270
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3271
lemma PX4: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3272
  assumes "(s1 @ s2) \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3273
  shows "bders (intern r) (s1 @ s2) >> code (PX r (s1 @ s2))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3274
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3275
  by (simp add: PX3)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3276
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3277
lemma PX_bders_iff2: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3278
  assumes "(s1 @ s2) \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3279
  shows "bders (intern r) (s1 @ s2) >> code (PX r (s1 @ s2)) \<longleftrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3280
         (intern r) >> code (PX r (s1 @ s2))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3281
  by (simp add: PX1 PX3 assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3282
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3283
lemma PV_bders_iff3: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3284
  assumes "\<Turnstile> v : ders (s1 @ s2) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3285
  shows "bders (intern r) (s1 @ s2) >> code (PV r (s1 @ s2) v) \<longleftrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3286
         bders (intern r) s1 >> code (PV r (s1 @ s2) v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3287
  by (metis PV3 PV_append Prf_PV assms ders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3288
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3289
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3290
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3291
lemma PX_bders_iff3: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3292
  assumes "(s1 @ s2) \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3293
  shows "bders (intern r) (s1 @ s2) >> code (PX r (s1 @ s2)) \<longleftrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3294
         bders (intern r) s1 >> code (PX r (s1 @ s2))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3295
  by (metis Ders_def L07XX PV_append PV_def PX4 PX_def Posix_Prf assms contains6 ders_append ders_correctness erase_bders erase_intern mem_Collect_eq retrieve_code_bders)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3296
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3297
lemma PV_bder_iff: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3298
  assumes "\<Turnstile> v : ders (s1 @ [c]) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3299
  shows "bder c (bders (intern r) s1) >> code (PV r (s1 @ [c]) v) \<longleftrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3300
         bders (intern r) s1 >> code (PV r (s1 @ [c]) v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3301
  by (simp add: PV_bders_iff3 assms bders_snoc)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3302
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3303
lemma PV_bder_IFF: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3304
  assumes "\<Turnstile> v : ders (s1 @ c # s2) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3305
  shows "bder c (bders (intern r) s1) >> code (PV r (s1 @ c # s2) v) \<longleftrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3306
         bders (intern r) s1 >> code (PV r (s1 @ c # s2) v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3307
  by (metis LA PV3 PV_def Prf_PV assms bders_append code_PV0 contains7 ders.simps(2) erase_bders erase_intern retrieve_code_bders)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3308
    
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3309
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3310
lemma PX_bder_iff: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3311
  assumes "(s1 @ [c]) \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3312
  shows "bder c (bders (intern r) s1) >> code (PX r (s1 @ [c])) \<longleftrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3313
         bders (intern r) s1 >> code (PX r (s1 @ [c]))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3314
  by (simp add: PX_bders_iff3 assms bders_snoc)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3315
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3316
lemma PV_bder_iff2: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3317
  assumes "\<Turnstile> v : ders (c # s1) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3318
  shows "bders (bder c (intern r)) s1 >> code (PV r (c # s1) v) \<longleftrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3319
         bder c (intern r) >> code (PV r (c # s1) v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3320
  by (metis PV3 Prf_PV assms bders.simps(2) code_PV0 contains7 ders.simps(2) erase_intern retrieve_code)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3321
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3322
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3323
lemma PX_bder_iff2: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3324
  assumes "(c # s1) \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3325
  shows "bders (bder c (intern r)) s1 >> code (PX r (c # s1)) \<longleftrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3326
         bder c (intern r) >> code (PX r (c # s1))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3327
  using PX2b PX3 assms by force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3328
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3329
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3330
lemma FC_id:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3331
  shows "FC r [] v = retrieve r v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3332
  by (simp add: FC_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3333
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3334
lemma FC_char:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3335
  shows "FC r [c] v = retrieve r (injval (erase r) c v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3336
  by (simp add: FC_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3337
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3338
lemma FC_char2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3339
  assumes "\<Turnstile> v : der c (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3340
  shows "FC r [c] v = FC (bder c r) [] v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3341
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3342
  by (simp add: FC_char FC_id bder_retrieve)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3343
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3344
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3345
lemma FC_bders_iff:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3346
  assumes "\<Turnstile> v : ders s (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3347
  shows "bders r s >> FC r s v \<longleftrightarrow> r >> FC r s v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3348
  unfolding FC_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3349
  by (simp add: assms contains8_iff)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3350
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3351
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3352
lemma FC_bder_iff:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3353
  assumes "\<Turnstile> v : der c (erase r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3354
  shows "bder c r >> FC r [c] v \<longleftrightarrow> r >> FC r [c] v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3355
  apply(subst FC_bders_iff[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3356
   apply(simp add: assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3357
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3358
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3359
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3360
lemma FC_bnullable0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3361
  assumes "bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3362
  shows "FC r [] (mkeps (erase r)) = FC (bsimp r) [] (mkeps (erase (bsimp r)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3363
  unfolding FC_def 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3364
  by (simp add: L0 assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3365
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3366
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3367
lemma FC_nullable2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3368
  assumes "bnullable (bders a s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3369
  shows "FC (bsimp a) s (mkeps (erase (bders (bsimp a) s))) = 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3370
         FC (bders (bsimp a) s) [] (mkeps (erase (bders (bsimp a) s)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3371
  unfolding FC_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3372
  using L02_bders assms by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3373
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3374
lemma FC_nullable3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3375
  assumes "bnullable (bders a s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3376
  shows "FC a s (mkeps (erase (bders a s))) = 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3377
         FC (bders a s) [] (mkeps (erase (bders a s)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3378
  unfolding FC_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3379
  using LA assms bnullable_correctness mkeps_nullable by fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3380
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3381
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3382
lemma FE_contains0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3383
  assumes "bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3384
  shows "r >> FE r []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3385
  by (simp add: FE_def assms bnullable_correctness contains6 mkeps_nullable)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3386
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3387
lemma FE_contains1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3388
  assumes "bnullable (bders r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3389
  shows "r >> FE r s"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3390
  by (metis FE_def Prf_flex assms bnullable_correctness contains6 erase_bders mkeps_nullable)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3391
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3392
lemma FE_bnullable0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3393
  assumes "bnullable r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3394
  shows "FE r [] = FE (bsimp r) []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3395
  unfolding FE_def 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3396
  by (simp add: L0 assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3397
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3398
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3399
lemma FE_nullable1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3400
  assumes "bnullable (bders r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3401
  shows "FE r s = FE (bders r s) []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3402
  unfolding FE_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3403
  using LA assms bnullable_correctness mkeps_nullable by fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3404
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3405
lemma FE_contains2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3406
  assumes "bnullable (bders r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3407
  shows "r >> FE (bders r s) []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3408
  by (metis FE_contains1 FE_nullable1 assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3409
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3410
lemma FE_contains3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3411
  assumes "bnullable (bder c r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3412
  shows "r >> FE (bsimp (bder c r)) []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3413
  by (metis FE_def L0 assms bder_retrieve bders.simps(1) bnullable_correctness contains7a erase_bder erase_bders flex.simps(1) id_apply mkeps_nullable)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3414
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3415
lemma FE_contains4:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3416
  assumes "bnullable (bders r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3417
  shows "r >> FE (bsimp (bders r s)) []"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3418
  using FE_bnullable0 FE_contains2 assms by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3419
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3420
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3421
(*
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3422
lemma FE_bnullable2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3423
  assumes "bnullable (bder c r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3424
  shows "FE r [c] = FE (bsimp r) [c]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3425
  unfolding FE_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3426
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3427
  using L0
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3428
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3429
  apply(subst FE_nullable1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3430
  using assms apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3431
  apply(subst FE_bnullable0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3432
  using assms apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3433
  unfolding FE_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3434
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3435
  apply(subst L0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3436
  using assms apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3437
  apply(subst bder_retrieve[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3438
  using LLLL(1) L_erase_bder_simp assms bnullable_correctness mkeps_nullable nullable_correctness apply b last
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3439
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3440
  find_theorems "retrieve _ (injval _ _ _)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3441
  find_theorems "retrieve (bsimp _) _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3442
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3443
  lemma FE_nullable3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3444
  assumes "bnullable (bders a s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3445
  shows "FE (bsimp a) s = FE a s"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3446
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3447
  unfolding FE_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3448
  using LA assms bnullable_correctness mkeps_nullable by fas tforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3449
*)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3450
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3451
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3452
lemma FC4:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3453
  assumes "\<Turnstile> v : ders s (erase a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3454
  shows "FC a s v = FC (bders a s) [] v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3455
  unfolding FC_def by (simp add: LA assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3456
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3457
lemma FC5:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3458
  assumes "nullable (erase a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3459
  shows "FC a [] (mkeps (erase a)) = FC (bsimp a) [] (mkeps (erase (bsimp a)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3460
  unfolding FC_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3461
  using L0 assms bnullable_correctness by auto 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3462
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3463
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3464
lemma FC6:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3465
  assumes "nullable (erase (bders a s))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3466
  shows "FC (bsimp a) s (mkeps (erase (bders (bsimp a) s))) = FC a s (mkeps (erase (bders a s)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3467
  apply(subst (2) FC4)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3468
  using assms mkeps_nullable apply auto[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3469
  apply(subst FC_nullable2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3470
  using assms bnullable_correctness apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3471
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3472
(*
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3473
lemma FC_bnullable:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3474
  assumes "bnullable (bders r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3475
  shows "FC r s (mkeps (erase r)) = FC (bsimp r) s (mkeps (erase (bsimp r)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3476
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3477
  unfolding FC_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3478
  using L0 L0a bder_retrieve L02_bders L04
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3479
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3480
  apply(induct s arbitrary: r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3481
   apply(simp add: FC_id)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3482
  apply (simp add: L0 assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3483
  apply(simp add: bders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3484
  apply(drule_tac x="bder a r" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3485
  apply(drule meta_mp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3486
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3487
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3488
  apply(subst bder_retrieve[symmetric])
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3489
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3490
*)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3491
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3492
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3493
lemma FC_bnullable:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3494
  assumes "bnullable (bders r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3495
  shows "FC r s (mkeps (ders s (erase r))) = FC (bsimp r) s (mkeps (ders s (erase (bsimp r))))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3496
  unfolding FC_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3497
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3498
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3499
lemma AA0:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3500
  assumes "bnullable (bders r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3501
  assumes "bders r s >> FC r s (mkeps (erase (bders r s)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3502
  shows "bders (bsimp r) s >> FC (bsimp r) s (mkeps (erase (bders (bsimp r) s)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3503
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3504
  apply(subst (asm) FC_bders_iff)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3505
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3506
  using bnullable_correctness mkeps_nullable apply fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3507
  apply(subst FC_bders_iff)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3508
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3509
  apply (metis LLLL(1) bnullable_correctness ders_correctness erase_bders mkeps_nullable nullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3510
  apply(simp add: PPP1_eq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3511
  unfolding FC_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3512
  find_theorems "retrieve (bsimp _) _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3513
  using contains7b
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3514
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3515
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3516
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3517
lemma AA1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3518
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3519
  assumes "\<Turnstile> v : der c (erase r)" "\<Turnstile> v : der c (erase (bsimp r))" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3520
  assumes "bder c r >> FC r [c] v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3521
  shows "bder c (bsimp r) >> FC (bsimp r) [c] v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3522
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3523
  apply(subst (asm) FC_bder_iff)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3524
  apply(rule assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3525
  apply(subst FC_bder_iff)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3526
   apply(rule assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3527
  apply(simp add: PPP1_eq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3528
  unfolding FC_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3529
  find_theorems "retrieve (bsimp _) _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3530
  using contains7b
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3531
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3532
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3533
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3534
lemma PX_bder_simp_iff: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3535
  assumes "\<Turnstile> v: ders (s1 @ s2) r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3536
  shows "bders (bsimp (bders (intern r) s1)) s2 >> code (PV r (s1 @ s2) v) \<longleftrightarrow>
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3537
         bders (intern r) s1 >> code (PV r (s1 @ s2) v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3538
  using assms 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3539
  apply(induct s2 arbitrary: r s1 v)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3540
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3541
  apply (simp add: PV3 contains55)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3542
  apply(drule_tac x="r" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3543
  apply(drule_tac x="s1 @ [a]" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3544
  apply(drule_tac x="v" in meta_spec)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3545
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3546
  apply(simp add: bders_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3547
  apply(subst (asm) PV_bder_IFF)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3548
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3549
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3550
lemma in1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3551
  assumes "AALTs bsX rsX \<in> set rs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3552
  shows "\<forall>r \<in> set rsX. fuse bsX r \<in> set (flts rs)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3553
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3554
  apply(induct rs arbitrary: bsX rsX)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3555
   apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3556
  by (metis append_assoc in_set_conv_decomp k0)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3557
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3558
lemma in2a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3559
  assumes "nonnested (bsimp r)" "\<not>nonalt(bsimp r)" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3560
  shows "(\<exists>bsX rsX. r = AALTs bsX rsX) \<or> (\<exists>bsX rX1 rX2. r = ASEQ bsX rX1 rX2 \<and> bnullable rX1)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3561
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3562
  apply(induct r)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3563
       apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3564
  by (metis arexp.distinct(25) b3 bnullable.simps(2) bsimp_ASEQ.simps(1) bsimp_ASEQ0 bsimp_ASEQ1 nonalt.elims(3) nonalt.simps(2))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3565
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3566
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3567
lemma in2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3568
  assumes "bder c r >> bs2" and
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3569
          "AALTs bsX rsX = bsimp r" and
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3570
          "XX \<in> set rsX" "nonnested (bsimp r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3571
        shows "bder c (fuse bsX XX) >> bs2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3572
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3573
  sorry  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3574
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3575
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3576
lemma
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3577
  assumes "bder c a >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3578
  shows "bder c (bsimp a) >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3579
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3580
  apply(induct a arbitrary: c bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3581
       apply(auto elim: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3582
   apply(case_tac "bnullable a1")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3583
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3584
  prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3585
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3586
    apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3587
          apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3588
    apply(case_tac "(bsimp a1) = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3589
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3590
     apply (metis append_Nil2 contains0 contains49 fuse.simps(1))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3591
   apply(case_tac "(bsimp a2a) = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3592
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3593
  apply (metis bder.simps(1) bsimp.simps(1) bsimp_ASEQ0 contains.intros(3) contains55)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3594
    apply(case_tac "\<exists>bsX. (bsimp a1) = AONE bsX")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3595
     apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3596
  using b3 apply fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3597
    apply(subst bsimp_ASEQ1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3598
  apply(auto)[3]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3599
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3600
    apply(subgoal_tac  "\<not> bnullable (bsimp a1)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3601
     prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3602
  using b3 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3603
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3604
    apply (simp add: contains.intros(3) contains55)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3605
  (* SEQ nullable case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3606
   apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3607
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3608
   apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3609
          apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3610
   apply(case_tac "(bsimp a1) = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3611
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3612
     apply (metis append_Nil2 contains0 contains49 fuse.simps(1))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3613
   apply(case_tac "(bsimp a2a) = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3614
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3615
  apply (metis bder.simps(1) bsimp.simps(1) bsimp_ASEQ0 contains.intros(3) contains55)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3616
    apply(case_tac "\<exists>bsX. (bsimp a1) = AONE bsX")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3617
     apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3618
  using contains.simps apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3619
    apply(subst bsimp_ASEQ1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3620
  apply(auto)[3]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3621
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3622
  apply(subgoal_tac  "bnullable (bsimp a1)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3623
     prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3624
  using b3 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3625
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3626
  apply (metis contains.intros(3) contains.intros(4) contains55 self_append_conv2)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3627
   apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3628
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3629
  apply(case_tac "(bsimp a1) = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3630
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3631
  using b3 apply force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3632
   apply(case_tac "(bsimp a2) = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3633
     apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3634
  apply (metis bder.simps(1) bsimp_ASEQ0 bsimp_ASEQ_fuse contains0 contains49 f_cont1)    
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3635
  apply(case_tac "\<exists>bsX. (bsimp a1) = AONE bsX")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3636
     apply(auto)[1]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3637
  apply (metis append_assoc bder_fuse bmkeps.simps(1) bmkeps_simp bsimp_ASEQ2 contains0 contains49 f_cont1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3638
   apply(subst bsimp_ASEQ1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3639
       apply(auto)[3]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3640
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3641
   apply(subgoal_tac  "bnullable (bsimp a1)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3642
     prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3643
  using b3 apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3644
    apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3645
  apply (metis bmkeps_simp contains.intros(4) contains.intros(5) contains0 contains49 f_cont1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3646
       apply(erule contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3647
         apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3648
  (* ALT case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3649
  apply(drule contains59)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3650
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3651
  apply(subst bder_bsimp_AALTs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3652
  apply(rule contains61a)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3653
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3654
  apply(subgoal_tac "bsimp r \<in> set (map bsimp x2a)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3655
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3656
   apply simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3657
  apply(case_tac "bsimp r = AZERO")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3658
  apply (metis Nil_is_append_conv bder.simps(1) bsimp_AALTs.elims bsimp_AALTs.simps(2) contains49 contains61 f_cont2 list.distinct(1) split_list_last)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3659
  apply(subgoal_tac "nonnested (bsimp r)")  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3660
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3661
  using nn1b apply blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3662
  apply(case_tac "nonalt (bsimp r)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3663
   apply(rule_tac x="bsimp r" in bexI)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3664
    apply (metis contains0 contains49 f_cont1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3665
   apply (metis append_Cons flts_append in_set_conv_decomp k0 k0b)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3666
  (* AALTS case *)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3667
  apply(subgoal_tac "\<exists>rsX bsX. (bsimp r) = AALTs bsX rsX \<and> (\<forall>r \<in> set rsX. nonalt r)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3668
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3669
  apply (metis n0 nonalt.elims(3))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3670
  apply(auto)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3671
 apply(subgoal_tac "bsimp r \<in> set (map bsimp x2a)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3672
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3673
  apply (metis imageI list.set_map)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3674
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3675
  apply(simp add: image_def)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3676
  apply(erule bexE)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3677
  apply(subgoal_tac "AALTs bsX rsX \<in> set (map bsimp x2a)")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3678
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3679
  apply simp
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3680
  apply(drule in1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3681
  apply(subgoal_tac "rsX \<noteq> []")
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3682
   prefer 2
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3683
   apply (metis arexp.distinct(7) good.simps(4) good1)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3684
  by (metis contains0 contains49 f_cont1 in2 list.exhaust list.set_intros(1))
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3685
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3686
lemma CONTAINS1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3687
  assumes "a >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3688
  shows "a >>2 bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3689
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3690
  apply(induct a bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3691
  apply(auto intro: contains2.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3692
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3693
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3694
lemma CONTAINS2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3695
  assumes "a >>2 bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3696
  shows "a >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3697
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3698
  apply(induct a bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3699
  apply(auto intro: contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3700
  using contains55 by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3701
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3702
lemma CONTAINS2_IFF:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3703
  shows "a >> bs \<longleftrightarrow> a >>2 bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3704
  using CONTAINS1 CONTAINS2 by blast
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3705
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3706
lemma
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3707
  assumes "bders (intern r) s >>2 bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3708
  shows   "bders_simp (intern r) s >>2 bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3709
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3710
  apply(induct s arbitrary: r bs)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3711
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3712
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3713
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3714
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3715
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3716
lemma
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3717
  assumes "s \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3718
  shows "(bders_simp (intern r) s >> code (PX r s)) \<longleftrightarrow> ((intern r) >> code (PX r s))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3719
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3720
  apply(induct s arbitrary: r rule: rev_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3721
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3722
  apply(simp add: bders_simp_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3723
  apply(simp add: PPP1_eq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3724
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3725
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3726
find_theorems "retrieve (bders _ _) _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3727
find_theorems "_ >> retrieve _ _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3728
find_theorems "bsimp _ >> _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3729
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3730
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3731
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3732
lemma PX4a: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3733
  assumes "(s1 @ s2) \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3734
  shows "bders (intern r) (s1 @ s2) >> code (PV r s1 (PX (ders s1 r) s2))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3735
  using PX4[OF assms]
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3736
  apply(simp add: PX_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3737
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3738
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3739
lemma PV5: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3740
  assumes "s2 \<in> (ders s1 r) \<rightarrow> v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3741
  shows "bders (intern r) (s1 @ s2) >> code (PV r s1 v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3742
  by (simp add: PPP0_isar PV_def Posix_flex assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3743
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3744
lemma PV6: 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3745
  assumes "s2 \<in> (ders s1 r) \<rightarrow> v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3746
  shows "bders (bders (intern r) s1) s2 >> code (PV r s1 v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3747
  using PV5 assms bders_append by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3748
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3749
find_theorems "retrieve (bders _ _) _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3750
find_theorems "_ >> retrieve _ _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3751
find_theorems "bder _ _ >> _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3752
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3753
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3754
lemma OO0_PX:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3755
  assumes "s \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3756
  shows "bders (intern r) s >> code (PX r s)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3757
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3758
  by (simp add: PX3)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3759
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3760
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3761
lemma OO1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3762
  assumes "[c] \<in> r \<rightarrow> v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3763
  shows "bder c (intern r) >> code v"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3764
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3765
  using PPP0_isar by force
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3766
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3767
lemma OO1a:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3768
  assumes "[c] \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3769
  shows "bder c (intern r) >> code (PX r [c])"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3770
  using assms unfolding PX_def PV_def
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3771
  using contains70 by fastforce
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3772
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3773
lemma OO12:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3774
  assumes "[c1, c2] \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3775
  shows "bders (intern r) [c1, c2] >> code (PX r [c1, c2])"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3776
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3777
  using PX_def PV_def contains70 by presburger
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3778
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3779
lemma OO2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3780
  assumes "[c] \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3781
  shows "bders_simp (intern r) [c] >> code (PX r [c])"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3782
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3783
  using OO1a Posix1(1) contains55 by auto
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3784
  
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3785
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3786
lemma OO22:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3787
  assumes "[c1, c2] \<in> L r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3788
  shows "bders_simp (intern r) [c1, c2] >> code (PX r [c1, c2])"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3789
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3790
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3791
  apply(rule contains55)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3792
  apply(rule Etrans)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3793
  thm contains7
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3794
  apply(rule contains7)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3795
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3796
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3797
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3798
lemma contains70:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3799
 assumes "s \<in> L(r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3800
 shows "bders_simp (intern r) s >> code (flex r id s (mkeps (ders s r)))"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3801
  using assms
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3802
  apply(induct s arbitrary: r rule: rev_induct)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3803
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3804
  apply (simp add: contains2 mkeps_nullable nullable_correctness)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3805
  apply(simp add: bders_simp_append flex_append)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3806
  apply(simp add: PPP1_eq)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3807
  apply(rule Etrans)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3808
  apply(rule_tac v="flex r id xs (mkeps (ders (xs @ [x]) r))" in contains7)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3809
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3810
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3811
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3812
thm L07XX PPP0b erase_intern
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3813
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3814
find_theorems "retrieve (bders _ _) _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3815
find_theorems "_ >> retrieve _ _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3816
find_theorems "bder _ _ >> _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3817
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3818
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3819
lemma PPP3:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3820
  assumes "\<Turnstile> v : ders s (erase a)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3821
  shows "bders a s >> retrieve a (flex (erase a) id s v)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3822
  using LA[OF assms] contains6 erase_bders assms by metis
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3823
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3824
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3825
find_theorems "bder _ _ >> _"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3826
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3827
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3828
lemma
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3829
  fixes n :: nat
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3830
  shows "(\<Sum>i \<in> {0..n}. i) = n * (n + 1) div 2"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3831
  apply(induct n)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3832
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3833
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3834
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3835
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3836
lemma COUNTEREXAMPLE:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3837
  assumes "r = AALTs [S] [ASEQ [S] (AALTs [S] [AONE [S], ACHAR [S] c]) (ACHAR [S] c)]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3838
  shows "bsimp (bder c (bsimp r)) = bsimp (bder c r)"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3839
  apply(simp_all add: assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3840
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3841
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3842
lemma COUNTEREXAMPLE:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3843
  assumes "r = AALTs [S] [ASEQ [S] (AALTs [S] [AONE [S], ACHAR [S] c]) (ACHAR [S] c)]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3844
  shows "bsimp r = r"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3845
  apply(simp_all add: assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3846
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3847
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3848
lemma COUNTEREXAMPLE:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3849
  assumes "r = AALTs [S] [ASEQ [S] (AALTs [S] [AONE [S], ACHAR [S] c]) (ACHAR [S] c)]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3850
  shows "bsimp r = XXX"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3851
  and   "bder c r = XXX"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3852
  and   "bder c (bsimp r) = XXX"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3853
  and   "bsimp (bder c (bsimp r)) = XXX"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3854
  and   "bsimp (bder c r) = XXX"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3855
  apply(simp_all add: assms)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3856
  oops
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3857
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3858
lemma COUNTEREXAMPLE_contains1:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3859
  assumes "r = AALTs [S] [ASEQ [S] (AALTs [S] [AONE [S], ACHAR [S] c]) (ACHAR [S] c)]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3860
  and   "bsimp (bder c r) >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3861
  shows "bsimp (bder c (bsimp r)) >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3862
  using assms 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3863
  apply(auto elim!: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3864
   apply(rule Etrans)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3865
    apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3866
    apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3867
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3868
  apply(rule Etrans)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3869
    apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3870
    apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3871
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3872
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3873
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3874
lemma COUNTEREXAMPLE_contains2:
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3875
  assumes "r = AALTs [S] [ASEQ [S] (AALTs [S] [AONE [S], ACHAR [S] c]) (ACHAR [S] c)]"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3876
  and   "bsimp (bder c (bsimp r)) >> bs"
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3877
  shows "bsimp (bder c r) >> bs" 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3878
  using assms 
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3879
  apply(auto elim!: contains.cases)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3880
   apply(rule Etrans)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3881
    apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3882
    apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3883
   apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3884
  apply(rule Etrans)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3885
    apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3886
    apply(rule contains.intros)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3887
  apply(simp)
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3888
  done
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3889
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3890
e4e507292bd8 proof attempt
Chengsong
parents:
diff changeset
  3891
end