thys2/ClosedForms.thy
author Chengsong
Tue, 08 Mar 2022 00:50:40 +0000
changeset 443 c6351a96bf80
child 444 a7e98deebb5c
permissions -rw-r--r--
writeupforclosedforms
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
443
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     1
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     2
theory ClosedForms
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     3
  imports "Lexer" "PDerivs" 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     4
begin
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     5
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     6
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     7
datatype rrexp = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     8
  RZERO
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
     9
| RONE 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    10
| RCHAR char
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    11
| RSEQ rrexp rrexp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    12
| RALTS "rrexp list"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    13
| RSTAR rrexp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    14
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    15
abbreviation
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    16
  "RALT r1 r2 \<equiv> RALTS [r1, r2]"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    17
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    18
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    19
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    20
fun
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    21
 rnullable :: "rrexp \<Rightarrow> bool"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    22
where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    23
  "rnullable (RZERO) = False"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    24
| "rnullable (RONE  ) = True"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    25
| "rnullable (RCHAR   c) = False"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    26
| "rnullable (RALTS   rs) = (\<exists>r \<in> set rs. rnullable r)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    27
| "rnullable (RSEQ  r1 r2) = (rnullable r1 \<and> rnullable r2)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    28
| "rnullable (RSTAR   r) = True"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    29
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    30
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    31
fun
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    32
 rder :: "char \<Rightarrow> rrexp \<Rightarrow> rrexp"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    33
where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    34
  "rder c (RZERO) = RZERO"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    35
| "rder c (RONE) = RZERO"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    36
| "rder c (RCHAR d) = (if c = d then RONE else RZERO)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    37
| "rder c (RALTS rs) = RALTS (map (rder c) rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    38
| "rder c (RSEQ r1 r2) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    39
     (if rnullable r1
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    40
      then RALT   (RSEQ (rder c r1) r2) (rder c r2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    41
      else RSEQ   (rder c r1) r2)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    42
| "rder c (RSTAR r) = RSEQ  (rder c r) (RSTAR r)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    43
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    44
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    45
fun 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    46
  rders :: "rrexp \<Rightarrow> string \<Rightarrow> rrexp"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    47
where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    48
  "rders r [] = r"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    49
| "rders r (c#s) = rders (rder c r) s"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    50
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    51
fun rdistinct :: "'a list \<Rightarrow>'a set \<Rightarrow> 'a list"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    52
  where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    53
  "rdistinct [] acc = []"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    54
| "rdistinct (x#xs)  acc = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    55
     (if x \<in> acc then rdistinct xs  acc 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    56
      else x # (rdistinct xs  ({x} \<union> acc)))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    57
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    58
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    59
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    60
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    61
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    62
fun rflts :: "rrexp list \<Rightarrow> rrexp list"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    63
  where 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    64
  "rflts [] = []"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    65
| "rflts (RZERO # rs) = rflts rs"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    66
| "rflts ((RALTS rs1) # rs) = rs1 @ rflts rs"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    67
| "rflts (r1 # rs) = r1 # rflts rs"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    68
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    69
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    70
fun rsimp_ALTs :: " rrexp list \<Rightarrow> rrexp"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    71
  where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    72
  "rsimp_ALTs  [] = RZERO"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    73
| "rsimp_ALTs [r] =  r"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    74
| "rsimp_ALTs rs = RALTS rs"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    75
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    76
fun rsimp_SEQ :: " rrexp \<Rightarrow> rrexp \<Rightarrow> rrexp"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    77
  where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    78
  "rsimp_SEQ  RZERO _ = RZERO"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    79
| "rsimp_SEQ  _ RZERO = RZERO"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    80
| "rsimp_SEQ RONE r2 = r2"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    81
| "rsimp_SEQ r1 r2 = RSEQ r1 r2"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    82
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    83
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    84
fun rsimp :: "rrexp \<Rightarrow> rrexp" 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    85
  where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    86
  "rsimp (RSEQ r1 r2) = rsimp_SEQ  (rsimp r1) (rsimp r2)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    87
| "rsimp (RALTS rs) = rsimp_ALTs  (rdistinct (rflts (map rsimp rs))  {}) "
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    88
| "rsimp r = r"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    89
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    90
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    91
fun 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    92
  rders_simp :: "rrexp \<Rightarrow> string \<Rightarrow> rrexp"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    93
where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    94
  "rders_simp r [] = r"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    95
| "rders_simp r (c#s) = rders_simp (rsimp (rder c r)) s"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    96
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    97
fun rsize :: "rrexp \<Rightarrow> nat" where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    98
  "rsize RZERO = 1"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
    99
| "rsize (RONE) = 1" 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   100
| "rsize (RCHAR  c) = 1"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   101
| "rsize (RALTS  rs) = Suc (sum_list (map rsize rs))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   102
| "rsize (RSEQ  r1 r2) = Suc (rsize r1 + rsize r2)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   103
| "rsize (RSTAR  r) = Suc (rsize r)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   104
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   105
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   106
fun rlist_size :: "rrexp list \<Rightarrow> nat" where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   107
"rlist_size (r # rs) = rsize r + rlist_size rs" 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   108
| "rlist_size [] = 0"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   109
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   110
fun vsuf :: "char list \<Rightarrow> rrexp \<Rightarrow> char list list" where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   111
"vsuf [] _ = []"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   112
|"vsuf (c#cs) r1 = (if (rnullable r1) then  (vsuf cs (rder c r1)) @ [c # cs]
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   113
                                      else  (vsuf cs (rder c r1))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   114
                   ) "
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   115
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   116
lemma seq_closed_form: shows 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   117
"rsimp (rders_simp (RSEQ r1 r2) s) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   118
rsimp ( RALTS ( (RSEQ (rders_simp r1 s) r2) # 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   119
                (map (rders r2) (vsuf s r1)) 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   120
              )  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   121
      )"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   122
  apply(induct s)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   123
  apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   124
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   125
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   126
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   127
fun star_update :: "char \<Rightarrow> rrexp \<Rightarrow> char list list \<Rightarrow> char list list" where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   128
"star_update c r [] = []"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   129
|"star_update c r (s # Ss) = (if (rnullable (rders_simp r s)) 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   130
                                then (s@[c]) # [c] # (star_update c r Ss) 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   131
                               else   (s@[c]) # (star_update c r Ss) )"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   132
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   133
fun star_updates :: "char list \<Rightarrow> rrexp \<Rightarrow> char list list \<Rightarrow> char list list"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   134
  where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   135
"star_updates [] r Ss = Ss"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   136
| "star_updates (c # cs) r Ss = star_updates cs r (star_update c r Ss)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   137
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   138
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   139
lemma star_closed_form:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   140
  shows "rders_simp (RSTAR r0) (c#s) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   141
rsimp ( RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) ) (star_updates s r [[c]]) ) ))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   142
  apply(induct s)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   143
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   144
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   145
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   146
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   147
lemma star_closed_form_bounded_by_rdistinct_list_estimate:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   148
  shows "rsize (rsimp ( RALTS ( (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) )
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   149
         (star_updates s r [[c]]) ) ))) \<le>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   150
        Suc (sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) )
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   151
         (star_updates s r [[c]]) ) {})  ) )"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   152
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   153
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   154
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   155
lemma distinct_list_rexp_up_to_certain_size_bouded_by_set_enumerating_up_to_that_size:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   156
  shows "\<forall>r\<in> set rs. (rsize r ) \<le> N \<Longrightarrow> sum_list (map rsize (rdistinct rs {})) \<le>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   157
         (card (rexp_enum N))* N"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   158
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   159
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   160
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   161
lemma ind_hypo_on_ders_leads_to_stars_bounded:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   162
  shows "\<forall>s. rsize (rders_simp r0 s) \<le> N \<Longrightarrow>        
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   163
      (sum_list (map rsize (rdistinct (map (\<lambda>s1. RSEQ (rders_simp r0 s1) (RSTAR r0) )
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   164
         (star_updates s r [[c]]) ) {})  ) ) \<le> 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   165
