thys2/SizeBound3.thy
author Christian Urban <christian.urban@kcl.ac.uk>
Sat, 30 Apr 2022 00:55:30 +0100
changeset 497 04b5e904a220
parent 493 1481f465e6ea
child 543 b2bea5968b89
permissions -rw-r--r--
cleaned up
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     1
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
     2
theory SizeBound3
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
     3
  imports "ClosedFormsBounds"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     4
begin
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     5
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     6
section \<open>Bit-Encodings\<close>
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     7
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     8
datatype bit = Z | S
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
     9
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    10
fun code :: "val \<Rightarrow> bit list"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    11
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    12
  "code Void = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    13
| "code (Char c) = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    14
| "code (Left v) = Z # (code v)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    15
| "code (Right v) = S # (code v)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    16
| "code (Seq v1 v2) = (code v1) @ (code v2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    17
| "code (Stars []) = [S]"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    18
| "code (Stars (v # vs)) =  (Z # code v) @ code (Stars vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    19
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    20
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    21
fun 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    22
  Stars_add :: "val \<Rightarrow> val \<Rightarrow> val"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    23
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    24
  "Stars_add v (Stars vs) = Stars (v # vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    25
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    26
function
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    27
  decode' :: "bit list \<Rightarrow> rexp \<Rightarrow> (val * bit list)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    28
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    29
  "decode' ds ZERO = (Void, [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    30
| "decode' ds ONE = (Void, ds)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    31
| "decode' ds (CH d) = (Char d, ds)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    32
| "decode' [] (ALT r1 r2) = (Void, [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    33
| "decode' (Z # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r1 in (Left v, ds'))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    34
| "decode' (S # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r2 in (Right v, ds'))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    35
| "decode' ds (SEQ r1 r2) = (let (v1, ds') = decode' ds r1 in
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    36
                             let (v2, ds'') = decode' ds' r2 in (Seq v1 v2, ds''))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    37
| "decode' [] (STAR r) = (Void, [])"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    38
| "decode' (S # ds) (STAR r) = (Stars [], ds)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    39
| "decode' (Z # ds) (STAR r) = (let (v, ds') = decode' ds r in
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    40
                                    let (vs, ds'') = decode' ds' (STAR r) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    41
                                    in (Stars_add v vs, ds''))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    42
by pat_completeness auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    43
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    44
lemma decode'_smaller:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    45
  assumes "decode'_dom (ds, r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    46
  shows "length (snd (decode' ds r)) \<le> length ds"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    47
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    48
apply(induct ds r)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    49
apply(auto simp add: decode'.psimps split: prod.split)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    50
using dual_order.trans apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    51
by (meson dual_order.trans le_SucI)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    52
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    53
termination "decode'"  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    54
apply(relation "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))") 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    55
apply(auto dest!: decode'_smaller)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    56
by (metis less_Suc_eq_le snd_conv)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    57
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    58
definition
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    59
  decode :: "bit list \<Rightarrow> rexp \<Rightarrow> val option"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    60
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    61
  "decode ds r \<equiv> (let (v, ds') = decode' ds r 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    62
                  in (if ds' = [] then Some v else None))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    63
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    64
lemma decode'_code_Stars:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    65
  assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> (\<forall>x. decode' (code v @ x) r = (v, x)) \<and> flat v \<noteq> []" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    66
  shows "decode' (code (Stars vs) @ ds) (STAR r) = (Stars vs, ds)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    67
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    68
  apply(induct vs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    69
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    70
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    71
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    72
lemma decode'_code:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    73
  assumes "\<Turnstile> v : r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    74
  shows "decode' ((code v) @ ds) r = (v, ds)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    75
using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    76
  apply(induct v r arbitrary: ds) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    77
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    78
  using decode'_code_Stars by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    79
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    80
lemma decode_code:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    81
  assumes "\<Turnstile> v : r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    82
  shows "decode (code v) r = Some v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    83
  using assms unfolding decode_def
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    84
  by (smt append_Nil2 decode'_code old.prod.case)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    85
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    86
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    87
section {* Annotated Regular Expressions *}
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    88
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    89
datatype arexp = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    90
  AZERO
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    91
| AONE "bit list"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    92
| ACHAR "bit list" char
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    93
| ASEQ "bit list" arexp arexp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    94
| AALTs "bit list" "arexp list"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    95
| ASTAR "bit list" arexp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    96
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    97
abbreviation
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    98
  "AALT bs r1 r2 \<equiv> AALTs bs [r1, r2]"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
    99
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   100
fun asize :: "arexp \<Rightarrow> nat" where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   101
  "asize AZERO = 1"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   102
| "asize (AONE cs) = 1" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   103
| "asize (ACHAR cs c) = 1"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   104
| "asize (AALTs cs rs) = Suc (sum_list (map asize rs))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   105
| "asize (ASEQ cs r1 r2) = Suc (asize r1 + asize r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   106
| "asize (ASTAR cs r) = Suc (asize r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   107
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   108
fun 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   109
  erase :: "arexp \<Rightarrow> rexp"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   110
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   111
  "erase AZERO = ZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   112
| "erase (AONE _) = ONE"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   113
| "erase (ACHAR _ c) = CH c"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   114
| "erase (AALTs _ []) = ZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   115
| "erase (AALTs _ [r]) = (erase r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   116
| "erase (AALTs bs (r#rs)) = ALT (erase r) (erase (AALTs bs rs))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   117
| "erase (ASEQ _ r1 r2) = SEQ (erase r1) (erase r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   118
| "erase (ASTAR _ r) = STAR (erase r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   119
493
Chengsong
parents: 492
diff changeset
   120
fun rerase :: "arexp \<Rightarrow> rrexp"
Chengsong
parents: 492
diff changeset
   121
where
Chengsong
parents: 492
diff changeset
   122
  "rerase AZERO = RZERO"
Chengsong
parents: 492
diff changeset
   123
| "rerase (AONE _) = RONE"
Chengsong
parents: 492
diff changeset
   124
| "rerase (ACHAR _ c) = RCHAR c"
Chengsong
parents: 492
diff changeset
   125
| "rerase (AALTs bs rs) = RALTS (map rerase rs)"
Chengsong
parents: 492
diff changeset
   126
| "rerase (ASEQ _ r1 r2) = RSEQ (rerase r1) (rerase r2)"
Chengsong
parents: 492
diff changeset
   127
| "rerase (ASTAR _ r) = RSTAR (rerase r)"
Chengsong
parents: 492
diff changeset
   128
Chengsong
parents: 492
diff changeset
   129
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   130
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   131
fun fuse :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp" where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   132
  "fuse bs AZERO = AZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   133
| "fuse bs (AONE cs) = AONE (bs @ cs)" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   134
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   135
| "fuse bs (AALTs cs rs) = AALTs (bs @ cs) rs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   136
| "fuse bs (ASEQ cs r1 r2) = ASEQ (bs @ cs) r1 r2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   137
| "fuse bs (ASTAR cs r) = ASTAR (bs @ cs) r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   138
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   139
lemma fuse_append:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   140
  shows "fuse (bs1 @ bs2) r = fuse bs1 (fuse bs2 r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   141
  apply(induct r)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   142
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   143
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   144
385
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
   145
lemma fuse_Nil:
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
   146
  shows "fuse [] r = r"
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
   147
  by (induct r)(simp_all)
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
   148
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   149
(*
385
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
   150
lemma map_fuse_Nil:
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
   151
  shows "map (fuse []) rs = rs"
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
   152
  by (induct rs)(simp_all add: fuse_Nil)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   153
*)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   154
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   155
fun intern :: "rexp \<Rightarrow> arexp" where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   156
  "intern ZERO = AZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   157
| "intern ONE = AONE []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   158
| "intern (CH c) = ACHAR [] c"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   159
| "intern (ALT r1 r2) = AALT [] (fuse [Z] (intern r1)) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   160
                                (fuse [S]  (intern r2))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   161
| "intern (SEQ r1 r2) = ASEQ [] (intern r1) (intern r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   162
| "intern (STAR r) = ASTAR [] (intern r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   163
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   164
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   165
fun retrieve :: "arexp \<Rightarrow> val \<Rightarrow> bit list" where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   166
  "retrieve (AONE bs) Void = bs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   167
| "retrieve (ACHAR bs c) (Char d) = bs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   168
| "retrieve (AALTs bs [r]) v = bs @ retrieve r v" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   169
| "retrieve (AALTs bs (r#rs)) (Left v) = bs @ retrieve r v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   170
| "retrieve (AALTs bs (r#rs)) (Right v) = bs @ retrieve (AALTs [] rs) v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   171
| "retrieve (ASEQ bs r1 r2) (Seq v1 v2) = bs @ retrieve r1 v1 @ retrieve r2 v2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   172
| "retrieve (ASTAR bs r) (Stars []) = bs @ [S]"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   173
| "retrieve (ASTAR bs r) (Stars (v#vs)) = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   174
     bs @ [Z] @ retrieve r v @ retrieve (ASTAR [] r) (Stars vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   175
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   176
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   177
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   178
fun
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   179
 bnullable :: "arexp \<Rightarrow> bool"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   180
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   181
  "bnullable (AZERO) = False"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   182
| "bnullable (AONE bs) = True"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   183
| "bnullable (ACHAR bs c) = False"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   184
| "bnullable (AALTs bs rs) = (\<exists>r \<in> set rs. bnullable r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   185
| "bnullable (ASEQ bs r1 r2) = (bnullable r1 \<and> bnullable r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   186
| "bnullable (ASTAR bs r) = True"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   187
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   188
abbreviation
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   189
  bnullables :: "arexp list \<Rightarrow> bool"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   190
where
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   191
  "bnullables rs \<equiv> (\<exists>r \<in> set rs. bnullable r)"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   192
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   193
fun 
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   194
  bmkeps :: "arexp \<Rightarrow> bit list" and
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   195
  bmkepss :: "arexp list \<Rightarrow> bit list"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   196
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   197
  "bmkeps(AONE bs) = bs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   198
| "bmkeps(ASEQ bs r1 r2) = bs @ (bmkeps r1) @ (bmkeps r2)"
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   199
| "bmkeps(AALTs bs rs) = bs @ (bmkepss rs)"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   200
| "bmkeps(ASTAR bs r) = bs @ [S]"
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   201
| "bmkepss [] = []"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   202
| "bmkepss (r # rs) = (if bnullable(r) then (bmkeps r) else (bmkepss rs))"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   203
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   204
lemma bmkepss1:
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   205
  assumes "\<not> bnullables rs1"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   206
  shows "bmkepss (rs1 @ rs2) = bmkepss rs2"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   207
  using assms
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   208
  by (induct rs1) (auto)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   209
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   210
lemma bmkepss2:
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   211
  assumes "bnullables rs1"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   212
  shows "bmkepss (rs1 @ rs2) = bmkepss rs1"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   213
  using assms
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   214
  by (induct rs1) (auto)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   215
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   216
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   217
fun
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   218
 bder :: "char \<Rightarrow> arexp \<Rightarrow> arexp"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   219
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   220
  "bder c (AZERO) = AZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   221
| "bder c (AONE bs) = AZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   222
| "bder c (ACHAR bs d) = (if c = d then AONE bs else AZERO)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   223
| "bder c (AALTs bs rs) = AALTs bs (map (bder c) rs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   224
| "bder c (ASEQ bs r1 r2) = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   225
     (if bnullable r1
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   226
      then AALT bs (ASEQ [] (bder c r1) r2) (fuse (bmkeps r1) (bder c r2))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   227
      else ASEQ bs (bder c r1) r2)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   228
| "bder c (ASTAR bs r) = ASEQ bs (fuse [Z] (bder c r)) (ASTAR [] r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   229
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   230
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   231
fun 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   232
  bders :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   233
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   234
  "bders r [] = r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   235
| "bders r (c#s) = bders (bder c r) s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   236
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   237
lemma bders_append:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   238
  "bders r (s1 @ s2) = bders (bders r s1) s2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   239
  apply(induct s1 arbitrary: r s2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   240
  apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   241
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   242
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   243
lemma bnullable_correctness:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   244
  shows "nullable (erase r) = bnullable r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   245
  apply(induct r rule: erase.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   246
  apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   247
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   248
493
Chengsong
parents: 492
diff changeset
   249
lemma rbnullable_correctness:
Chengsong
parents: 492
diff changeset
   250
  shows "rnullable (rerase r) = bnullable r"
Chengsong
parents: 492
diff changeset
   251
  apply(induct r rule: rerase.induct)
Chengsong
parents: 492
diff changeset
   252
       apply simp+
Chengsong
parents: 492
diff changeset
   253
  done
Chengsong
parents: 492
diff changeset
   254
Chengsong
parents: 492
diff changeset
   255
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   256
lemma erase_fuse:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   257
  shows "erase (fuse bs r) = erase r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   258
  apply(induct r rule: erase.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   259
  apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   260
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   261
493
Chengsong
parents: 492
diff changeset
   262
lemma rerase_fuse:
Chengsong
parents: 492
diff changeset
   263
  shows "rerase (fuse bs r) = rerase r"
Chengsong
parents: 492
diff changeset
   264
  apply(induct r)
Chengsong
parents: 492
diff changeset
   265
       apply simp+
Chengsong
parents: 492
diff changeset
   266
  done
Chengsong
parents: 492
diff changeset
   267
Chengsong
parents: 492
diff changeset
   268
Chengsong
parents: 492
diff changeset
   269
Chengsong
parents: 492
diff changeset
   270
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   271
lemma erase_intern [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   272
  shows "erase (intern r) = r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   273
  apply(induct r)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   274
  apply(simp_all add: erase_fuse)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   275
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   276
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   277
lemma erase_bder [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   278
  shows "erase (bder a r) = der a (erase r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   279
  apply(induct r rule: erase.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   280
  apply(simp_all add: erase_fuse bnullable_correctness)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   281
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   282
493
Chengsong
parents: 492
diff changeset
   283
Chengsong
parents: 492
diff changeset
   284
  
Chengsong
parents: 492
diff changeset
   285
Chengsong
parents: 492
diff changeset
   286
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   287
lemma erase_bders [simp]:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   288
  shows "erase (bders r s) = ders s (erase r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   289
  apply(induct s arbitrary: r )
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   290
  apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   291
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   292
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   293
lemma bnullable_fuse:
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   294
  shows "bnullable (fuse bs r) = bnullable r"
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   295
  apply(induct r arbitrary: bs)
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   296
  apply(auto)
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   297
  done
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   298
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   299
lemma retrieve_encode_STARS:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   300
  assumes "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> code v = retrieve (intern r) v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   301
  shows "code (Stars vs) = retrieve (ASTAR [] (intern r)) (Stars vs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   302
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   303
  apply(induct vs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   304
  apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   305
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   306
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   307
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   308
lemma retrieve_fuse2:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   309
  assumes "\<Turnstile> v : (erase r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   310
  shows "retrieve (fuse bs r) v = bs @ retrieve r v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   311
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   312
  apply(induct r arbitrary: v bs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   313
         apply(auto elim: Prf_elims)[4]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   314
   defer
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   315
  using retrieve_encode_STARS
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   316
   apply(auto elim!: Prf_elims)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   317
   apply(case_tac vs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   318
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   319
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   320
  (* AALTs  case *)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   321
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   322
  apply(case_tac x2a)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   323
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   324
   apply(auto elim!: Prf_elims)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   325
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   326
   apply(case_tac list)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   327
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   328
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   329
  apply(auto elim!: Prf_elims)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   330
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   331
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   332
lemma retrieve_fuse:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   333
  assumes "\<Turnstile> v : r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   334
  shows "retrieve (fuse bs (intern r)) v = bs @ retrieve (intern r) v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   335
  using assms 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   336
  by (simp_all add: retrieve_fuse2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   337
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   338
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   339
lemma retrieve_code:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   340
  assumes "\<Turnstile> v : r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   341
  shows "code v = retrieve (intern r) v"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   342
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   343
  apply(induct v r )
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   344
  apply(simp_all add: retrieve_fuse retrieve_encode_STARS)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   345
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   346
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   347
(*
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   348
lemma bnullable_Hdbmkeps_Hd:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   349
  assumes "bnullable a" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   350
  shows  "bmkeps (AALTs bs (a # rs)) = bs @ (bmkeps a)"
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   351
  using assms by simp
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   352
*)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   353
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   354
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   355
lemma r2:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   356
  assumes "x \<in> set rs" "bnullable x"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   357
  shows "bnullable (AALTs bs rs)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   358
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   359
  apply(induct rs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   360
   apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   361
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   362
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   363
lemma  r3:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   364
  assumes "\<not> bnullable r" 
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   365
          "bnullables rs"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   366
  shows "retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs))) =
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   367
         retrieve (AALTs bs (r # rs)) (mkeps (erase (AALTs bs (r # rs))))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   368
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   369
  apply(induct rs arbitrary: r bs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   370
   apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   371
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   372
  using bnullable_correctness apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   373
    apply(auto simp add: bnullable_correctness mkeps_nullable retrieve_fuse2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   374
   apply(subst retrieve_fuse2[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   375
  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)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   376
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   377
  apply(case_tac "bnullable a")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   378
  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)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   379
  apply(drule_tac x="a" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   380
  apply(drule_tac x="bs" in meta_spec)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   381
  apply(drule meta_mp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   382
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   383
  apply(drule meta_mp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   384
   apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   385
  apply(subst retrieve_fuse2[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   386
  apply(case_tac rs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   387
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   388
   apply(auto)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   389
      apply (simp add: bnullable_correctness)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   390
  
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   391
  apply (metis append_Nil2 bnullable_correctness erase_fuse fuse.simps(4) list.set_intros(1) mkeps.simps(3) mkeps_nullable nullable.simps(4) r2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   392
    apply (simp add: bnullable_correctness)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   393
  apply (metis append_Nil2 bnullable_correctness erase.simps(6) erase_fuse fuse.simps(4) list.set_intros(2) mkeps.simps(3) mkeps_nullable r2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   394
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   395
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   396
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   397
lemma t: 
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   398
  assumes "\<forall>r \<in> set rs. bnullable r \<longrightarrow> bmkeps r = retrieve r (mkeps (erase r))" 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   399
          "bnullables rs"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   400
  shows "bs @ bmkepss rs = retrieve (AALTs bs rs) (mkeps (erase (AALTs bs rs)))"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   401
 using assms
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   402
  apply(induct rs arbitrary: bs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   403
  apply(auto)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   404
  apply (metis (no_types, opaque_lifting) bmkepss.cases bnullable_correctness erase.simps(5) erase.simps(6) mkeps.simps(3) retrieve.simps(3) retrieve.simps(4))
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   405
  apply (metis r3)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   406
  apply (metis (no_types, lifting) bmkepss.cases bnullable_correctness empty_iff erase.simps(6) list.set(1) mkeps.simps(3) retrieve.simps(4))
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   407
  apply (metis r3)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   408
  done
493
Chengsong
parents: 492
diff changeset
   409
Chengsong
parents: 492
diff changeset
   410
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   411
lemma bmkeps_retrieve:
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   412
  assumes "bnullable r"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   413
  shows "bmkeps r = retrieve r (mkeps (erase r))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   414
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   415
  apply(induct r)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   416
  apply(auto)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   417
  using t by auto
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   418
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   419
lemma bder_retrieve:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   420
  assumes "\<Turnstile> v : der c (erase r)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   421
  shows "retrieve (bder c r) v = retrieve r (injval (erase r) c v)"
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   422
  using assms  
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   423
  apply(induct r arbitrary: v rule: erase.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   424
         apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   425
         apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   426
        apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   427
        apply(erule Prf_elims) 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   428
        apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   429
      apply(case_tac "c = ca")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   430
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   431
       apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   432
       apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   433
      apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   434
       apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   435
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   436
      apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   437
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   438
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   439
  apply(rename_tac "r\<^sub>1" "r\<^sub>2" rs v)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   440
    apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   441
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   442
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   443
    apply(case_tac rs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   444
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   445
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   446
  apply (smt Prf_elims(3) injval.simps(2) injval.simps(3) retrieve.simps(4) retrieve.simps(5) same_append_eq)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   447
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   448
   apply(case_tac "nullable (erase r1)")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   449
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   450
  apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   451
     apply(subgoal_tac "bnullable r1")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   452
  prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   453
  using bnullable_correctness apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   454
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   455
     apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   456
     apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   457
   apply(subgoal_tac "bnullable r1")
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   458
  prefer 2
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   459
  using bnullable_correctness apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   460
    apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   461
    apply(simp add: retrieve_fuse2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   462
    apply(simp add: bmkeps_retrieve)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   463
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   464
   apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   465
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   466
  using bnullable_correctness apply blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   467
  apply(rename_tac bs r v)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   468
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   469
  apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   470
     apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   471
  apply(erule Prf_elims)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   472
  apply(clarify)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   473
  apply(subst injval.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   474
  apply(simp del: retrieve.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   475
  apply(subst retrieve.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   476
  apply(subst retrieve.simps)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   477
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   478
  apply(simp add: retrieve_fuse2)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   479
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   480
  
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   481
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   482
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   483
lemma MAIN_decode:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   484
  assumes "\<Turnstile> v : ders s r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   485
  shows "Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   486
  using assms
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   487
proof (induct s arbitrary: v rule: rev_induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   488
  case Nil
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   489
  have "\<Turnstile> v : ders [] r" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   490
  then have "\<Turnstile> v : r" by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   491
  then have "Some v = decode (retrieve (intern r) v) r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   492
    using decode_code retrieve_code by auto
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   493
  then show "Some (flex r id [] v) = decode (retrieve (bders (intern r) []) v) r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   494
    by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   495
next
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   496
  case (snoc c s v)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   497
  have IH: "\<And>v. \<Turnstile> v : ders s r \<Longrightarrow> 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   498
     Some (flex r id s v) = decode (retrieve (bders (intern r) s) v) r" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   499
  have asm: "\<Turnstile> v : ders (s @ [c]) r" by fact
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   500
  then have asm2: "\<Turnstile> injval (ders s r) c v : ders s r" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   501
    by (simp add: Prf_injval ders_append)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   502
  have "Some (flex r id (s @ [c]) v) = Some (flex r id s (injval (ders s r) c v))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   503
    by (simp add: flex_append)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   504
  also have "... = decode (retrieve (bders (intern r) s) (injval (ders s r) c v)) r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   505
    using asm2 IH by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   506
  also have "... = decode (retrieve (bder c (bders (intern r) s)) v) r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   507
    using asm by (simp_all add: bder_retrieve ders_append)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   508
  finally show "Some (flex r id (s @ [c]) v) = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   509
                 decode (retrieve (bders (intern r) (s @ [c])) v) r" by (simp add: bders_append)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   510
qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   511
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   512
definition blexer where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   513
 "blexer r s \<equiv> if bnullable (bders (intern r) s) then 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   514
                decode (bmkeps (bders (intern r) s)) r else None"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   515
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   516
lemma blexer_correctness:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   517
  shows "blexer r s = lexer r s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   518
proof -
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   519
  { define bds where "bds \<equiv> bders (intern r) s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   520
    define ds  where "ds \<equiv> ders s r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   521
    assume asm: "nullable ds"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   522
    have era: "erase bds = ds" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   523
      unfolding ds_def bds_def by simp
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   524
    have mke: "\<Turnstile> mkeps ds : ds"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   525
      using asm by (simp add: mkeps_nullable)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   526
    have "decode (bmkeps bds) r = decode (retrieve bds (mkeps ds)) r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   527
      using bmkeps_retrieve
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   528
      using asm era
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   529
      using bnullable_correctness by force 
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   530
    also have "... =  Some (flex r id s (mkeps ds))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   531
      using mke by (simp_all add: MAIN_decode ds_def bds_def)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   532
    finally have "decode (bmkeps bds) r = Some (flex r id s (mkeps ds))" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   533
      unfolding bds_def ds_def .
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   534
  }
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   535
  then show "blexer r s = lexer r s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   536
    unfolding blexer_def lexer_flex
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   537
    by (auto simp add: bnullable_correctness[symmetric])
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   538
qed
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   539
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   540
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   541
fun distinctBy :: "'a list \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b set \<Rightarrow> 'a list"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   542
  where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   543
  "distinctBy [] f acc = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   544
| "distinctBy (x#xs) f acc = 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   545
     (if (f x) \<in> acc then distinctBy xs f acc 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   546
      else x # (distinctBy xs f ({f x} \<union> acc)))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   547
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   548
 
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   549
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   550
fun flts :: "arexp list \<Rightarrow> arexp list"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   551
  where 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   552
  "flts [] = []"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   553
| "flts (AZERO # rs) = flts rs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   554
| "flts ((AALTs bs  rs1) # rs) = (map (fuse bs) rs1) @ flts rs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   555
| "flts (r1 # rs) = r1 # flts rs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   556
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   557
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   558
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   559
fun bsimp_ASEQ :: "bit list \<Rightarrow> arexp \<Rightarrow> arexp \<Rightarrow> arexp"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   560
  where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   561
  "bsimp_ASEQ _ AZERO _ = AZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   562
| "bsimp_ASEQ _ _ AZERO = AZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   563
| "bsimp_ASEQ bs1 (AONE bs2) r2 = fuse (bs1 @ bs2) r2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   564
| "bsimp_ASEQ bs1 r1 r2 = ASEQ  bs1 r1 r2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   565
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   566
lemma bsimp_ASEQ0[simp]:
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   567
  shows "bsimp_ASEQ bs r1 AZERO = AZERO"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   568
  by (case_tac r1)(simp_all)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   569
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   570
lemma bsimp_ASEQ1:
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   571
  assumes "r1 \<noteq> AZERO" "r2 \<noteq> AZERO" "\<nexists>bs. r1 = AONE bs"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   572
  shows "bsimp_ASEQ bs r1 r2 = ASEQ bs r1 r2"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   573
  using assms
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   574
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   575
  apply(auto)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   576
  done
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   577
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   578
lemma bsimp_ASEQ2[simp]:
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   579
  shows "bsimp_ASEQ bs1 (AONE bs2) r2 = fuse (bs1 @ bs2) r2"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   580
  by (case_tac r2) (simp_all)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   581
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   582
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   583
fun bsimp_AALTs :: "bit list \<Rightarrow> arexp list \<Rightarrow> arexp"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   584
  where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   585
  "bsimp_AALTs _ [] = AZERO"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   586
| "bsimp_AALTs bs1 [r] = fuse bs1 r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   587
| "bsimp_AALTs bs1 rs = AALTs bs1 rs"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   588
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   589
493
Chengsong
parents: 492
diff changeset
   590
Chengsong
parents: 492
diff changeset
   591
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   592
fun bsimp :: "arexp \<Rightarrow> arexp" 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   593
  where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   594
  "bsimp (ASEQ bs1 r1 r2) = bsimp_ASEQ bs1 (bsimp r1) (bsimp r2)"
493
Chengsong
parents: 492
diff changeset
   595
| "bsimp (AALTs bs1 rs) = bsimp_AALTs bs1 (distinctBy (flts (map bsimp rs)) rerase {}) "
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   596
| "bsimp r = r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   597
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   598
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   599
fun 
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   600
  bders_simp :: "arexp \<Rightarrow> string \<Rightarrow> arexp"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   601
where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   602
  "bders_simp r [] = r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   603
| "bders_simp r (c # s) = bders_simp (bsimp (bder c r)) s"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   604
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   605
definition blexer_simp where
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   606
 "blexer_simp r s \<equiv> if bnullable (bders_simp (intern r) s) then 
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
   607
                    decode (bmkeps (bders_simp (intern r) s)) r else None"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   608
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   609
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   610
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   611
lemma bders_simp_append:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   612
  shows "bders_simp r (s1 @ s2) = bders_simp (bders_simp r s1) s2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   613
  apply(induct s1 arbitrary: r s2)
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
   614
  apply(simp_all)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   615
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   616
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   617
lemma L_bsimp_ASEQ:
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   618
  "L (erase (ASEQ bs r1 r2)) = L (erase (bsimp_ASEQ bs r1 r2))"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   619
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   620
  apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   621
  by (metis erase_fuse fuse.simps(4))
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   622
493
Chengsong
parents: 492
diff changeset
   623
lemma RL_bsimp_ASEQ:
Chengsong
parents: 492
diff changeset
   624
  "RL (rerase (ASEQ bs r1 r2)) = RL (rerase (bsimp_ASEQ bs r1 r2))"
Chengsong
parents: 492
diff changeset
   625
  apply(induct bs r1 r2 rule: bsimp_ASEQ.induct)
Chengsong
parents: 492
diff changeset
   626
  apply simp+
Chengsong
parents: 492
diff changeset
   627
  done
Chengsong
parents: 492
diff changeset
   628
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   629
lemma L_bsimp_AALTs:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   630
  "L (erase (AALTs bs rs)) = L (erase (bsimp_AALTs bs rs))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   631
  apply(induct bs rs rule: bsimp_AALTs.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   632
  apply(simp_all add: erase_fuse)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   633
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   634
493
Chengsong
parents: 492
diff changeset
   635
lemma RL_bsimp_AALTs:
Chengsong
parents: 492
diff changeset
   636
 "RL (rerase (AALTs bs rs)) = RL (rerase (bsimp_AALTs bs rs))"
Chengsong
parents: 492
diff changeset
   637
  apply(induct bs rs rule: bsimp_AALTs.induct)
Chengsong
parents: 492
diff changeset
   638
  apply(simp_all add: rerase_fuse)
Chengsong
parents: 492
diff changeset
   639
  done
Chengsong
parents: 492
diff changeset
   640
Chengsong
parents: 492
diff changeset
   641
lemma RL_rerase_AALTs:
Chengsong
parents: 492
diff changeset
   642
  shows "RL (rerase (AALTs bs rs)) = \<Union> (RL ` rerase ` (set rs))"
Chengsong
parents: 492
diff changeset
   643
  apply(induct rs)
Chengsong
parents: 492
diff changeset
   644
   apply(simp)
Chengsong
parents: 492
diff changeset
   645
  apply(simp)
Chengsong
parents: 492
diff changeset
   646
  done
Chengsong
parents: 492
diff changeset
   647
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   648
lemma L_erase_AALTs:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   649
  shows "L (erase (AALTs bs rs)) = \<Union> (L ` erase ` (set rs))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   650
  apply(induct rs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   651
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   652
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   653
  apply(case_tac rs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   654
   apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   655
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   656
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   657
493
Chengsong
parents: 492
diff changeset
   658
Chengsong
parents: 492
diff changeset
   659
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   660
lemma L_erase_flts:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   661
  shows "\<Union> (L ` erase ` (set (flts rs))) = \<Union> (L ` erase ` (set rs))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   662
  apply(induct rs rule: flts.induct)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   663
  apply(simp_all)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   664
  apply(auto)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   665
  using L_erase_AALTs erase_fuse apply auto[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   666
  by (simp add: L_erase_AALTs erase_fuse)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   667
493
Chengsong
parents: 492
diff changeset
   668
Chengsong
parents: 492
diff changeset
   669
lemma RL_erase_flts:
Chengsong
parents: 492
diff changeset
   670
  shows "\<Union> (RL ` rerase ` (set (flts rs))) =
Chengsong
parents: 492
diff changeset
   671
         \<Union> (RL ` rerase ` (set rs))"
Chengsong
parents: 492
diff changeset
   672
  apply(induct rs rule: flts.induct)
Chengsong
parents: 492
diff changeset
   673
        apply simp+
Chengsong
parents: 492
diff changeset
   674
      apply auto
Chengsong
parents: 492
diff changeset
   675
  apply (smt (verit) fuse.elims rerase.simps(2) rerase.simps(3) rerase.simps(4) rerase.simps(5) rerase.simps(6))
Chengsong
parents: 492
diff changeset
   676
  by (smt (verit, best) fuse.elims rerase.simps(2) rerase.simps(3) rerase.simps(4) rerase.simps(5) rerase.simps(6))
Chengsong
parents: 492
diff changeset
   677
Chengsong
parents: 492
diff changeset
   678
Chengsong
parents: 492
diff changeset
   679
Chengsong
parents: 492
diff changeset
   680
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   681
lemma L_erase_dB_acc:
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   682
  shows "(\<Union> (L ` acc) \<union> (\<Union> (L ` erase ` (set (distinctBy rs erase acc))))) 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   683
            = \<Union> (L ` acc) \<union>  \<Union> (L ` erase ` (set rs))"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   684
  apply(induction rs arbitrary: acc)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   685
  apply simp_all
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   686
  by (smt (z3) SUP_absorb UN_insert sup_assoc sup_commute)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   687
493
Chengsong
parents: 492
diff changeset
   688
lemma RL_rerase_dB_acc:
Chengsong
parents: 492
diff changeset
   689
  shows "(\<Union> (RL ` acc) \<union> (\<Union> (RL ` rerase ` (set (distinctBy rs rerase acc)))))
Chengsong
parents: 492
diff changeset
   690
           = \<Union> (RL ` acc) \<union> \<Union> (RL ` rerase ` (set rs))"
Chengsong
parents: 492
diff changeset
   691
  apply(induction rs arbitrary: acc)
Chengsong
parents: 492
diff changeset
   692
   apply simp_all
Chengsong
parents: 492
diff changeset
   693
    by (smt (z3) SUP_absorb UN_insert sup_assoc sup_commute)
Chengsong
parents: 492
diff changeset
   694
Chengsong
parents: 492
diff changeset
   695
Chengsong
parents: 492
diff changeset
   696
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   697
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   698
lemma L_erase_dB:
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   699
  shows "(\<Union> (L ` erase ` (set (distinctBy rs erase {})))) = \<Union> (L ` erase ` (set rs))"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   700
  by (metis L_erase_dB_acc Un_commute Union_image_empty)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   701
493
Chengsong
parents: 492
diff changeset
   702
lemma RL_rerase_dB:
Chengsong
parents: 492
diff changeset
   703
  shows "(\<Union> (RL ` rerase ` (set (distinctBy rs rerase {})))) = \<Union> (RL ` rerase ` (set rs))"
Chengsong
parents: 492
diff changeset
   704
  by (metis RL_rerase_dB_acc Un_commute Union_image_empty)
Chengsong
parents: 492
diff changeset
   705
Chengsong
parents: 492
diff changeset
   706
(*
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   707
lemma L_bsimp_erase:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   708
  shows "L (erase r) = L (erase (bsimp r))"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   709
  apply(induct r)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   710
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   711
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   712
  apply(simp)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   713
  apply(auto simp add: Sequ_def)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   714
  apply(subst L_bsimp_ASEQ[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   715
  apply(auto simp add: Sequ_def)[1]
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   716
  apply(subst (asm)  L_bsimp_ASEQ[symmetric])
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   717
  apply(auto simp add: Sequ_def)[1]
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
   718
  apply(simp)
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
   719
  apply(subst L_bsimp_AALTs[symmetric])
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
   720
  defer
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
   721
  apply(simp)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   722
  apply(subst (2)L_erase_AALTs)  
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   723
  apply(subst L_erase_dB)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   724
  apply(subst L_erase_flts)
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
   725
  apply (simp add: L_erase_AALTs)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   726
  done
493
Chengsong
parents: 492
diff changeset
   727
*)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   728
493
Chengsong
parents: 492
diff changeset
   729
lemma RL_bsimp_rerase:
Chengsong
parents: 492
diff changeset
   730
  shows "RL (rerase r) = RL (rerase (bsimp r))"
Chengsong
parents: 492
diff changeset
   731
  apply(induct r)
Chengsong
parents: 492
diff changeset
   732
  apply(simp)
Chengsong
parents: 492
diff changeset
   733
  apply(simp)
Chengsong
parents: 492
diff changeset
   734
  apply(simp)
Chengsong
parents: 492
diff changeset
   735
  apply(auto simp add: Sequ_def)[1]
Chengsong
parents: 492
diff changeset
   736
  apply(subst RL_bsimp_ASEQ[symmetric])
Chengsong
parents: 492
diff changeset
   737
  apply(auto simp add: Sequ_def)[1]
Chengsong
parents: 492
diff changeset
   738
  apply(subst (asm)  RL_bsimp_ASEQ[symmetric])
Chengsong
parents: 492
diff changeset
   739
  apply(auto simp add: Sequ_def)[1]
Chengsong
parents: 492
diff changeset
   740
  apply(simp)
Chengsong
parents: 492
diff changeset
   741
  apply(subst RL_bsimp_AALTs[symmetric])
Chengsong
parents: 492
diff changeset
   742
  defer
Chengsong
parents: 492
diff changeset
   743
  apply(simp)
Chengsong
parents: 492
diff changeset
   744
  using RL_erase_flts RL_rerase_dB by force
Chengsong
parents: 492
diff changeset
   745
Chengsong
parents: 492
diff changeset
   746
lemma rder_correctness:
Chengsong
parents: 492
diff changeset
   747
  shows "RL (rder c r) = Der c (RL r)"
Chengsong
parents: 492
diff changeset
   748
  by (simp add: RL_rder)
Chengsong
parents: 492
diff changeset
   749
Chengsong
parents: 492
diff changeset
   750
Chengsong
parents: 492
diff changeset
   751
Chengsong
parents: 492
diff changeset
   752
Chengsong
parents: 492
diff changeset
   753
lemma asize_rsize:
Chengsong
parents: 492
diff changeset
   754
  shows "rsize (rerase r) = asize r"
Chengsong
parents: 492
diff changeset
   755
  apply(induct r)
Chengsong
parents: 492
diff changeset
   756
       apply simp+
Chengsong
parents: 492
diff changeset
   757
  
Chengsong
parents: 492
diff changeset
   758
  apply (metis (mono_tags, lifting) comp_apply map_eq_conv)
Chengsong
parents: 492
diff changeset
   759
  by simp
Chengsong
parents: 492
diff changeset
   760
Chengsong
parents: 492
diff changeset
   761
lemma rb_nullability:
Chengsong
parents: 492
diff changeset
   762
  shows " rnullable (rerase a) = bnullable a"
Chengsong
parents: 492
diff changeset
   763
  apply(induct a)
Chengsong
parents: 492
diff changeset
   764
       apply simp+
Chengsong
parents: 492
diff changeset
   765
  done
Chengsong
parents: 492
diff changeset
   766
Chengsong
parents: 492
diff changeset
   767
lemma fuse_anything_doesnt_matter:
Chengsong
parents: 492
diff changeset
   768
  shows "rerase a = rerase (fuse bs a)"
Chengsong
parents: 492
diff changeset
   769
  by (smt (verit) fuse.elims rerase.simps(2) rerase.simps(3) rerase.simps(4) rerase.simps(5) rerase.simps(6))
Chengsong
parents: 492
diff changeset
   770
Chengsong
parents: 492
diff changeset
   771
Chengsong
parents: 492
diff changeset
   772
Chengsong
parents: 492
diff changeset
   773
lemma rder_bder_rerase:
Chengsong
parents: 492
diff changeset
   774
  shows "rder c (rerase r ) = rerase (bder c r)"
Chengsong
parents: 492
diff changeset
   775
  apply (induct r)
Chengsong
parents: 492
diff changeset
   776
       apply simp+
Chengsong
parents: 492
diff changeset
   777
    apply(case_tac "bnullable r1")
Chengsong
parents: 492
diff changeset
   778
     apply simp
Chengsong
parents: 492
diff changeset
   779
  apply (simp add: rb_nullability rerase_fuse)
Chengsong
parents: 492
diff changeset
   780
  using rb_nullability apply presburger
Chengsong
parents: 492
diff changeset
   781
   apply simp
Chengsong
parents: 492
diff changeset
   782
  apply simp
Chengsong
parents: 492
diff changeset
   783
  using rerase_fuse by presburger
Chengsong
parents: 492
diff changeset
   784
Chengsong
parents: 492
diff changeset
   785
Chengsong
parents: 492
diff changeset
   786
Chengsong
parents: 492
diff changeset
   787
Chengsong
parents: 492
diff changeset
   788
lemma RL_bder_preserved:
Chengsong
parents: 492
diff changeset
   789
  shows "RL (rerase a1) = RL (rerase a2) \<Longrightarrow> RL (rerase (bder c a1 )) = RL (rerase (bder c a2))"
Chengsong
parents: 492
diff changeset
   790
  by (metis rder_bder_rerase rder_correctness)
Chengsong
parents: 492
diff changeset
   791
Chengsong
parents: 492
diff changeset
   792
Chengsong
parents: 492
diff changeset
   793
lemma RL_bders_simp:
Chengsong
parents: 492
diff changeset
   794
  shows "RL (rerase (bders_simp r s)) = RL (rerase (bders r s))"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   795
  apply(induct s arbitrary: r rule: rev_induct)
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
   796
  apply(simp)
493
Chengsong
parents: 492
diff changeset
   797
  apply(simp add: bders_append)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   798
  apply(simp add: bders_simp_append)
493
Chengsong
parents: 492
diff changeset
   799
  apply(simp add: RL_bsimp_rerase[symmetric])
Chengsong
parents: 492
diff changeset
   800
  using RL_bder_preserved by blast
Chengsong
parents: 492
diff changeset
   801
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   802
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   803
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   804
lemma bmkeps_fuse:
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   805
  assumes "bnullable r"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   806
  shows "bmkeps (fuse bs r) = bs @ bmkeps r"
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   807
  by (metis assms bmkeps_retrieve bnullable_correctness erase_fuse mkeps_nullable retrieve_fuse2)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   808
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   809
lemma bmkepss_fuse: 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   810
  assumes "bnullables rs"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   811
  shows "bmkepss (map (fuse bs) rs) = bs @ bmkepss rs"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   812
  using assms
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   813
  apply(induct rs arbitrary: bs)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   814
  apply(auto simp add: bmkeps_fuse bnullable_fuse)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   815
  done
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   816
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   817
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   818
lemma b4:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   819
  shows "bnullable (bders_simp r s) = bnullable (bders r s)"
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   820
proof -
493
Chengsong
parents: 492
diff changeset
   821
  have "RL (rerase (bders_simp r s)) = RL (rerase (bders r s))"
Chengsong
parents: 492
diff changeset
   822
    by (simp add: RL_bders_simp)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   823
  then show "bnullable (bders_simp r s) = bnullable (bders r s)"
493
Chengsong
parents: 492
diff changeset
   824
    using RL_rnullable rb_nullability by blast
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   825
qed
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   826
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   827
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   828
lemma bder_fuse:
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   829
  shows "bder c (fuse bs a) = fuse bs  (bder c a)"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   830
  apply(induct a arbitrary: bs c)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   831
       apply(simp_all)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   832
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   833
385
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
   834
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
   835
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
   836
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   837
inductive 
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   838
  rrewrite:: "arexp \<Rightarrow> arexp \<Rightarrow> bool" ("_ \<leadsto> _" [99, 99] 99)
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   839
and 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   840
  srewrite:: "arexp list \<Rightarrow> arexp list \<Rightarrow> bool" (" _ s\<leadsto> _" [100, 100] 100)
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   841
where
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   842
  bs1: "ASEQ bs AZERO r2 \<leadsto> AZERO"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   843
| bs2: "ASEQ bs r1 AZERO \<leadsto> AZERO"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   844
| bs3: "ASEQ bs1 (AONE bs2) r \<leadsto> fuse (bs1@bs2) r"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   845
| bs4: "r1 \<leadsto> r2 \<Longrightarrow> ASEQ bs r1 r3 \<leadsto> ASEQ bs r2 r3"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   846
| bs5: "r3 \<leadsto> r4 \<Longrightarrow> ASEQ bs r1 r3 \<leadsto> ASEQ bs r1 r4"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   847
| bs6: "AALTs bs [] \<leadsto> AZERO"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   848
| bs7: "AALTs bs [r] \<leadsto> fuse bs r"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   849
| bs10: "rs1 s\<leadsto> rs2 \<Longrightarrow> AALTs bs rs1 \<leadsto> AALTs bs rs2"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   850
| ss1:  "[] s\<leadsto> []"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   851
| ss2:  "rs1 s\<leadsto> rs2 \<Longrightarrow> (r # rs1) s\<leadsto> (r # rs2)"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   852
| ss3:  "r1 \<leadsto> r2 \<Longrightarrow> (r1 # rs) s\<leadsto> (r2 # rs)"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   853
| ss4:  "(AZERO # rs) s\<leadsto> rs"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   854
| ss5:  "(AALTs bs1 rs1 # rsb) s\<leadsto> ((map (fuse bs1) rs1) @ rsb)"
493
Chengsong
parents: 492
diff changeset
   855
| ss6:  "rerase a1 = rerase a2 \<Longrightarrow> (rsa@[a1]@rsb@[a2]@rsc) s\<leadsto> (rsa@[a1]@rsb@rsc)"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   856
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   857
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   858
inductive 
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   859
  rrewrites:: "arexp \<Rightarrow> arexp \<Rightarrow> bool" ("_ \<leadsto>* _" [100, 100] 100)
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   860
where 
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   861
  rs1[intro, simp]:"r \<leadsto>* r"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   862
| rs2[intro]: "\<lbrakk>r1 \<leadsto>* r2; r2 \<leadsto> r3\<rbrakk> \<Longrightarrow> r1 \<leadsto>* r3"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   863
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   864
inductive 
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   865
  srewrites:: "arexp list \<Rightarrow> arexp list \<Rightarrow> bool" ("_ s\<leadsto>* _" [100, 100] 100)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   866
where 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   867
  sss1[intro, simp]:"rs s\<leadsto>* rs"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   868
| sss2[intro]: "\<lbrakk>rs1 s\<leadsto> rs2; rs2 s\<leadsto>* rs3\<rbrakk> \<Longrightarrow> rs1 s\<leadsto>* rs3"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   869
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   870
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   871
lemma r_in_rstar : "r1 \<leadsto> r2 \<Longrightarrow> r1 \<leadsto>* r2"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   872
  using rrewrites.intros(1) rrewrites.intros(2) by blast
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   873
 
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   874
lemma rrewrites_trans[trans]: 
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   875
  assumes a1: "r1 \<leadsto>* r2"  and a2: "r2 \<leadsto>* r3"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   876
  shows "r1 \<leadsto>* r3"
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   877
  using a2 a1
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   878
  apply(induct r2 r3 arbitrary: r1 rule: rrewrites.induct) 
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
   879
  apply(auto)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   880
  done
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   881
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   882
lemma srewrites_trans[trans]: 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   883
  assumes a1: "r1 s\<leadsto>* r2"  and a2: "r2 s\<leadsto>* r3"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   884
  shows "r1 s\<leadsto>* r3"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   885
  using a1 a2
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   886
  apply(induct r1 r2 arbitrary: r3 rule: srewrites.induct) 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   887
   apply(auto)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   888
  done
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   889
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   890
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   891
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   892
lemma contextrewrites0: 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   893
  "rs1 s\<leadsto>* rs2 \<Longrightarrow> AALTs bs rs1 \<leadsto>* AALTs bs rs2"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   894
  apply(induct rs1 rs2 rule: srewrites.inducts)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   895
   apply simp
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   896
  using bs10 r_in_rstar rrewrites_trans by blast
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   897
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   898
lemma contextrewrites1: 
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   899
  "r \<leadsto>* r' \<Longrightarrow> AALTs bs (r # rs) \<leadsto>* AALTs bs (r' # rs)"
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   900
  apply(induct r r' rule: rrewrites.induct)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   901
   apply simp
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   902
  using bs10 ss3 by blast
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   903
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   904
lemma srewrite1: 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   905
  shows "rs1 s\<leadsto> rs2 \<Longrightarrow> (rs @ rs1) s\<leadsto> (rs @ rs2)"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   906
  apply(induct rs)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   907
   apply(auto)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   908
  using ss2 by auto
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   909
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   910
lemma srewrites1: 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   911
  shows "rs1 s\<leadsto>* rs2 \<Longrightarrow> (rs @ rs1) s\<leadsto>* (rs @ rs2)"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   912
  apply(induct rs1 rs2 rule: srewrites.induct)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   913
   apply(auto)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   914
  using srewrite1 by blast
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   915
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   916
lemma srewrite2: 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   917
  shows  "r1 \<leadsto> r2 \<Longrightarrow> True"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   918
  and "rs1 s\<leadsto> rs2 \<Longrightarrow> (rs1 @ rs) s\<leadsto>* (rs2 @ rs)"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   919
  apply(induct rule: rrewrite_srewrite.inducts)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   920
               apply(auto)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   921
     apply (metis append_Cons append_Nil srewrites1)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   922
    apply(meson srewrites.simps ss3)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   923
  apply (meson srewrites.simps ss4)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   924
  apply (meson srewrites.simps ss5)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   925
  by (metis append_Cons append_Nil srewrites.simps ss6)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   926
  
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   927
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   928
lemma srewrites3: 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   929
  shows "rs1 s\<leadsto>* rs2 \<Longrightarrow> (rs1 @ rs) s\<leadsto>* (rs2 @ rs)"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   930
  apply(induct rs1 rs2 arbitrary: rs rule: srewrites.induct)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   931
   apply(auto)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   932
  by (meson srewrite2(2) srewrites_trans)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
   933
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   934
(*
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   935
lemma srewrites4:
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   936
  assumes "rs3 s\<leadsto>* rs4" "rs1 s\<leadsto>* rs2" 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   937
  shows "(rs1 @ rs3) s\<leadsto>* (rs2 @ rs4)"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   938
  using assms
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   939
  apply(induct rs3 rs4 arbitrary: rs1 rs2 rule: srewrites.induct)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   940
  apply (simp add: srewrites3)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   941
  using srewrite1 by blast
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   942
*)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   943
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   944
lemma srewrites6:
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   945
  assumes "r1 \<leadsto>* r2" 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   946
  shows "[r1] s\<leadsto>* [r2]"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   947
  using assms
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   948
  apply(induct r1 r2 rule: rrewrites.induct)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   949
   apply(auto)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   950
  by (meson srewrites.simps srewrites_trans ss3)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   951
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   952
lemma srewrites7:
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   953
  assumes "rs3 s\<leadsto>* rs4" "r1 \<leadsto>* r2" 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   954
  shows "(r1 # rs3) s\<leadsto>* (r2 # rs4)"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   955
  using assms
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   956
  by (smt (verit, best) append_Cons append_Nil srewrites1 srewrites3 srewrites6 srewrites_trans)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
   957
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   958
lemma ss6_stronger_aux:
493
Chengsong
parents: 492
diff changeset
   959
  shows "(rs1 @ rs2) s\<leadsto>* (rs1 @ distinctBy rs2 rerase (set (map rerase rs1)))"
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   960
  apply(induct rs2 arbitrary: rs1)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   961
   apply(auto)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   962
  apply (smt (verit, best) append.assoc append.right_neutral append_Cons append_Nil split_list srewrite2(2) srewrites_trans ss6)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   963
  apply(drule_tac x="rs1 @ [a]" in meta_spec)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   964
  apply(simp)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   965
  done
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   966
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   967
lemma ss6_stronger:
493
Chengsong
parents: 492
diff changeset
   968
  shows "rs1 s\<leadsto>* distinctBy rs1 rerase {}"
Chengsong
parents: 492
diff changeset
   969
  by (metis append_Nil list.set(1) list.simps(8) ss6_stronger_aux)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   970
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   971
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   972
lemma rewrite_preserves_fuse: 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   973
  shows "r2 \<leadsto> r3 \<Longrightarrow> fuse bs r2 \<leadsto> fuse bs r3"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   974
  and   "rs2 s\<leadsto> rs3 \<Longrightarrow> map (fuse bs) rs2 s\<leadsto>* map (fuse bs) rs3"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   975
proof(induct rule: rrewrite_srewrite.inducts)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   976
  case (bs3 bs1 bs2 r)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   977
  then show ?case
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   978
    by (metis fuse.simps(5) fuse_append rrewrite_srewrite.bs3) 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   979
next
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   980
  case (bs7 bs r)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   981
  then show ?case
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   982
    by (metis fuse.simps(4) fuse_append rrewrite_srewrite.bs7) 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   983
next
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   984
  case (ss2 rs1 rs2 r)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   985
  then show ?case
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   986
    using srewrites7 by force 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   987
next
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   988
  case (ss3 r1 r2 rs)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   989
  then show ?case by (simp add: r_in_rstar srewrites7)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   990
next
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   991
  case (ss5 bs1 rs1 rsb)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   992
  then show ?case 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   993
    apply(simp)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   994
    by (metis (mono_tags, lifting) comp_def fuse_append map_eq_conv rrewrite_srewrite.ss5 srewrites.simps)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   995
next
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   996
  case (ss6 a1 a2 rsa rsb rsc)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   997
  then show ?case 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
   998
    apply(simp only: map_append)
493
Chengsong
parents: 492
diff changeset
   999
    by (smt (verit, ccfv_threshold) rerase_fuse list.simps(8) list.simps(9) rrewrite_srewrite.ss6 srewrites.simps)  
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1000
qed (auto intro: rrewrite_srewrite.intros)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1001
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1002
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1003
lemma rewrites_fuse:  
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1004
  assumes "r1 \<leadsto>* r2"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1005
  shows "fuse bs r1 \<leadsto>* fuse bs r2"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1006
using assms
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1007
apply(induction r1 r2 arbitrary: bs rule: rrewrites.induct)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1008
apply(auto intro: rewrite_preserves_fuse rrewrites_trans)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1009
done
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1010
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1011
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1012
lemma star_seq:  
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1013
  assumes "r1 \<leadsto>* r2"
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1014
  shows "ASEQ bs r1 r3 \<leadsto>* ASEQ bs r2 r3"
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1015
using assms
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1016
apply(induct r1 r2 arbitrary: r3 rule: rrewrites.induct)
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1017
apply(auto intro: rrewrite_srewrite.intros)
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1018
done
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1019
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1020
lemma star_seq2:  
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1021
  assumes "r3 \<leadsto>* r4"
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1022
  shows "ASEQ bs r1 r3 \<leadsto>* ASEQ bs r1 r4"
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1023
  using assms
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1024
apply(induct r3 r4 arbitrary: r1 rule: rrewrites.induct)
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1025
apply(auto intro: rrewrite_srewrite.intros)
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1026
done
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1027
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1028
lemma continuous_rewrite: 
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1029
  assumes "r1 \<leadsto>* AZERO"
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1030
  shows "ASEQ bs1 r1 r2 \<leadsto>* AZERO"
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1031
using assms bs1 star_seq by blast
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1032
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1033
(*
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1034
lemma continuous_rewrite2: 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1035
  assumes "r1 \<leadsto>* AONE bs"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1036
  shows "ASEQ bs1 r1 r2 \<leadsto>* (fuse (bs1 @ bs) r2)"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1037
  using assms  by (meson bs3 rrewrites.simps star_seq)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1038
*)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1039
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1040
lemma bsimp_aalts_simpcases: 
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1041
  shows "AONE bs \<leadsto>* bsimp (AONE bs)"  
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1042
  and   "AZERO \<leadsto>* bsimp AZERO" 
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1043
  and   "ACHAR bs c \<leadsto>* bsimp (ACHAR bs c)"
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1044
  by (simp_all)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1045
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1046
lemma bsimp_AALTs_rewrites: 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1047
  shows "AALTs bs1 rs \<leadsto>* bsimp_AALTs bs1 rs"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1048
  by (smt (verit) bs6 bs7 bsimp_AALTs.elims rrewrites.simps)
385
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
  1049
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
  1050
lemma trivialbsimp_srewrites: 
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1051
  "\<lbrakk>\<And>x. x \<in> set rs \<Longrightarrow> x \<leadsto>* f x \<rbrakk> \<Longrightarrow> rs s\<leadsto>* (map f rs)"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1052
  apply(induction rs)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1053
   apply simp
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1054
  apply(simp)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1055
  using srewrites7 by auto
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1056
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1057
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1058
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1059
lemma fltsfrewrites: "rs s\<leadsto>* flts rs"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1060
  apply(induction rs rule: flts.induct)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1061
  apply(auto intro: rrewrite_srewrite.intros)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1062
  apply (meson srewrites.simps srewrites1 ss5)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1063
  using rs1 srewrites7 apply presburger
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1064
  using srewrites7 apply force
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1065
  apply (simp add: srewrites7)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1066
  by (simp add: srewrites7)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1067
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1068
lemma bnullable0:
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1069
shows "r1 \<leadsto> r2 \<Longrightarrow> bnullable r1 = bnullable r2" 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1070
  and "rs1 s\<leadsto> rs2 \<Longrightarrow> bnullables rs1 = bnullables rs2" 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1071
  apply(induct rule: rrewrite_srewrite.inducts)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1072
  apply(auto simp add:  bnullable_fuse)
493
Chengsong
parents: 492
diff changeset
  1073
   apply (meson UnCI bnullable_fuse imageI)
Chengsong
parents: 492
diff changeset
  1074
  by (metis rb_nullability)
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1075
373
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1076
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1077
lemma rewritesnullable: 
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1078
  assumes "r1 \<leadsto>* r2" 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1079
  shows "bnullable r1 = bnullable r2"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1080
using assms 
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1081
  apply(induction r1 r2 rule: rrewrites.induct)
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1082
  apply simp
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1083
  using bnullable0(1) by auto
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1084
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1085
lemma rewrite_bmkeps_aux: 
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1086
  shows "r1 \<leadsto> r2 \<Longrightarrow> (bnullable r1 \<and> bnullable r2 \<Longrightarrow> bmkeps r1 = bmkeps r2)"
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1087
  and   "rs1 s\<leadsto> rs2 \<Longrightarrow> (bnullables rs1 \<and> bnullables rs2 \<Longrightarrow> bmkepss rs1 = bmkepss rs2)" 
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1088
proof (induct rule: rrewrite_srewrite.inducts)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1089
  case (bs3 bs1 bs2 r)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1090
  then show ?case by (simp add: bmkeps_fuse) 
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1091
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1092
  case (bs7 bs r)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1093
  then show ?case by (simp add: bmkeps_fuse) 
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1094
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1095
  case (ss3 r1 r2 rs)
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1096
  then show ?case
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1097
    by (metis bmkepss.simps(2) bnullable0(1))
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1098
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1099
  case (ss5 bs1 rs1 rsb)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1100
  then show ?case
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1101
    by (simp add: bmkepss1 bmkepss2 bmkepss_fuse bnullable_fuse)
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1102
next
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1103
  case (ss6 a1 a2 rsa rsb rsc)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1104
  then show ?case
493
Chengsong
parents: 492
diff changeset
  1105
    by (smt (z3) append_is_Nil_conv bmkepss1 bmkepss2 in_set_conv_decomp_first list.set_intros(1) rb_nullability set_ConsD)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1106
qed (auto)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1107
373
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1108
lemma rewrites_bmkeps: 
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1109
  assumes "r1 \<leadsto>* r2" "bnullable r1" 
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1110
  shows "bmkeps r1 = bmkeps r2"
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1111
  using assms
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1112
proof(induction r1 r2 rule: rrewrites.induct)
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1113
  case (rs1 r)
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1114
  then show "bmkeps r = bmkeps r" by simp
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1115
next
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1116
  case (rs2 r1 r2 r3)
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1117
  then have IH: "bmkeps r1 = bmkeps r2" by simp
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1118
  have a1: "bnullable r1" by fact
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1119
  have a2: "r1 \<leadsto>* r2" by fact
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1120
  have a3: "r2 \<leadsto> r3" by fact
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1121
  have a4: "bnullable r2" using a1 a2 by (simp add: rewritesnullable) 
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1122
  then have "bmkeps r2 = bmkeps r3"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1123
    using a3 bnullable0(1) rewrite_bmkeps_aux(1) by blast 
373
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1124
  then show "bmkeps r1 = bmkeps r3" using IH by simp
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1125
qed
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1126
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1127
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1128
lemma rewrites_to_bsimp: 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1129
  shows "r \<leadsto>* bsimp r"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1130
proof (induction r rule: bsimp.induct)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1131
  case (1 bs1 r1 r2)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1132
  have IH1: "r1 \<leadsto>* bsimp r1" by fact
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1133
  have IH2: "r2 \<leadsto>* bsimp r2" by fact
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1134
  { assume as: "bsimp r1 = AZERO \<or> bsimp r2 = AZERO"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1135
    with IH1 IH2 have "r1 \<leadsto>* AZERO \<or> r2 \<leadsto>* AZERO" by auto
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1136
    then have "ASEQ bs1 r1 r2 \<leadsto>* AZERO"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1137
      by (metis bs2 continuous_rewrite rrewrites.simps star_seq2)  
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1138
    then have "ASEQ bs1 r1 r2 \<leadsto>* bsimp (ASEQ bs1 r1 r2)" using as by auto
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1139
  }
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1140
  moreover
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1141
  { assume "\<exists>bs. bsimp r1 = AONE bs"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1142
    then obtain bs where as: "bsimp r1 = AONE bs" by blast
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1143
    with IH1 have "r1 \<leadsto>* AONE bs" by simp
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1144
    then have "ASEQ bs1 r1 r2 \<leadsto>* fuse (bs1 @ bs) r2" using bs3 star_seq by blast
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1145
    with IH2 have "ASEQ bs1 r1 r2 \<leadsto>* fuse (bs1 @ bs) (bsimp r2)"
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1146
      using rewrites_fuse by (meson rrewrites_trans) 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1147
    then have "ASEQ bs1 r1 r2 \<leadsto>* bsimp (ASEQ bs1 (AONE bs) r2)" by simp
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1148
    then have "ASEQ bs1 r1 r2 \<leadsto>* bsimp (ASEQ bs1 r1 r2)" by (simp add: as) 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1149
  } 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1150
  moreover
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1151
  { assume as1: "bsimp r1 \<noteq> AZERO" "bsimp r2 \<noteq> AZERO" and as2: "(\<nexists>bs. bsimp r1 = AONE bs)" 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1152
    then have "bsimp_ASEQ bs1 (bsimp r1) (bsimp r2) = ASEQ bs1 (bsimp r1) (bsimp r2)" 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1153
      by (simp add: bsimp_ASEQ1) 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1154
    then have "ASEQ bs1 r1 r2 \<leadsto>* bsimp_ASEQ bs1 (bsimp r1) (bsimp r2)" using as1 as2 IH1 IH2
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1155
      by (metis rrewrites_trans star_seq star_seq2) 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1156
    then have "ASEQ bs1 r1 r2 \<leadsto>* bsimp (ASEQ bs1 r1 r2)" by simp
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1157
  } 
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1158
  ultimately show "ASEQ bs1 r1 r2 \<leadsto>* bsimp (ASEQ bs1 r1 r2)" by blast
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1159
next
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1160
  case (2 bs1 rs)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1161
  have IH: "\<And>x. x \<in> set rs \<Longrightarrow> x \<leadsto>* bsimp x" by fact
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1162
  then have "rs s\<leadsto>* (map bsimp rs)" by (simp add: trivialbsimp_srewrites)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1163
  also have "... s\<leadsto>* flts (map bsimp rs)" by (simp add: fltsfrewrites) 
493
Chengsong
parents: 492
diff changeset
  1164
  also have "... s\<leadsto>* distinctBy (flts (map bsimp rs)) rerase {}" by (simp add: ss6_stronger) 
Chengsong
parents: 492
diff changeset
  1165
  finally have "AALTs bs1 rs \<leadsto>* AALTs bs1 (distinctBy (flts (map bsimp rs)) rerase {})"
Chengsong
parents: 492
diff changeset
  1166
    using contextrewrites0 by auto
Chengsong
parents: 492
diff changeset
  1167
  also have "... \<leadsto>* bsimp_AALTs  bs1 (distinctBy (flts (map bsimp rs)) rerase {})"
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1168
    by (simp add: bsimp_AALTs_rewrites)     
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1169
  finally show "AALTs bs1 rs \<leadsto>* bsimp (AALTs bs1 rs)" by simp
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1170
qed (simp_all)
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1171
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1172
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1173
lemma to_zero_in_alt: 
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1174
  shows "AALT bs (ASEQ [] AZERO r) r2 \<leadsto> AALT bs AZERO r2"
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1175
  by (simp add: bs1 bs10 ss3)
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1176
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1177
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1178
374
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1179
lemma  bder_fuse_list: 
98362002c818 slightly more
Christian Urban <christian.urban@kcl.ac.uk>
parents: 373
diff changeset
  1180
  shows "map (bder c \<circ> fuse bs1) rs1 = map (fuse bs1 \<circ> bder c) rs1"
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1181
  apply(induction rs1)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1182
  apply(simp_all add: bder_fuse)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1183
  done
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1184
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1185
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1186
lemma rewrite_preserves_bder: 
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1187
  shows "r1 \<leadsto> r2 \<Longrightarrow> (bder c r1) \<leadsto>* (bder c r2)"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1188
  and   "rs1 s\<leadsto> rs2 \<Longrightarrow> map (bder c) rs1 s\<leadsto>* map (bder c) rs2"
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1189
proof(induction rule: rrewrite_srewrite.inducts)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1190
  case (bs1 bs r2)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1191
  then show ?case
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1192
    by (simp add: continuous_rewrite) 
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1193
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1194
  case (bs2 bs r1)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1195
  then show ?case 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1196
    apply(auto)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1197
    apply (meson bs6 contextrewrites0 rrewrite_srewrite.bs2 rs2 ss3 ss4 sss1 sss2)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1198
    by (simp add: r_in_rstar rrewrite_srewrite.bs2)
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1199
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1200
  case (bs3 bs1 bs2 r)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1201
  then show ?case 
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1202
    apply(simp)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1203
    
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1204
    by (metis (no_types, lifting) bder_fuse bs10 bs7 fuse_append rrewrites.simps ss4 to_zero_in_alt)
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1205
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1206
  case (bs4 r1 r2 bs r3)
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1207
  have as: "r1 \<leadsto> r2" by fact
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1208
  have IH: "bder c r1 \<leadsto>* bder c r2" by fact
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1209
  from as IH show "bder c (ASEQ bs r1 r3) \<leadsto>* bder c (ASEQ bs r2 r3)"
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1210
    by (metis bder.simps(5) bnullable0(1) contextrewrites1 rewrite_bmkeps_aux(1) star_seq)
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1211
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1212
  case (bs5 r3 r4 bs r1)
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1213
  have as: "r3 \<leadsto> r4" by fact 
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1214
  have IH: "bder c r3 \<leadsto>* bder c r4" by fact 
385
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
  1215
  from as IH show "bder c (ASEQ bs r1 r3) \<leadsto>* bder c (ASEQ bs r1 r4)"
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1216
    apply(simp)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1217
    apply(auto)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1218
    using contextrewrites0 r_in_rstar rewrites_fuse srewrites6 srewrites7 star_seq2 apply presburger
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1219
    using star_seq2 by blast
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1220
next
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1221
  case (bs6 bs)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1222
  then show ?case
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1223
    using rrewrite_srewrite.bs6 by force 
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1224
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1225
  case (bs7 bs r)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1226
  then show ?case
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1227
    by (simp add: bder_fuse r_in_rstar rrewrite_srewrite.bs7) 
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1228
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1229
  case (bs10 rs1 rs2 bs)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1230
  then show ?case
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1231
    using contextrewrites0 by force    
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1232
next
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1233
  case ss1
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1234
  then show ?case by simp
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1235
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1236
  case (ss2 rs1 rs2 r)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1237
  then show ?case
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1238
    by (simp add: srewrites7) 
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1239
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1240
  case (ss3 r1 r2 rs)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1241
  then show ?case
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1242
    by (simp add: srewrites7) 
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1243
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1244
  case (ss4 rs)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1245
  then show ?case
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1246
    using rrewrite_srewrite.ss4 by fastforce 
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1247
next
392
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1248
  case (ss5 bs1 rs1 rsb)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1249
  then show ?case 
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1250
    apply(simp)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1251
    using bder_fuse_list map_map rrewrite_srewrite.ss5 srewrites.simps by blast
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1252
next
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1253
  case (ss6 a1 a2 bs rsa rsb)
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1254
  then show ?case
8194086c2a8a simplified version
Christian Urban <christian.urban@kcl.ac.uk>
parents: 385
diff changeset
  1255
    apply(simp only: map_append)
493
Chengsong
parents: 492
diff changeset
  1256
    by (smt (verit, best) rder_bder_rerase list.simps(8) list.simps(9) local.ss6 rrewrite_srewrite.ss6 srewrites.simps)
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1257
qed
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1258
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1259
lemma rewrites_preserves_bder: 
373
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1260
  assumes "r1 \<leadsto>* r2"
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1261
  shows "bder c r1 \<leadsto>* bder c r2"
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1262
using assms  
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1263
apply(induction r1 r2 rule: rrewrites.induct)
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1264
apply(simp_all add: rewrite_preserves_bder rrewrites_trans)
373
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1265
done
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1266
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1267
373
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1268
lemma central:  
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1269
  shows "bders r s \<leadsto>* bders_simp r s"
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1270
proof(induct s arbitrary: r rule: rev_induct)
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1271
  case Nil
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1272
  then show "bders r [] \<leadsto>* bders_simp r []" by simp
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1273
next
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1274
  case (snoc x xs)
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1275
  have IH: "\<And>r. bders r xs \<leadsto>* bders_simp r xs" by fact
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1276
  have "bders r (xs @ [x]) = bders (bders r xs) [x]" by (simp add: bders_append)
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1277
  also have "... \<leadsto>* bders (bders_simp r xs) [x]" using IH
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1278
    by (simp add: rewrites_preserves_bder)
373
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1279
  also have "... \<leadsto>* bders_simp (bders_simp r xs) [x]" using IH
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1280
    by (simp add: rewrites_to_bsimp)
373
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1281
  finally show "bders r (xs @ [x]) \<leadsto>* bders_simp r (xs @ [x])" 
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1282
    by (simp add: bders_simp_append)
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1283
qed
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1284
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1285
lemma main_aux: 
373
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1286
  assumes "bnullable (bders r s)"
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1287
  shows "bmkeps (bders r s) = bmkeps (bders_simp r s)"
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1288
proof -
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1289
  have "bders r s \<leadsto>* bders_simp r s" by (rule central)
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1290
  then 
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1291
  show "bmkeps (bders r s) = bmkeps (bders_simp r s)" using assms
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1292
    by (rule rewrites_bmkeps)
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1293
qed  
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1294
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1295
385
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
  1296
c80720289645 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 381
diff changeset
  1297
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1298
theorem main_blexer_simp: 
373
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1299
  shows "blexer r s = blexer_simp r s"
381
0c666a0c57d7 isarfied some proofs
Christian Urban <christian.urban@kcl.ac.uk>
parents: 379
diff changeset
  1300
  unfolding blexer_def blexer_simp_def
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1301
  using b4 main_aux by simp
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1302
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1303
373
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1304
theorem blexersimp_correctness: 
320f923c77b9 slightly
Christian Urban <christian.urban@kcl.ac.uk>
parents: 365
diff changeset
  1305
  shows "lexer r s = blexer_simp r s"
393
3954579ebdaf polished
Christian Urban <christian.urban@kcl.ac.uk>
parents: 392
diff changeset
  1306
  using blexer_correctness main_blexer_simp by simp
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1307
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1308
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1309
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1310
lemma rerase_preimage:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1311
  shows "rerase r = RZERO \<Longrightarrow> r = AZERO"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1312
  apply(case_tac r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1313
       apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1314
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1315
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1316
lemma rerase_preimage2:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1317
  shows "rerase r = RONE \<Longrightarrow> \<exists>bs. r = AONE bs"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1318
  apply(case_tac r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1319
       apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1320
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1321
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1322
lemma rerase_preimage3:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1323
  shows "rerase r= RCHAR c \<Longrightarrow> \<exists>bs. r = ACHAR bs c"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1324
  apply(case_tac r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1325
       apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1326
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1327
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1328
lemma rerase_preimage4:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1329
  shows "rerase r = RSEQ r1 r2 \<Longrightarrow> \<exists>bs a1 a2. r = ASEQ bs a1 a2 \<and> rerase a1 = r1 \<and> rerase a2 = r2"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1330
  apply(case_tac r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1331
       apply(simp)+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1332
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1333
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1334
lemma rerase_preimage5:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1335
  shows "rerase r = RALTS rs \<Longrightarrow> \<exists>bs as. r = AALTs bs as \<and> map rerase as = rs"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1336
  apply(case_tac r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1337
       apply(simp)+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1338
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1339
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1340
lemma rerase_preimage6:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1341
  shows "rerase r = RSTAR r0 \<Longrightarrow> \<exists>bs a0. r = ASTAR bs a0 \<and> rerase a0 = r0 "
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1342
  apply(case_tac r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1343
       apply(simp)+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1344
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1345
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1346
lemma map_rder_bder:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1347
  shows "\<lbrakk> \<And>xa a. \<lbrakk>xa \<in> set x; rerase a = xa\<rbrakk> \<Longrightarrow> rerase (bder c a) = rder c xa;
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1348
         map rerase as = x\<rbrakk> \<Longrightarrow>
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1349
        map rerase (map (bder c) as) = map (rder c) x"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1350
  apply(induct x arbitrary: as)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1351
   apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1352
  by force
378
Chengsong
parents: 375
diff changeset
  1353
Chengsong
parents: 375
diff changeset
  1354
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1355
lemma der_rerase:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1356
  shows "rerase a = r \<Longrightarrow> rerase (bder c a) = rder c r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1357
  apply(induct r arbitrary: a)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1358
       apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1359
  using rerase_preimage apply fastforce
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1360
  using rerase_preimage2 apply force
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1361
     apply (metis bder.simps(3) rder.simps(3) rerase.simps(1) rerase.simps(2) rerase_preimage3)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1362
    apply(insert rerase_preimage4)[1]
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1363
    apply(subgoal_tac " \<exists>bs a1 a2. a = ASEQ bs a1 a2 \<and> rerase a1 = r1 \<and> rerase a2 = r2")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1364
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1365
     apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1366
    apply(erule exE)+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1367
    apply(erule conjE)+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1368
    apply(subgoal_tac " rerase (bder c a1) = rder c r1")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1369
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1370
     apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1371
    apply(subgoal_tac " rerase (bder c a2) = rder c r2")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1372
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1373
     apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1374
    apply(case_tac "rnullable r1")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1375
     apply(subgoal_tac "bnullable a1")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1376
  apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1377
  using fuse_anything_doesnt_matter apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1378
  using rb_nullability apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1379
    apply (metis bder.simps(5) rb_nullability rder.simps(5) rerase.simps(5))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1380
  apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1381
   apply(insert rerase_preimage5)[1]
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1382
   apply(subgoal_tac "\<exists>bs as. a = AALTs bs as \<and> map rerase as = x")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1383
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1384
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1385
    apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1386
   apply(erule exE)+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1387
   apply(erule conjE)+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1388
  apply(subgoal_tac "map rerase (map (bder c) as) = map (rder c) x")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1389
  using bder.simps(4) rerase.simps(4) apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1390
  using map_rder_bder apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1391
  using fuse_anything_doesnt_matter rerase_preimage6 by force
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1392
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1393
lemma der_rerase2:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1394
  shows "rerase (bder c a) = rder c (rerase a)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1395
  using der_rerase by force
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1396
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1397
lemma ders_rerase:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1398
  shows "rerase (bders a s) = rders (rerase a) s"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1399
  apply(induct s rule: rev_induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1400
   apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1401
  by (simp add: bders_append der_rerase rders_append)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1402
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1403
lemma rerase_bsimp_ASEQ:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1404
  shows "rerase (bsimp_ASEQ x1 a1 a2) = rsimp_SEQ (rerase a1) (rerase a2)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1405
  by (smt (verit, ccfv_SIG) SizeBound3.bsimp_ASEQ0 SizeBound3.bsimp_ASEQ2 basic_rsimp_SEQ_property1 basic_rsimp_SEQ_property2 basic_rsimp_SEQ_property3 bsimp_ASEQ.simps(1) bsimp_ASEQ1 fuse_anything_doesnt_matter rerase.simps(1) rerase.simps(2) rerase.simps(5) rerase_preimage rerase_preimage2 rsimp_SEQ.simps(1))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1406
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1407
lemma rerase_bsimp_AALTs:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1408
  shows "rerase (bsimp_AALTs bs rs) = rsimp_ALTs (map rerase rs)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1409
  apply(induct rs arbitrary: bs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1410
   apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1411
  by (smt (verit, ccfv_threshold) Cons_eq_map_conv bsimp_AALTs.elims fuse_anything_doesnt_matter list.discI list.inject list.simps(9) rerase.simps(4) rsimp_ALTs.elims)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1412
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1413
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1414
fun anonalt :: "arexp \<Rightarrow> bool"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1415
  where
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1416
  "anonalt (AALTs bs2 rs) = False"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1417
| "anonalt r = True"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1418
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1419
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1420
fun agood :: "arexp \<Rightarrow> bool" where
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1421
  "agood AZERO = False"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1422
| "agood (AONE cs) = True" 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1423
| "agood (ACHAR cs c) = True"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1424
| "agood (AALTs cs []) = False"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1425
| "agood (AALTs cs [r]) = False"
493
Chengsong
parents: 492
diff changeset
  1426
| "agood (AALTs cs (r1#r2#rs)) = (distinct (map rerase (r1 # r2 # rs)) \<and>(\<forall>r' \<in> set (r1#r2#rs). agood r' \<and> anonalt r'))"
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1427
| "agood (ASEQ _ AZERO _) = False"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1428
| "agood (ASEQ _ (AONE _) _) = False"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1429
| "agood (ASEQ _ _ AZERO) = False"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1430
| "agood (ASEQ cs r1 r2) = (agood r1 \<and> agood r2)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1431
| "agood (ASTAR cs r) = True"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1432
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1433
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1434
fun anonnested :: "arexp \<Rightarrow> bool"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1435
  where
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1436
  "anonnested (AALTs bs2 []) = True"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1437
| "anonnested (AALTs bs2 ((AALTs bs1 rs1) # rs2)) = False"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1438
| "anonnested (AALTs bs2 (r # rs2)) = anonnested (AALTs bs2 rs2)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1439
| "anonnested r = True"
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1440
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  1441
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1442
lemma  k0:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1443
  shows "flts (r # rs1) = flts [r] @ flts rs1"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1444
  apply(induct r arbitrary: rs1)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1445
   apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1446
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1447
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1448
lemma  k00:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1449
  shows "flts (rs1 @ rs2) = flts rs1 @ flts rs2"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1450
  apply(induct rs1 arbitrary: rs2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1451
   apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1452
  by (metis append.assoc k0)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1453
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1454
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1455
lemma bbbbs:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1456
  assumes "agood r" "r = AALTs bs1 rs"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1457
  shows "bsimp_AALTs bs (flts [r]) = AALTs bs (map (fuse bs1) rs)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1458
  using  assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1459
  by (smt (verit, ccfv_SIG) Cons_eq_map_conv agood.simps(4) agood.simps(5) append.right_neutral bsimp_AALTs.elims flts.simps(1) flts.simps(3) list.map_disc_iff)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1460
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1461
lemma bbbbs1:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1462
  shows "anonalt r \<or> (\<exists>bs rs. r  = AALTs bs rs)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1463
  by (meson anonalt.elims(3))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1464
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1465
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1466
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1467
lemma good_fuse:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1468
  shows "agood (fuse bs r) = agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1469
  apply(induct r arbitrary: bs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1470
       apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1471
     apply(case_tac r1)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1472
          apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1473
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1474
          apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1475
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1476
            apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1477
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1478
           apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1479
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1480
          apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1481
  apply(case_tac r1)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1482
          apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1483
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1484
           apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1485
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1486
           apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1487
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1488
           apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1489
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1490
         apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1491
  apply(case_tac x2a)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1492
    apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1493
  apply(case_tac list)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1494
    apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1495
  apply(case_tac x2a)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1496
    apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1497
  apply(case_tac list)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1498
    apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1499
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1500
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1501
lemma good0:
493
Chengsong
parents: 492
diff changeset
  1502
  assumes "rs \<noteq> Nil" "\<forall>r \<in> set rs. anonalt r" "distinct (map rerase rs)"
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1503
  shows "agood (bsimp_AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. agood r)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1504
  using  assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1505
  apply(induct bs rs rule: bsimp_AALTs.induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1506
    apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1507
   apply (simp add: good_fuse)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1508
  apply(subgoal_tac "bsimp_AALTs bs1 (v # vb # vc) = AALTs bs1 (v # vb # vc)")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1509
   prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1510
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1511
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1512
  using bsimp_AALTs.simps(3) apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1513
  apply(simp only:)
493
Chengsong
parents: 492
diff changeset
  1514
  apply(subgoal_tac "agood (AALTs bs1 (v # vb # vc)) = ((\<forall>r \<in> (set (v # vb # vc)). agood r \<and> anonalt r) \<and> distinct (map rerase (v # vb # vc)))")
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1515
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1516
  using agood.simps(6) apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1517
  apply(simp only:)
493
Chengsong
parents: 492
diff changeset
  1518
  apply(subgoal_tac "((\<forall>r\<in>set (v # vb # vc). agood r \<and> anonalt r) \<and> distinct (map rerase (v # vb # vc))) = ((\<forall>r\<in>set (v # vb # vc). agood r) \<and> distinct (map rerase (v # vb # vc)))")
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1519
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1520
  apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1521
  apply(simp only:)
493
Chengsong
parents: 492
diff changeset
  1522
  apply(subgoal_tac "((\<forall>r \<in> set (v # vb # vc). agood r) \<and> distinct (map rerase (v # vb # vc))) = (\<forall> r \<in> set (v # vb # vc). agood r) ")
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1523
  prefer 2
493
Chengsong
parents: 492
diff changeset
  1524
   apply(subgoal_tac "distinct (map rerase (v # vb # vc)) = True")
Chengsong
parents: 492
diff changeset
  1525
    prefer 2
Chengsong
parents: 492
diff changeset
  1526
  sledgehammer
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1527
    apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1528
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1529
   apply force
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1530
  apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1531
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1532
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1533
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1534
lemma nn11a:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1535
  assumes "anonalt r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1536
  shows "anonalt (fuse bs r)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1537
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1538
  apply(induct r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1539
       apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1540
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1541
378
Chengsong
parents: 375
diff changeset
  1542
Chengsong
parents: 375
diff changeset
  1543
Chengsong
parents: 375
diff changeset
  1544
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1545
lemma flts0:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1546
  assumes "r \<noteq> AZERO" "anonalt r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1547
  shows "flts [r] \<noteq> []"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1548
  using  assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1549
  apply(induct r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1550
       apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1551
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1552
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1553
lemma flts1:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1554
  assumes "agood r" 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1555
  shows "flts [r] \<noteq> []"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1556
  using  assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1557
  apply(induct r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1558
       apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1559
  apply(case_tac x2a)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1560
   apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1561
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1562
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1563
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1564
lemma flts2:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1565
  assumes "agood r" 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1566
  shows "\<forall>r' \<in> set (flts [r]). agood r' \<and> anonalt r'"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1567
  using  assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1568
  apply(induct r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1569
       apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1570
      apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1571
     apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1572
    prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1573
    apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1574
    apply(auto)[1]
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1575
     apply (metis bsimp_AALTs.elims agood.simps(4) agood.simps(5) agood.simps(6) good_fuse)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1576
  apply (metis bsimp_AALTs.elims agood.simps(4) agood.simps(5) agood.simps(6) nn11a)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1577
   apply fastforce
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1578
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1579
  done  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1580
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1581
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1582
lemma flts3:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1583
  assumes "\<forall>r \<in> set rs. agood r \<or> r = AZERO" 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1584
  shows "\<forall>r \<in> set (flts rs). agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1585
  using  assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1586
  apply(induct rs arbitrary: rule: flts.induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1587
        apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1588
  by (metis SizeBound3.flts2 UnE append.right_neutral flts.simps(1) flts.simps(3) list.set_map)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1589
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1590
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1591
lemma flts3b:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1592
  assumes "\<exists>r\<in>set rs. agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1593
  shows "flts rs \<noteq> []"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1594
  using  assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1595
  apply(induct rs arbitrary: rule: flts.induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1596
        apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1597
       apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1598
      apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1599
      apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1600
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1601
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1602
lemma k0a:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1603
  shows "flts [AALTs bs rs] = map (fuse bs)  rs"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1604
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1605
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1606
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1607
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1608
lemma k0b:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1609
  assumes "anonalt r" "r \<noteq> AZERO"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1610
  shows "flts [r] = [r]"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1611
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1612
  apply(case_tac  r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1613
  apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1614
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1615
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1616
lemma flts4_nogood:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1617
  shows "bsimp_AALTs bs0 rs = AZERO \<Longrightarrow> \<forall>r \<in> set rs. \<not> agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1618
  by (metis SizeBound3.flts3b arexp.distinct(7) bsimp_AALTs.elims flts.simps(1) flts.simps(2) fuse_anything_doesnt_matter rerase.simps(1) rerase_preimage)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1619
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1620
lemma flts4_append:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1621
  shows "bsimp_AALTs bs0 (rs @ flts rsa) = AZERO \<Longrightarrow> bsimp_AALTs bs0 rs = AZERO"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1622
  by (metis append_is_Nil_conv arexp.simps(13) bsimp_AALTs.elims bsimp_AALTs.simps(1) butlast_append butlast_snoc)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1623
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1624
lemma flts4:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1625
  assumes "bsimp_AALTs bs (flts rs) = AZERO"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1626
  shows "\<forall>r \<in> set rs. \<not> agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1627
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1628
  apply(induct rs arbitrary: bs rule: flts.induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1629
        apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1630
        defer
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1631
        apply (metis (no_types, lifting) Nil_is_append_conv append_self_conv2 bsimp_AALTs.elims butlast.simps(2) butlast_append flts3b anonalt.simps(1) anonalt.simps(2))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1632
       apply (metis agood.simps(1) agood.simps(2) arexp.distinct(7) bsimp_AALTs.elims good_fuse list.distinct(1) list.inject)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1633
      apply (metis agood.simps(1) agood.simps(3) arexp.distinct(7) bsimp_AALTs.elims good_fuse list.distinct(1) list.inject)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1634
     apply (metis agood.simps(1) arexp.distinct(7) bsimp_AALTs.elims good_fuse list.discI list.inject)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1635
    apply (metis arexp.distinct(7) bsimp_AALTs.elims list.distinct(1) list.inject)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1636
  apply (metis agood.simps(1) agood.simps(33) arexp.distinct(7) bsimp_AALTs.elims good_fuse list.discI list.inject)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1637
  by (metis SizeBound3.bbbbs SizeBound3.k0a arexp.simps(13) flts4_append)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1638
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1639
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1640
lemma flts_nil:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1641
  assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow>
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1642
            agood (bsimp y) \<or> bsimp y = AZERO"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1643
  and "\<forall>r\<in>set rs. \<not> agood (bsimp r)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1644
  shows "flts (map bsimp rs) = []"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1645
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1646
  apply(induct rs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1647
   apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1648
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1649
  apply(subst k0)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1650
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1651
  by force
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1652
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1653
lemma flts_nil2:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1654
  assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow>
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1655
            agood (bsimp y) \<or> bsimp y = AZERO"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1656
  and "bsimp_AALTs bs (flts (map bsimp rs)) = AZERO"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1657
  shows "flts (map bsimp rs) = []"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1658
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1659
  apply(induct rs arbitrary: bs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1660
   apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1661
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1662
  apply(subst k0)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1663
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1664
  apply(subst (asm) k0)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1665
  apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1666
  apply (metis flts.simps(1) flts.simps(2) flts4 k0 less_add_Suc1 list.set_intros(1))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1667
  by (metis flts.simps(2) flts4 k0 less_add_Suc1 list.set_intros(1))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1668
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1669
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1670
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1671
lemma good_SEQ:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1672
  assumes "r1 \<noteq> AZERO" "r2 \<noteq> AZERO" "\<forall>bs. r1 \<noteq> AONE bs"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1673
  shows "agood (ASEQ bs r1 r2) = (agood r1 \<and> agood r2)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1674
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1675
  apply(case_tac r1)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1676
       apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1677
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1678
          apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1679
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1680
         apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1681
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1682
        apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1683
  apply(case_tac r2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1684
       apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1685
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1686
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1687
lemma asize0:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1688
  shows "0 < asize r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1689
  apply(induct  r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1690
       apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1691
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1692
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1693
lemma nn1qq:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1694
  assumes "anonnested (AALTs bs rs)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1695
  shows "\<nexists>bs1 rs1. AALTs bs1 rs1 \<in> set rs"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1696
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1697
  apply(induct rs rule: flts.induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1698
  apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1699
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1700
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1701
lemma nn1c:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1702
  assumes "\<forall>r \<in> set rs. anonnested r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1703
  shows "\<forall>r \<in> set (flts rs). anonalt r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1704
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1705
  apply(induct rs rule: flts.induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1706
        apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1707
  apply(rule nn11a)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1708
  by (metis nn1qq anonalt.elims(3))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1709
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1710
lemma n0:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1711
  shows "anonnested (AALTs bs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. anonalt r)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1712
  apply(induct rs  arbitrary: bs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1713
   apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1714
  apply (metis SizeBound3.nn1qq anonalt.elims(3) list.set_intros(1))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1715
  apply (metis SizeBound3.bbbbs1 SizeBound3.nn1qq list.set_intros(2))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1716
  by (metis anonalt.elims(2) anonnested.simps(3) anonnested.simps(4) anonnested.simps(5) anonnested.simps(6) anonnested.simps(7))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1717
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1718
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1719
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1720
lemma nn1bb:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1721
  assumes "\<forall>r \<in> set rs. anonalt r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1722
  shows "anonnested (bsimp_AALTs bs rs)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1723
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1724
  apply(induct bs rs rule: bsimp_AALTs.induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1725
    apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1726
   apply (metis nn11a anonalt.simps(1) anonnested.elims(3))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1727
  using n0 by auto
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1728
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1729
lemma nn10:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1730
  assumes "anonnested (AALTs cs rs)" 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1731
  shows "anonnested (AALTs (bs @ cs) rs)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1732
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1733
  apply(induct rs arbitrary: cs bs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1734
   apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1735
  apply(case_tac a)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1736
       apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1737
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1738
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1739
lemma nn1a:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1740
  assumes "anonnested r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1741
  shows "anonnested (fuse bs r)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1742
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1743
  apply(induct bs r arbitrary: rule: fuse.induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1744
       apply(simp_all add: nn10)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1745
  done  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1746
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1747
lemma dB_keeps_property:
493
Chengsong
parents: 492
diff changeset
  1748
  shows "(\<forall>r \<in> set rs. P r) \<longrightarrow> (\<forall>r \<in> set (distinctBy rs rerase rset). P r)"
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1749
  apply(induct rs arbitrary: rset)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1750
   apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1751
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1752
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1753
lemma dB_filters_out:
493
Chengsong
parents: 492
diff changeset
  1754
  shows "rerase a \<in> rset \<Longrightarrow> a \<notin> set (distinctBy rs rerase (rset))"
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1755
  apply(induct rs arbitrary: rset)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1756
   apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1757
  apply(case_tac "a = aa")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1758
   apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1759
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1760
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1761
lemma dB_will_be_distinct:
493
Chengsong
parents: 492
diff changeset
  1762
  shows "distinct (distinctBy rs rerase (insert (rerase a) rset)) \<Longrightarrow> distinct (a #  (distinctBy rs rerase (insert (rerase a) rset)))"
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1763
  using dB_filters_out by force
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1764
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1765
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1766
lemma dB_does_the_job2:
493
Chengsong
parents: 492
diff changeset
  1767
  shows "distinct (distinctBy rs rerase rset)"
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1768
  apply(induct rs arbitrary: rset)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1769
   apply simp
493
Chengsong
parents: 492
diff changeset
  1770
  apply(case_tac "rerase a \<in> rset")
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1771
   apply simp
493
Chengsong
parents: 492
diff changeset
  1772
  apply(drule_tac x = "insert (rerase a) rset" in meta_spec)
Chengsong
parents: 492
diff changeset
  1773
  apply(subgoal_tac "distinctBy (a # rs) rerase rset = a # distinctBy rs rerase (insert (rerase a ) rset)")
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1774
   apply(simp only:)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1775
  using dB_will_be_distinct apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1776
  by auto
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1777
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1778
lemma dB_does_more_job:
493
Chengsong
parents: 492
diff changeset
  1779
  shows "distinct (map rerase (distinctBy rs rerase rset))"
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1780
  apply(induct rs arbitrary:rset)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1781
   apply simp
493
Chengsong
parents: 492
diff changeset
  1782
  apply(case_tac "rerase a \<in> rset")
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1783
   apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1784
  using dB_filters_out by force
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1785
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1786
lemma dB_mono2:
493
Chengsong
parents: 492
diff changeset
  1787
  shows "rset \<subseteq> rset' \<Longrightarrow> distinctBy rs rerase rset = [] \<Longrightarrow> distinctBy rs rerase rset' = []"
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1788
  apply(induct rs arbitrary: rset rset')
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1789
   apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1790
  by (meson in_mono list.discI)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1791
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1792
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1793
lemma nn1b:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1794
  shows "anonnested (bsimp r)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1795
  apply(induct r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1796
       apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1797
  apply(case_tac "bsimp r1 = AZERO")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1798
    apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1799
 apply(case_tac "bsimp r2 = AZERO")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1800
   apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1801
  apply(case_tac "\<exists>bs. bsimp r1 = AONE bs")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1802
    apply(auto)[1]
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1803
  apply (simp add: nn1a)    
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1804
   apply(subst bsimp_ASEQ1)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1805
      apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1806
  apply(rule nn1bb)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1807
  apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1808
  apply(subgoal_tac "\<forall>r \<in> set (flts (map bsimp x2a)). anonalt r")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1809
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1810
  apply (metis (mono_tags, lifting) SizeBound3.nn1c image_iff list.set_map)
493
Chengsong
parents: 492
diff changeset
  1811
  apply(subgoal_tac "\<forall>r \<in> set (distinctBy (flts (map bsimp x2a)) rerase {}). anonalt r")
Chengsong
parents: 492
diff changeset
  1812
   prefer 2
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1813
  using dB_keeps_property apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1814
  by blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1815
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1816
lemma induct_smaller_elem_list:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1817
  shows  "\<forall>r \<in> set list. asize r < Suc (sum_list (map asize list))"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1818
  apply(induct list)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1819
   apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1820
  by fastforce
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1821
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1822
lemma no0s_fltsbsimp:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1823
  shows "\<forall>r \<in> set (flts (map bsimp rs)).  r \<noteq> AZERO"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1824
  oops
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1825
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1826
lemma flts_all0s:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1827
  shows "\<forall>r \<in> set rs. r = AZERO \<Longrightarrow> flts rs = []"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1828
  apply(induct rs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1829
   apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1830
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1831
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1832
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1833
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1834
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1835
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1836
lemma good1:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1837
  shows "agood (bsimp a) \<or> bsimp a = AZERO" 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1838
  apply(induct a  taking: asize rule: measure_induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1839
  apply(case_tac x)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1840
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1841
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1842
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1843
  prefer 3
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1844
    apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1845
   prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1846
  (*  AALTs case  *)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1847
  apply(simp only:)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1848
   apply(case_tac "x52")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1849
    apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1850
   (*  AALTs list at least one - case *)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1851
   apply(simp only: )
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1852
  apply(frule_tac x="a" in spec)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1853
   apply(drule mp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1854
    apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1855
   (* either first element is agood, or AZERO *)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1856
    apply(erule disjE)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1857
     prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1858
    apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1859
   (* in  the AZERO case, the size  is smaller *)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1860
   apply(drule_tac x="AALTs x51 list" in spec)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1861
   apply(drule mp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1862
     apply(simp add: asize0)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1863
    apply(subst (asm) bsimp.simps)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1864
  apply(subst (asm) bsimp.simps)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1865
    apply(assumption)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1866
   (* in the agood case *)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1867
  apply(frule_tac x="AALTs x51 list" in spec)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1868
   apply(drule mp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1869
    apply(simp add: asize0)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1870
   apply(erule disjE)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1871
    apply(rule disjI1)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1872
  apply(simp add: good0)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1873
    apply(subst good0)  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1874
  using SizeBound3.flts3b distinctBy.elims apply force
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1875
  apply(subgoal_tac " Ball (set ( (flts (bsimp a # map bsimp list)))) anonalt")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1876
       prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1877
  apply (metis Cons_eq_map_conv SizeBound3.nn1b SizeBound3.nn1c ex_map_conv)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1878
  using dB_keeps_property apply presburger
493
Chengsong
parents: 492
diff changeset
  1879
  sledgehammer
Chengsong
parents: 492
diff changeset
  1880
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1881
  using dB_does_more_job apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1882
  apply(subgoal_tac " Ball (set ( (flts (bsimp a # map bsimp list)) )) agood")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1883
  using dB_keeps_property apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1884
    apply(subgoal_tac "\<forall>r \<in> (set (bsimp a # map bsimp list)). (agood r) \<or> (r = AZERO)")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1885
  using SizeBound3.flts3 apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1886
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1887
    apply(subgoal_tac "\<forall>r \<in> set list. asize r < Suc (asize a + sum_list (map asize list))")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1888
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1889
  apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1890
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1891
    apply(subgoal_tac "\<forall>r \<in> set list. asize r < Suc (sum_list (map asize list))")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1892
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1893
     apply fastforce
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1894
  using induct_smaller_elem_list apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1895
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1896
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1897
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1898
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1899
   apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1900
   apply(subgoal_tac "agood (bsimp a)")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1901
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1902
    apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1903
   apply(subgoal_tac "\<forall>r \<in> (set (map bsimp list)). r = AZERO \<or> agood r")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1904
    prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1905
  apply (metis add_Suc_right image_iff induct_smaller_elem_list list.set_map trans_less_add2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1906
   apply(subgoal_tac "\<not>(\<exists> r\<in>set (map bsimp list). agood r)")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1907
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1908
    apply (metis SizeBound3.flts3 SizeBound3.flts3b distinctBy.elims empty_iff flts4_nogood list.set_intros(1))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1909
   apply(subgoal_tac "\<forall>r \<in> set (map bsimp list). r = AZERO")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1910
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1911
    apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1912
  apply(subgoal_tac "flts (map bsimp list) = []")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1913
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1914
  using flts_all0s apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1915
  apply (smt (verit, del_insts) SizeBound3.flts2 SizeBound3.good0 SizeBound3.k0 dB_does_more_job dB_keeps_property distinctBy.simps(1) flts.simps(1))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1916
  apply(subgoal_tac "agood (bsimp x42) \<or> bsimp x42 = AZERO")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1917
   apply(subgoal_tac "agood (bsimp x43) \<or> bsimp x43 = AZERO")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1918
    apply(case_tac "bsimp x42 = AZERO")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1919
     apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1920
    apply(case_tac "bsimp x43 = AZERO")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1921
     apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1922
    apply(case_tac "\<exists>bs'. bsimp x42 = AONE bs'")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1923
  apply(erule exE)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1924
  apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1925
  using good_fuse apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1926
  apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1927
    apply(subgoal_tac "bsimp_ASEQ x41 (bsimp x42) (bsimp x43) = ASEQ x41 (bsimp x42) (bsimp x43)")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1928
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1929
  using bsimp_ASEQ1 apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1930
  using SizeBound3.good_SEQ apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1931
  using asize.simps(5) less_add_Suc2 apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1932
  by simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1933
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1934
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1935
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1936
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1937
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1938
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1939
lemma good1a:
493
Chengsong
parents: 492
diff changeset
  1940
  assumes "RL (rerase a) \<noteq> {}"
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1941
  shows "agood (bsimp a)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1942
  using good1 assms
493
Chengsong
parents: 492
diff changeset
  1943
  using RL_bsimp_rerase by force
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1944
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1945
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1946
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1947
lemma flts_append:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1948
  "flts (xs1 @ xs2) = flts xs1 @ flts xs2"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1949
  apply(induct xs1  arbitrary: xs2  rule: rev_induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1950
   apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1951
  apply(case_tac xs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1952
   apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1953
   apply(case_tac x)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1954
        apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1955
  apply(case_tac x)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1956
        apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1957
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1958
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1959
lemma g1:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1960
  assumes "agood (bsimp_AALTs bs rs)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1961
  shows "bsimp_AALTs bs rs = AALTs bs rs \<or> (\<exists>r. rs = [r] \<and> bsimp_AALTs bs [r] = fuse bs r)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1962
using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1963
    apply(induct rs arbitrary: bs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1964
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1965
  apply(case_tac rs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1966
  apply(simp only:)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1967
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1968
  apply(case_tac  list)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1969
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1970
  by simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1971
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1972
lemma flts_0:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1973
  assumes "anonnested (AALTs bs  rs)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1974
  shows "\<forall>r \<in> set (flts rs). r \<noteq> AZERO"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1975
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1976
  apply(induct rs arbitrary: bs rule: flts.induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1977
        apply(simp) 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1978
       apply(simp) 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1979
      defer
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1980
      apply(simp) 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1981
     apply(simp) 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1982
    apply(simp) 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1983
apply(simp) 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1984
  apply(rule ballI)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1985
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1986
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1987
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1988
lemma flts_0a:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1989
  assumes "anonnested (AALTs bs  rs)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1990
  shows "AZERO \<notin> set (flts rs)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1991
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1992
  using flts_0 by blast 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1993
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1994
lemma qqq1:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1995
  shows "AZERO \<notin> set (flts (map bsimp rs))"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1996
  by (metis ex_map_conv flts3 agood.simps(1) good1)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1997
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1998
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  1999
fun nonazero :: "arexp \<Rightarrow> bool"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2000
  where
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2001
  "nonazero AZERO = False"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2002
| "nonazero r = True"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2003
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2004
lemma flts_concat:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2005
  shows "flts rs = concat (map (\<lambda>r. flts [r]) rs)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2006
  apply(induct rs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2007
   apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2008
  apply(subst k0)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2009
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2010
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2011
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2012
lemma flts_single1:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2013
  assumes "anonalt r" "nonazero r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2014
  shows "flts [r] = [r]"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2015
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2016
  apply(induct r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2017
  apply(auto)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2018
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2019
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2020
lemma flts_qq:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2021
  assumes "\<forall>y. asize y < Suc (sum_list (map asize rs)) \<longrightarrow> agood y \<longrightarrow> bsimp y = y" 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2022
          "\<forall>r'\<in>set rs. agood r' \<and> anonalt r'"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2023
  shows "flts (map bsimp rs) = rs"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2024
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2025
  apply(induct rs)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2026
   apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2027
  apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2028
  apply(subst k0)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2029
  apply(subgoal_tac "flts [bsimp a] =  [a]")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2030
   prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2031
   apply(drule_tac x="a" in spec)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2032
   apply(drule mp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2033
    apply(simp)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2034
   apply(auto)[1]
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2035
  using agood.simps(1) k0b apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2036
  apply(auto)[1]  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2037
  done
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2038
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2039
lemma test:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2040
  assumes "agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2041
  shows "bsimp r = r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2042
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2043
  apply(induct r taking: "asize" rule: measure_induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2044
  apply(erule agood.elims)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2045
                      apply(simp_all)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2046
  apply(subst k0)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2047
  apply(subst (2) k0)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2048
                apply(subst flts_qq)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2049
                  apply(auto)[1]
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2050
                 apply(auto)[1]
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2051
  oops
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2052
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2053
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2054
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2055
lemma bsimp_idem:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2056
  shows "bsimp (bsimp r) = bsimp r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2057
  using test good1
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2058
  oops
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2059
493
Chengsong
parents: 492
diff changeset
  2060
(*
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2061
lemma erase_preimage1:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2062
  assumes "anonalt r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2063
  shows "erase r = ONE \<Longrightarrow> \<exists>bs. r = AONE bs"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2064
  apply(case_tac r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2065
  apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2066
  using anonalt.simps(1) assms apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2067
  by fastforce
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2068
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2069
lemma erase_preimage_char:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2070
  assumes "anonalt r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2071
  shows "erase r = CH c \<Longrightarrow> \<exists>bs. r = ACHAR bs c"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2072
  apply(case_tac r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2073
  apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2074
  using assms apply fastforce
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2075
  by simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2076
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2077
lemma erase_preimage_seq:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2078
  assumes "anonalt r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2079
  shows "erase r = SEQ r1 r2 \<Longrightarrow> \<exists>bs a1 a2. r = ASEQ bs a1 a2 \<and> erase a1 = r1 \<and> erase a2 = r2"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2080
  apply(case_tac r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2081
  apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2082
  using assms apply fastforce
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2083
  by simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2084
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2085
lemma rerase_preimage_seq:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2086
  assumes "anonalt r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2087
  shows "rerase r = RSEQ r1 r2 \<Longrightarrow> \<exists>bs a1 a2. r = ASEQ bs a1 a2 \<and> rerase a1 = r1 \<and> rerase a2 = r2 "
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2088
  using rerase_preimage4 by presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2089
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2090
lemma seq_recursive_equality:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2091
  shows "\<lbrakk>r1 = a1; r2 = a2\<rbrakk> \<Longrightarrow> SEQ r1 r2 = SEQ a1 a2"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2092
  by meson
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2093
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2094
lemma almost_identical_image:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2095
  assumes "agood r" "\<forall>r \<in> rset. agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2096
  shows "erase r \<in> erase ` rset \<Longrightarrow> \<exists>r' \<in> rset. erase r' = erase r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2097
  by auto
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2098
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2099
lemma goodalts_never_change:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2100
  assumes "r = AALTs bs rs" "agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2101
  shows "\<exists>r1 r2. erase r = ALT r1 r2"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2102
  by (metis agood.simps(4) agood.simps(5) assms(1) assms(2) bmkepss.cases erase.simps(6))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2103
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2104
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2105
fun shape_preserving :: "arexp \<Rightarrow> bool" where
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2106
  "shape_preserving AZERO = True"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2107
| "shape_preserving (AONE bs) = True"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2108
| "shape_preserving (ACHAR bs c) = True"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2109
| "shape_preserving (AALTs bs []) = False"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2110
| "shape_preserving (AALTs bs [a]) = False"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2111
| "shape_preserving (AALTs bs (a1 # a2 # rs)) = (\<forall>r \<in> set (a1 # a2 # rs). shape_preserving r)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2112
| "shape_preserving (ASEQ bs r1 r2) = (shape_preserving r1 \<and> shape_preserving r2)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2113
| "shape_preserving (ASTAR bs r) = shape_preserving r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2114
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2115
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2116
lemma good_shape_preserving:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2117
  assumes "\<nexists>bs r0. r = ASTAR bs r0"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2118
  shows "agood r \<Longrightarrow> shape_preserving r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2119
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2120
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2121
  apply(induct r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2122
  prefer 6
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2123
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2124
  apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2125
      apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2126
 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2127
  oops
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2128
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2129
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2130
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2131
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2132
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2133
lemma shadow_arexp_rerase_erase:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2134
  shows "\<lbrakk>agood r; agood r';  erase r = erase r'\<rbrakk> \<Longrightarrow> rerase r = rerase r'"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2135
  apply(induct r )
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2136
       apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2137
      apply(induct r')
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2138
           apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2139
       apply (metis goodalts_never_change rexp.distinct(15))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2140
  apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2141
     apply (metis anonalt.elims(3) erase_preimage_char goodalts_never_change rerase.simps(3) rexp.distinct(21))
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2142
    apply(induct r')
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2143
         apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2144
  apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2145
  apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2146
      apply(subgoal_tac "agood r1")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2147
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2148
  apply (metis SizeBound3.good_SEQ agood.simps(10) agood.simps(11) agood.simps(2) agood.simps(3) agood.simps(33) agood.simps(7) bsimp.cases)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2149
      apply(subgoal_tac "agood r2")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2150
       apply(subgoal_tac "agood r'1")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2151
        apply(subgoal_tac "agood r'2")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2152
         apply(subgoal_tac "rerase r'1 = rerase r1")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2153
  apply(subgoal_tac "rerase r'2 = rerase r2")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2154
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2155
  using rerase.simps(5) apply presburger
493
Chengsong
parents: 492
diff changeset
  2156
  oops
Chengsong
parents: 492
diff changeset
  2157
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2158
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2159
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2160
lemma rerase_erase_good:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2161
  assumes "agood r" "\<forall>r \<in> rset. agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2162
  shows "erase r \<in> erase ` rset \<Longrightarrow> rerase r \<in> rerase ` rset"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2163
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2164
  apply(case_tac r)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2165
       apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2166
  oops
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2167
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2168
lemma rerase_erase_both:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2169
  assumes "\<forall>r \<in> rset. agood r" "agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2170
  shows "(rerase r \<in> (rerase ` rset)) \<longleftrightarrow> (erase r \<in> (erase ` rset))"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2171
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2172
  apply(induct r )
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2173
       apply force
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2174
  apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2175
      apply(case_tac "RONE \<in> rerase ` rset")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2176
       apply(subgoal_tac "\<exists>bs. (AONE bs) \<in> rset")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2177
        apply (metis erase.simps(2) rev_image_eqI)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2178
       apply (metis image_iff rerase_preimage2)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2179
      apply(subgoal_tac "\<nexists>bs. (AONE bs) \<in> rset")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2180
  apply(subgoal_tac "ONE \<notin> erase ` rset")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2181
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2182
        apply blast
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2183
  sledgehammer
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2184
       apply (metis erase_preimage1 image_iff)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2185
      apply (metis rerase.simps(2) rev_image_eqI)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2186
     apply (smt (verit, best) erase.simps(3) erase_preimage_char image_iff rerase.simps(3) rerase_preimage3)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2187
(*    apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2188
    apply(subgoal_tac "(RSEQ (rerase r1) (rerase r2) \<in> rerase ` rset) \<Longrightarrow>  (SEQ (erase r1) (erase r2) \<in> erase ` rset)")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2189
  prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2190
     apply(subgoal_tac "\<exists>bs a1 a2. (ASEQ bs a1 a2) \<in> rset \<and> rerase a1 = rerase r1 \<and> rerase a2 = rerase r2")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2191
      prefer 2
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2192
  apply (metis (full_types) image_iff rerase_preimage4)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2193
     apply(erule exE)+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2194
     apply(subgoal_tac "erase (ASEQ bs a1 a2) \<in> (erase ` rset) ")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2195
      apply(subgoal_tac "SEQ (erase a1) (erase a2) \<in> (erase ` rset)")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2196
  apply(subgoal_tac "SEQ (erase a1) (erase a2) = SEQ (erase r1) (erase r2)")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2197
        apply metis
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2198
       apply(erule conjE)+*)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2199
  apply(drule_tac x = "rset" in meta_spec)+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2200
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2201
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2202
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2203
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2204
  oops
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2205
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2206
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2207
lemma rerase_pushin1_general:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2208
  assumes "\<forall>r \<in> set rs. agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2209
  shows "map rerase (distinctBy rs erase (erase ` rset)) = rdistinct (map rerase rs) (rerase ` rset)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2210
  apply(induct rs arbitrary: rset)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2211
   apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2212
  apply(case_tac "erase a \<in> erase ` rset")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2213
   apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2214
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2215
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2216
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2217
  oops
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2218
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2219
lemma rerase_erase:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2220
  assumes "\<forall>r \<in> set as. agood r \<and> anonalt r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2221
  shows "rdistinct (map rerase as) (rerase ` rset) = map rerase (distinctBy as erase (erase ` rset))"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2222
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2223
  apply(induct as)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2224
   apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2225
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2226
  sorry
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2227
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2228
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2229
lemma rerase_pushin1:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2230
  assumes "\<forall>r \<in> set rs. anonalt r \<and> agood r"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2231
  shows "map rerase (distinctBy rs erase {}) = rdistinct (map rerase rs) {}"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2232
  apply(insert rerase_erase)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2233
  by (metis assms image_empty)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2234
  
493
Chengsong
parents: 492
diff changeset
  2235
*)
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2236
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2237
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2238
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2239
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2240
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2241
lemma nonalt_flts : shows 
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2242
  "\<forall>r \<in> set (flts (map bsimp rs)). r \<noteq> AZERO"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2243
  using SizeBound3.qqq1 by force
493
Chengsong
parents: 492
diff changeset
  2244
Chengsong
parents: 492
diff changeset
  2245
Chengsong
parents: 492
diff changeset
  2246
lemma rerase_map_bsimp:
Chengsong
parents: 492
diff changeset
  2247
  assumes "\<And> r. r \<in> set x2a \<Longrightarrow> rerase (bsimp r) = (rsimp \<circ> rerase) r"
Chengsong
parents: 492
diff changeset
  2248
  shows "  map rerase (map bsimp x2a) =  map (rsimp \<circ> rerase) x2a "
Chengsong
parents: 492
diff changeset
  2249
  using assms
Chengsong
parents: 492
diff changeset
  2250
  
Chengsong
parents: 492
diff changeset
  2251
  apply(induct x2a)
Chengsong
parents: 492
diff changeset
  2252
   apply simp
Chengsong
parents: 492
diff changeset
  2253
  apply(subgoal_tac "a \<in> set (a # x2a)")
Chengsong
parents: 492
diff changeset
  2254
  prefer 2
Chengsong
parents: 492
diff changeset
  2255
  apply (meson list.set_intros(1))
Chengsong
parents: 492
diff changeset
  2256
  apply(subgoal_tac "rerase (bsimp a ) = (rsimp \<circ> rerase) a")
Chengsong
parents: 492
diff changeset
  2257
  apply simp
Chengsong
parents: 492
diff changeset
  2258
  by presburger
Chengsong
parents: 492
diff changeset
  2259
Chengsong
parents: 492
diff changeset
  2260
Chengsong
parents: 492
diff changeset
  2261
Chengsong
parents: 492
diff changeset
  2262
lemma rerase_flts:
Chengsong
parents: 492
diff changeset
  2263
  shows "map rerase (flts rs) = rflts (map rerase rs)"
Chengsong
parents: 492
diff changeset
  2264
  apply(induct rs)
Chengsong
parents: 492
diff changeset
  2265
   apply simp+
Chengsong
parents: 492
diff changeset
  2266
  apply(case_tac a)
Chengsong
parents: 492
diff changeset
  2267
       apply simp+
Chengsong
parents: 492
diff changeset
  2268
   apply(simp add: rerase_fuse)
Chengsong
parents: 492
diff changeset
  2269
  apply simp
Chengsong
parents: 492
diff changeset
  2270
  done
Chengsong
parents: 492
diff changeset
  2271
Chengsong
parents: 492
diff changeset
  2272
lemma rerase_dB:
Chengsong
parents: 492
diff changeset
  2273
  shows "map rerase (distinctBy rs rerase acc) = rdistinct (map rerase rs) acc"
Chengsong
parents: 492
diff changeset
  2274
  apply(induct rs arbitrary: acc)
Chengsong
parents: 492
diff changeset
  2275
   apply simp+
Chengsong
parents: 492
diff changeset
  2276
  done
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2277
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2278
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2279
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2280
493
Chengsong
parents: 492
diff changeset
  2281
lemma rerase_earlier_later_same:
Chengsong
parents: 492
diff changeset
  2282
  assumes " \<And>r. r \<in> set x2a \<Longrightarrow> rerase (bsimp r) = rsimp (rerase r)"
Chengsong
parents: 492
diff changeset
  2283
  shows " (map rerase (distinctBy (flts (map bsimp x2a)) rerase {})) =
Chengsong
parents: 492
diff changeset
  2284
          (rdistinct (rflts (map (rsimp \<circ> rerase) x2a)) {})"
Chengsong
parents: 492
diff changeset
  2285
  apply(subst rerase_dB)
Chengsong
parents: 492
diff changeset
  2286
  apply(subst rerase_flts)
Chengsong
parents: 492
diff changeset
  2287
  apply(subst rerase_map_bsimp)
Chengsong
parents: 492
diff changeset
  2288
   apply auto
Chengsong
parents: 492
diff changeset
  2289
  using assms
Chengsong
parents: 492
diff changeset
  2290
  apply simp
Chengsong
parents: 492
diff changeset
  2291
  done
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2292
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2293
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2294
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2295
lemma simp_rerase:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2296
  shows "rerase (bsimp a) = rsimp (rerase a)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2297
  apply(induct  a)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2298
  apply simp+
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2299
  using rerase_bsimp_ASEQ apply presburger
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2300
  apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2301
   apply(subst rerase_bsimp_AALTs)
493
Chengsong
parents: 492
diff changeset
  2302
  apply(subgoal_tac "map rerase (distinctBy (flts (map bsimp x2a)) rerase {}) =  rdistinct (rflts (map (rsimp \<circ> rerase) x2a)) {}")  
Chengsong
parents: 492
diff changeset
  2303
    apply simp
Chengsong
parents: 492
diff changeset
  2304
  using rerase_earlier_later_same apply presburger
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2305
  apply simp
493
Chengsong
parents: 492
diff changeset
  2306
  done
Chengsong
parents: 492
diff changeset
  2307
Chengsong
parents: 492
diff changeset
  2308
492
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2309
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2310
lemma rders_simp_size:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2311
  shows " rders_simp (rerase r) s  = rerase (bders_simp r s)"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2312
  apply(induct s rule: rev_induct)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2313
   apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2314
  apply(subst rders_simp_append)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2315
  apply(subst bders_simp_append)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2316
  apply(subgoal_tac "rders_simp (rerase r ) xs = rerase (bders_simp r xs)")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2317
   apply(simp only:)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2318
   apply simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2319
  apply (simp add: der_rerase2 simp_rerase)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2320
  by simp
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2321
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2322
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2323
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2324
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2325
corollary aders_simp_finiteness:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2326
  assumes "\<exists>N. \<forall>s. rsize (rders_simp (rerase r) s) \<le> N"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2327
  shows " \<exists>N. \<forall>s. asize (bders_simp r s) \<le> N"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2328
  using assms
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2329
  apply(subgoal_tac "\<forall>s. asize (bders_simp r s) = rsize (rerase (bders_simp r s))")
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2330
   apply(erule exE)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2331
   apply(rule_tac x = "N" in exI)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2332
  using rders_simp_size apply auto[1]
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2333
  using asize_rsize by auto
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2334
  
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2335
theorem annotated_size_bound:
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2336
  shows "\<exists>N. \<forall>s. asize (bders_simp r s) \<le> N"
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2337
  apply(insert aders_simp_finiteness)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2338
  by (simp add: rders_simp_bounded)
61eff2abb0b6 problem with erase
Chengsong
parents: 393
diff changeset
  2339
365
ec5e4fe4cc70 for new journal/conf paper!
Chengsong
parents:
diff changeset
  2340
end