(card (rexp_enum (Suc (N + rsize (RSTAR r0))))) * (Suc (N + rsize (RSTAR r0)))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   166
"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   167
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   168
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   169
lemma r0_bounded_star_bounded:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   170
  shows "\<forall>s. rsize (rders_simp r0 s) \<le> N \<Longrightarrow>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   171
             \<forall>s. rsize (rders_simp (RSTAR r0) s) \<le> 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   172
(card (rexp_enum (Suc (N + rsize (RSTAR r0))))) * (Suc (N + rsize (RSTAR r0)))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   173
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   174
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   175
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   176
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   177
(*some basic facts about rsimp*)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   178
lemma hand_made_def_rlist_size:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   179
  shows "rlist_size rs = sum_list (map rsize rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   180
proof (induct rs)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   181
  case Nil show ?case by simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   182
next
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   183
  case (Cons a rs) thus ?case
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   184
    by simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   185
qed
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   186
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   187
lemma rder_rsimp_ALTs_commute:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   188
  shows "  (rder x (rsimp_ALTs rs)) = rsimp_ALTs (map (rder x) rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   189
  apply(induct rs)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   190
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   191
  apply(case_tac rs)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   192
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   193
  apply auto
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   194
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   195
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   196
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   197
lemma rsimp_aalts_smaller:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   198
  shows "rsize (rsimp_ALTs  rs) \<le> rsize (RALTS rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   199
  apply(induct rs)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   200
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   201
  apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   202
  apply(case_tac "rs = []")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   203
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   204
  apply(subgoal_tac "\<exists>rsp ap. rs = ap # rsp")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   205
   apply(erule exE)+
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   206
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   207
  apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   208
  by(meson neq_Nil_conv)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   209
  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   210
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   211
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   212
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   213
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   214
lemma rSEQ_mono:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   215
  shows "rsize (rsimp_SEQ r1 r2) \<le>rsize ( RSEQ r1 r2)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   216
  apply auto
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   217
  apply(induct r1)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   218
       apply auto
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   219
      apply(case_tac "r2")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   220
       apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   221
     apply(case_tac r2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   222
          apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   223
     apply(case_tac r2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   224
         apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   225
     apply(case_tac r2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   226
        apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   227
     apply(case_tac r2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   228
  apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   229
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   230
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   231
lemma ralts_cap_mono:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   232
  shows "rsize (RALTS rs) \<le> Suc ( sum_list (map rsize rs)) "
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   233
  by simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   234
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   235
lemma rflts_def_idiot:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   236
  shows "\<lbrakk> a \<noteq> RZERO; \<nexists>rs1. a = RALTS rs1\<rbrakk>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   237
       \<Longrightarrow> rflts (a # rs) = a # rflts rs"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   238
  apply(case_tac a)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   239
       apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   240
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   241
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   242
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   243
lemma rflts_mono:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   244
  shows "sum_list (map rsize (rflts rs))\<le> sum_list (map rsize rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   245
  apply(induct rs)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   246
  apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   247
  apply(case_tac "a = RZERO")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   248
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   249
  apply(case_tac "\<exists>rs1. a = RALTS rs1")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   250
  apply(erule exE)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   251
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   252
  apply(subgoal_tac "rflts (a # rs) = a # (rflts rs)")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   253
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   254
  using rflts_def_idiot apply blast
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   255
  apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   256
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   257
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   258
lemma rdistinct_smaller: shows "sum_list (map rsize (rdistinct rs ss)) \<le>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   259
sum_list (map rsize rs )"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   260
  apply (induct rs arbitrary: ss)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   261
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   262
  by (simp add: trans_le_add2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   263
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   264
lemma rdistinct_phi_smaller: "sum_list (map rsize (rdistinct rs {})) \<le> sum_list (map rsize rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   265
  by (simp add: rdistinct_smaller)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   266
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   267
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   268
lemma rsimp_alts_mono :
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   269
  shows "\<And>x. (\<And>xa. xa \<in> set x \<Longrightarrow> rsize (rsimp xa) \<le> rsize xa)  \<Longrightarrow>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   270
rsize (rsimp_ALTs (rdistinct (rflts (map rsimp x)) {})) \<le> Suc (sum_list (map rsize x))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   271
  apply(subgoal_tac "rsize (rsimp_ALTs (rdistinct (rflts (map rsimp x)) {} )) 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   272
                    \<le> rsize (RALTS (rdistinct (rflts (map rsimp x)) {} ))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   273
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   274
  using rsimp_aalts_smaller apply auto[1]
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   275
  apply(subgoal_tac "rsize (RALTS (rdistinct (rflts (map rsimp x)) {})) \<le>Suc( sum_list (map rsize (rdistinct (rflts (map rsimp x)) {})))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   276
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   277
  using ralts_cap_mono apply blast
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   278
  apply(subgoal_tac "sum_list (map rsize (rdistinct (rflts (map rsimp x)) {})) \<le>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   279
                     sum_list (map rsize ( (rflts (map rsimp x))))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   280
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   281
  using rdistinct_smaller apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   282
  apply(subgoal_tac "sum_list (map rsize (rflts (map rsimp x))) \<le> 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   283
                     sum_list (map rsize (map rsimp x))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   284
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   285
  using rflts_mono apply blast
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   286
  apply(subgoal_tac "sum_list (map rsize (map rsimp x)) \<le> sum_list (map rsize x)")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   287
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   288
  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   289
  apply (simp add: sum_list_mono)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   290
  by linarith
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   291
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   292
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   293
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   294
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   295
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   296
lemma rsimp_mono:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   297
  shows "rsize (rsimp r) \<le> rsize r"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   298
  apply(induct r)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   299
  apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   300
  apply(subgoal_tac "rsize (rsimp_SEQ (rsimp r1) (rsimp r2)) \<le> rsize (RSEQ (rsimp r1) (rsimp r2))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   301
    apply force
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   302
  using rSEQ_mono
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   303
   apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   304
  using rsimp_alts_mono by auto
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   305
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   306
lemma idiot:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   307
  shows "rsimp_SEQ RONE r = r"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   308
  apply(case_tac r)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   309
       apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   310
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   311
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   312
lemma no_alt_short_list_after_simp:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   313
  shows "RALTS rs = rsimp r \<Longrightarrow> rsimp_ALTs rs = RALTS rs"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   314
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   315
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   316
lemma no_further_dB_after_simp:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   317
  shows "RALTS rs = rsimp r \<Longrightarrow> rdistinct rs {} = rs"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   318
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   319
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   320
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   321
lemma idiot2:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   322
  shows " \<lbrakk>r1 \<noteq> RZERO; r1 \<noteq> RONE;r2 \<noteq> RZERO\<rbrakk>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   323
    \<Longrightarrow> rsimp_SEQ r1 r2 = RSEQ r1 r2"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   324
  apply(case_tac r1)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   325
       apply(case_tac r2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   326
  apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   327
     apply(case_tac r2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   328
  apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   329
     apply(case_tac r2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   330
  apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   331
   apply(case_tac r2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   332
  apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   333
  apply(case_tac r2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   334
       apply simp_all
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   335
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   336
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   337
lemma rders__onechar:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   338
  shows " (rders_simp r [c]) =  (rsimp (rders r [c]))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   339
  by simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   340
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   341
lemma rders_append:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   342
  "rders c (s1 @ s2) = rders (rders c s1) s2"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   343
  apply(induct s1 arbitrary: c s2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   344
  apply(simp_all)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   345
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   346
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   347
lemma rders_simp_append:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   348
  "rders_simp c (s1 @ s2) = rders_simp (rders_simp c s1) s2"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   349
  apply(induct s1 arbitrary: c s2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   350
  apply(simp_all)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   351
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   352
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   353
lemma inside_simp_removal:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   354
  shows " rsimp (rder x (rsimp r)) = rsimp (rder x r)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   355
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   356
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   357
lemma set_related_list:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   358
  shows "distinct rs  \<Longrightarrow> length rs = card (set rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   359
  by (simp add: distinct_card)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   360
(*this section deals with the property of distinctBy: creates a list without duplicates*)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   361
lemma rdistinct_never_added_twice:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   362
  shows "rdistinct (a # rs) {a} = rdistinct rs {a}"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   363
  by force
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   364
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   365
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   366
lemma rdistinct_does_the_job:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   367
  shows "distinct (rdistinct rs s)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   368
  apply(induct rs arbitrary: s)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   369
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   370
  apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   371
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   372
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   373
lemma rders_simp_same_simpders:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   374
  shows "s \<noteq> [] \<Longrightarrow> rders_simp r s = rsimp (rders r s)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   375
  apply(induct s rule: rev_induct)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   376
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   377
  apply(case_tac "xs = []")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   378
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   379
  apply(simp add: rders_append rders_simp_append)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   380
  using inside_simp_removal by blast
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   381
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   382
lemma simp_helps_der_pierce:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   383
  shows " rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   384
            (rder x
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   385
              (rsimp_ALTs rs)) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   386
          rsimp 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   387
            (rsimp_ALTs 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   388
              (map (rder x )
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   389
                rs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   390
              )
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   391
            )"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   392
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   393
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   394
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   395
lemma rders_simp_one_char:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   396
  shows "rders_simp r [c] = rsimp (rder c r)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   397
  apply auto
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   398
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   399
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   400
lemma rsimp_idem:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   401
  shows "rsimp (rsimp r) = rsimp r"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   402
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   403
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   404
corollary rsimp_inner_idem1:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   405
  shows "rsimp r = RSEQ r1 r2 \<Longrightarrow> rsimp r1 = r1 \<and> rsimp r2 = r2"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   406
  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   407
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   408
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   409
corollary rsimp_inner_idem2:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   410
  shows "rsimp r = RALTS rs \<Longrightarrow> \<forall>r' \<in> (set rs). rsimp r' = r'"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   411
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   412
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   413
corollary rsimp_inner_idem3:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   414
  shows "rsimp r = RALTS rs \<Longrightarrow> map rsimp rs = rs"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   415
  by (meson map_idI rsimp_inner_idem2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   416
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   417
corollary rsimp_inner_idem4:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   418
  shows "rsimp r = RALTS rs \<Longrightarrow> flts rs = rs"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   419
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   420
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   421
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   422
lemma head_one_more_simp:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   423
  shows "map rsimp (r # rs) = map rsimp (( rsimp r) # rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   424
  by (simp add: rsimp_idem)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   425
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   426
lemma head_one_more_dersimp:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   427
  shows "map rsimp ((rder x (rders_simp r s) # rs)) = map rsimp ((rders_simp r (s@[x]) ) # rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   428
  using head_one_more_simp rders_simp_append rders_simp_one_char by presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   429
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   430
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   431
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   432
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   433
lemma ders_simp_nullability:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   434
  shows "rnullable (rders r s) = rnullable (rders_simp r s)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   435
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   436
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   437
lemma  first_elem_seqder:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   438
  shows "\<not>rnullable r1p \<Longrightarrow> map rsimp (rder x (RSEQ r1p r2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   439
                   # rs) = map rsimp ((RSEQ (rder x r1p) r2) # rs) "
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   440
  by auto
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   441
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   442
lemma first_elem_seqder1:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   443
  shows  "\<not>rnullable (rders_simp r xs) \<Longrightarrow> map rsimp ( (rder x (RSEQ (rders_simp r xs) r2)) # rs) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   444
                                          map rsimp ( (RSEQ (rsimp (rder x (rders_simp r xs))) r2) # rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   445
  by (simp add: rsimp_idem)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   446
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   447
lemma first_elem_seqdersimps:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   448
  shows "\<not>rnullable (rders_simp r xs) \<Longrightarrow> map rsimp ( (rder x (RSEQ (rders_simp r xs) r2)) # rs) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   449
                                          map rsimp ( (RSEQ (rders_simp r (xs @ [x])) r2) # rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   450
  using first_elem_seqder1 rders_simp_append by auto
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   451
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   452
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   453
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   454
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   455
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   456
lemma seq_update_seq_ders:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   457
  shows "rsimp (rder c ( rsimp (RALTS ((RSEQ (rders_simp r1 s) r2) # 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   458
(map (rders_simp r2) Ss))))) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   459
         rsimp (RALTS ((RSEQ (rders_simp r1 (s @ [c])) r2) # 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   460
(map (rders_simp r2) (seq_update c (rders_simp r1 s) Ss))))  "
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   461
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   462
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   463
lemma seq_ders_closed_form1:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   464
  shows "\<exists>Ss. rders_simp (RSEQ r1 r2) [c] = rsimp (RALTS ((RSEQ (rders_simp r1 [c]) r2) # 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   465
(map ( rders_simp r2 ) Ss)))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   466
  apply(case_tac "rnullable r1")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   467
   apply(subgoal_tac " rders_simp (RSEQ r1 r2) [c] = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   468
rsimp (RALTS ((RSEQ (rders_simp r1 [c]) r2) # (map (rders_simp r2) [[c]])))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   469
    prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   470
    apply (simp add: rsimp_idem)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   471
   apply(rule_tac x = "[[c]]" in exI)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   472
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   473
  apply(subgoal_tac  " rders_simp (RSEQ r1 r2) [c] = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   474
rsimp (RALTS ((RSEQ (rders_simp r1 [c]) r2) # (map (rders_simp r2) [])))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   475
   apply blast
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   476
  apply(simp add: rsimp_idem)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   477
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   478
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   479
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   480
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   481
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   482
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   483
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   484
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   485
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   486
lemma simp_flatten2:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   487
  shows "rsimp (RALTS (r # [RALTS rs])) = rsimp (RALTS (r # rs))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   488
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   489
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   490
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   491
lemma simp_flatten:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   492
  shows "rsimp (RALTS ((RALTS rsa) # rsb)) = rsimp (RALTS (rsa @ rsb))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   493
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   494
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   495
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   496
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   497
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   498
(*^^^^^^^^^nullable_seq_with_list1 related ^^^^^^^^^^^^^^^^*)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   499
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   500
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   501
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   502
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   503
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   504
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   505
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   506
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   507
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   508
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   509
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   510
lemma non_zero_size:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   511
  shows "rsize r \<ge> Suc 0"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   512
  apply(induct r)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   513
  apply auto done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   514
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   515
corollary size_geq1:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   516
  shows "rsize r \<ge> 1"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   517
  by (simp add: non_zero_size)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   518
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   519
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   520
lemma rexp_size_induct:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   521
  shows "\<And>N r x5 a list.
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   522
       \<lbrakk> rsize r = Suc N; r = RALTS x5;
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   523
        x5 = a # list\<rbrakk>  \<Longrightarrow>\<exists>i j. rsize a = i \<and> rsize (RALTS list) = j \<and> i + j =  Suc N \<and> i \<le> N \<and> j \<le> N"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   524
  apply(rule_tac x = "rsize a" in exI)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   525
  apply(rule_tac x = "rsize (RALTS list)" in exI)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   526
  apply(subgoal_tac "rsize a \<ge> 1")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   527
   prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   528
  using One_nat_def non_zero_size apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   529
  apply(subgoal_tac "rsize (RALTS list) \<ge> 1 ")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   530
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   531
  using size_geq1 apply blast
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   532
  apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   533
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   534
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   535
definition SEQ_set where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   536
  "SEQ_set A n \<equiv> {RSEQ r1 r2 | r1 r2. r1 \<in> A \<and> r2 \<in> A \<and> rsize r1 + rsize r2 \<le> n}"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   537
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   538
definition SEQ_set_cartesian where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   539
"SEQ_set_cartesian A n  = {RSEQ r1 r2 | r1 r2. r1 \<in> A \<and> r2 \<in> A}"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   540
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   541
definition ALT_set where
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   542
"ALT_set A n \<equiv> {RALTS rs | rs. set rs \<subseteq> A \<and> sum_list (map rsize rs) \<le> n}"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   543
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   544
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   545
definition
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   546
  "sizeNregex N \<equiv> {r. rsize r \<le> N}"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   547
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   548
lemma sizenregex_induct:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   549
  shows "sizeNregex (Suc n) = sizeNregex n \<union> {RZERO, RONE, RALTS []} \<union> {RCHAR c| c. True} \<union>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   550
SEQ_set ( sizeNregex n) n \<union> ALT_set (sizeNregex n) n \<union> (RSTAR ` (sizeNregex n))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   551
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   552
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   553
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   554
lemma chars_finite:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   555
  shows "finite (RCHAR ` (UNIV::(char set)))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   556
  apply(simp)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   557
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   558
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   559
thm full_SetCompr_eq 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   560
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   561
lemma size1finite:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   562
  shows "finite (sizeNregex (Suc 0))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   563
  apply(subst sizenregex_induct)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   564
  apply(subst finite_Un)+
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   565
  apply(subgoal_tac "sizeNregex 0 = {}")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   566
  apply(rule conjI)+
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   567
  apply (metis Collect_empty_eq finite.emptyI non_zero_size not_less_eq_eq sizeNregex_def)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   568
      apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   569
      apply (simp add: full_SetCompr_eq)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   570
  apply (simp add: SEQ_set_def)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   571
    apply (simp add: ALT_set_def)  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   572
   apply(simp add: full_SetCompr_eq)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   573
  using non_zero_size not_less_eq_eq sizeNregex_def by fastforce
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   574
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   575
lemma seq_included_in_cart:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   576
  shows "SEQ_set A n \<subseteq> SEQ_set_cartesian A n"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   577
  using SEQ_set_cartesian_def SEQ_set_def by fastforce
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   578
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   579
lemma finite_seq:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   580
  shows " finite (sizeNregex n) \<Longrightarrow> finite (SEQ_set (sizeNregex n) n)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   581
  apply(rule finite_subset)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   582
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   583
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   584
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   585
lemma finite_size_n:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   586
  shows "finite (sizeNregex n)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   587
  apply(induct n)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   588
  apply (metis Collect_empty_eq finite.emptyI non_zero_size not_less_eq_eq sizeNregex_def)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   589
  apply(subst sizenregex_induct)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   590
  apply(subst finite_Un)+
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   591
  apply(rule conjI)+
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   592
       apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   593
      apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   594
     apply (simp add: full_SetCompr_eq)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   595
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   596
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   597
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   598
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   599
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   600
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   601
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   602
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   603
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   604
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   605
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   606
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   607
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   608
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   609
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   610
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   611
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   612
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   613
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   614
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   615
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   616
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   617
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   618
lemma star_update_case1:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   619
  shows "rnullable (rders_simp r s) \<Longrightarrow> star_update c r (s # Ss) = (s @ [c]) # [c] # (star_update c r Ss)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   620
  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   621
  by force
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   622
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   623
lemma star_update_case2:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   624
  shows "\<not>rnullable (rders_simp r s) \<Longrightarrow> star_update c r (s # Ss) = (s @ [c]) # (star_update c r Ss)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   625
  by simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   626
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   627
lemma bubble_break: shows "rflts [r, RZERO] = rflts [r]"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   628
  apply(case_tac r)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   629
       apply simp+
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   630
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   631
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   632
lemma rsimp_alts_idem_aux1:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   633
  shows "rsimp_ALTs (rdistinct (rflts [rsimp a]) {}) = rsimp (RALTS [a])"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   634
  by force
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   635
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   636
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   637
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   638
lemma rsimp_alts_idem_aux2:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   639
  shows "rsimp a = rsimp (RALTS [a])"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   640
  apply(simp)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   641
  apply(case_tac "rsimp a")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   642
       apply simp+
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   643
  apply (metis no_alt_short_list_after_simp no_further_dB_after_simp)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   644
  by simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   645
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   646
lemma rsimp_alts_idem:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   647
  shows "rsimp (rsimp_ALTs (a # as)) = rsimp (rsimp_ALTs (a # [(rsimp (rsimp_ALTs as))] ))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   648
  apply(induct as)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   649
   apply(subgoal_tac "rsimp (rsimp_ALTs [a, rsimp (rsimp_ALTs [])]) = rsimp (rsimp_ALTs [a, RZERO])")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   650
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   651
    apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   652
  using bubble_break rsimp_alts_idem_aux2 apply auto[1]
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   653
  apply(case_tac as)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   654
   apply(subgoal_tac "rsimp_ALTs( aa # as) = aa")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   655
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   656
    apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   657
  using head_one_more_simp apply fastforce
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   658
  apply(subgoal_tac "rsimp_ALTs (aa # as) = RALTS (aa # as)")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   659
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   660
  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   661
  using rsimp_ALTs.simps(3) apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   662
  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   663
  apply(simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   664
  apply(subgoal_tac "rsimp_ALTs (a # aa # aaa # list) = RALTS (a # aa # aaa # list)")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   665
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   666
  using rsimp_ALTs.simps(3) apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   667
  apply(simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   668
  apply(subgoal_tac "rsimp_ALTs [a, rsimp (RALTS (aa # aaa # list))] = RALTS (a # [rsimp (RALTS (aa # aaa # list))])")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   669
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   670
  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   671
  using rsimp_ALTs.simps(3) apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   672
  apply(simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   673
  using simp_flatten2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   674
  apply(subgoal_tac " rsimp (RALT a (rsimp (RALTS (aa # aaa # list))))  =  rsimp (RALT a ((RALTS (aa # aaa # list)))) ")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   675
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   676
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   677
  apply (metis head_one_more_simp list.simps(9) rsimp.simps(2))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   678
  apply (simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   679
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   680
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   681
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   682
lemma rsimp_alts_idem2:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   683
  shows "rsimp (rsimp_ALTs (a # as)) = rsimp (rsimp_ALTs ((rsimp a) # [(rsimp (rsimp_ALTs as))] ))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   684
  using head_one_more_simp rsimp_alts_idem by auto
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   685
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   686
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   687
lemma evolution_step1:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   688
  shows "rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   689
        (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   690
          (rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   691
         rsimp 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   692
        (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   693
          (rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # [(rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)))]))   "
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   694
  using rsimp_alts_idem by auto
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   695
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   696
lemma evolution_step2:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   697
  assumes " rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   698
       rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   699
  shows "rsimp 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   700
        (rsimp_ALTs 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   701
          (rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   702
                 rsimp 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   703
        (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   704
          (rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)) # [ rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]))  "
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   705
  by (simp add: assms rsimp_alts_idem)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   706
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   707
lemma rsimp_seq_aux1:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   708
  shows "r = RONE \<and> r2 = RSTAR r0 \<Longrightarrow> rsimp_SEQ r r2 = r2"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   709
  apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   710
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   711
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   712
lemma multiple_alts_simp_flatten:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   713
  shows "rsimp (RALT (RALT r1 r2) (rsimp_ALTs rs)) = rsimp (RALTS (r1 # r2 # rs))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   714
  by (metis Cons_eq_appendI append_self_conv2 rsimp_ALTs.simps(2) rsimp_ALTs.simps(3) rsimp_alts_idem simp_flatten)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   715
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   716
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   717
lemma evo3_main_aux1:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   718
  shows "rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   719
            (RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   720
              (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   721
           rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   722
            (RALTS
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   723
              (RSEQ (rders_simp r (a @ [x])) (RSTAR r) #
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   724
               RSEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   725
  apply(subgoal_tac "rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   726
            (RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   727
              (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   728
rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   729
            (RALT (RALT (RSEQ ( (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   730
              (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))) ")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   731
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   732
   apply (simp add: rsimp_idem)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   733
  apply (simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   734
  apply(subst multiple_alts_simp_flatten)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   735
  by simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   736
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   737
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   738
lemma evo3_main_nullable:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   739
  shows "
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   740
\<And>a Ss.
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   741
       \<lbrakk>rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   742
        rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)));
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   743
        rders_simp r a \<noteq> RONE; rders_simp r a \<noteq> RZERO; rnullable (rders_simp r a)\<rbrakk>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   744
       \<Longrightarrow> rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   745
            (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   746
              [rder x (RSEQ (rders_simp r a) (RSTAR r)),
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   747
               rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   748
           rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r (a # Ss))))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   749
  apply(subgoal_tac "rder x (RSEQ (rders_simp r a) (RSTAR r)) 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   750
                   = RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ (rder x r) (RSTAR r))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   751
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   752
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   753
  apply(simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   754
  apply(subgoal_tac "star_update x r (a # Ss) = (a @ [x]) # [x] # (star_update x r Ss)")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   755
   prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   756
  using star_update_case1 apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   757
  apply(simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   758
  apply(subst List.list.map(2))+
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   759
  apply(subgoal_tac "rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   760
            (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   761
              [RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ (rder x r) (RSTAR r)),
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   762
               rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   763
rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   764
            (RALTS
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   765
              [RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ (rder x r) (RSTAR r)),
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   766
               rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))])")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   767
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   768
  using rsimp_ALTs.simps(3) apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   769
  apply(simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   770
  apply(subgoal_tac " rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   771
            (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   772
              (rsimp_SEQ (rders_simp r (a @ [x])) (RSTAR r) #
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   773
               rsimp_SEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))) 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   774
= 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   775
 rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   776
            (RALTS
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   777
              (rsimp_SEQ (rders_simp r (a @ [x])) (RSTAR r) #
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   778
               rsimp_SEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   779
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   780
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   781
  using rsimp_ALTs.simps(3) apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   782
  apply (simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   783
  apply(subgoal_tac " rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   784
            (RALT (RALT (RSEQ (rder x (rders_simp r a)) (RSTAR r)) (RSEQ ( (rder x r)) (RSTAR r)))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   785
              (rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))))) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   786
             rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   787
            (RALT (RALT (RSEQ (rsimp (rder x (rders_simp r a))) (RSTAR r)) (RSEQ (rsimp (rder x r)) (RSTAR r)))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   788
              (rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   789
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   790
   apply (simp add: rsimp_idem)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   791
  apply(simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   792
  apply(subgoal_tac "             rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   793
            (RALT (RALT (RSEQ (rsimp (rder x (rders_simp r a))) (RSTAR r)) (RSEQ (rsimp (rder x r)) (RSTAR r)))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   794
              (rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))))) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   795
             rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   796
            (RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   797
              (rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   798
   prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   799
  using rders_simp_append rders_simp_one_char rsimp_idem apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   800
  apply(simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   801
  apply(subgoal_tac " rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   802
            (RALTS
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   803
              (rsimp_SEQ (rders_simp r (a @ [x])) (RSTAR r) #
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   804
               rsimp_SEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   805
 rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   806
            (RALTS
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   807
              (RSEQ (rders_simp r (a @ [x])) (RSTAR r) #
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   808
               RSEQ (rders_simp r [x]) (RSTAR r) # map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   809
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   810
  apply (smt (z3) idiot2 list.simps(9) rrexp.distinct(9) rsimp.simps(1) rsimp.simps(2) rsimp.simps(3) rsimp.simps(4) rsimp.simps(6) rsimp_idem)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   811
  apply(simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   812
  apply(subgoal_tac "      rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   813
            (RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   814
              (rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))))) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   815
     rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   816
            (RALT (RALT (RSEQ (rsimp (rders_simp r (a @ [x]))) (RSTAR r)) (RSEQ (rders_simp r [x]) (RSTAR r)))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   817
              ( (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))))  ")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   818
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   819
  using rsimp_idem apply force
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   820
  apply(simp only:)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   821
  using evo3_main_aux1 by blast
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   822
  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   823
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   824
lemma evo3_main_not1:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   825
  shows " \<not>rnullable (rders_simp r a) \<Longrightarrow> rder x (RSEQ (rders_simp r a) (RSTAR r)) = RSEQ (rder x (rders_simp r a)) (RSTAR r)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   826
  by fastforce
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   827
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   828
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   829
lemma evo3_main_not2:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   830
  shows "\<not>rnullable (rders_simp r a) \<Longrightarrow>  rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   831
            (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   832
              (rder x (RSEQ (rders_simp r a) (RSTAR r)) # rs)) = rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   833
            (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   834
              ((RSEQ (rders_simp r (a @ [x])) (RSTAR r)) # rs))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   835
  by (simp add: rders_simp_append rsimp_alts_idem2 rsimp_idem)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   836
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   837
lemma evo3_main_not3:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   838
  shows "rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   839
            (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   840
              (rsimp_SEQ r1 (RSTAR r) # rs)) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   841
         rsimp (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   842
              (RSEQ r1 (RSTAR r) # rs))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   843
  by (metis idiot2 rrexp.distinct(9) rsimp.simps(1) rsimp.simps(3) rsimp.simps(4) rsimp.simps(6) rsimp_alts_idem rsimp_alts_idem2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   844
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   845
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   846
lemma evo3_main_notnullable:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   847
  shows "\<And>a Ss.
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   848
       \<lbrakk>rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   849
        rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)));
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   850
        rders_simp r a \<noteq> RONE; rders_simp r a \<noteq> RZERO; \<not>rnullable (rders_simp r a)\<rbrakk>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   851
       \<Longrightarrow> rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   852
            (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   853
              [rder x (RSEQ (rders_simp r a) (RSTAR r)),
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   854
               rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   855
           rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r (a # Ss))))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   856
  apply(subst star_update_case2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   857
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   858
  apply(subst List.list.map(2))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   859
  apply(subst evo3_main_not2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   860
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   861
  apply(subst evo3_main_not3)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   862
  using rsimp_alts_idem by presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   863
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   864
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   865
lemma evo3_aux2:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   866
  shows "rders_simp r a = RONE \<Longrightarrow> rsimp_SEQ (rders_simp (rders_simp r a) [x]) (RSTAR r) = RZERO"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   867
  by simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   868
lemma evo3_aux3:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   869
  shows "rsimp (rsimp_ALTs (RZERO # rs)) = rsimp (rsimp_ALTs rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   870
  by (metis list.simps(8) list.simps(9) rdistinct.simps(1) rflts.simps(1) rflts.simps(2) rsimp.simps(2) rsimp_ALTs.simps(1) rsimp_ALTs.simps(2) rsimp_ALTs.simps(3) rsimp_alts_idem)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   871
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   872
lemma evo3_aux4:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   873
  shows " rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   874
            (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   875
              [RSEQ (rder x r) (RSTAR r),
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   876
               rsimp (rsimp_ALTs rs)]) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   877
           rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   878
            (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   879
              (rsimp_SEQ (rders_simp r [x]) (RSTAR r) # rs))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   880
  by (metis rders_simp_one_char rsimp.simps(1) rsimp.simps(6) rsimp_alts_idem rsimp_alts_idem2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   881
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   882
lemma evo3_aux5:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   883
  shows "rders_simp r a \<noteq> RONE \<and> rders_simp r a \<noteq> RZERO \<Longrightarrow> rsimp_SEQ (rders_simp r a) (RSTAR r) = RSEQ (rders_simp r a) (RSTAR r)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   884
  using idiot2 by blast
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   885
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   886
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   887
lemma evolution_step3:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   888
  shows" \<And>a Ss.
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   889
       rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss)) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   890
       rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))) \<Longrightarrow>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   891
       rsimp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   892
        (rsimp_ALTs
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   893
          [rder x (rsimp_SEQ (rders_simp r a) (RSTAR r)),
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   894
           rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss)))]) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   895
       rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r (a # Ss))))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   896
  apply(case_tac "rders_simp r a = RONE")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   897
   apply(subst rsimp_seq_aux1)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   898
    apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   899
  apply(subst rder.simps(6))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   900
   apply(subgoal_tac "rnullable (rders_simp r a)")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   901
    prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   902
  using rnullable.simps(2) apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   903
   apply(subst star_update_case1)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   904
    apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   905
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   906
   apply(subst List.list.map)+
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   907
  apply(subst rders_simp_append)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   908
   apply(subst evo3_aux2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   909
    apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   910
   apply(subst evo3_aux3)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   911
   apply(subst evo3_aux4)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   912
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   913
  apply(case_tac "rders_simp r a = RZERO")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   914
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   915
   apply (simp add: rsimp_alts_idem2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   916
   apply(subgoal_tac "rders_simp r (a @ [x]) = RZERO")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   917
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   918
  using rder.simps(1) rders_simp_append rders_simp_one_char rsimp.simps(3) apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   919
  using rflts.simps(2) rsimp.simps(3) rsimp_SEQ.simps(1) apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   920
  apply(subst evo3_aux5)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   921
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   922
  apply(case_tac "rnullable (rders_simp r a) ")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   923
  using evo3_main_nullable apply blast
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   924
  using evo3_main_notnullable apply blast
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   925
  done
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   926
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   927
(*
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   928
proof (prove)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   929
goal (1 subgoal):
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   930
 1. map f (a # s) = f a # map f s 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   931
Auto solve_direct: the current goal can be solved directly with
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   932
  HOL.nitpick_simp(115): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   933
  List.list.map(2): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   934
  List.list.simps(9): map ?f (?x21.0 # ?x22.0) = ?f ?x21.0 # map ?f ?x22.0
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   935
*)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   936
lemma starseq_list_evolution:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   937
  fixes  r :: rrexp and Ss :: "char list list" and x :: char 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   938
  shows "rsimp (rsimp_ALTs (map (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss) ) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   939
         rsimp (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) (star_update x r Ss))  )"   
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   940
  apply(induct Ss)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   941
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   942
  apply(subst List.list.map(2))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   943
  apply(subst evolution_step2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   944
   apply simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   945
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   946
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   947
  sorry
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   948
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   949
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   950
lemma star_seqs_produce_star_seqs:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   951
  shows "rsimp (rsimp_ALTs (map (rder x \<circ> (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r))) Ss))
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   952
       = rsimp (rsimp_ALTs (map ( (\<lambda>s1. rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r)))) Ss))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   953
  by (meson comp_apply)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   954
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   955
lemma map_der_lambda_composition:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   956
  shows "map (rder x) (map (\<lambda>s. f s) Ss) = map (\<lambda>s. (rder x (f s))) Ss"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   957
  by force
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   958
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   959
lemma ralts_vs_rsimpalts:
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   960
  shows "rsimp (RALTS rs) = rsimp (rsimp_ALTs rs)"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   961
  by (metis evo3_aux3 rsimp_ALTs.simps(2) rsimp_ALTs.simps(3) simp_flatten2)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   962
  
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   963
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   964
lemma linearity_of_list_of_star_or_starseqs: 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   965
  fixes r::rrexp and Ss::"char list list" and x::char
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   966
  shows "\<exists>Ssa. rsimp (rder x (rsimp_ALTs (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   967
                 rsimp (RALTS ( (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ssa)))"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   968
  apply(subst rder_rsimp_ALTs_commute)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   969
  apply(subst map_der_lambda_composition)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   970
  using starseq_list_evolution
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   971
  apply(rule_tac x = "star_update x r Ss" in exI)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   972
  apply(subst ralts_vs_rsimpalts)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   973
  by simp
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   974
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   975
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   976
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   977
(*certified correctness---does not depend on any previous sorry*)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   978
lemma star_list_push_der: shows  " \<lbrakk>xs \<noteq> [] \<Longrightarrow> \<exists>Ss. rders_simp (RSTAR r) xs = rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss));
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   979
        xs @ [x] \<noteq> []; xs \<noteq> []\<rbrakk> \<Longrightarrow>
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   980
     \<exists>Ss. rders_simp (RSTAR r ) (xs @ [x]) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   981
        rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r))) ) Ss) )"
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   982
  apply(subgoal_tac  "\<exists>Ss. rders_simp (RSTAR r) xs = rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   983
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   984
  apply blast
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   985
  apply(erule exE)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   986
  apply(subgoal_tac "rders_simp (RSTAR r) (xs @ [x]) = rsimp (rder x (rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   987
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   988
  using rders_simp_append
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   989
  using rders_simp_one_char apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   990
  apply(rule_tac x= "Ss" in exI)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   991
  apply(subgoal_tac " rsimp (rder x (rsimp (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) = 
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   992
                       rsimp (rsimp (rder x (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   993
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   994
  using inside_simp_removal rsimp_idem apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   995
  apply(subgoal_tac "rsimp (rsimp (rder x (RALTS (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   996
                     rsimp (rsimp (RALTS (map (rder x) (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss))))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   997
  prefer 2
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   998
  using rder.simps(4) apply presburger
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
   999
  apply(subgoal_tac "rsimp (rsimp (RALTS (map (rder x) (map (\<lambda>s1. rsimp_SEQ (rders_simp r s1) (RSTAR r)) Ss)))) =
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1000
                     rsimp (rsimp (RALTS (map (\<lambda>s1. (rder x (rsimp_SEQ (rders_simp r s1) (RSTAR r)))) Ss)))")
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1001
   apply (metis rsimp_idem)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1002
  by (metis map_der_lambda_composition)
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1003
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1004
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1005
c6351a96bf80 writeupforclosedforms
Chengsong
parents:
diff changeset
  1006
end